| <!DOCTYPE html> |
| <title>Web Authentication API: PublicKeyCredential's [[get]] success cases with a mock hid authenticator.</title> |
| <script src="/resources/testharness.js"></script> |
| <script src="/resources/testharnessreport.js"></script> |
| <script src="./resources/util.js"></script> |
| <script> |
| // Default mock configuration. Tests need to override if they need different configuration. |
| if (window.internals) |
| internals.setMockWebAuthenticationConfiguration({ hid: { stage: "request", subStage: "msg", error: "success", payloadBase64: [testAssertionMessageBase64] } }); |
| |
| promise_test(t => { |
| const options = { |
| publicKey: { |
| challenge: Base64URL.parse("MTIzNDU2"), |
| timeout: 100 |
| } |
| }; |
| |
| return navigator.credentials.get(options).then(credential => { |
| return checkCtapGetAssertionResult(credential); |
| }); |
| }, "PublicKeyCredential's [[get]] with minimum options in a mock hid authenticator."); |
| |
| promise_test(t => { |
| const options = { |
| publicKey: { |
| challenge: Base64URL.parse("MTIzNDU2"), |
| allowCredentials: [ |
| { type: "public-key", id: Base64URL.parse(testHidCredentialIdBase64), transports: ["usb"] } |
| ], |
| timeout: 100 |
| } |
| }; |
| |
| return navigator.credentials.get(options).then(credential => { |
| return checkCtapGetAssertionResult(credential); |
| }); |
| }, "PublicKeyCredential's [[get]] with matched allow credentials in a mock hid authenticator."); |
| |
| promise_test(t => { |
| const options = { |
| publicKey: { |
| challenge: Base64URL.parse("MTIzNDU2"), |
| userVerification: "preferred", |
| timeout: 100 |
| } |
| }; |
| |
| return navigator.credentials.get(options).then(credential => { |
| return checkCtapGetAssertionResult(credential); |
| }); |
| }, "PublicKeyCredential's [[get]] with userVerification { preferred } in a mock hid authenticator."); |
| |
| promise_test(t => { |
| const options = { |
| publicKey: { |
| challenge: Base64URL.parse("MTIzNDU2"), |
| userVerification: "discouraged", |
| timeout: 100 |
| } |
| }; |
| |
| return navigator.credentials.get(options).then(credential => { |
| return checkCtapGetAssertionResult(credential); |
| }); |
| }, "PublicKeyCredential's [[get]] with userVerification { discouraged } in a mock hid authenticator."); |
| |
| promise_test(t => { |
| const options = { |
| publicKey: { |
| challenge: Base64URL.parse("MTIzNDU2"), |
| allowCredentials: [ |
| { type: "public-key", id: Base64URL.parse(testHidCredentialIdBase64), transports: ["usb"] } |
| ], |
| userVerification: "preferred", |
| timeout: 100 |
| } |
| }; |
| |
| return navigator.credentials.get(options).then(credential => { |
| return checkCtapGetAssertionResult(credential); |
| }); |
| }, "PublicKeyCredential's [[get]] with mixed options in a mock hid authenticator."); |
| |
| promise_test(t => { |
| const options = { |
| publicKey: { |
| challenge: Base64URL.parse("MTIzNDU2"), |
| timeout: 100 |
| } |
| }; |
| |
| |
| // Stall the first request to wait for cancellation. |
| if (window.internals) |
| internals.setMockWebAuthenticationConfiguration({ hid: { stage: "request", subStage: "msg", error: "success", payloadBase64: [testAssertionMessageBase64], expectCancel: true } }); |
| promiseRejects(t, "NotAllowedError", navigator.credentials.get(options), "This request has been cancelled by a new request."); |
| if (window.internals) |
| internals.setMockWebAuthenticationConfiguration({ hid: { stage: "request", subStage: "msg", error: "success", payloadBase64: [testAssertionMessageBase64] } }); |
| return navigator.credentials.get(options).then(credential => { |
| return checkCtapGetAssertionResult(credential); |
| }); |
| }, "PublicKeyCredential's [[get]] with two consecutive requests."); |
| |
| promise_test(t => { |
| const options = { |
| publicKey: { |
| challenge: Base64URL.parse("MTIzNDU2"), |
| timeout: 100 |
| } |
| }; |
| |
| if (window.internals) |
| internals.setMockWebAuthenticationConfiguration({ hid: { stage: "request", subStage: "msg", error: "success", payloadBase64: [testAssertionMessageLongBase64, testAssertionMessageLongBase64] } }); |
| return navigator.credentials.get(options).then(credential => { |
| return checkCtapGetAssertionResult(credential, "MIIBkzCCATigAwIBAjCCAZMwggE4oAMCAQIwggGTMII="); |
| }); |
| }, "PublicKeyCredential's [[get]] with multiple accounts in a mock hid authenticator."); |
| |
| promise_test(t => { |
| const options = { |
| publicKey: { |
| challenge: Base64URL.parse("MTIzNDU2"), |
| userVerification: "discouraged", |
| timeout: 100 |
| } |
| }; |
| |
| if (window.internals) |
| internals.setMockWebAuthenticationConfiguration({ hid: { supportClientPin: true, payloadBase64: [testAssertionMessageBase64] } }); |
| return navigator.credentials.get(options).then(credential => { |
| return checkCtapGetAssertionResult(credential); |
| }); |
| }, "PublicKeyCredential's [[get]] with PIN supported in the authenticator but userVerification = 'discouraged' in a mock hid authenticator."); |
| </script> |