tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

test_insecure_reload.html (2233B)


      1 <!DOCTYPE HTML>
      2 <html>
      3 <head>
      4 <title>Bug 1702001: Https-only mode does not reload pages after clicking "Continue to HTTP Site", when url contains navigation </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 *
     15 *   Load a page including a fragment portion which does not support https and make
     16 *   sure that exempting the page from https-only-mode does not result in a fragment
     17 *   navigation.
     18 */
     19 
     20 
     21 function resolveAfter6Seconds() {
     22  return new Promise(resolve => {
     23    setTimeout(() => {
     24      resolve();
     25    }, 6000);
     26  });
     27 }
     28 
     29 SimpleTest.requestFlakyTimeout("We need to wait for the HTTPS-Only error page to appear");
     30 SimpleTest.waitForExplicitFinish();
     31 
     32 let winTest = null;
     33 let TEST_URL = "http://example.com/tests/dom/security/test/https-only/file_insecure_reload.sjs#nav";
     34 
     35 // verify that https-only page appeared
     36 async function verifyErrorPage() {
     37  let errorPageL10nId = "about-httpsonly-title-alert";
     38  let innerHTML = content.document.body.innerHTML;
     39  ok(innerHTML.includes(errorPageL10nId), "the error page should be shown for ");
     40  let button = content.document.getElementById("openInsecure");
     41  // Click "Continue to HTTP Site"
     42  ok(button, "button exist");
     43  if(button) {
     44    button.click();
     45  }
     46 }
     47 // verify that you entered the page and are not still displaying
     48 // the https-only error page
     49 async function receiveMessage(event) {
     50  // read event
     51  let { result, historyLength } = event.data;
     52  is(result, "you entered the http page", "The requested page should be shown");
     53  is(historyLength, 1, "History should contain one item");
     54  window.removeEventListener("message",receiveMessage);
     55  winTest.close();
     56  SimpleTest.finish();
     57 }
     58 
     59 
     60 async function runTest() {
     61  //Test: With https-only mode activated
     62  await SpecialPowers.pushPrefEnv({ set: [
     63    ["dom.security.https_only_mode", true],
     64  ]});
     65  winTest = window.open(TEST_URL);
     66  await resolveAfter6Seconds();
     67  await SpecialPowers.spawn(winTest,[],verifyErrorPage);
     68 }
     69 window.addEventListener("message", receiveMessage);
     70 runTest();
     71 
     72 </script>
     73 </body>
     74 </html>