[WebAuthn] Move the mock testing entrance to Internals
[WebKit-https.git] / LayoutTests / http / wpt / webauthn / public-key-credential-get-success-nfc.https.html
1 <!DOCTYPE html>
2 <title>Web Authentication API: PublicKeyCredential's [[get]] success cases with a mock nfc 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.internals)
9         internals.setMockWebAuthenticationConfiguration({ nfc: { error: "success", payloadBase64: [testNfcCtapVersionBase64, testGetInfoResponseApduBase64, testAssertionMessageApduBase64] } });
10
11     promise_test(t => {
12         const options = {
13             publicKey: {
14                 challenge: Base64URL.parse("MTIzNDU2"),
15                 timeout: 100
16             }
17         };
18
19         return navigator.credentials.get(options).then(credential => {
20             return checkCtapGetAssertionResult(credential);
21         });
22     }, "PublicKeyCredential's [[get]] with minimum options in a mock nfc authenticator.");
23
24     promise_test(t => {
25         const options = {
26             publicKey: {
27                 challenge: Base64URL.parse("MTIzNDU2"),
28                 allowCredentials: [{ type: "public-key", id: Base64URL.parse(testU2fCredentialIdBase64), transports: ["nfc"] }],
29                 timeout: 100
30             }
31         };
32
33         if (window.internals)
34             internals.setMockWebAuthenticationConfiguration({ nfc: { error: "success", payloadBase64: [testNfcU2fVersionBase64, testU2fApduInsNotSupportedOnlyResponseBase64, testU2fSignResponse] } });
35         return navigator.credentials.get(options).then(credential => {
36             return checkU2fGetAssertionResult(credential);
37         });
38     }, "PublicKeyCredential's [[get]] with U2F in a mock nfc authenticator.");
39 </script>