tor-browser

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

test_slow_non_standard_port.html (1592B)


      1 <!DOCTYPE HTML>
      2 <html>
      3 <head>
      4 <title>Bug 1736562 : Test that slow nonstandard port sites don't get timeout</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 * Open a site with non standard port that answers after 1 sec.
     15 *  Expected result: https-first is not timeouting the page and
     16 *                   doesn't upgrade the request.
     17 */
     18 
     19 SimpleTest.waitForExplicitFinish();
     20 
     21 const REQUEST_URL =
     22  "http://mochi.test:8888/tests/dom/security/test/https-first/file_slow_non_standard_port.sjs";
     23 
     24 let testWin;
     25 window.addEventListener("message", receiveMessage);
     26 
     27 // Receive message and verify that it is from an http site.
     28 // When the message is 'downgraded' then it was send by an http site
     29 // and the test worked.
     30 async function receiveMessage(event) {
     31  let data = event.data;
     32  ok(data.result === "downgraded", "Downgraded successful to 'http' for non standard port localhost request");
     33  is(data.scheme,"http:", "scheme is 'http' " );
     34  testWin.close();
     35  window.removeEventListener("message", receiveMessage);
     36  SimpleTest.finish();
     37 }
     38 
     39 async function runTest() {
     40  testWin = window.open(REQUEST_URL, "_blank");
     41 }
     42 
     43 SpecialPowers.pushPrefEnv({ set: [
     44    ["dom.security.https_first", true],
     45    // To speed up the test, tell HTTPS-First to potentially downgrade after 0.1s
     46    ["dom.security.https_only_fire_http_request_background_timer_ms", 100]
     47  ]}, runTest);
     48 
     49 </script>
     50 </body>
     51 </html>