blob: 0022ea90b076afe2c464bf76f25d49b53ca481b9 [file] [log] [blame]
<!DOCTYPE html>
<title>Web Authentication API: PublicKeyCredential's [[get]] failure 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: "malicious-payload" } });
promise_test(t => {
const options = {
publicKey: {
challenge: asciiToUint8Array("123456"),
allowCredentials: [
{ type: "public-key", id: Base64URL.parse(testHidCredentialIdBase64), transports: ["nfc"] },
{ type: "public-key", id: Base64URL.parse(testHidCredentialIdBase64), transports: ["ble"] },
{ type: "public-key", id: Base64URL.parse(testHidCredentialIdBase64), transports: ["internal"] }
],
timeout: 10
}
};
return promiseRejects(t, "NotAllowedError", navigator.credentials.get(options), "Operation timed out.");
}, "PublicKeyCredential's [[get]] with timeout in a mock hid authenticator.");
promise_test(function(t) {
const options = {
publicKey: {
challenge: asciiToUint8Array("123456")
}
};
if (window.internals)
internals.setMockWebAuthenticationConfiguration({ hid: { stage: "request", subStage: "msg", error: "malicious-payload", payloadBase64: [testDummyMessagePayloadBase64] } });
return promiseRejects(t, "UnknownError", navigator.credentials.get(options), "Unknown internal error. Error code: 255");
}, "PublicKeyCredential's [[get]] with malicious payload in a mock hid authenticator.");
promise_test(function(t) {
const options = {
publicKey: {
challenge: asciiToUint8Array("123456"),
userVerification: "required"
}
};
if (window.internals)
internals.setMockWebAuthenticationConfiguration({ hid: { stage: "request", subStage: "msg", error: "unsupported-options" } });
return promiseRejects(t, "UnknownError", navigator.credentials.get(options), "Unknown internal error. Error code: 43");
}, "PublicKeyCredential's [[get]] with unsupported options in a mock hid authenticator.");
promise_test(function(t) {
const options = {
publicKey: {
challenge: asciiToUint8Array("123456")
}
};
if (window.internals)
internals.setMockWebAuthenticationConfiguration({ hid: { stage: "request", subStage: "msg", error: "malicious-payload", payloadBase64: [testCtapErrInvalidCredentialResponseBase64] } });
return promiseRejects(t, "UnknownError", navigator.credentials.get(options), "Unknown internal error. Error code: 34");
}, "PublicKeyCredential's [[get]] with authenticator downgrade failed in a mock hid authenticator.");
promise_test(function(t) {
const options = {
publicKey: {
challenge: asciiToUint8Array("123456"),
extensions: { appid: "" }
}
};
if (window.internals)
internals.setMockWebAuthenticationConfiguration({ hid: { stage: "request", subStage: "msg", error: "malicious-payload", canDowngrade: true, payloadBase64: [testCtapErrInvalidCredentialResponseBase64] } });
return promiseRejects(t, "NotSupportedError", navigator.credentials.get(options), "Cannot convert the request to U2F command.");
}, "PublicKeyCredential's [[get]] with authenticator downgrade succeeded and then U2F failed in a mock hid authenticator. 2");
</script>