-
Notifications
You must be signed in to change notification settings - Fork 196
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #746 from jelhan/fix-content-security-policy
CSP: refactor to not require `style-src 'unsafe-inline` and add test coverage
- Loading branch information
Showing
10 changed files
with
210 additions
and
57 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
export default function({ beforeEach, afterEach }) { | ||
let styleSheet = [...document.styleSheets].find((sheet) => sheet.href.includes('test-support.css')); | ||
let numberOfInsertedRules; | ||
|
||
beforeEach(function() { | ||
numberOfInsertedRules = 0; | ||
|
||
this.insertCSSRule = function(rule) { | ||
styleSheet.insertRule(rule, styleSheet.length); | ||
numberOfInsertedRules++; | ||
}; | ||
}); | ||
|
||
afterEach(function() { | ||
// since we insert the rules at the end of the stylesheet, we could safely | ||
// remove the same amount of rules from the end as we have inserted | ||
for (let i = 1; i <= numberOfInsertedRules; i++) { | ||
styleSheet.deleteRule(styleSheet.length); | ||
} | ||
}); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.