tor-browser

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

non-fully-active.https.html (2220B)


      1 <!DOCTYPE html>
      2 <meta charset="utf-8" />
      3 <title>Credential Management API Test: non-fully active document</title>
      4 <link
      5  rel="help"
      6  href="https://github.com/w3c/webappsec-credential-management"
      7 />
      8 <script src="/resources/testharness.js"></script>
      9 <script src="/resources/testharnessreport.js"></script>
     10 <script src="/resources/testdriver.js"></script>
     11 <script src="/resources/testdriver-vendor.js"></script>
     12 <body>
     13  <iframe></iframe>
     14 </body>
     15 <script>
     16  promise_setup(async () => {
     17    const iframe = document.querySelector("iframe");
     18    await new Promise((resolve) => {
     19      iframe.addEventListener("load", resolve, { once: true });
     20      iframe.src = "about:blank";
     21      document.body.appendChild(iframe);
     22    });
     23  });
     24 
     25  promise_test(async (t) => {
     26    const iframe = document.querySelector("iframe");
     27 
     28    // The signal check happens after the fully active check.
     29    // This allows us to confirm the right error is thrown
     30    // and in the right order.
     31    const controller = new iframe.contentWindow.AbortController();
     32    const signal = controller.signal;
     33    controller.abort();
     34 
     35    // Steal all the needed references.
     36    const { credentials } = iframe.contentWindow.navigator;
     37    const DOMExceptionCtor = iframe.contentWindow.DOMException;
     38 
     39    // No longer fully active.
     40    iframe.remove();
     41 
     42    // Try to get credentials while not fully active...
     43    await promise_rejects_dom(
     44      t,
     45      "InvalidStateError",
     46      DOMExceptionCtor,
     47      credentials.get({ signal }),
     48      "Expected InvalidStateError for get() on non-fully-active document"
     49    );
     50 
     51    // Try to create credentials while not fully active...
     52    await promise_rejects_dom(
     53      t,
     54      "InvalidStateError",
     55      DOMExceptionCtor,
     56      credentials.create({ signal }),
     57      "Expected InvalidStateError for create() on non-fully-active document"
     58    );
     59 
     60    // Try to prevent silent access while not fully active...
     61    await promise_rejects_dom(
     62      t,
     63      "InvalidStateError",
     64      DOMExceptionCtor,
     65      credentials.preventSilentAccess(),
     66      "Expected InvalidStateError for preventSilentAccess() on non-fully-active document"
     67    );
     68  }, "non-fully active document behavior for CredentialsContainer");
     69 </script>