blob: f02c255e88240474f1222c12b065c6b9f8e99f32 [file] [log] [blame]
<!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>
(async function() {
const userhandleBase64 = generateUserhandleBase64();
const privateKeyBase64 = await generatePrivateKeyBase64();
const credentialID = await calculateCredentialID(privateKeyBase64);
// Default mock configuration. Tests need to override if they need different configuration.
if (window.internals)
internals.setMockWebAuthenticationConfiguration({ silentFailure: true, local: { acceptAuthentication: false, acceptAttestation: false, preferredUserhandleBase64: userhandleBase64 } });
promise_test(t => {
const options = {
publicKey: {
challenge: asciiToUint8Array("123456"),
allowCredentials: [
{ type: "public-key", id: credentialID, transports: ["usb"] },
{ type: "public-key", id: credentialID, transports: ["nfc"] },
{ type: "public-key", id: credentialID, transports: ["ble"] },
{ type: "public-key", id: credentialID, transports: ["internal"] }
],
timeout: 10
}
};
return promiseRejects(t, "NotAllowedError", navigator.credentials.get(options), "Operation timed out.");
}, "PublicKeyCredential's [[get]] with silent failure in a mock local authenticator.");
promise_test(t => {
const options = {
publicKey: {
challenge: asciiToUint8Array("123456"),
allowCredentials: [
{ type: "public-key", id: Base64URL.parse(userhandleBase64) }
],
timeout: 10
}
};
if (window.testRunner)
testRunner.addTestKeyToKeychain(privateKeyBase64, testRpId, userhandleBase64);
return promiseRejects(t, "NotAllowedError", navigator.credentials.get(options), "Operation timed out.").then(() => {
if (window.testRunner)
testRunner.cleanUpKeychain(testRpId, userhandleBase64);
});
}, "PublicKeyCredential's [[get]] with silent failure in a mock local authenticator. 2");
promise_test(t => {
const options = {
publicKey: {
challenge: asciiToUint8Array("123456"),
timeout: 10
}
};
if (window.testRunner)
testRunner.addTestKeyToKeychain(privateKeyBase64, testRpId, userhandleBase64);
return promiseRejects(t, "NotAllowedError", navigator.credentials.get(options), "Operation timed out.").then(() => {
if (window.testRunner)
testRunner.cleanUpKeychain(testRpId, userhandleBase64);
});
}, "PublicKeyCredential's [[get]] with silent failure in a mock local authenticator. 3");
})();
</script>