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:
Ray Lin 2017-10-25 09:47:58 +08:00
parent a5064a01cb
commit 2295ced962
2 changed files with 5 additions and 12 deletions

View File

@ -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.

View File

@ -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" />`,