tor-browser

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

window.html (1334B)


      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 </head>
      9 <body>
     10 <script type="text/javascript">
     11 
     12 function wait_until_controlled() {
     13  return new Promise(function(resolve) {
     14    if (navigator.serviceWorker.controller) {
     15      resolve();
     16      return;
     17    }
     18    navigator.serviceWorker.addEventListener('controllerchange', function onController() {
     19      if (navigator.serviceWorker.controller) {
     20        navigator.serviceWorker.removeEventListener('controllerchange', onController);
     21        resolve();
     22      }
     23    });
     24  });
     25 }
     26 addEventListener('load', function(event) {
     27  var registration;
     28  navigator.serviceWorker.register('worker.js').then(function(swr) {
     29    registration = swr;
     30 
     31    // While the iframe below is a navigation, we still wait until we are
     32    // controlled here.  We want an active client to hold the service worker
     33    // alive since it calls unregister() on itself.
     34    return wait_until_controlled();
     35 
     36  }).then(function() {
     37    var frame = document.createElement('iframe');
     38    document.body.appendChild(frame);
     39    frame.src = 'fake_download';
     40 
     41    // The service worker is unregistered in the fetch event.  The window and
     42    // frame are cleaned up from the browser chrome script.
     43  });
     44 });
     45 </script>
     46 </body>
     47 </html>