[WebAuthN] Implement authenticatorMakeCredential
[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.setCreationReturnBundle(hexStringToUint8Array('00'), hexStringToUint8Array('01'));
24
25         return navigator.credentials.create(options).then(function(credential) {
26                 assert_equals(credential.id, 'AA');
27                 assert_equals(credential.type, 'public-key');
28                 assert_equals(bytesToHexString(credential.rawId), '00');
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), '01');
31                 console.log()
32                 try {
33                     assert_throws("NotSupportedError", credential.getClientExtensionResults());
34                 } catch(error) { }
35             });
36     }, "PublicKeyCredential's [[create]] with minimum options");
37 </script>