tor-browser

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

requireInteraction-manual.https.html (1852B)


      1 <!DOCTYPE html>
      2 <meta charset="utf-8">
      3 <title>requireInteraction: true</title>
      4 <script src="/resources/testharness.js"></script>
      5 <script src="/resources/testharnessreport.js"></script>
      6 <p>
      7  <button id="button">Push me to open a requireInteraction=true notification!</button>
      8  <button id="finish">Push me if you are done</button>
      9 </p>
     10 Steps:
     11 <ol>
     12  <li>Make sure you didn't block the notification permission.</li>
     13  <li>Allow the notification permission if the prompt opens.</li>
     14  <li>Click the first button.</li>
     15  <li>See whether the notification disappears from the screen without interaction. It must not.</li>
     16  <li>If you are sure it's not disappearing, then click that second button.</li>
     17 </ol>
     18 Why this is manual? Because
     19 <ol>
     20  <li>
     21    One need to wait for more than arbitrary platform-specific time to see
     22    it really does not disappear automatically.
     23  </li>
     24  <li>There's simply no API to tell it's disappeared from the screen or not</li>
     25 </ol>
     26 <script>
     27  setup({ explicit_timeout: true })
     28 
     29  promise_test(async () => {
     30    const permission = await Notification.requestPermission();
     31    if (permission === "denied") {
     32      throw new Error("Permission is denied, can't proceed");
     33    }
     34    await new Promise(r => button.onclick = r);
     35    const n = new Notification("Test notification", { requireInteraction: true });
     36    await new Promise((resolve, reject) => {
     37      n.onshow = resolve;
     38      n.onerror = () => reject(new Error(
     39        "Notification failed, and there's no good error message. Maybe some permission issue?"
     40      ));
     41    });
     42    await Promise.race([
     43      new Promise(r => finish.onclick = r),
     44      new Promise((r, reject) => {
     45        n.onclose = n.onclick = () => reject(new Error(
     46          "Uh, you should finish the test before you interact with the notification."
     47        ));
     48      }),
     49    ]);
     50  });
     51 </script>