mirror of
https://github.com/bitwarden/browser
synced 2025-12-11 22:03:36 +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", () => {
|
it("returns null if the field cannot be hidden", () => {
|
||||||
|
usernameField.form = "differentFormId";
|
||||||
const result = autofillService["findUsernameField"](
|
const result = autofillService["findUsernameField"](
|
||||||
pageDetails,
|
pageDetails,
|
||||||
passwordField,
|
passwordField,
|
||||||
@@ -4116,6 +4117,18 @@ describe("AutofillService", () => {
|
|||||||
expect(result).toBe(null);
|
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", () => {
|
it("returns the field if the field can be hidden", () => {
|
||||||
const result = autofillService["findUsernameField"](
|
const result = autofillService["findUsernameField"](
|
||||||
pageDetails,
|
pageDetails,
|
||||||
|
|||||||
@@ -2286,11 +2286,16 @@ export default class AutofillService implements AutofillServiceInterface {
|
|||||||
this.findMatchingFieldIndex(f, AutoFillConstants.UsernameFieldNames) > -1;
|
this.findMatchingFieldIndex(f, AutoFillConstants.UsernameFieldNames) > -1;
|
||||||
const isInSameForm = f.form === passwordField.form;
|
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 (
|
if (
|
||||||
!f.disabled &&
|
!f.disabled &&
|
||||||
(canBeReadOnly || !f.readonly) &&
|
(canBeReadOnly || !f.readonly) &&
|
||||||
(withoutForm || isInSameForm || includesUsernameFieldName) &&
|
(withoutForm || isInSameForm || includesUsernameFieldName) &&
|
||||||
(canBeHidden || f.viewable) &&
|
(canBeHidden || f.viewable || isQualifiedUsernameField) &&
|
||||||
(f.type === "text" || f.type === "email" || f.type === "tel")
|
(f.type === "text" || f.type === "email" || f.type === "tel")
|
||||||
) {
|
) {
|
||||||
// Prioritize fields in the same form as the password field
|
// Prioritize fields in the same form as the password field
|
||||||
|
|||||||
Reference in New Issue
Block a user