Bug 2040812 - show passkeys in autocomplete="webauthn" autofill dropdown. r=credential-management-reviewers,mtigley
Differential Revision: https://phabricator.services.mozilla.com/D301432
This commit is contained in:
committed by
jschanck@mozilla.com
parent
73e23aa0cc
commit
f3c0eac8f6
@@ -4637,7 +4637,8 @@ void HTMLInputElement::MaybeDispatchLoginManagerEvents(HTMLFormElement* aForm) {
|
||||
} else {
|
||||
nsAutoString autocompleteValue;
|
||||
GetAutocomplete(autocompleteValue);
|
||||
if (!autocompleteValue.EqualsASCII("username")) {
|
||||
if (!autocompleteValue.EqualsASCII("username") &&
|
||||
!autocompleteValue.EqualsASCII("webauthn")) {
|
||||
return;
|
||||
}
|
||||
target = GetComposedDoc();
|
||||
|
||||
@@ -1355,7 +1355,7 @@ export const LoginHelper = {
|
||||
const expr = /username/i;
|
||||
|
||||
let ac = element.getAutocompleteInfo()?.fieldName;
|
||||
if (ac && ac == "username") {
|
||||
if (ac && (ac == "username" || ac == "webauthn")) {
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@@ -862,6 +862,33 @@ This tests the login manager in a secure setting using https. A similar test fil
|
||||
let credential = await webauthnPromise;
|
||||
is(credential.type, "public-key", "received a webauthn credential");
|
||||
});
|
||||
|
||||
add_named_task("webauthn standalone", async () => {
|
||||
await setStoredLoginsDuringTask();
|
||||
const form = setContentForTask(`<form id="form1" action="https://autocomplete">
|
||||
<input type="text" name="uname" autocomplete="webauthn">
|
||||
</form>`);
|
||||
|
||||
let authenticatorId = await addVirtualAuthenticator();
|
||||
addCredential(authenticatorId, document.domain);
|
||||
|
||||
let challenge = crypto.getRandomValues(new Uint8Array(16));
|
||||
let publicKey = { challenge, rpId: document.domain };
|
||||
let webauthnPromise = navigator.credentials.get( { publicKey, mediation: "conditional" });
|
||||
|
||||
const autofillResult = await formAutofillResult(form.id);
|
||||
is(autofillResult, "no_saved_logins", "form has not been filled due to no saved logins");
|
||||
|
||||
form.uname.focus();
|
||||
await popupByArrowDown();
|
||||
|
||||
synthesizeKey("KEY_ArrowDown");
|
||||
synthesizeKey("KEY_Enter");
|
||||
await untilAutocompletePopupClosed();
|
||||
|
||||
let credential = await webauthnPromise;
|
||||
is(credential.type, "public-key", "received a webauthn credential");
|
||||
});
|
||||
</script>
|
||||
</pre>
|
||||
</body>
|
||||
|
||||
@@ -124,7 +124,7 @@ const TESTCASES = [
|
||||
expectation: "email",
|
||||
},
|
||||
{
|
||||
testValues: ["username"],
|
||||
testValues: ["username", "webauthn"],
|
||||
expectation: "username",
|
||||
},
|
||||
],
|
||||
|
||||
Reference in New Issue
Block a user