| <!DOCTYPE html> |
| <title>Web Authentication API: PublicKeyCredential's [[get]] failure cases.</title> |
| <script src="/resources/testharness.js"></script> |
| <script src="/resources/testharnessreport.js"></script> |
| <script src="./resources/util.js"></script> |
| <script> |
| promise_test(function(t) { |
| const options = { |
| publicKey: { |
| challenge: asciiToUint8Array("123456"), |
| timeout: 0, |
| } |
| }; |
| internals.mockCredentialsMessenger.setDidTimeOut(); |
| |
| return promise_rejects(t, "NotAllowedError", |
| navigator.credentials.get(options)); |
| }, "PublicKeyCredential's [[get]] with timeout"); |
| |
| promise_test(function(t) { |
| const options = { |
| publicKey: { |
| rpId: "example.com", |
| challenge: asciiToUint8Array("123456"), |
| } |
| }; |
| return promise_rejects(t, "SecurityError", |
| navigator.credentials.get(options)); |
| }, "PublicKeyCredential's [[get]] with a mismatched RP ID"); |
| |
| promise_test(function(t) { |
| const options = { |
| publicKey: { |
| challenge: asciiToUint8Array("123456"), |
| allowCredentials: [{ type: "public-key", id: asciiToUint8Array("123456") }], |
| } |
| }; |
| internals.mockCredentialsMessenger.setDidUserCancel(); |
| |
| return promise_rejects(t, "NotAllowedError", |
| navigator.credentials.get(options)); |
| }, "PublicKeyCredential's [[get]] with user cancellations"); |
| </script> |