tor-browser

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

register-closed-window-iframe.html (563B)


      1 <html>
      2 <head>
      3 <script>
      4 window.addEventListener('message', async function(evt) {
      5  if (evt.data === 'START') {
      6    var w = window.open('./');
      7    var sw = w.navigator.serviceWorker;
      8    w.close();
      9    w = null;
     10 
     11    // Ensure sw.register receives a valid URL. The popup might have
     12    // about:blank as base so sw.register('doestnmatter.js') would be invalid.
     13    const swUrl = new URL('doestnmatter.js', document.baseURI).href;
     14    try {
     15      await sw.register(swUrl);
     16    } finally {
     17      parent.postMessage('OK', '*');
     18    }
     19  }
     20 });
     21 </script>
     22 </head>
     23 </html>