test_uir_top_nav.html (1618B)
1 <!DOCTYPE HTML> 2 <html> 3 <head> 4 <title>Bug 1391011: Test uir for toplevel navigations</title> 5 <script src="/tests/SimpleTest/SimpleTest.js"></script> 6 <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" /> 7 </head> 8 <body> 9 <iframe style="width:100%;" id="testframe"></iframe> 10 11 <script class="testbody" type="text/javascript"> 12 13 SimpleTest.waitForExplicitFinish(); 14 15 /* Description of the test: 16 * We load an https page which defines upgrade-insecure-requests into an iframe 17 * and perform a same origin and a cross origin toplevel load and make sure that 18 * upgrade-insecure-requests applies to the same origin load. 19 */ 20 21 let totalTests = 2; 22 let testCounter = 0; 23 24 function checkResults(aResult) { 25 ok(aResult == "https://example.com/tests/dom/security/test/csp/file_uir_top_nav_dummy.html" || 26 aResult == "http://test1.example.com/tests/dom/security/test/csp/file_uir_top_nav_dummy.html", 27 "same origin should be upgraded to https, cross origin should remain http"); 28 if (++testCounter < totalTests) { 29 return; 30 } 31 window.removeEventListener("message", receiveMessage); 32 SimpleTest.finish(); 33 } 34 35 window.addEventListener("message", receiveMessage); 36 function receiveMessage(event) { 37 checkResults(event.data.result); 38 } 39 40 function startTest() { 41 document.getElementById("testframe").src = 42 "https://example.com/tests/dom/security/test/csp/file_uir_top_nav.html"; 43 } 44 45 // Don't upgrade to https to test that upgrade-insecure-requests acts correctly and 46 // start test 47 SpecialPowers.pushPrefEnv({ set: [ 48 ["dom.security.https_first", false] 49 ]}, startTest); 50 51 </script> 52 </body> 53 </html>