[WebAuthN] Import a JS CBOR coder
[WebKit-https.git] / LayoutTests / http / wpt / webauthn / idl.https.html
1 <!doctype html>
2 <html>
3 <head>
4     <meta charset=utf-8>
5     <title>IDL check of WebAuthN</title>
6     <link rel="help" href="https://www.w3.org/TR/webauthn/#idl-index">
7     <script src=/resources/testharness.js></script>
8     <script src=/resources/testharnessreport.js></script>
9     <script src=/resources/WebIDLParser.js></script>
10     <script src=/resources/idlharness.js></script>
11     <script src="./resources/util.js"></script>
12 </head>
13 <body>
14
15 <h1 class="instructions">Description</h1>
16
17 <p class="instructions">This test verifies that the implementations of the WebAuthN API match with its WebIDL definition.</p>
18
19 <div id='log'></div>
20
21 <script>
22 if (window.testRunner)
23     testRunner.setWebAuthenticationMockConfiguration({
24         local: {
25             acceptAuthentication: true,
26             acceptAttestation: true,
27             privateKeyBase64: testES256PrivateKeyBase64,
28             userCertificateBase64: testAttestationCertificateBase64,
29             intermediateCACertificateBase64: testAttestationIssuingCACertificateBase64
30         }
31     });
32
33 promise_test(async () => {
34     const idlURL = ["WebAuthN.idl"];
35     const idlArray = new IdlArray();
36     const idlText = await fetch(idlURL).then(r => r.text());
37
38     idlArray.add_untested_idls("interface ArrayBuffer {};");
39     idlArray.add_untested_idls("dictionary CredentialCreationOptions {};");
40     idlArray.add_untested_idls("dictionary CredentialRequestOptions {};");
41
42     idlArray.add_idls(`
43         [Exposed=Window, SecureContext]
44         interface Credential {
45             readonly attribute USVString id;
46             readonly attribute DOMString type;
47         };
48     `);
49     idlArray.add_idls(idlText);
50
51     const creationOptions = {
52         publicKey: {
53             rp: {
54                 name: "localhost",
55             },
56             user: {
57                 name: "John Appleseed",
58                 id: Base64URL.parse(testUserhandleBase64),
59                 displayName: "Appleseed",
60             },
61             challenge: Base64URL.parse("MTIzNDU2"),
62             pubKeyCredParams: [{ type: "public-key", alg: -7 }],
63         }
64     };
65     createdCredential = await navigator.credentials.create(creationOptions);
66
67
68     const requestOptions = {
69         publicKey: {
70             challenge: Base64URL.parse("MTIzNDU2"),
71         }
72     };
73     requestedCredential = await navigator.credentials.get(requestOptions);
74
75     idlArray.add_objects({"PublicKeyCredential": ["createdCredential"], "AuthenticatorAttestationResponse": ["createdCredential.response"], "AuthenticatorAssertionResponse": ["requestedCredential.response"]});
76     idlArray.test();
77
78     if (window.testRunner)
79         testRunner.cleanUpKeychain(testRpId);
80 }, "Setup for WebAuthN API IDL tests.");
81 </script>