[WebAuthN] Support CTAP HID authenticators on macOS
[WebKit-https.git] / LayoutTests / http / wpt / webauthn / public-key-credential-get-failure-hid.https.html
1 <!DOCTYPE html>
2 <title>Web Authentication API: PublicKeyCredential's [[get]] failure 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     // Default mock configuration. Tests need to override if they need different configuration.
8     if (window.testRunner)
9         testRunner.setWebAuthenticationMockConfiguration({ hid: { stage: "request", subStage: "msg", error: "malicious-payload" } });
10
11     promise_test(t => {
12         const options = {
13             publicKey: {
14                 challenge: asciiToUint8Array("123456"),
15                 allowCredentials: [
16                     { type: "public-key", id: Base64URL.parse(testHidCredentialIdBase64), transports: ["nfc"] },
17                     { type: "public-key", id: Base64URL.parse(testHidCredentialIdBase64), transports: ["ble"] },
18                     { type: "public-key", id: Base64URL.parse(testHidCredentialIdBase64), transports: ["internal"] }
19                 ],
20                 timeout: 10
21             }
22         };
23
24         return promiseRejects(t, "NotAllowedError", navigator.credentials.get(options), "Operation timed out.");
25     }, "PublicKeyCredential's [[get]] with timeout in a mock hid authenticator.");
26
27     promise_test(function(t) {
28         const options = {
29             publicKey: {
30                 challenge: asciiToUint8Array("123456")
31             }
32         };
33
34         if (window.testRunner)
35             testRunner.setWebAuthenticationMockConfiguration({ hid: { stage: "request", subStage: "msg", error: "malicious-payload", payloadBase64: testDummyMessagePayloadBase64 } });
36         return promiseRejects(t, "UnknownError", navigator.credentials.get(options), "Unknown internal error. Error code: -1");
37     }, "PublicKeyCredential's [[get]] with malicious payload in a mock hid authenticator.");
38
39     promise_test(function(t) {
40         const options = {
41             publicKey: {
42                 challenge: asciiToUint8Array("123456"),
43                 userVerification: "required"
44             }
45         };
46
47         if (window.testRunner)
48             testRunner.setWebAuthenticationMockConfiguration({ hid: { stage: "request", subStage: "msg", error: "unsupported-options" } });
49         return promiseRejects(t, "UnknownError", navigator.credentials.get(options), "Unknown internal error. Error code: 43");
50     }, "PublicKeyCredential's [[get]] with unsupported options in a mock hid authenticator.");
51 </script>