Files
sousa-gecko/testing/web-platform/tests/digital-credentials/concurrent-requests.https.html
T
Marcos Cáceres 079da8d255 Bug 2052411 [wpt PR 61056] - [digital-credentials] concurrent-requests: park the first request with a "wait" wallet, a=testonly
Automatic update from web-platform-tests
[digital-credentials] concurrent-requests: park the first request with a "wait" wallet (#61056)

The test issues two concurrent navigator.credentials.get() calls, expecting
the second to be rejected with NotAllowedError by the concurrency guard while
the first is still pending. Without a virtual wallet the first request fails
before it can stay pending, so the guard never runs and the second request
fails with the wrong error.

Set a "wait" virtual wallet behavior via test_driver.set_virtual_wallet_behavior
so the first request parks and stays pending, letting the guard reject the
second request. Load testdriver.js with ?feature=bidi, matching the other
digital-credentials tests that drive the virtual wallet.
--

wpt-commits: b86e7702bb511e40f60302f352e8cde84d0eca6f
wpt-pr: 61056
2026-07-10 09:25:30 +00:00

52 lines
1.9 KiB
HTML

<!DOCTYPE html>
<meta charset="utf-8">
<title>Digital Credential concurrent request rejection tests</title>
<link rel="help" href="https://w3c-fedid.github.io/digital-credentials/" />
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="/resources/testdriver.js?feature=bidi"></script>
<script src="/resources/testdriver-vendor.js"></script>
<body></body>
<script type="module">
import { makeGetOptions } from "./support/helper.js";
promise_test(async (t) => {
// Park the first request ("wait") so the second hits the concurrency guard.
await test_driver.set_virtual_wallet_behavior("wait");
t.add_cleanup(() => test_driver.set_virtual_wallet_behavior("clear"));
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>