8a7cd8a5bb91d81b1476add7c42d01363b0d6c7a
[WebKit-https.git] / LayoutTests / http / wpt / webauthn / public-key-credential-get-failure-u2f-silent.https.html
1 <!DOCTYPE html>
2 <title>Web Authentication API: PublicKeyCredential's [[get]] failure cases with a mock u2f 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                 allowCredentials: [{ type: "public-key", id: Base64URL.parse(testCredentialIdBase64) }],
12                 timeout: 10
13             }
14         };
15
16         if (window.testRunner)
17             testRunner.setWebAuthenticationMockConfiguration({ silentFailure: true, hid: { stage: "request", subStage: "msg", error: "malicious-payload", isU2f: true, payloadBase64: [testU2fApduNoErrorOnlyResponseBase64] } });
18         return promiseRejects(t, "NotAllowedError", navigator.credentials.get(options), "Operation timed out.");
19     }, "PublicKeyCredential's [[get]] with malformed sign response in a mock hid authenticator.");
20
21     promise_test(function(t) {
22         const options = {
23             publicKey: {
24                 challenge: asciiToUint8Array("123456"),
25                 allowCredentials: [{ type: "public-key", id: Base64URL.parse(testCredentialIdBase64) }],
26                 timeout: 10
27             }
28         };
29
30         if (window.testRunner)
31             testRunner.setWebAuthenticationMockConfiguration({ silentFailure: true, hid: { stage: "request", subStage: "msg", error: "malicious-payload", isU2f: true, payloadBase64: [testU2fApduWrongDataOnlyResponseBase64] } });
32         return promiseRejects(t, "NotAllowedError", navigator.credentials.get(options), "Operation timed out.");
33     }, "PublicKeyCredential's [[get]] with no matched allow credentials in a mock hid authenticator.");
34
35     promise_test(function(t) {
36         const options = {
37             publicKey: {
38                 challenge: asciiToUint8Array("123456"),
39                 allowCredentials: [{ type: "public-key", id: Base64URL.parse(testCredentialIdBase64) }, { type: "public-key", id: Base64URL.parse(testCredentialIdBase64) }],
40                 timeout: 10
41             }
42         };
43
44         if (window.testRunner)
45             testRunner.setWebAuthenticationMockConfiguration({ silentFailure: true, hid: { stage: "request", subStage: "msg", error: "malicious-payload", isU2f: true, payloadBase64: [testU2fApduWrongDataOnlyResponseBase64, testU2fApduWrongDataOnlyResponseBase64] } });
46         return promiseRejects(t, "NotAllowedError", navigator.credentials.get(options), "Operation timed out.");
47     }, "PublicKeyCredential's [[get]] with no matched allow credentials in a mock hid authenticator. 2");
48 </script>