e85c2c84af722d7519c55ec7c5ce6c500636ac20
[WebKit-https.git] / LayoutTests / http / wpt / webauthn / public-key-credential-get-failure-hid-silent.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     promise_test(function(t) {
8         const options = {
9             publicKey: {
10                 challenge: asciiToUint8Array("123456"),
11                 timeout: 10
12             }
13         };
14
15         if (window.testRunner)
16             testRunner.setWebAuthenticationMockConfiguration({ silentFailure: true, hid: { stage: "request", subStage: "msg", error: "malicious-payload", payloadBase64: [testDummyMessagePayloadBase64] } });
17         return promiseRejects(t, "NotAllowedError", navigator.credentials.get(options), "Operation timed out.");
18     }, "PublicKeyCredential's [[get]] with malicious payload in a mock hid authenticator.");
19
20     promise_test(function(t) {
21         const options = {
22             publicKey: {
23                 challenge: asciiToUint8Array("123456"),
24                 userVerification: "required",
25                 timeout: 10
26             }
27         };
28
29         if (window.testRunner)
30             testRunner.setWebAuthenticationMockConfiguration({ silentFailure: true, hid: { stage: "request", subStage: "msg", error: "unsupported-options" } });
31         return promiseRejects(t, "NotAllowedError", navigator.credentials.get(options), "Operation timed out.");
32     }, "PublicKeyCredential's [[get]] with unsupported options in a mock hid authenticator.");
33
34     promise_test(function(t) {
35         const options = {
36             publicKey: {
37                 challenge: asciiToUint8Array("123456"),
38                 timeout: 10
39             }
40         };
41
42         if (window.testRunner)
43             testRunner.setWebAuthenticationMockConfiguration({ silentFailure: true, hid: { stage: "request", subStage: "msg", error: "malicious-payload", payloadBase64: [testCtapErrInvalidCredentialResponseBase64] } });
44         return promiseRejects(t, "NotAllowedError", navigator.credentials.get(options), "Operation timed out.");
45     }, "PublicKeyCredential's [[get]] with invalid credential in a mock hid authenticator.");
46
47     promise_test(function(t) {
48         const options = {
49             publicKey: {
50                 challenge: asciiToUint8Array("123456"),
51                 timeout: 10
52             }
53         };
54
55         if (window.testRunner)
56             testRunner.setWebAuthenticationMockConfiguration({ silentFailure: true, hid: { stage: "request", subStage: "msg", error: "malicious-payload", canDowngrade: true, payloadBase64: [testCtapErrInvalidCredentialResponseBase64] } });
57         return promiseRejects(t, "NotAllowedError", navigator.credentials.get(options), "Operation timed out.");
58     }, "PublicKeyCredential's [[get]] with authenticator downgrade in a mock hid authenticator.");
59
60     promise_test(function(t) {
61         const options = {
62             publicKey: {
63                 challenge: asciiToUint8Array("123456"),
64                 extensions: { appid: "" },
65                 timeout: 10
66             }
67         };
68
69         if (window.testRunner)
70             testRunner.setWebAuthenticationMockConfiguration({ silentFailure: true, hid: { stage: "request", subStage: "msg", error: "malicious-payload", canDowngrade: true, payloadBase64: [testCtapErrInvalidCredentialResponseBase64] } });
71         return promiseRejects(t, "NotAllowedError", navigator.credentials.get(options), "Operation timed out.");
72     }, "PublicKeyCredential's [[get]] with authenticator downgrade in a mock hid authenticator. 2");
73 </script>