[WebAuthN] Support CTAP HID authenticators on macOS
[WebKit-https.git] / LayoutTests / http / wpt / webauthn / ctap-hid-success.https.html
1 <!DOCTYPE html>
2 <title>Web Authentication API: CTAP HID success cases with a mock hid authenticator.</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     const defaultOptions = {
8         publicKey: {
9             rp: {
10                 name: "example.com"
11             },
12             user: {
13                 name: "John Appleseed",
14                 id: asciiToUint8Array("123456"),
15                 displayName: "John",
16             },
17             challenge: asciiToUint8Array("123456"),
18             pubKeyCredParams: [{ type: "public-key", alg: -7 }],
19         }
20     };
21
22     promise_test(function(t) {
23         if (window.testRunner)
24             testRunner.setWebAuthenticationMockConfiguration({ hid: { stage: "request", subStage: "msg", error: "success", payloadBase64: testCreationMessageBase64, keepAlive: true } });
25         return navigator.credentials.create(defaultOptions).then(credential => {
26             assert_not_equals(credential, undefined);
27             assert_not_equals(credential, null);
28         });
29     }, "CTAP HID with keep alive message in a mock hid authenticator.");
30
31     promise_test(function(t) {
32         if (window.testRunner)
33             testRunner.setWebAuthenticationMockConfiguration({ hid: { stage: "request", subStage: "msg", error: "success", payloadBase64: testCreationMessageBase64, fastDataArrival: true } });
34         return navigator.credentials.create(defaultOptions).then(credential => {
35             assert_not_equals(credential, undefined);
36             assert_not_equals(credential, null);
37         });
38     }, "CTAP HID with fast data arrival in a mock hid authenticator.");
39
40     promise_test(function(t) {
41         if (window.testRunner)
42             testRunner.setWebAuthenticationMockConfiguration({ hid: { stage: "info", subStage: "init", error: "empty-report", payloadBase64: testCreationMessageBase64, continueAfterErrorData: true } });
43         return navigator.credentials.create(defaultOptions).then(credential => {
44             assert_not_equals(credential, undefined);
45             assert_not_equals(credential, null);
46         });
47     }, "CTAP HID with continue after empty report in a mock hid authenticator.");
48
49     promise_test(function(t) {
50         if (window.testRunner)
51             testRunner.setWebAuthenticationMockConfiguration({ hid: { stage: "info", subStage: "init", error: "wrong-channel-id", payloadBase64: testCreationMessageBase64, continueAfterErrorData: true } });
52         return navigator.credentials.create(defaultOptions).then(credential => {
53             assert_not_equals(credential, undefined);
54             assert_not_equals(credential, null);
55         });
56     }, "CTAP HID with continue after wrong channel id in a mock hid authenticator.");
57 </script>