test_escapedSlashes.html (2564B)
1 <!-- 2 Any copyright is dedicated to the Public Domain. 3 http://creativecommons.org/publicdomain/zero/1.0/ 4 --> 5 <!DOCTYPE HTML> 6 <html> 7 <head> 8 <title>Test for escaped slashes in navigator.serviceWorker.register</title> 9 <script type="text/javascript" src="http://mochi.test:8888/tests/SimpleTest/SimpleTest.js"></script> 10 <link rel="stylesheet" type="text/css" href="http://mochi.test:8888/tests/SimpleTest/test.css" /> 11 <base href="https://mozilla.org/"> 12 </head> 13 <body> 14 <p id="display"></p> 15 <div id="content" style="display: none"> 16 </div> 17 <pre id="test"></pre> 18 <script class="testbody" type="text/javascript"> 19 20 var tests = [ 21 { status: true, 22 scriptURL: "a.js?foo%2fbar", 23 scopeURL: null }, 24 { status: false, 25 scriptURL: "foo%2fbar", 26 scopeURL: null }, 27 { status: true, 28 scriptURL: "a.js?foo%2Fbar", 29 scopeURL: null }, 30 { status: false, 31 scriptURL: "foo%2Fbar", 32 scopeURL: null }, 33 { status: true, 34 scriptURL: "a.js?foo%5cbar", 35 scopeURL: null }, 36 { status: false, 37 scriptURL: "foo%5cbar", 38 scopeURL: null }, 39 { status: true, 40 scriptURL: "a.js?foo%2Cbar", 41 scopeURL: null }, 42 { status: false, 43 scriptURL: "foo%5Cbar", 44 scopeURL: null }, 45 { status: true, 46 scriptURL: "ok.js", 47 scopeURL: "/scope?foo%2fbar"}, 48 { status: false, 49 scriptURL: "ok.js", 50 scopeURL: "/foo%2fbar"}, 51 { status: true, 52 scriptURL: "ok.js", 53 scopeURL: "/scope?foo%2Fbar"}, 54 { status: false, 55 scriptURL: "ok.js", 56 scopeURL: "foo%2Fbar"}, 57 { status: true, 58 scriptURL: "ok.js", 59 scopeURL: "/scope?foo%5cbar"}, 60 { status: false, 61 scriptURL: "ok.js", 62 scopeURL: "foo%5cbar"}, 63 { status: true, 64 scriptURL: "ok.js", 65 scopeURL: "/scope?foo%5Cbar"}, 66 { status: false, 67 scriptURL: "ok.js", 68 scopeURL: "foo%5Cbar"}, 69 ]; 70 71 function runTest() { 72 if (!tests.length) { 73 SimpleTest.finish(); 74 return; 75 } 76 77 var test = tests.shift(); 78 navigator.serviceWorker.register(test.scriptURL, test.scopeURL) 79 .then(reg => { 80 ok(false, "Register should fail"); 81 }, err => { 82 if (!test.status) { 83 is(err.name, "TypeError", "Registration should fail with TypeError"); 84 } else { 85 ok(test.status, "Register should fail"); 86 } 87 }) 88 .then(runTest); 89 } 90 91 SimpleTest.waitForExplicitFinish(); 92 onload = function() { 93 SpecialPowers.pushPrefEnv({"set": [ 94 ["dom.serviceWorkers.exemptFromPerDomainMax", true], 95 ["dom.serviceWorkers.testing.enabled", true], 96 ["dom.serviceWorkers.enabled", true], 97 ]}, runTest); 98 }; 99 100 </script> 101 </body> 102 </html>