tor-browser

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

credentialscontainer-get-basics.https.html (2437B)


      1 <!DOCTYPE html>
      2 <title>Credential Management API: get() basics.</title>
      3 <script src="/resources/testharness.js"></script>
      4 <script src="/resources/testharnessreport.js"></script>
      5 <script>
      6  promise_test(async (t) => {
      7    await promise_rejects_dom(
      8      t,
      9      "NotSupportedError",
     10      navigator.credentials.get()
     11    );
     12 
     13    await promise_rejects_dom(
     14      t,
     15      "NotSupportedError",
     16      navigator.credentials.get({})
     17    );
     18 
     19    await promise_rejects_dom(
     20      t,
     21      "NotSupportedError",
     22      navigator.credentials.get({ x: "y" })
     23    );
     24 
     25    await promise_rejects_dom(
     26      t,
     27      "NotSupportedError",
     28      navigator.credentials.get({ x: "y", y: "z" })
     29    );
     30 
     31    await promise_rejects_dom(
     32      t,
     33      "NotSupportedError",
     34      navigator.credentials.get({ x: "y" })
     35    );
     36 
     37    await promise_rejects_dom(
     38      t,
     39      "NotSupportedError",
     40      navigator.credentials.get({ mediation: "required" })
     41    );
     42 
     43    const abortController = new AbortController();
     44    const { signal } = abortController;
     45    await promise_rejects_dom(
     46      t,
     47      "NotSupportedError",
     48      navigator.credentials.get({ signal })
     49    );
     50 
     51    await promise_rejects_dom(
     52      t,
     53      "NotSupportedError",
     54      navigator.credentials.get({ signal, mediation: "required" })
     55    );
     56  }, "Calling navigator.credentials.get() without a valid matching interface.");
     57 
     58  promise_test(function(t) {
     59    const controller = new AbortController();
     60    controller.abort("custom reason");
     61 
     62    return promise_rejects_exactly(t, "custom reason",
     63        navigator.credentials.get({ signal: controller.signal }));
     64  }, "navigator.credentials.get() aborted with custom reason");
     65 
     66  promise_test(async function(t) {
     67    const reasons = [{}, [], new Error("custom error")];
     68 
     69    for (let reason of reasons) {
     70        const result = navigator.credentials.get({ signal: AbortSignal.abort(reason) });
     71        await promise_rejects_exactly(t, reason, result);
     72    }
     73  }, "navigator.credentials.get() aborted with different objects");
     74 
     75  promise_test(function(t) {
     76    const error = new Error("custom error");
     77    const controller = new AbortController();
     78 
     79    const result = navigator.credentials.get({ signal: controller.signal });
     80    controller.abort(error); // aborted after the promise is created
     81 
     82    return promise_rejects_exactly(t, error, result);
     83  }, "navigator.credentials.get() rejects when aborted after the promise creation");
     84 </script>