Unreviewed, rolling out r228444.
[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     // The following test is specifically tuned for current dummy authenticator.
8     promise_test(function(t) {
9         const options = {
10             publicKey: {
11                 rp: {
12                     name: "localhost",
13                 },
14                 user: {
15                     name: "John Appleseed",
16                     id: asciiToUint8Array("123456"),
17                     displayName: "Appleseed",
18                 },
19                 challenge: Base64URL.parse("MTIzNDU2"),
20                 pubKeyCredParams: [{ type: "public-key", alg: -7 }],
21             }
22         };
23
24         return navigator.credentials.create(options).then(function(credential) {
25                 assert_equals(credential.id, '_w');
26                 assert_equals(credential.type, 'public-key');
27                 assert_equals(bytesToHexString(credential.rawId), 'ff');
28                 assert_equals(bytesToASCIIString(credential.response.clientDataJSON), '{"type":"webauthn.create","challenge":"MTIzNDU2","origin":"https://localhost:9443","hashAlgorithm":"SHA-256"}');
29                 // This field is completely fake 0x00*43 | 0x0001ff | SHA-256 hash of the clientDataJSON
30                 assert_equals(bytesToHexString(credential.response.attestationObject), '000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001ff3374b98316b38046727a770b8e95c4580a292b9e2f4bb44a250a5402d6d3783a');
31                 try {
32                     assert_throws("NotSupportedError", credential.getClientExtensionResults());
33                 } catch(error) { }
34             });
35     }, "PublicKeyCredential's [[create]] with minimum options");
36 </script>