tor-browser

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

test_websocket_localhost.html (1283B)


      1 <!DOCTYPE HTML>
      2 <html>
      3 <head>
      4  <meta charset="utf-8">
      5  <title>Bug 1729897: Allow unsecure websocket from localhost page with CSP: upgrade-insecure </title>
      6  <!-- Including SimpleTest.js so we can use waitForExplicitFinish !-->
      7  <script src="/tests/SimpleTest/SimpleTest.js"></script>
      8  <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
      9 </head>
     10 <body>
     11 <iframe style="width:100%;" id="test_ws_self_frame"></iframe>
     12 
     13 <script class="testbody" type="text/javascript">
     14 
     15 SimpleTest.waitForExplicitFinish();
     16 
     17 function finishTest() {
     18  window.removeEventListener("message", receiveMessage);
     19  SimpleTest.finish();
     20 }
     21 
     22 window.addEventListener("message", receiveMessage);
     23 function receiveMessage(event) {
     24  is(event.data.result, "self-ws-loaded", "websocket loaded");
     25  ok(event.data.url.startsWith("ws://"), `scheme must be ws:// but got ${event.data.url}`);
     26  finishTest();
     27 }
     28 
     29 SpecialPowers.pushPrefEnv({set: [
     30  ["network.proxy.allow_hijacking_localhost", true],
     31 ]}).then(function() {
     32  const HOST = "http://localhost/tests/dom/security/test/csp/";
     33  var test_ws_self_frame = document.getElementById("test_ws_self_frame");
     34  test_ws_self_frame.src = HOST + "file_websocket_csp_upgrade.html";
     35 });
     36 
     37 </script>
     38 </body>
     39 </html>