Files
sousa-gecko/testing/web-platform/tests/digital-credentials/webdriver/get-openid4vp.https.html
T
Marcos Cáceres b04ca65d7f Bug 2051057 [wpt PR 60952] - Digital Credentials: Split WebDriver get() tests by protocol (openid4vp, org-iso-mdoc), a=testonly
Automatic update from web-platform-tests
Digital Credentials: Split WebDriver get() tests by protocol (openid4vp, org-iso-mdoc) (#60952)

Rename webdriver/get.https.html to get-openid4vp.https.html to make its
protocol explicit, and add a complementary get-mdoc.https.html exercising
the same virtual wallet behaviors (respond/decline/wait) with org-iso-mdoc.
The two files are identical apart from the protocol. This follows the
existing protocol-filtering-{openid4vp,mdoc}.https.html naming convention.

Also harden the abort subtest: drop the arbitrary step_timeout(100) before
abort() (the abort algorithm is registered synchronously in "prepare
credential requests", so abort is deterministic regardless of timing), and
abort with an explicit reason asserted via promise_rejects_exactly, proving
the rejection is caused by the abort() call.
--

wpt-commits: 4f814254d05dd94bf1bc7e056388d0803eff684c
wpt-pr: 60952
2026-07-10 09:24:07 +00:00

63 lines
3.0 KiB
HTML

<!DOCTYPE html>
<title>Digital Credential API: get() webdriver tests for openid4vp-v1-unsigned.</title>
<link rel="help" href="https://wicg.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) => {
const responseData = "test-response-data";
await test_driver.set_virtual_wallet_behavior("respond", "openid4vp-v1-unsigned", { "value": responseData });
t.add_cleanup(() => test_driver.set_virtual_wallet_behavior("clear"));
await test_driver.bless("user activation");
const options = makeGetOptions({ protocol: "openid4vp-v1-unsigned" });
const result = await navigator.credentials.get(options);
assert_equals(result.protocol, "openid4vp-v1-unsigned");
assert_equals(result.data.value, responseData);
}, "navigator.credentials.get() with respond mode should resolve with the specified data.");
promise_test(async (t) => {
const complexData = { "a": 1, "b": [2, 3], "c": { "d": 4 } };
await test_driver.set_virtual_wallet_behavior("respond", "openid4vp-v1-unsigned", complexData);
t.add_cleanup(() => test_driver.set_virtual_wallet_behavior("clear"));
await test_driver.bless("user activation");
const options = makeGetOptions({ protocol: "openid4vp-v1-unsigned" });
const result = await navigator.credentials.get(options);
assert_equals(result.protocol, "openid4vp-v1-unsigned");
assert_equals(result.data.a, 1);
assert_array_equals(result.data.b, [2, 3]);
assert_equals(result.data.c.d, 4);
}, "navigator.credentials.get() with complex data response should resolve with structured data.");
promise_test(async (t) => {
await test_driver.set_virtual_wallet_behavior("decline");
t.add_cleanup(() => test_driver.set_virtual_wallet_behavior("clear"));
await test_driver.bless("user activation");
const options = makeGetOptions({ protocol: "openid4vp-v1-unsigned" });
await promise_rejects_dom(t, "NotAllowedError", navigator.credentials.get(options));
}, "navigator.credentials.get() with decline mode should reject with NotAllowedError.");
promise_test(async (t) => {
await test_driver.set_virtual_wallet_behavior("wait");
t.add_cleanup(() => test_driver.set_virtual_wallet_behavior("clear"));
await test_driver.bless("user activation");
const controller = new AbortController();
const options = makeGetOptions({ protocol: "openid4vp-v1-unsigned", signal: controller.signal });
const promise = navigator.credentials.get(options);
const reason = new Error("aborted by test");
controller.abort(reason);
await promise_rejects_exactly(t, reason, promise);
}, "navigator.credentials.get() with wait mode should reject with the abort reason when aborted.");
</script>