mirror of
https://github.com/mozilla/gecko-dev.git
synced 2025-01-12 15:02:11 +00:00
Bug 1411190 - Collect and parse only eligible fields in form autofill heuristics. r=lchang,seanlee
MozReview-Commit-ID: GWp0cU5jt6k --HG-- extra : rebase_source : bc890687ff9686eb077fbc5d05e864b8e04e70b8
This commit is contained in:
parent
a5064a01cb
commit
2295ced962
@ -539,11 +539,14 @@ this.FormAutofillHeuristics = {
|
||||
* all field details in the form.
|
||||
*/
|
||||
getFormInfo(form, allowDuplicates = false) {
|
||||
if (form.elements.length <= 0) {
|
||||
const eligibleFields = Array.from(form.elements)
|
||||
.filter(elem => FormAutofillUtils.isFieldEligibleForAutofill(elem));
|
||||
|
||||
if (eligibleFields.length <= 0) {
|
||||
return [];
|
||||
}
|
||||
|
||||
let fieldScanner = new FieldScanner(form.elements);
|
||||
let fieldScanner = new FieldScanner(eligibleFields);
|
||||
while (!fieldScanner.parsingFinished) {
|
||||
let parsedPhoneFields = this._parsePhoneFields(fieldScanner);
|
||||
let parsedAddressFields = this._parseAddressFields(fieldScanner);
|
||||
@ -629,10 +632,6 @@ this.FormAutofillHeuristics = {
|
||||
},
|
||||
|
||||
getInfo(element) {
|
||||
if (!FormAutofillUtils.isFieldEligibleForAutofill(element)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
let info = element.getAutocompleteInfo();
|
||||
// An input[autocomplete="on"] will not be early return here since it stll
|
||||
// needs to find the field name.
|
||||
|
@ -157,12 +157,6 @@ const TESTCASES = [
|
||||
contactType: "",
|
||||
},
|
||||
},
|
||||
{
|
||||
description: "non-input element",
|
||||
document: `<label id="targetElement">street</label>`,
|
||||
elementId: "targetElement",
|
||||
expectedReturnValue: null,
|
||||
},
|
||||
{
|
||||
description: "input element with \"submit\" type",
|
||||
document: `<input id="targetElement" type="submit" />`,
|
||||
|
Loading…
x
Reference in New Issue
Block a user