diff options
author | Matt A. Tobin <mattatobin@localhost.localdomain> | 2018-02-02 04:16:08 -0500 |
---|---|---|
committer | Matt A. Tobin <mattatobin@localhost.localdomain> | 2018-02-02 04:16:08 -0500 |
commit | 5f8de423f190bbb79a62f804151bc24824fa32d8 (patch) | |
tree | 10027f336435511475e392454359edea8e25895d /dom/security/test/csp/test_require_sri_meta.html | |
parent | 49ee0794b5d912db1f95dce6eb52d781dc210db5 (diff) | |
download | UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.gz UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.lz UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.xz UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.zip |
Add m-esr52 at 52.6.0
Diffstat (limited to 'dom/security/test/csp/test_require_sri_meta.html')
-rw-r--r-- | dom/security/test/csp/test_require_sri_meta.html | 77 |
1 files changed, 77 insertions, 0 deletions
diff --git a/dom/security/test/csp/test_require_sri_meta.html b/dom/security/test/csp/test_require_sri_meta.html new file mode 100644 index 000000000..a06fe122a --- /dev/null +++ b/dom/security/test/csp/test_require_sri_meta.html @@ -0,0 +1,77 @@ +<!DOCTYPE HTML> +<html> +<head> + <meta charset="utf-8"> + <title>Bug 1277557 - CSP require-sri-for does not block when CSP is in meta tag</title> + <!-- Including SimpleTest.js so we can use waitForExplicitFinish !--> + <script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script> + <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" /> +</head> +<body> +<iframe style="width:100%;" id="testframe"></iframe> + +<script class="testbody" type="text/javascript"> + +/* Description of the test: + * We load scripts within an iframe and make sure that meta-csp of + * require-sri-for applies correctly to preloaded scripts. + * Please note that we have to use <script src=""> to kick + * off the html preloader. + */ + +SimpleTest.waitForExplicitFinish(); + +SpecialPowers.setBoolPref("security.csp.experimentalEnabled", true); + +var curTest; +var counter = -1; + +const tests = [ + { // test 1 + description: "script with *no* SRI should be blocked", + query: "no-sri", + expected: "script-blocked" + }, + { // test 2 + description: "script-with *incorrect* SRI should be blocked", + query: "wrong-sri", + expected: "script-blocked" + }, + { // test 3 + description: "script-with *correct* SRI should be loaded", + query: "correct-sri", + expected: "script-loaded" + }, +]; + +function finishTest() { + window.removeEventListener("message", receiveMessage, false); + SimpleTest.finish(); +} + +function checkResults(result) { + is(result, curTest.expected, curTest.description); + loadNextTest(); +} + +window.addEventListener("message", receiveMessage, false); +function receiveMessage(event) { + checkResults(event.data.result); +} + +function loadNextTest() { + counter++; + if (counter == tests.length) { + finishTest(); + return; + } + curTest = tests[counter]; + var testframe = document.getElementById("testframe"); + testframe.src = "file_require_sri_meta.sjs?" + curTest.query; +} + +loadNextTest(); + +</script> +</body> +</html> |