tor-browser

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

notification-before-activation.html (1492B)


      1 <!DOCTYPE html>
      2 <script src="/resources/testharness.js"></script>
      3 <script src="/resources/testharnessreport.js"></script>
      4 <script src="/speculation-rules/prerender/resources/utils.js"></script>
      5 <script src="/speculation-rules/prerender/resources/deferred-promise-utils.js"></script>
      6 <script>
      7 
      8 const params = new URLSearchParams(location.search);
      9 
     10 // The main test page (restriction-notification.https.html) loads the
     11 // initiator page, then the initiator page will prerender itself with the
     12 // `prerendering` parameter.
     13 const isPrerendering = params.has('prerendering');
     14 
     15 if (!isPrerendering) {
     16  loadInitiatorPage();
     17 } else {
     18  const prerenderEventCollector = new PrerenderEventCollector();
     19  prerenderEventCollector.addEvent(
     20    `Notification permission is ${Notification.permission}`);
     21  const promise = Notification.requestPermission()
     22    .then(permission => {
     23      prerenderEventCollector.addEvent(`permission was ${permission}`);
     24      if (permission !== "granted") return;
     25      const displayPromise = new Promise((resolve, reject) => {
     26        const notification = new Notification("Prerender Notification");
     27        notification.onshow = () => {
     28          prerenderEventCollector.addEvent('notification displayed');
     29          resolve("Displayed");
     30        };
     31        notification.onerror = () => {
     32          reject("Error on displaying notification");
     33        };
     34      });
     35      return displayPromise;
     36    });
     37  prerenderEventCollector.start(promise, 'notification');
     38 }
     39 
     40 </script>