tor-browser

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

test_importScripts_1.html (977B)


      1 <head>
      2  <title>Test for ServiceWorker importScripts</title>
      3  <script src="/tests/SimpleTest/SimpleTest.js"></script>
      4  <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
      5 </head>
      6 <body>
      7 <script id="worker" type="javascript/worker">
      8 onconnect = async function(e) {
      9    e.ports[0].onmessage = async function(msg) {
     10      try {
     11        self.importScripts("N:", "");
     12      } catch (ex) {
     13        e.source.postMessage("done");
     14      }
     15    };
     16 };
     17 </script>
     18 <script>
     19 SimpleTest.waitForExplicitFinish();
     20 document.addEventListener("DOMContentLoaded", async () => {
     21    const blob = new Blob([document.querySelector('#worker').textContent],
     22                          {type: "text/javascript"});
     23    const sw = new SharedWorker(window.URL.createObjectURL(blob));
     24    sw.port.postMessage([], []);
     25    sw.port.onmessage = function(e) {
     26      if (e.data == "done") {
     27        ok(true);
     28        SimpleTest.finish();
     29      }
     30    };
     31 });
     32 </script>
     33 </pre>
     34 </body>
     35 </html>