tor-browser

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

test_offline_localhost_fetch.html (1698B)


      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 1843001</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 <iframe></iframe>
     14 <script>
     15 
     16 const basePath = window.location.pathname.replace(/\/[^\/]*$/, '/');
     17 const localhostBaseURL = "http://127.0.0.1:8888" + basePath;
     18 
     19  var iframe;
     20  function runTest() {
     21    iframe = document.querySelector("iframe");
     22    iframe.src = localhostBaseURL + "offline_fetch/register.html";
     23    var ios;
     24    window.onmessage = function(e) {
     25      if (e.data.status == "ok") {
     26        ok(e.data.result, e.data.message);
     27      } else if (e.data.status == "registrationdone") {
     28        ios = SpecialPowers.Cc["@mozilla.org/network/io-service;1"]
     29                           .getService(SpecialPowers.Ci.nsIIOService);
     30        ios.offline = true;
     31        iframe.src = localhostBaseURL + "offline_fetch/index.html";
     32      } else if (e.data.status == "done") {
     33        ios.offline = false;
     34        iframe.src = localhostBaseURL + "offline_fetch/unregister.html";
     35      } else if (e.data.status == "unregistrationdone") {
     36        window.onmessage = null;
     37        ok(true, "Test finished successfully");
     38        SimpleTest.finish();
     39      }
     40    };
     41  }
     42 
     43  SimpleTest.waitForExplicitFinish();
     44  onload = function() {
     45    SpecialPowers.pushPrefEnv({"set": [
     46      ["dom.serviceWorkers.exemptFromPerDomainMax", true],
     47      ["dom.serviceWorkers.enabled", true],
     48      ["dom.serviceWorkers.testing.enabled", true],
     49    ]}, runTest);
     50  };
     51 </script>
     52 </pre>
     53 </body>
     54 </html>