tor-browser

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

data-url-shared-window.html (660B)


      1 <!DOCTYPE html>
      2 <head>
      3 <title>data URL shared worker</title>
      4 </head>
      5 <body>
      6 <script>
      7 onmessage = event => {
      8  const port = event.ports[0];
      9  // This shared worker counts the total number of connected documents and
     10  // notifies the connector of it.
     11  const kScript =
     12      "onconnect = e => {" +
     13      "  if (self.count === undefined)" +
     14      "    self.count = 0;" +
     15      "  self.count++;" +
     16      "  e.ports[0].postMessage(self.count);" +
     17      "};";
     18  const worker = new SharedWorker('data:application/javascript,' + kScript);
     19  worker.port.onmessage = e => port.postMessage(e.data);
     20 };
     21 
     22 window.opener.postMessage('LOADED', '*');
     23 </script>
     24 </body>
     25 </html>