mirror of
https://github.com/bitwarden/browser
synced 2025-12-06 00:13:28 +00:00
Autofill shadow dom fields (#16769)
This commit is contained in:
@@ -4105,6 +4105,7 @@ describe("AutofillService", () => {
|
||||
});
|
||||
|
||||
it("returns null if the field cannot be hidden", () => {
|
||||
usernameField.form = "differentFormId";
|
||||
const result = autofillService["findUsernameField"](
|
||||
pageDetails,
|
||||
passwordField,
|
||||
@@ -4116,6 +4117,18 @@ describe("AutofillService", () => {
|
||||
expect(result).toBe(null);
|
||||
});
|
||||
|
||||
it("returns the field if the username field is in the form", () => {
|
||||
const result = autofillService["findUsernameField"](
|
||||
pageDetails,
|
||||
passwordField,
|
||||
false,
|
||||
false,
|
||||
false,
|
||||
);
|
||||
|
||||
expect(result).toBe(usernameField);
|
||||
});
|
||||
|
||||
it("returns the field if the field can be hidden", () => {
|
||||
const result = autofillService["findUsernameField"](
|
||||
pageDetails,
|
||||
|
||||
@@ -2286,11 +2286,16 @@ export default class AutofillService implements AutofillServiceInterface {
|
||||
this.findMatchingFieldIndex(f, AutoFillConstants.UsernameFieldNames) > -1;
|
||||
const isInSameForm = f.form === passwordField.form;
|
||||
|
||||
// An email or tel field in the same form as the password field is likely a qualified
|
||||
// candidate for autofill, even if visibility checks are unreliable
|
||||
const isQualifiedUsernameField =
|
||||
f.form === passwordField.form && (f.type === "email" || f.type === "tel");
|
||||
|
||||
if (
|
||||
!f.disabled &&
|
||||
(canBeReadOnly || !f.readonly) &&
|
||||
(withoutForm || isInSameForm || includesUsernameFieldName) &&
|
||||
(canBeHidden || f.viewable) &&
|
||||
(canBeHidden || f.viewable || isQualifiedUsernameField) &&
|
||||
(f.type === "text" || f.type === "email" || f.type === "tel")
|
||||
) {
|
||||
// Prioritize fields in the same form as the password field
|
||||
|
||||
Reference in New Issue
Block a user