Source code
Revision control
Copy as Markdown
Other Tools
Test Info:
- This WPT test may be referenced by the following Test IDs:
- /digital-credentials/concurrent-requests.https.html - WPT Dashboard Interop Dashboard
<!DOCTYPE html>
<meta charset="utf-8">
<title>Digital Credential concurrent request rejection tests</title>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="/resources/testdriver.js"></script>
<script src="/resources/testdriver-vendor.js"></script>
<body></body>
<script type="module">
import { makeGetOptions } from "./support/helper.js";
promise_test(async (t) => {
const abortController = new AbortController();
const firstOptions = makeGetOptions({ signal: abortController.signal });
const secondOptions = makeGetOptions();
await test_driver.bless("user activation for first request");
const firstRequest = navigator.credentials.get(firstOptions);
// Use bless's action callback so the second get() is called within
// the same microtask as activation grant. This prevents the first
// request's IPC response from completing (clearing the pending state
// in the browser process) before the second call is dispatched.
let secondRequest;
await test_driver.bless("user activation for second request", () => {
assert_true(navigator.userActivation.isActive);
secondRequest = navigator.credentials.get(secondOptions);
});
await promise_rejects_dom(
t,
"NotAllowedError",
secondRequest,
"Second concurrent request should be rejected with NotAllowedError"
);
abortController.abort();
await promise_rejects_dom(
t,
"AbortError",
firstRequest,
"First request should be aborted"
);
}, "A second get() call while another is pending should reject with NotAllowedError.");
</script>