blob: 087c934a8e265688490fa2839686cdf50cc9910a [file] [log] [blame]
<!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
}
};
promiseRejects(t, "NotAllowedError", navigator.credentials.get(options), "This request has been cancelled by a new request.");
return navigator.credentials.get(options).then(credential => {
return checkCtapGetAssertionResult(credential);
});
}, "PublicKeyCredential's [[get]] with two consecutive requests.");
</script>