Source code
Revision control
Copy as Markdown
Other Tools
Test Info: Warnings
- This test has a WPT meta file that expects 4 subtest issues.
- This WPT test may be referenced by the following Test IDs:
- /digital-credentials/webdriver/get.https.html - WPT Dashboard Interop Dashboard
<!DOCTYPE html>
<title>Digital Credential API: get() webdriver tests.</title>
<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);
// Give it some time to make sure it's pending.
await new Promise(resolve => t.step_timeout(resolve, 100));
controller.abort();
await promise_rejects_dom(t, "AbortError", promise);
}, "navigator.credentials.get() with wait mode should remain pending until aborted.");
</script>