--- a/browser/extensions/formautofill/test/unit/heuristics/third_party/test_BestBuy.js
+++ b/browser/extensions/formautofill/test/unit/heuristics/third_party/test_BestBuy.js
@@ -1,17 +1,17 @@
/* global runHeuristicsTest */
"use strict";
runHeuristicsTest([
{
fixturePath: "Checkout_ShippingAddress.html",
expectedResult: [
- [[]], // Search form
+ [], // Search form
[[
{"section": "", "addressType": "", "contactType": "", "fieldName": "given-name"},
{"section": "", "addressType": "", "contactType": "", "fieldName": "family-name"},
{"section": "", "addressType": "", "contactType": "", "fieldName": "address-line1"},
{"section": "", "addressType": "", "contactType": "", "fieldName": "address-level2"}, // city
{"section": "", "addressType": "", "contactType": "", "fieldName": "address-level1"}, // state
{"section": "", "addressType": "", "contactType": "", "fieldName": "postal-code"},
]],
@@ -21,17 +21,17 @@ runHeuristicsTest([
[[ // unknown
{"section": "", "addressType": "", "contactType": "", "fieldName": "email"},
{"section": "", "addressType": "", "contactType": "", "fieldName": "tel"},
]],
],
}, {
fixturePath: "Checkout_Payment.html",
expectedResult: [
- [[]], // Search form
+ [], // Search form
[[ // Sign up
{"section": "", "addressType": "", "contactType": "", "fieldName": "email"},
]],
[[
{"section": "", "addressType": "", "contactType": "", "fieldName": "given-name"},
{"section": "", "addressType": "", "contactType": "", "fieldName": "family-name"},
{"section": "", "addressType": "", "contactType": "", "fieldName": "address-line1"},
{"section": "", "addressType": "", "contactType": "", "fieldName": "address-level2"}, // city
--- a/browser/extensions/formautofill/test/unit/heuristics/third_party/test_CDW.js
+++ b/browser/extensions/formautofill/test/unit/heuristics/third_party/test_CDW.js
@@ -15,19 +15,20 @@ runHeuristicsTest([
{"section": "", "addressType": "", "contactType": "", "fieldName": "address-level2"}, // city
{"section": "", "addressType": "", "contactType": "", "fieldName": "address-level1"}, // state
{"section": "", "addressType": "", "contactType": "", "fieldName": "postal-code"},
// FIXME: bug 1392932 - misdetect ZIP ext string
{"section": "", "addressType": "", "contactType": "", "fieldName": "tel-extension"},
{"section": "", "addressType": "", "contactType": "", "fieldName": "email"},
{"section": "", "addressType": "", "contactType": "", "fieldName": "tel"},
+ ], [
// The below "tel-extension" is correct and removed due to the
// duplicated field above.
-// {"section": "", "addressType": "", "contactType": "", "fieldName": "tel-extension"},
+ {"section": "", "addressType": "", "contactType": "", "fieldName": "tel-extension"},
]],
[],
],
}, {
fixturePath: "Checkout_BillingPaymentInfo.html",
expectedResult: [
[[
{"section": "", "addressType": "", "contactType": "", "fieldName": "given-name"},
@@ -42,21 +43,23 @@ runHeuristicsTest([
// FIXME: bug 1392932 - misdetect ZIP ext string
{"section": "", "addressType": "", "contactType": "", "fieldName": "tel-extension"},
// {"section": "", "addressType": "", "contactType": "", "fieldName": "cc-type"},
{"section": "", "addressType": "", "contactType": "", "fieldName": "cc-number"}, // ac-off
{"section": "", "addressType": "", "contactType": "", "fieldName": "cc-exp-month"},
{"section": "", "addressType": "", "contactType": "", "fieldName": "cc-exp-year"},
// {"section": "", "addressType": "", "contactType": "", "fieldName": "cc-csc"},
+ ], [
+ {"section": "", "addressType": "", "contactType": "", "fieldName": "tel-extension"},
]],
[],
],
}, {
fixturePath: "Checkout_Logon.html",
expectedResult: [
[],
- [[]],
+ [],
[],
],
},
], "../../../fixtures/third_party/CDW/");
--- a/browser/extensions/formautofill/test/unit/heuristics/third_party/test_CostCo.js
+++ b/browser/extensions/formautofill/test/unit/heuristics/third_party/test_CostCo.js
@@ -45,25 +45,24 @@ runHeuristicsTest([
}, {
fixturePath: "Payment.html",
expectedResult: [
[[
// {"section": "", "addressType": "", "contactType": "", "fieldName": "cc-type"},
{"section": "", "addressType": "", "contactType": "", "fieldName": "cc-number"}, // ac-off
{"section": "", "addressType": "", "contactType": "", "fieldName": "cc-exp-month"},
{"section": "", "addressType": "", "contactType": "", "fieldName": "cc-exp-year"},
-
// {"section": "", "addressType": "", "contactType": "", "fieldName": "cc-csc"}, // ac-off
{"section": "", "addressType": "", "contactType": "", "fieldName": "cc-name"}, // ac-off
]],
[[
{"section": "", "addressType": "", "contactType": "", "fieldName": "cc-number"}, // ac-off
]],
[],
- [[]],
+ [],
[[
{"section": "", "addressType": "", "contactType": "", "fieldName": "given-name"},
{"section": "", "addressType": "", "contactType": "", "fieldName": "additional-name"}, // middle-name initial
{"section": "", "addressType": "", "contactType": "", "fieldName": "family-name"},
{"section": "", "addressType": "", "contactType": "", "fieldName": "organization"},
{"section": "", "addressType": "", "contactType": "", "fieldName": "country"},
{"section": "", "addressType": "", "contactType": "", "fieldName": "address-line1"},
{"section": "", "addressType": "", "contactType": "", "fieldName": "address-line2"},
@@ -91,17 +90,17 @@ runHeuristicsTest([
[[
{"section": "", "addressType": "", "contactType": "", "fieldName": "email"},
]],
[],
],
}, {
fixturePath: "SignIn.html",
expectedResult: [
- [[]],
+ [],
[],
[[
{"section": "", "addressType": "", "contactType": "", "fieldName": "email"},
]],
[],
[[ // Forgot password
{"section": "", "addressType": "", "contactType": "", "fieldName": "email"},
]],
--- a/browser/extensions/formautofill/test/unit/heuristics/third_party/test_Macys.js
+++ b/browser/extensions/formautofill/test/unit/heuristics/third_party/test_Macys.js
@@ -11,20 +11,17 @@ runHeuristicsTest([
{"section": "", "addressType": "", "contactType": "", "fieldName": "family-name"},
{"section": "", "addressType": "", "contactType": "", "fieldName": "address-line1"},
{"section": "", "addressType": "", "contactType": "", "fieldName": "address-line2"},
{"section": "", "addressType": "", "contactType": "", "fieldName": "address-level2"}, // city
{"section": "", "addressType": "", "contactType": "", "fieldName": "address-level1"}, // state
{"section": "", "addressType": "", "contactType": "", "fieldName": "postal-code"},
{"section": "", "addressType": "", "contactType": "", "fieldName": "tel"},
]],
- [
-/*
-*/
- ],
+ [],
],
}, {
fixturePath: "Checkout_Payment.html",
expectedResult: [
[[
// {"section": "", "addressType": "", "contactType": "", "fieldName": "cc-type"}, // ac-off
{"section": "", "addressType": "", "contactType": "", "fieldName": "cc-number"}, // ac-off
{"section": "", "addressType": "", "contactType": "", "fieldName": "cc-exp-month"}, // ac-off
@@ -51,15 +48,15 @@ runHeuristicsTest([
// {"section": "", "addressType": "", "contactType": "", "fieldName": "password"},
]],
[[ // Forgot password
{"section": "", "addressType": "", "contactType": "", "fieldName": "email"},
]],
[[
{"section": "", "addressType": "", "contactType": "", "fieldName": "email"},
]],
- [[]],
+ [],
[],
[],
],
},
], "../../../fixtures/third_party/Macys/");
--- a/browser/extensions/formautofill/test/unit/heuristics/third_party/test_NewEgg.js
+++ b/browser/extensions/formautofill/test/unit/heuristics/third_party/test_NewEgg.js
@@ -21,16 +21,19 @@ runHeuristicsTest([
[],
],
}, {
fixturePath: "BillingInfo.html",
expectedResult: [
[[
{"section": "", "addressType": "", "contactType": "", "fieldName": "cc-name"},
{"section": "", "addressType": "", "contactType": "", "fieldName": "cc-number"}, // ac-off
+ ], [
+ {"section": "", "addressType": "", "contactType": "", "fieldName": "cc-name"},
+ {"section": "", "addressType": "", "contactType": "", "fieldName": "cc-number"}, // ac-off
{"section": "", "addressType": "", "contactType": "", "fieldName": "cc-exp-month"},
{"section": "", "addressType": "", "contactType": "", "fieldName": "cc-exp-year"},
// {"section": "", "addressType": "", "contactType": "", "fieldName": "cc-csc"},
{"section": "", "addressType": "", "contactType": "", "fieldName": "country"},
{"section": "", "addressType": "", "contactType": "", "fieldName": "address-line1"},
{"section": "", "addressType": "", "contactType": "", "fieldName": "address-line2"},
{"section": "", "addressType": "", "contactType": "", "fieldName": "address-level2"},
{"section": "", "addressType": "", "contactType": "", "fieldName": "address-level1"}, // state
--- a/browser/extensions/formautofill/test/unit/heuristics/third_party/test_OfficeDepot.js
+++ b/browser/extensions/formautofill/test/unit/heuristics/third_party/test_OfficeDepot.js
@@ -50,15 +50,15 @@ runHeuristicsTest([
// FIXME: bug 1392950 - the membership number should not be detected
// as cc-number.
{"section": "", "addressType": "", "contactType": "", "fieldName": "cc-number"},
]],
],
}, {
fixturePath: "SignIn.html",
expectedResult: [
- [[ // ac-off
+ [ // ac-off
// {"section": "", "addressType": "", "contactType": "", "fieldName": "email"},
- ]],
+ ],
],
},
], "../../../fixtures/third_party/OfficeDepot/");
--- a/browser/extensions/formautofill/test/unit/heuristics/third_party/test_QVC.js
+++ b/browser/extensions/formautofill/test/unit/heuristics/third_party/test_QVC.js
@@ -8,50 +8,50 @@ runHeuristicsTest([
expectedResult: [
[[
// {"section": "", "addressType": "", "contactType": "", "fieldName": "tel"}, // ac-off
{"section": "", "addressType": "", "contactType": "", "fieldName": "email"},
// {"section": "", "addressType": "", "contactType": "", "fieldName": "bday-month"}, // select
// {"section": "", "addressType": "", "contactType": "", "fieldName": "bday-day"}, // select
// {"section": "", "addressType": "", "contactType": "", "fieldName": "bday-year"},
// {"section": "", "addressType": "", "contactType": "", "fieldName": "cc-type"},
-
{"section": "", "addressType": "", "contactType": "", "fieldName": "cc-number"},
{"section": "", "addressType": "", "contactType": "", "fieldName": "cc-exp"},
-
// {"section": "", "addressType": "", "contactType": "", "fieldName": "cc-csc"},
+ ], [
+ {"section": "", "addressType": "", "contactType": "", "fieldName": "cc-number"},
]],
[[
{"section": "", "addressType": "", "contactType": "", "fieldName": "email"},
]],
],
}, {
fixturePath: "PaymentMethod.html",
expectedResult: [
[[
// {"section": "", "addressType": "", "contactType": "", "fieldName": "tel"}, // ac-off
{"section": "", "addressType": "", "contactType": "", "fieldName": "email"},
// {"section": "", "addressType": "", "contactType": "", "fieldName": "bday-month"}, // select
// {"section": "", "addressType": "", "contactType": "", "fieldName": "bday-day"}, // select
// {"section": "", "addressType": "", "contactType": "", "fieldName": "bday-year"}, // select
// {"section": "", "addressType": "", "contactType": "", "fieldName": "cc-type"}, // select
-
{"section": "", "addressType": "", "contactType": "", "fieldName": "cc-number"}, // ac-off
{"section": "", "addressType": "", "contactType": "", "fieldName": "cc-exp"},
-
// {"section": "", "addressType": "", "contactType": "", "fieldName": "cc-csc"},
+ ], [
+ {"section": "", "addressType": "", "contactType": "", "fieldName": "cc-number"}, // ac-off
]],
[[
{"section": "", "addressType": "", "contactType": "", "fieldName": "email"},
]],
],
}, {
fixturePath: "SignIn.html",
expectedResult: [
- [[]],
+ [],
[[ // Sign in
{"section": "", "addressType": "", "contactType": "", "fieldName": "email"},
]],
[],
],
},
], "../../../fixtures/third_party/QVC/");
--- a/browser/extensions/formautofill/test/unit/heuristics/third_party/test_Sears.js
+++ b/browser/extensions/formautofill/test/unit/heuristics/third_party/test_Sears.js
@@ -2,61 +2,61 @@
"use strict";
runHeuristicsTest([
{
fixturePath: "ShippingAddress.html",
expectedResult: [
[],
- [[]], // search form, ac-off
- [[ // ac-off
+ [], // search form, ac-off
+ [ // ac-off
// {"section": "", "addressType": "", "contactType": "", "fieldName": "email"},
- ]],
- [[ // check-out, ac-off
+ ],
+ [ // check-out, ac-off
/*
{"section": "", "addressType": "", "contactType": "", "fieldName": "given-name"},
{"section": "", "addressType": "", "contactType": "", "fieldName": "family-name"},
{"section": "", "addressType": "", "contactType": "", "fieldName": "address-line1"},
{"section": "", "addressType": "", "contactType": "", "fieldName": "address-line2"},
{"section": "", "addressType": "", "contactType": "", "fieldName": "address-level2"},
{"section": "", "addressType": "", "contactType": "", "fieldName": "address-level1"},
{"section": "", "addressType": "", "contactType": "", "fieldName": "postal-code"},
{"section": "", "addressType": "", "contactType": "", "fieldName": "tel"},
// {"section": "", "addressType": "", "contactType": "", "fieldName": "tel-extension"},
{"section": "", "addressType": "", "contactType": "", "fieldName": "email"},
*/
- ]],
+ ],
[ // ac-off
/*
{"section": "", "addressType": "", "contactType": "", "fieldName": "email"},
{"section": "", "addressType": "", "contactType": "", "fieldName": "given-name"},
{"section": "", "addressType": "", "contactType": "", "fieldName": "family-name"},
{"section": "", "addressType": "", "contactType": "", "fieldName": "address-line1"},
{"section": "", "addressType": "", "contactType": "", "fieldName": "address-line2"},
{"section": "", "addressType": "", "contactType": "", "fieldName": "address-level2"},
{"section": "", "addressType": "", "contactType": "", "fieldName": "address-level1"},
{"section": "", "addressType": "", "contactType": "", "fieldName": "postal-code"},
{"section": "", "addressType": "", "contactType": "", "fieldName": "tel"},
{"section": "", "addressType": "", "contactType": "", "fieldName": "tel-extension"},
// {"section": "", "addressType": "", "contactType": "", "fieldName": "new-password"},
*/
],
- [[ // ac-off
+ [ // ac-off
// {"section": "", "addressType": "", "contactType": "", "fieldName": "email"},
- ]],
- [[ // ac-off
+ ],
+ [ // ac-off
// {"section": "", "addressType": "", "contactType": "", "fieldName": "email"},
- ]],
+ ],
],
}, {
fixturePath: "PaymentOptions.html",
expectedResult: [
[],
- [[]], // search
+ [], // search
[[ // credit card
{"section": "", "addressType": "", "contactType": "", "fieldName": "cc-number"},
// FIXME: bug 1392958 - Cardholder name field should be detected as cc-name
// {"section": "", "addressType": "", "contactType": "", "fieldName": "cc-name"},
// {"section": "", "addressType": "", "contactType": "", "fieldName": "cc-csc"},
{"section": "", "addressType": "", "contactType": "", "fieldName": "cc-exp-month"},
{"section": "", "addressType": "", "contactType": "", "fieldName": "cc-exp-year"},
]],
--- a/browser/extensions/formautofill/test/unit/heuristics/third_party/test_Staples.js
+++ b/browser/extensions/formautofill/test/unit/heuristics/third_party/test_Staples.js
@@ -1,25 +1,25 @@
/* global runHeuristicsTest */
"use strict";
runHeuristicsTest([
{
fixturePath: "Basic.html",
expectedResult: [
- [[ // ac-off
+ [ // ac-off
// {"section": "", "addressType": "", "contactType": "", "fieldName": "given-name"},
// {"section": "", "addressType": "", "contactType": "", "fieldName": "family-name"},
// {"section": "", "addressType": "", "contactType": "", "fieldName": "address-line1"},
// {"section": "", "addressType": "", "contactType": "", "fieldName": "email"},
// {"section": "", "addressType": "", "contactType": "", "fieldName": "tel"},
// {"section": "", "addressType": "", "contactType": "", "fieldName": "tel-extension"},
// {"section": "", "addressType": "", "contactType": "", "fieldName": "organization"},
- ]],
+ ],
],
}, {
fixturePath: "Basic_ac_on.html",
expectedResult: [
[[
{"section": "", "addressType": "", "contactType": "", "fieldName": "given-name"},
{"section": "", "addressType": "", "contactType": "", "fieldName": "family-name"},
{"section": "", "addressType": "", "contactType": "", "fieldName": "address-line1"},
--- a/browser/extensions/formautofill/test/unit/heuristics/third_party/test_Walmart.js
+++ b/browser/extensions/formautofill/test/unit/heuristics/third_party/test_Walmart.js
@@ -4,33 +4,33 @@
runHeuristicsTest([
{
fixturePath: "Checkout.html",
expectedResult: [
[[
{"section": "", "addressType": "", "contactType": "", "fieldName": "postal-code"},
]],
- [[]],
+ [],
[[
{"section": "", "addressType": "", "contactType": "", "fieldName": "email"},
// {"section": "", "addressType": "", "contactType": "", "fieldName": "password"}, // ac-off
]],
[[
{"section": "", "addressType": "", "contactType": "", "fieldName": "given-name"},
{"section": "", "addressType": "", "contactType": "", "fieldName": "family-name"},
// {"section": "", "addressType": "", "contactType": "", "fieldName": "email"}, // ac-off
// {"section": "", "addressType": "", "contactType": "", "fieldName": "password"},
// {"section": "", "addressType": "", "contactType": "", "fieldName": "password"}, // ac-off
]],
],
}, {
fixturePath: "Payment.html",
expectedResult: [
- [[]],
+ [],
[
[
{"section": "section-payment", "addressType": "", "contactType": "", "fieldName": "given-name"},
{"section": "section-payment", "addressType": "", "contactType": "", "fieldName": "family-name"},
{"section": "section-payment", "addressType": "", "contactType": "", "fieldName": "cc-number"},
{"section": "section-payment", "addressType": "", "contactType": "", "fieldName": "cc-exp-month"},
{"section": "section-payment", "addressType": "", "contactType": "", "fieldName": "cc-exp-year"},
// {"section": "section-payment", "addressType": "", "contactType": "", "fieldName": "cc-csc"},
@@ -45,17 +45,17 @@ runHeuristicsTest([
],
],
}, {
fixturePath: "Shipping.html",
expectedResult: [
[[
{"section": "", "addressType": "", "contactType": "", "fieldName": "postal-code"},
]],
- [[]],
+ [],
[[
{"section": "", "addressType": "", "contactType": "", "fieldName": "given-name"},
{"section": "", "addressType": "", "contactType": "", "fieldName": "family-name"},
{"section": "", "addressType": "", "contactType": "", "fieldName": "tel"},
{"section": "", "addressType": "", "contactType": "", "fieldName": "address-line1"},
{"section": "", "addressType": "", "contactType": "", "fieldName": "address-line2"},
{"section": "", "addressType": "", "contactType": "", "fieldName": "address-level2"}, // city
{"section": "", "addressType": "", "contactType": "", "fieldName": "address-level1"}, // state
--- a/browser/extensions/formautofill/test/unit/test_collectFormFields.js
+++ b/browser/extensions/formautofill/test/unit/test_collectFormFields.js
@@ -287,20 +287,32 @@ const TESTCASES = [
</form>`,
allowDuplicates: true,
sections: [{
addressFieldDetails: [
{"section": "", "addressType": "", "contactType": "", "fieldName": "tel-area-code"},
{"section": "", "addressType": "", "contactType": "", "fieldName": "tel-local-prefix"},
{"section": "", "addressType": "", "contactType": "", "fieldName": "tel-local-suffix"},
{"section": "", "addressType": "", "contactType": "", "fieldName": "tel-extension"},
+ ],
+ creditCardFieldDetails: [],
+ }, {
+ addressFieldDetails: [
{"section": "", "addressType": "", "contactType": "", "fieldName": "tel-area-code"},
{"section": "", "addressType": "", "contactType": "", "fieldName": "tel-local-prefix"},
{"section": "", "addressType": "", "contactType": "", "fieldName": "tel-local-suffix"},
+
+ // TODO Bug 1421181 - "tel-country-code" field should belong to the next
+ // section. There should be a way to group the related fields during the
+ // parsing stage.
{"section": "", "addressType": "", "contactType": "", "fieldName": "tel-country-code"},
+ ],
+ creditCardFieldDetails: [],
+ }, {
+ addressFieldDetails: [
{"section": "", "addressType": "", "contactType": "", "fieldName": "tel-area-code"},
{"section": "", "addressType": "", "contactType": "", "fieldName": "tel-local-prefix"},
{"section": "", "addressType": "", "contactType": "", "fieldName": "tel-local-suffix"},
],
creditCardFieldDetails: [],
}],
validFieldDetails: [
{"section": "", "addressType": "", "contactType": "", "fieldName": "tel-area-code"},
@@ -456,23 +468,20 @@ for (let tc of TESTCASES) {
handlerDetails.forEach((detail, index) => {
Assert.equal(detail.fieldName, testCaseDetails[index].fieldName, "fieldName");
Assert.equal(detail.section, testCaseDetails[index].section, "section");
Assert.equal(detail.addressType, testCaseDetails[index].addressType, "addressType");
Assert.equal(detail.contactType, testCaseDetails[index].contactType, "contactType");
Assert.equal(detail.elementWeakRef.get(), testCaseDetails[index].elementWeakRef.get(), "DOM reference");
});
}
- for (let i = 0; i < testcase.sections.length; i++) {
- let section = testcase.sections[i];
- [
- section.addressFieldDetails,
- section.creditCardFieldDetails,
- ].forEach(details => setElementWeakRef(details));
- }
+ setElementWeakRef(testcase.sections.reduce((fieldDetails, section) => {
+ fieldDetails.push(...section.addressFieldDetails, ...section.creditCardFieldDetails);
+ return fieldDetails;
+ }, []));
setElementWeakRef(testcase.validFieldDetails);
let handler = new FormAutofillHandler(formLike);
let validFieldDetails = handler.collectFormFields(testcase.allowDuplicates);
Assert.equal(handler.sections.length, testcase.sections.length);
for (let i = 0; i < handler.sections.length; i++) {
let section = handler.sections[i];