-
Notifications
You must be signed in to change notification settings - Fork 3.8k
Expand file tree
/
Copy pathcreate.https.html
More file actions
64 lines (52 loc) · 2.95 KB
/
create.https.html
File metadata and controls
64 lines (52 loc) · 2.95 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
<!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>