tor-browser

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

test_importscript_mixedcontent.html (1899B)


      1 <!--
      2  Any copyright is dedicated to the Public Domain.
      3  http://creativecommons.org/publicdomain/zero/1.0/
      4 -->
      5 <!DOCTYPE HTML>
      6 <html>
      7 <head>
      8  <title>Bug 1198078 - test that we respect mixed content blocking in importScript() inside service workers</title>
      9  <script src="/tests/SimpleTest/SimpleTest.js"></script>
     10  <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
     11 </head>
     12 <body>
     13 <p id="display"></p>
     14 <div id="content" style="display: none">
     15 <iframe></iframe>
     16 </div>
     17 <pre id="test"></pre>
     18 <script class="testbody" type="text/javascript">
     19 
     20  var iframe;
     21  function runTest() {
     22    iframe = document.querySelector("iframe");
     23    iframe.src = "https://example.com/tests/dom/serviceworkers/test/fetch/importscript-mixedcontent/register.html";
     24    var ios;
     25    window.onmessage = function(e) {
     26      if (e.data.status == "ok") {
     27        ok(e.data.result, e.data.message);
     28      } else if (e.data.status == "registrationdone") {
     29        iframe.src = "https://example.com/tests/dom/serviceworkers/test/fetch/importscript-mixedcontent/index.html";
     30      } else if (e.data.status == "done") {
     31        is(e.data.data, "good", "Mixed content blocking should work correctly for service workers");
     32        iframe.src = "https://example.com/tests/dom/serviceworkers/test/fetch/importscript-mixedcontent/unregister.html";
     33      } else if (e.data.status == "unregistrationdone") {
     34        window.onmessage = null;
     35        ok(true, "Test finished successfully");
     36        SimpleTest.finish();
     37      }
     38    };
     39  }
     40 
     41  SimpleTest.waitForExplicitFinish();
     42  onload = function() {
     43    SpecialPowers.pushPrefEnv({"set": [
     44      ["dom.serviceWorkers.exemptFromPerDomainMax", true],
     45      ["dom.serviceWorkers.enabled", true],
     46      ["dom.serviceWorkers.testing.enabled", true],
     47      ["security.mixed_content.block_active_content", false],
     48    ]}, runTest);
     49  };
     50 </script>
     51 </pre>
     52 </body>
     53 </html>