Files
sousa-gecko/testing/web-platform/tests/digital-credentials/webdriver/create.https.html
T
Mohamed Amir Yosef 6994d2ac0d Bug 2039512 [wpt PR 58587] - Digital Credentials: Add WebDriver automation commands and tests, a=testonly
Automatic update from web-platform-tests
Digital Credentials: Add WebDriver automation commands and tests (#58587)

* Digital Credentials: Add WebDriver automation and tests

---------

Co-authored-by: Marcos Cáceres <marcos@marcosc.com>
--

wpt-commits: f5c8fb8bae361ff7c62da5eed638298a26fc3fb1
wpt-pr: 58587
2026-06-18 14:40:19 +00:00

65 lines
2.9 KiB
HTML

<!DOCTYPE html>
<title>Digital Credential API: create() webdriver tests.</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 { makeCreateOptions } from "../support/helper.js";
promise_test(async (t) => {
const responseData = "test-create-response-data";
await test_driver.set_virtual_wallet_behavior("respond", "openid4vci", { "value": responseData });
t.add_cleanup(() => test_driver.set_virtual_wallet_behavior("clear"));
await test_driver.bless("user activation");
const options = makeCreateOptions({ protocol: "openid4vci" });
const result = await navigator.credentials.create(options);
assert_equals(result.protocol, "openid4vci");
assert_equals(result.data.value, responseData);
}, "navigator.credentials.create() 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", "openid4vci", complexData);
t.add_cleanup(() => test_driver.set_virtual_wallet_behavior("clear"));
await test_driver.bless("user activation");
const options = makeCreateOptions({ protocol: "openid4vci" });
const result = await navigator.credentials.create(options);
assert_equals(result.protocol, "openid4vci");
assert_equals(result.data.a, 1);
assert_array_equals(result.data.b, [2, 3]);
assert_equals(result.data.c.d, 4);
}, "navigator.credentials.create() 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 = makeCreateOptions({ protocol: "openid4vci" });
await promise_rejects_dom(t, "NotAllowedError", navigator.credentials.create(options));
}, "navigator.credentials.create() 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 = makeCreateOptions({ protocol: "openid4vci", signal: controller.signal });
const promise = navigator.credentials.create(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.create() with wait mode should remain pending until aborted.");
</script>