tor-browser

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

partitioned-service-worker-third-party-iframe-matchAll.html (924B)


      1 <!DOCTYPE html>
      2 <title>Service Worker: 3P iframe for partitioned service workers</title>
      3 <script src="./test-helpers.sub.js"></script>
      4 <script src="/common/get-host-info.sub.js"></script>
      5 <script src="./partitioned-utils.js"></script>
      6 
      7 <body>
      8  This iframe will register a service worker when it loads and then will use
      9  getRegistrations to get a handle to the SW. It will then postMessage to the
     10  SW to get the SW's clients via matchAll(). This iframe will then forward the
     11  SW's response up, eventually, to the test.
     12  <script>
     13    async function onLoad() {
     14      reg = await setupServiceWorker();
     15 
     16      // Once the SW sends us its ID, forward it up to the window.
     17      navigator.serviceWorker.addEventListener('message', evt => {
     18        window.parent.postMessage(evt.data, '*');
     19      });
     20 
     21      reg.active.postMessage({type: "get-match-all"});
     22 
     23    }
     24 
     25    self.addEventListener('load', onLoad);
     26  </script>
     27 </body>