[WebAuthN] Revisit the whole async model of task dispatching, timeout and aborting
[WebKit-https.git] / LayoutTests / http / wpt / webauthn / public-key-credential-create-success.https.html
1 <!DOCTYPE html>
2 <title>Web Authentication API: PublicKeyCredential's [[create]] success cases.</title>
3 <script src="/resources/testharness.js"></script>
4 <script src="/resources/testharnessreport.js"></script>
5 <script src="./resources/util.js"></script>
6 <script>
7     promise_test(function(t) {
8         const options = {
9             publicKey: {
10                 rp: {
11                     name: "localhost",
12                 },
13                 user: {
14                     name: "John Appleseed",
15                     id: asciiToUint8Array("123456"),
16                     displayName: "Appleseed",
17                 },
18                 challenge: Base64URL.parse("MTIzNDU2"),
19                 pubKeyCredParams: [{ type: "public-key", alg: -7 }],
20             }
21         };
22         // A mock attestation object
23         internals.mockCredentialsMessenger.setAttestationObject(hexStringToUint8Array('000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001ff'));
24
25         return navigator.credentials.create(options).then(function(credential) {
26                 assert_equals(credential.id, '_w');
27                 assert_equals(credential.type, 'public-key');
28                 assert_equals(bytesToHexString(credential.rawId), 'ff');
29                 assert_equals(bytesToASCIIString(credential.response.clientDataJSON), '{"type":"webauthn.create","challenge":"MTIzNDU2","origin":"https://localhost:9443","hashAlgorithm":"SHA-256"}');
30                 assert_equals(bytesToHexString(credential.response.attestationObject), '000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001ff');
31                 try {
32                     assert_throws("NotSupportedError", credential.getClientExtensionResults());
33                 } catch(error) { }
34             });
35     }, "PublicKeyCredential's [[create]] with minimum options");
36 </script>