1
0
mirror of https://github.com/bitwarden/browser synced 2025-12-15 15:53:27 +00:00

Remove all autocompleteDisabledValues disqualification (#16089)

* Removes disabled autocomplete checks, preserves test cases with inverted 
expectations to ensure no regressions.

* Corrects test case description.
This commit is contained in:
Miles Blackwood
2025-09-17 10:09:21 -04:00
committed by GitHub
parent 961cbbe91d
commit 75596f85d8
2 changed files with 10 additions and 23 deletions

View File

@@ -221,7 +221,7 @@ describe("InlineMenuFieldQualificationService", () => {
expect( expect(
inlineMenuFieldQualificationService.isFieldForLoginForm(field, pageDetails), inlineMenuFieldQualificationService.isFieldForLoginForm(field, pageDetails),
).toBe(false); ).toBe(true);
}); });
}); });
@@ -509,7 +509,7 @@ describe("InlineMenuFieldQualificationService", () => {
expect( expect(
inlineMenuFieldQualificationService.isFieldForLoginForm(field, pageDetails), inlineMenuFieldQualificationService.isFieldForLoginForm(field, pageDetails),
).toBe(false); ).toBe(true);
}); });
it("is structured on a page with no password fields but has other types of fields in the form", () => { it("is structured on a page with no password fields but has other types of fields in the form", () => {
@@ -568,7 +568,7 @@ describe("InlineMenuFieldQualificationService", () => {
).toBe(false); ).toBe(false);
}); });
it("contains a disabled autocomplete type when multiple password fields are on the page", () => { it("will not exclude a field by autocomplete type when it is the only viewable password field on the page", () => {
const field = mock<AutofillField>({ const field = mock<AutofillField>({
type: "text", type: "text",
autoCompleteType: "off", autoCompleteType: "off",
@@ -599,7 +599,7 @@ describe("InlineMenuFieldQualificationService", () => {
expect( expect(
inlineMenuFieldQualificationService.isFieldForLoginForm(field, pageDetails), inlineMenuFieldQualificationService.isFieldForLoginForm(field, pageDetails),
).toBe(false); ).toBe(true);
}); });
}); });
}); });

View File

@@ -37,7 +37,6 @@ export class InlineMenuFieldQualificationService
private newPasswordAutoCompleteValue = "new-password"; private newPasswordAutoCompleteValue = "new-password";
private autofillFieldKeywordsMap: AutofillKeywordsMap = new WeakMap(); private autofillFieldKeywordsMap: AutofillKeywordsMap = new WeakMap();
private submitButtonKeywordsMap: SubmitButtonKeywordsMap = new WeakMap(); private submitButtonKeywordsMap: SubmitButtonKeywordsMap = new WeakMap();
private autocompleteDisabledValues = new Set(["off", "false"]);
private accountCreationFieldKeywords = [ private accountCreationFieldKeywords = [
"register", "register",
"registration", "registration",
@@ -419,10 +418,8 @@ export class InlineMenuFieldQualificationService
} }
// If a single username field or less is present on the page, then we can assume that the // If a single username field or less is present on the page, then we can assume that the
// provided field is for a login form. This will only be the case if the field does not // provided field is for a login form.
// explicitly have its autocomplete attribute set to "off" or "false". return true;
return !this.fieldContainsAutocompleteValues(field, this.autocompleteDisabledValues);
} }
// If the field has a form parent and there are multiple visible password fields // If the field has a form parent and there are multiple visible password fields
@@ -442,9 +439,8 @@ export class InlineMenuFieldQualificationService
return true; return true;
} }
// If the field has a form parent and no username field exists and the field has an // If the field has a form parent and a username field exists this is a password field
// autocomplete attribute set to "off" or "false", this is not a password field return true;
return !this.fieldContainsAutocompleteValues(field, this.autocompleteDisabledValues);
} }
/** /**
@@ -512,20 +508,12 @@ export class InlineMenuFieldQualificationService
} }
// If the page does not contain any password fields, it might be part of a multistep login form. // If the page does not contain any password fields, it might be part of a multistep login form.
// That will only be the case if the field does not explicitly have its autocomplete attribute return true;
// set to "off" or "false".
return !this.fieldContainsAutocompleteValues(field, this.autocompleteDisabledValues);
} }
// If the field is structured within a form, but no password fields are present in the form, // If the field is structured within a form, but no password fields are present in the form,
// we need to consider whether the field is part of a multistep login form. // we need to consider whether the field is part of a multistep login form.
if (passwordFieldsInPageDetails.length === 0) { if (passwordFieldsInPageDetails.length === 0) {
// If the field's autocomplete is set to a disabled value, we should assume that the field is
// not part of a login form.
if (this.fieldContainsAutocompleteValues(field, this.autocompleteDisabledValues)) {
return false;
}
// If the form that contains a single field, we should assume that it is part // If the form that contains a single field, we should assume that it is part
// of a multistep login form. // of a multistep login form.
const fieldsWithinForm = pageDetails.fields.filter( const fieldsWithinForm = pageDetails.fields.filter(
@@ -561,8 +549,7 @@ export class InlineMenuFieldQualificationService
} }
// If no visible password fields are found, this field might be part of a multipart form. // If no visible password fields are found, this field might be part of a multipart form.
// Check for an invalid autocompleteType to determine if the field is part of a login form. return true;
return !this.fieldContainsAutocompleteValues(field, this.autocompleteDisabledValues);
} }
/** /**