test_fragment.html (1674B)
1 <!DOCTYPE HTML> 2 <html> 3 <head> 4 <title>Bug 1706577: Have https-first mode account for fragment 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 10 <script class="testbody" type="text/javascript"> 11 "use strict"; 12 /* 13 * Description of the test: 14 * Have https-first detect a fragment navigation rather than navigating away 15 * from the page. 16 */ 17 18 SimpleTest.waitForExplicitFinish(); 19 20 const REQUEST_URL = "http://example.com/tests/dom/security/test/https-first/file_fragment.html"; 21 const EXPECT_URL = REQUEST_URL.replace("http://", "https://"); 22 23 let winTest = null; 24 let checkButtonClicked = false; 25 26 async function receiveMessage(event) { 27 let data = event.data; 28 if (!checkButtonClicked) { 29 ok(data.result == EXPECT_URL, "location is correct"); 30 ok(data.button, "button is clicked"); 31 ok(data.info == "onload", "Onloading worked"); 32 checkButtonClicked = true; 33 return; 34 } 35 36 // Once the button was clicked we know the tast has finished 37 ok(data.button, "button is clicked"); 38 is(data.result, EXPECT_URL + "#foo", "location (hash) is correct"); 39 ok(data.info == "scrolled-to-foo","Scrolled successfully without reloading!"); 40 is(data.documentURI, EXPECT_URL + "#foo", "Document URI is correct"); 41 window.removeEventListener("message",receiveMessage); 42 winTest.close(); 43 SimpleTest.finish(); 44 } 45 46 async function runTest() { 47 await SpecialPowers.pushPrefEnv({ set: [ 48 ["dom.security.https_first", true], 49 ]}); 50 winTest = window.open(REQUEST_URL); 51 } 52 53 window.addEventListener("message", receiveMessage); 54 55 runTest(); 56 57 </script> 58 </body> 59 </html>