tor-browser

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

share-sharePromise-internal-slot.https.html (1377B)


      1 <!DOCTYPE html>
      2 <html>
      3  <head>
      4    <meta charset="utf-8" />
      5    <link rel="help" href="https://github.com/w3c/web-share/pull/113" />
      6    <title>WebShare Test: only one share at a time</title>
      7    <script src="/resources/testharness.js"></script>
      8    <script src="/resources/testharnessreport.js"></script>
      9    <script src="/resources/testdriver.js"></script>
     10    <script src="/resources/testdriver-vendor.js"></script>
     11  </head>
     12  <body>
     13    <button>
     14    <script>
     15      setup({ allow_uncaught_exception:true });
     16      promise_test(async t => {
     17        const button = document.querySelector("button");
     18        const p = new Promise(r => {
     19          button.onclick = () => {
     20            const promises = [];
     21            promises.push(
     22              navigator.share({ title: "should be pending" }),
     23              navigator.share({ title: "should reject" }),
     24              navigator.share({ title: "should also reject" })
     25            );
     26            r(promises);
     27          };
     28        });
     29        test_driver.click(button);
     30        const [, promise2, promise3] = await p;
     31        await Promise.all([
     32          promise_rejects_dom(t, "InvalidStateError", promise2),
     33          promise_rejects_dom(t, "InvalidStateError", promise3)
     34        ]);
     35      }, "Only allow one share call at a time, which is controlled by the [[sharePromise]] internal slot.");
     36    </script>
     37  </body>
     38 </html>