4 <title>Bug
1428793: Block insecure redirects to data: URIs
</title>
5 <script src=
"/tests/SimpleTest/SimpleTest.js"></script>
6 <link rel=
"stylesheet" type=
"text/css" href=
"/tests/SimpleTest/test.css" />
10 <script id=
"testScriptRedirectToData"></script>
11 <script id=
"testModuleScriptRedirectToData" type=
"module"></script>
13 <script class=
"testbody" type=
"text/javascript">
15 SimpleTest.waitForExplicitFinish();
19 function checkFinish() {
21 if (testCounter === NUM_TESTS) {
26 // --- test regular scripts
27 let testScriptRedirectToData = document.getElementById(
"testScriptRedirectToData");
28 testScriptRedirectToData.onerror = function() {
29 ok(true,
"script that redirects to data: URI should not load");
32 testScriptRedirectToData.onload = function() {
33 ok(false,
"script that redirects to data: URI should not load");
36 testScriptRedirectToData.src =
"file_block_subresource_redir_to_data.sjs?script";
39 let worker = new Worker(
"file_block_subresource_redir_to_data.sjs?worker");
40 worker.onerror = function() {
41 // please note that workers need to be same origin, hence the data: URI
42 // redirect is blocked by worker code and not the content security manager!
43 ok(true,
"worker script that redirects to data: URI should not load");
46 worker.onmessage = function() {
47 ok(false,
"worker script that redirects to data: URI should not load");
50 worker.postMessage(
"dummy");
52 // --- test script modules
53 let testModuleScriptRedirectToData = document.getElementById(
"testModuleScriptRedirectToData");
54 testModuleScriptRedirectToData.onerror = function() {
55 ok(true,
"module script that redirects to data: URI should not load");
58 testModuleScriptRedirectToData.onload = function() {
59 ok(false,
"module script that redirects to data: URI should not load");
62 testModuleScriptRedirectToData.src =
"file_block_subresource_redir_to_data.sjs?modulescript";