tor-browser

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

cross-origin-serviceworker-iframe.sub.html (926B)


      1 <!DOCTYPE html>
      2 <meta charset="utf-8">
      3 <title>Notification cross origin iframe with service worker</title>
      4 <body>
      5 <script src="/resources/testdriver.js"></script>
      6 <script src="/resources/testdriver-vendor.js"></script>
      7 <script src="helpers.js"></script>
      8 <script type="module">
      9 const firstPartyOrigin = 'https://{{hosts[][]}}:{{ports[https][0]}}';
     10 
     11 // As our service worker cannot directly ping the first party window,
     12 // let's be a proxy here.
     13 navigator.serviceWorker.addEventListener("message", ev => {
     14  window.top.postMessage(ev.data, firstPartyOrigin);
     15 });
     16 
     17 // Grant the permission so that we can confirm the permission being denied
     18 // regardless of the actual permission status.
     19 test_driver.set_test_context(window.top);
     20 await test_driver.set_permission({ name: "notifications" }, "granted");
     21 
     22 await unregisterAllServiceWorker();
     23 const registration = await navigator.serviceWorker.register("permission-sw.js");
     24 </script>