test_data_uri.html (1383B)
1 <!DOCTYPE HTML> 2 <html> 3 <head> 4 <meta charset="utf-8"> 5 <title>Bug 1709069: Test that Data URI which makes a top-level request gets updated in https-first</title> 6 <script src="/tests/SimpleTest/SimpleTest.js"></script> 7 <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" /> 8 </head> 9 <body> 10 <iframe style="width:100%;" id="testframe"></iframe> 11 <script class="testbody" type="text/javascript"> 12 13 SimpleTest.waitForExplicitFinish(); 14 window.addEventListener("message", receiveMessage); 15 16 // HTML site which makes a top-level http request 17 const HTML = ` 18 <html> 19 <body> 20 DATA HTML 21 <script> 22 window.open("http://example.com/tests/dom/security/test/https-first/file_data_uri.html"); 23 <\/script> 24 <\/body> 25 <\/html> 26 `; 27 28 const DATA_HTML = "data:text/html, " + HTML; 29 30 // Verify that data uri top-level request got upgraded to https and 31 // the reached location is correct 32 async function receiveMessage(event){ 33 let data = event.data; 34 is(data.location, "https://example.com/tests/dom/security/test/https-first/file_data_uri.html", 35 "Reached the correct location"); 36 window.removeEventListener("message", receiveMessage); 37 SimpleTest.finish(); 38 } 39 40 function test_toplevel_https() { 41 document.getElementById("testframe").src = DATA_HTML; 42 } 43 44 SpecialPowers.pushPrefEnv({ set: [ 45 ["dom.security.https_first", true], 46 ]}, test_toplevel_https); 47 48 49 </script> 50 </body> 51 </html>