summaryrefslogtreecommitdiffstats
path: root/dom/security/test/csp/test_nonce_redirects.html
diff options
context:
space:
mode:
authorjanekptacijarabaci <janekptacijarabaci@seznam.cz>2018-06-23 04:29:34 +0200
committerjanekptacijarabaci <janekptacijarabaci@seznam.cz>2018-06-23 04:29:34 +0200
commitd413e1fb87779a0c3f474f8e773e01ad0878beea (patch)
treee5a68f831dca178b1d1deb4fcb64730d9f8fbc33 /dom/security/test/csp/test_nonce_redirects.html
parentc1315412cc21a85fb779bef0d87dadde751cfe71 (diff)
downloadUXP-d413e1fb87779a0c3f474f8e773e01ad0878beea.tar
UXP-d413e1fb87779a0c3f474f8e773e01ad0878beea.tar.gz
UXP-d413e1fb87779a0c3f474f8e773e01ad0878beea.tar.lz
UXP-d413e1fb87779a0c3f474f8e773e01ad0878beea.tar.xz
UXP-d413e1fb87779a0c3f474f8e773e01ad0878beea.zip
Bug 1469150 - Tests added to check scripts with valid nonce is allowed if URL redirects (follow up)
Diffstat (limited to 'dom/security/test/csp/test_nonce_redirects.html')
-rw-r--r--dom/security/test/csp/test_nonce_redirects.html47
1 files changed, 47 insertions, 0 deletions
diff --git a/dom/security/test/csp/test_nonce_redirects.html b/dom/security/test/csp/test_nonce_redirects.html
new file mode 100644
index 000000000..f84fdcc7b
--- /dev/null
+++ b/dom/security/test/csp/test_nonce_redirects.html
@@ -0,0 +1,47 @@
+<!DOCTYPE HTML>
+<html>
+<head>
+ <meta charset="utf-8">
+ <title>Bug 1469150:Scripts with valid nonce get blocked if URL redirects</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 a script with a matching nonce, which redirects
+ * and we make sure that script is allowed.
+ */
+
+SimpleTest.waitForExplicitFinish();
+
+function finishTest() {
+ window.removeEventListener("message", receiveMessage);
+ SimpleTest.finish();
+}
+
+function checkResults(aResult) {
+
+ if (aResult === "script-loaded") {
+ ok(true, "expected result: script loaded");
+ }
+ else {
+ ok(false, "unexpected result: script blocked");
+ }
+ finishTest();
+}
+
+window.addEventListener("message", receiveMessage);
+function receiveMessage(event) {
+ checkResults(event.data.result);
+}
+
+document.getElementById("testframe").src = "file_nonce_redirects.html";
+
+</script>
+</body>
+</html>