summaryrefslogtreecommitdiffstats
path: root/browser/extensions/formautofill/test/unit/heuristics
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-07 09:22:09 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-07 09:22:09 +0000
commit43a97878ce14b72f0981164f87f2e35e14151312 (patch)
tree620249daf56c0258faa40cbdcf9cfba06de2a846 /browser/extensions/formautofill/test/unit/heuristics
parentInitial commit. (diff)
downloadfirefox-upstream.tar.xz
firefox-upstream.zip
Adding upstream version 110.0.1.upstream/110.0.1upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'browser/extensions/formautofill/test/unit/heuristics')
-rw-r--r--browser/extensions/formautofill/test/unit/heuristics/test_autocomplete_off_on_form.js185
-rw-r--r--browser/extensions/formautofill/test/unit/heuristics/test_autocomplete_off_on_inputs.js270
-rw-r--r--browser/extensions/formautofill/test/unit/heuristics/test_basic.js180
-rw-r--r--browser/extensions/formautofill/test/unit/heuristics/test_cc_exp.js112
-rw-r--r--browser/extensions/formautofill/test/unit/heuristics/test_de_fields.js82
-rw-r--r--browser/extensions/formautofill/test/unit/heuristics/test_fr_fields.js39
-rw-r--r--browser/extensions/formautofill/test/unit/heuristics/test_known_strings.js145
-rw-r--r--browser/extensions/formautofill/test/unit/heuristics/test_multiple_section.js280
-rw-r--r--browser/extensions/formautofill/test/unit/heuristics/third_party/test_BestBuy.js163
-rw-r--r--browser/extensions/formautofill/test/unit/heuristics/third_party/test_CDW.js169
-rw-r--r--browser/extensions/formautofill/test/unit/heuristics/third_party/test_CostCo.js448
-rw-r--r--browser/extensions/formautofill/test/unit/heuristics/third_party/test_DirectAsda.js42
-rw-r--r--browser/extensions/formautofill/test/unit/heuristics/third_party/test_Ebay.js42
-rw-r--r--browser/extensions/formautofill/test/unit/heuristics/third_party/test_GlobalDirectAsda.js36
-rw-r--r--browser/extensions/formautofill/test/unit/heuristics/third_party/test_HomeDepot.js110
-rw-r--r--browser/extensions/formautofill/test/unit/heuristics/third_party/test_Lufthansa.js64
-rw-r--r--browser/extensions/formautofill/test/unit/heuristics/third_party/test_Lush.js56
-rw-r--r--browser/extensions/formautofill/test/unit/heuristics/third_party/test_Macys.js190
-rw-r--r--browser/extensions/formautofill/test/unit/heuristics/third_party/test_NewEgg.js232
-rw-r--r--browser/extensions/formautofill/test/unit/heuristics/third_party/test_OfficeDepot.js227
-rw-r--r--browser/extensions/formautofill/test/unit/heuristics/third_party/test_QVC.js148
-rw-r--r--browser/extensions/formautofill/test/unit/heuristics/third_party/test_Sears.js309
-rw-r--r--browser/extensions/formautofill/test/unit/heuristics/third_party/test_Staples.js146
-rw-r--r--browser/extensions/formautofill/test/unit/heuristics/third_party/test_Walmart.js173
-rw-r--r--browser/extensions/formautofill/test/unit/heuristics/third_party/xpcshell.ini38
-rw-r--r--browser/extensions/formautofill/test/unit/heuristics/xpcshell.ini20
26 files changed, 3906 insertions, 0 deletions
diff --git a/browser/extensions/formautofill/test/unit/heuristics/test_autocomplete_off_on_form.js b/browser/extensions/formautofill/test/unit/heuristics/test_autocomplete_off_on_form.js
new file mode 100644
index 0000000000..41db67e3f3
--- /dev/null
+++ b/browser/extensions/formautofill/test/unit/heuristics/test_autocomplete_off_on_form.js
@@ -0,0 +1,185 @@
+/* Any copyright is dedicated to the Public Domain.
+http://creativecommons.org/publicdomain/zero/1.0/ */
+
+"use strict";
+
+/* global runHeuristicsTest */
+
+// Ensures that fields are identified correctly even when the containing form
+// has its autocomplete attribute set to off.
+runHeuristicsTest(
+ [
+ {
+ fixturePath: "autocomplete_off_on_form.html",
+ expectedResult: [
+ [
+ [
+ {
+ section: "",
+ addressType: "",
+ contactType: "",
+ fieldName: "organization",
+ },
+ {
+ section: "",
+ addressType: "",
+ contactType: "",
+ fieldName: "street-address",
+ },
+ {
+ section: "",
+ addressType: "",
+ contactType: "",
+ fieldName: "address-level2",
+ },
+ {
+ section: "",
+ addressType: "",
+ contactType: "",
+ fieldName: "address-level1",
+ },
+ {
+ section: "",
+ addressType: "",
+ contactType: "",
+ fieldName: "postal-code",
+ },
+ {
+ section: "",
+ addressType: "",
+ contactType: "",
+ fieldName: "country",
+ },
+ { section: "", addressType: "", contactType: "", fieldName: "tel" },
+ {
+ section: "",
+ addressType: "",
+ contactType: "",
+ fieldName: "email",
+ },
+ ],
+ ],
+ [
+ [
+ {
+ section: "",
+ addressType: "",
+ contactType: "",
+ fieldName: "organization",
+ },
+ {
+ section: "",
+ addressType: "",
+ contactType: "",
+ fieldName: "address-line1",
+ },
+ {
+ section: "",
+ addressType: "",
+ contactType: "",
+ fieldName: "address-line2",
+ },
+ {
+ section: "",
+ addressType: "",
+ contactType: "",
+ fieldName: "address-line3",
+ },
+ {
+ section: "",
+ addressType: "",
+ contactType: "",
+ fieldName: "address-level2",
+ },
+ {
+ section: "",
+ addressType: "",
+ contactType: "",
+ fieldName: "address-level1",
+ },
+ {
+ section: "",
+ addressType: "",
+ contactType: "",
+ fieldName: "postal-code",
+ },
+ {
+ section: "",
+ addressType: "",
+ contactType: "",
+ fieldName: "country",
+ },
+ { section: "", addressType: "", contactType: "", fieldName: "tel" },
+ {
+ section: "",
+ addressType: "",
+ contactType: "",
+ fieldName: "email",
+ },
+ ],
+ [
+ {
+ section: "",
+ addressType: "",
+ contactType: "",
+ fieldName: "cc-number",
+ },
+ {
+ section: "",
+ addressType: "",
+ contactType: "",
+ fieldName: "cc-name",
+ },
+ {
+ section: "",
+ addressType: "",
+ contactType: "",
+ fieldName: "cc-exp-month",
+ },
+ {
+ section: "",
+ addressType: "",
+ contactType: "",
+ fieldName: "cc-exp-year",
+ },
+ ],
+ ],
+ [
+ [
+ {
+ section: "",
+ addressType: "",
+ contactType: "",
+ fieldName: "address-line1",
+ },
+ {
+ section: "",
+ addressType: "",
+ contactType: "",
+ fieldName: "address-level2",
+ },
+ {
+ section: "",
+ addressType: "",
+ contactType: "",
+ fieldName: "address-line2",
+ },
+ {
+ section: "",
+ addressType: "",
+ contactType: "",
+ fieldName: "organization",
+ },
+ {
+ section: "",
+ addressType: "",
+ contactType: "",
+ fieldName: "address-line3",
+ },
+ ],
+ ],
+ ],
+ },
+ ],
+ "../../fixtures/"
+);
diff --git a/browser/extensions/formautofill/test/unit/heuristics/test_autocomplete_off_on_inputs.js b/browser/extensions/formautofill/test/unit/heuristics/test_autocomplete_off_on_inputs.js
new file mode 100644
index 0000000000..6d48e83fd5
--- /dev/null
+++ b/browser/extensions/formautofill/test/unit/heuristics/test_autocomplete_off_on_inputs.js
@@ -0,0 +1,270 @@
+/* Any copyright is dedicated to the Public Domain.
+http://creativecommons.org/publicdomain/zero/1.0/ */
+
+"use strict";
+
+/* global runHeuristicsTest */
+
+// Ensures that fields are identified correctly even when the inputs
+// have their autocomplete attribute set to off.
+runHeuristicsTest(
+ [
+ {
+ fixturePath: "autocomplete_off_on_inputs.html",
+ expectedResult: [
+ [
+ [
+ {
+ section: "",
+ addressType: "",
+ contactType: "",
+ fieldName: "organization",
+ },
+ {
+ section: "",
+ addressType: "",
+ contactType: "",
+ fieldName: "street-address",
+ },
+ {
+ section: "",
+ addressType: "",
+ contactType: "",
+ fieldName: "address-level2",
+ },
+ {
+ section: "",
+ addressType: "",
+ contactType: "",
+ fieldName: "address-level1",
+ },
+ {
+ section: "",
+ addressType: "",
+ contactType: "",
+ fieldName: "postal-code",
+ },
+ {
+ section: "",
+ addressType: "",
+ contactType: "",
+ fieldName: "country",
+ },
+ { section: "", addressType: "", contactType: "", fieldName: "tel" },
+ {
+ section: "",
+ addressType: "",
+ contactType: "",
+ fieldName: "email",
+ },
+ ],
+ ],
+ [
+ [
+ {
+ section: "",
+ addressType: "",
+ contactType: "",
+ fieldName: "organization",
+ },
+ {
+ section: "",
+ addressType: "",
+ contactType: "",
+ fieldName: "address-line1",
+ },
+ {
+ section: "",
+ addressType: "",
+ contactType: "",
+ fieldName: "address-line2",
+ },
+ {
+ section: "",
+ addressType: "",
+ contactType: "",
+ fieldName: "address-line3",
+ },
+ {
+ section: "",
+ addressType: "",
+ contactType: "",
+ fieldName: "address-level2",
+ },
+ {
+ section: "",
+ addressType: "",
+ contactType: "",
+ fieldName: "address-level1",
+ },
+ {
+ section: "",
+ addressType: "",
+ contactType: "",
+ fieldName: "postal-code",
+ },
+ {
+ section: "",
+ addressType: "",
+ contactType: "",
+ fieldName: "country",
+ },
+ { section: "", addressType: "", contactType: "", fieldName: "tel" },
+ {
+ section: "",
+ addressType: "",
+ contactType: "",
+ fieldName: "email",
+ },
+ ],
+ [
+ {
+ section: "",
+ addressType: "",
+ contactType: "",
+ fieldName: "cc-number",
+ },
+ {
+ section: "",
+ addressType: "",
+ contactType: "",
+ fieldName: "cc-name",
+ },
+ {
+ section: "",
+ addressType: "",
+ contactType: "",
+ fieldName: "cc-exp-month",
+ },
+ {
+ section: "",
+ addressType: "",
+ contactType: "",
+ fieldName: "cc-exp-year",
+ },
+ ],
+ ],
+ [
+ [
+ {
+ section: "",
+ addressType: "",
+ contactType: "",
+ fieldName: "address-line1",
+ },
+ {
+ section: "",
+ addressType: "",
+ contactType: "",
+ fieldName: "address-level2",
+ },
+ {
+ section: "",
+ addressType: "",
+ contactType: "",
+ fieldName: "address-line2",
+ },
+ {
+ section: "",
+ addressType: "",
+ contactType: "",
+ fieldName: "organization",
+ },
+ {
+ section: "",
+ addressType: "",
+ contactType: "",
+ fieldName: "address-line3",
+ },
+ ],
+ ],
+ [
+ [
+ {
+ section: "",
+ addressType: "",
+ contactType: "",
+ fieldName: "organization",
+ },
+ {
+ section: "",
+ addressType: "",
+ contactType: "",
+ fieldName: "address-line1",
+ },
+ {
+ section: "",
+ addressType: "",
+ contactType: "",
+ fieldName: "address-line2",
+ },
+ {
+ section: "",
+ addressType: "",
+ contactType: "",
+ fieldName: "address-line3",
+ },
+ {
+ section: "",
+ addressType: "",
+ contactType: "",
+ fieldName: "address-level2",
+ },
+ {
+ section: "",
+ addressType: "",
+ contactType: "",
+ fieldName: "address-level1",
+ },
+ {
+ section: "",
+ addressType: "",
+ contactType: "",
+ fieldName: "postal-code",
+ },
+ {
+ section: "",
+ addressType: "",
+ contactType: "",
+ fieldName: "country",
+ },
+ { section: "", addressType: "", contactType: "", fieldName: "tel" },
+ {
+ section: "",
+ addressType: "",
+ contactType: "",
+ fieldName: "email",
+ },
+ ],
+ [
+ {
+ section: "",
+ addressType: "",
+ contactType: "",
+ fieldName: "cc-number",
+ },
+ {
+ section: "",
+ addressType: "",
+ contactType: "",
+ fieldName: "cc-name",
+ },
+ {
+ section: "",
+ addressType: "",
+ contactType: "",
+ fieldName: "cc-exp-month",
+ },
+ {
+ section: "",
+ addressType: "",
+ contactType: "",
+ fieldName: "cc-exp-year",
+ },
+ ],
+ ],
+ ],
+ },
+ ],
+ "../../fixtures/"
+);
diff --git a/browser/extensions/formautofill/test/unit/heuristics/test_basic.js b/browser/extensions/formautofill/test/unit/heuristics/test_basic.js
new file mode 100644
index 0000000000..be148adb64
--- /dev/null
+++ b/browser/extensions/formautofill/test/unit/heuristics/test_basic.js
@@ -0,0 +1,180 @@
+/* global runHeuristicsTest */
+
+"use strict";
+
+runHeuristicsTest(
+ [
+ {
+ fixturePath: "autocomplete_basic.html",
+ expectedResult: [
+ [
+ [
+ {
+ section: "",
+ addressType: "",
+ contactType: "",
+ fieldName: "organization",
+ },
+ {
+ section: "",
+ addressType: "",
+ contactType: "",
+ fieldName: "street-address",
+ },
+ {
+ section: "",
+ addressType: "",
+ contactType: "",
+ fieldName: "address-level2",
+ },
+ {
+ section: "",
+ addressType: "",
+ contactType: "",
+ fieldName: "address-level1",
+ },
+ {
+ section: "",
+ addressType: "",
+ contactType: "",
+ fieldName: "postal-code",
+ },
+ {
+ section: "",
+ addressType: "",
+ contactType: "",
+ fieldName: "country",
+ },
+ { section: "", addressType: "", contactType: "", fieldName: "tel" },
+ {
+ section: "",
+ addressType: "",
+ contactType: "",
+ fieldName: "email",
+ },
+ ],
+ ],
+ [
+ [
+ {
+ section: "",
+ addressType: "",
+ contactType: "",
+ fieldName: "organization",
+ },
+ {
+ section: "",
+ addressType: "",
+ contactType: "",
+ fieldName: "address-line1",
+ },
+ {
+ section: "",
+ addressType: "",
+ contactType: "",
+ fieldName: "address-line2",
+ },
+ {
+ section: "",
+ addressType: "",
+ contactType: "",
+ fieldName: "address-line3",
+ },
+ {
+ section: "",
+ addressType: "",
+ contactType: "",
+ fieldName: "address-level2",
+ },
+ {
+ section: "",
+ addressType: "",
+ contactType: "",
+ fieldName: "address-level1",
+ },
+ {
+ section: "",
+ addressType: "",
+ contactType: "",
+ fieldName: "postal-code",
+ },
+ {
+ section: "",
+ addressType: "",
+ contactType: "",
+ fieldName: "country",
+ },
+ { section: "", addressType: "", contactType: "", fieldName: "tel" },
+ {
+ section: "",
+ addressType: "",
+ contactType: "",
+ fieldName: "email",
+ },
+ ],
+ [
+ {
+ section: "",
+ addressType: "",
+ contactType: "",
+ fieldName: "cc-number",
+ },
+ {
+ section: "",
+ addressType: "",
+ contactType: "",
+ fieldName: "cc-name",
+ },
+ {
+ section: "",
+ addressType: "",
+ contactType: "",
+ fieldName: "cc-exp-month",
+ },
+ {
+ section: "",
+ addressType: "",
+ contactType: "",
+ fieldName: "cc-exp-year",
+ },
+ ],
+ ],
+ [
+ [
+ {
+ section: "",
+ addressType: "",
+ contactType: "",
+ fieldName: "address-line1",
+ },
+ {
+ section: "",
+ addressType: "",
+ contactType: "",
+ fieldName: "address-level2",
+ },
+ {
+ section: "",
+ addressType: "",
+ contactType: "",
+ fieldName: "address-line2",
+ },
+ {
+ section: "",
+ addressType: "",
+ contactType: "",
+ fieldName: "organization",
+ },
+ {
+ section: "",
+ addressType: "",
+ contactType: "",
+ fieldName: "address-line3",
+ },
+ ],
+ ],
+ ],
+ },
+ ],
+ "../../fixtures/"
+);
diff --git a/browser/extensions/formautofill/test/unit/heuristics/test_cc_exp.js b/browser/extensions/formautofill/test/unit/heuristics/test_cc_exp.js
new file mode 100644
index 0000000000..50a1766966
--- /dev/null
+++ b/browser/extensions/formautofill/test/unit/heuristics/test_cc_exp.js
@@ -0,0 +1,112 @@
+/* global runHeuristicsTest */
+
+"use strict";
+
+runHeuristicsTest(
+ [
+ {
+ fixturePath: "heuristics_cc_exp.html",
+ expectedResult: [
+ [
+ [
+ {
+ section: "",
+ addressType: "",
+ contactType: "",
+ fieldName: "cc-name",
+ },
+ {
+ section: "",
+ addressType: "",
+ contactType: "",
+ fieldName: "cc-number",
+ },
+ {
+ section: "",
+ addressType: "",
+ contactType: "",
+ fieldName: "cc-exp-month",
+ },
+ {
+ section: "",
+ addressType: "",
+ contactType: "",
+ fieldName: "cc-exp-year",
+ },
+ ],
+ ],
+ [
+ [
+ {
+ section: "",
+ addressType: "",
+ contactType: "",
+ fieldName: "cc-number",
+ },
+ {
+ section: "",
+ addressType: "",
+ contactType: "",
+ fieldName: "cc-exp",
+ },
+ ],
+ ],
+ [
+ [
+ {
+ section: "",
+ addressType: "",
+ contactType: "",
+ fieldName: "cc-number",
+ },
+ {
+ section: "",
+ addressType: "",
+ contactType: "",
+ fieldName: "cc-exp",
+ },
+ ],
+ ],
+ [
+ [
+ {
+ section: "",
+ addressType: "",
+ contactType: "",
+ fieldName: "cc-number",
+ },
+ {
+ section: "",
+ addressType: "",
+ contactType: "",
+ fieldName: "cc-exp-month",
+ },
+ {
+ section: "",
+ addressType: "",
+ contactType: "",
+ fieldName: "cc-exp-year",
+ },
+ ],
+ ],
+ [
+ [
+ {
+ section: "",
+ addressType: "",
+ contactType: "",
+ fieldName: "cc-exp-month",
+ },
+ {
+ section: "",
+ addressType: "",
+ contactType: "",
+ fieldName: "cc-exp-year",
+ },
+ ],
+ ],
+ ],
+ },
+ ],
+ "../../fixtures/"
+);
diff --git a/browser/extensions/formautofill/test/unit/heuristics/test_de_fields.js b/browser/extensions/formautofill/test/unit/heuristics/test_de_fields.js
new file mode 100644
index 0000000000..cb6786701f
--- /dev/null
+++ b/browser/extensions/formautofill/test/unit/heuristics/test_de_fields.js
@@ -0,0 +1,82 @@
+/* global runHeuristicsTest */
+
+"use strict";
+
+runHeuristicsTest(
+ [
+ {
+ fixturePath: "heuristics_de_fields.html",
+ expectedResult: [
+ [
+ [
+ {
+ section: "",
+ addressType: "",
+ contactType: "",
+ fieldName: "cc-name",
+ },
+ {
+ section: "",
+ addressType: "",
+ contactType: "",
+ fieldName: "cc-type",
+ },
+ {
+ section: "",
+ addressType: "",
+ contactType: "",
+ fieldName: "cc-number",
+ },
+ {
+ section: "",
+ addressType: "",
+ contactType: "",
+ fieldName: "cc-exp-month",
+ },
+ {
+ section: "",
+ addressType: "",
+ contactType: "",
+ fieldName: "cc-exp-year",
+ },
+ ],
+ ],
+ [
+ [
+ {
+ section: "",
+ addressType: "",
+ contactType: "",
+ fieldName: "cc-name",
+ },
+ {
+ section: "",
+ addressType: "",
+ contactType: "",
+ fieldName: "cc-type",
+ },
+ {
+ section: "",
+ addressType: "",
+ contactType: "",
+ fieldName: "cc-number",
+ },
+ {
+ section: "",
+ addressType: "",
+ contactType: "",
+ fieldName: "cc-exp-month",
+ },
+ {
+ section: "",
+ addressType: "",
+ contactType: "",
+ fieldName: "cc-exp-year",
+ },
+ ],
+ ],
+ ],
+ },
+ ],
+ "../../fixtures/"
+);
diff --git a/browser/extensions/formautofill/test/unit/heuristics/test_fr_fields.js b/browser/extensions/formautofill/test/unit/heuristics/test_fr_fields.js
new file mode 100644
index 0000000000..dfd58af300
--- /dev/null
+++ b/browser/extensions/formautofill/test/unit/heuristics/test_fr_fields.js
@@ -0,0 +1,39 @@
+/* Any copyright is dedicated to the Public Domain.
+http://creativecommons.org/publicdomain/zero/1.0/ */
+
+/* global runHeuristicsTest */
+
+"use strict";
+
+runHeuristicsTest(
+ [
+ {
+ fixturePath: "heuristics_fr_fields.html",
+ expectedResult: [
+ [
+ [
+ {
+ section: "",
+ addressType: "",
+ contactType: "",
+ fieldName: "cc-number",
+ },
+ {
+ section: "",
+ addressType: "",
+ contactType: "",
+ fieldName: "cc-exp",
+ },
+ {
+ section: "",
+ addressType: "",
+ contactType: "",
+ fieldName: "cc-name",
+ },
+ ],
+ ],
+ ],
+ },
+ ],
+ "../../fixtures/"
+);
diff --git a/browser/extensions/formautofill/test/unit/heuristics/test_known_strings.js b/browser/extensions/formautofill/test/unit/heuristics/test_known_strings.js
new file mode 100644
index 0000000000..b44bf0159f
--- /dev/null
+++ b/browser/extensions/formautofill/test/unit/heuristics/test_known_strings.js
@@ -0,0 +1,145 @@
+"use strict";
+/* global FormAutofillHeuristics: true */
+
+const KNOWN_NAMES = {
+ "cc-name": ["cc-name", "card-name", "cardholder-name", "cardholder"],
+ "cc-number": [
+ "cc-number",
+ "cc-num",
+ "card-number",
+ "card-num",
+ "number",
+ "cc",
+ "cc-no",
+ "card-no",
+ "credit-card",
+ "numero-carte",
+ "carte",
+ "carte-credit",
+ "num-carte",
+ "cb-num",
+ ],
+ "cc-exp": [
+ "cc-exp",
+ "card-exp",
+ "cc-expiration",
+ "card-expiration",
+ "cc-ex",
+ "card-ex",
+ "card-expire",
+ "card-expiry",
+ "validite",
+ "expiration",
+ "expiry",
+ "mm-yy",
+ "mm-yyyy",
+ "yy-mm",
+ "yyyy-mm",
+ "expiration-date",
+ "payment-card-expiration",
+ "payment-cc-date",
+ ],
+ "cc-exp-month": [
+ "exp-month",
+ "cc-exp-month",
+ "cc-month",
+ "card-month",
+ "cc-mo",
+ "card-mo",
+ "exp-mo",
+ "card-exp-mo",
+ "cc-exp-mo",
+ "card-expiration-month",
+ "expiration-month",
+ "cc-mm",
+ "cc-m",
+ "card-mm",
+ "card-m",
+ "card-exp-mm",
+ "cc-exp-mm",
+ "exp-mm",
+ "exp-m",
+ "expire-month",
+ "expire-mo",
+ "expiry-month",
+ "expiry-mo",
+ "card-expire-month",
+ "card-expire-mo",
+ "card-expiry-month",
+ "card-expiry-mo",
+ "mois-validite",
+ "mois-expiration",
+ "m-validite",
+ "m-expiration",
+ "expiry-date-field-month",
+ "expiration-date-month",
+ "expiration-date-mm",
+ "exp-mon",
+ "validity-mo",
+ "exp-date-mo",
+ "cb-date-mois",
+ "date-m",
+ ],
+ "cc-exp-year": [
+ "exp-year",
+ "cc-exp-year",
+ "cc-year",
+ "card-year",
+ "cc-yr",
+ "card-yr",
+ "exp-yr",
+ "card-exp-yr",
+ "cc-exp-yr",
+ "card-expiration-year",
+ "expiration-year",
+ "cc-yy",
+ "cc-y",
+ "card-yy",
+ "card-y",
+ "card-exp-yy",
+ "cc-exp-yy",
+ "exp-yy",
+ "exp-y",
+ "cc-yyyy",
+ "card-yyyy",
+ "card-exp-yyyy",
+ "cc-exp-yyyy",
+ "expire-year",
+ "expire-yr",
+ "expiry-year",
+ "expiry-yr",
+ "card-expire-year",
+ "card-expire-yr",
+ "card-expiry-year",
+ "card-expiry-yr",
+ "an-validite",
+ "an-expiration",
+ "annee-validite",
+ "annee-expiration",
+ "expiry-date-field-year",
+ "expiration-date-year",
+ "cb-date-ann",
+ "expiration-date-yy",
+ "expiration-date-yyyy",
+ "validity-year",
+ "exp-date-year",
+ "date-y",
+ ],
+};
+
+add_setup(async () => {
+ ({ FormAutofillHeuristics } = ChromeUtils.import(
+ "resource://autofill/FormAutofillHeuristics.jsm"
+ ));
+});
+
+for (let field in KNOWN_NAMES) {
+ KNOWN_NAMES[field].forEach(name => {
+ add_task(async () => {
+ ok(
+ FormAutofillHeuristics.RULES[field].test(name),
+ `RegExp for ${field} matches string '${name}'`
+ );
+ });
+ });
+}
diff --git a/browser/extensions/formautofill/test/unit/heuristics/test_multiple_section.js b/browser/extensions/formautofill/test/unit/heuristics/test_multiple_section.js
new file mode 100644
index 0000000000..752d13bbc4
--- /dev/null
+++ b/browser/extensions/formautofill/test/unit/heuristics/test_multiple_section.js
@@ -0,0 +1,280 @@
+/* global runHeuristicsTest */
+
+"use strict";
+
+runHeuristicsTest(
+ [
+ {
+ fixturePath: "multiple_section.html",
+ expectedResult: [
+ [
+ [
+ {
+ section: "",
+ addressType: "",
+ contactType: "",
+ fieldName: "name",
+ },
+ {
+ section: "",
+ addressType: "",
+ contactType: "",
+ fieldName: "organization",
+ },
+ {
+ section: "",
+ addressType: "",
+ contactType: "work",
+ fieldName: "tel",
+ },
+ {
+ section: "",
+ addressType: "",
+ contactType: "work",
+ fieldName: "email",
+ },
+
+ // Even the `contactType` of these two fields are different with the
+ // above two, we still consider they are identical until supporting
+ // multiple phone number and email in one profile.
+ // {"section": "", "addressType": "", "contactType": "home", "fieldName": "tel"},
+ // {"section": "", "addressType": "", "contactType": "home", "fieldName": "email"},
+ ],
+ [
+ {
+ section: "",
+ addressType: "shipping",
+ contactType: "",
+ fieldName: "street-address",
+ },
+ {
+ section: "",
+ addressType: "shipping",
+ contactType: "",
+ fieldName: "address-level2",
+ },
+ {
+ section: "",
+ addressType: "shipping",
+ contactType: "",
+ fieldName: "address-level1",
+ },
+ {
+ section: "",
+ addressType: "shipping",
+ contactType: "",
+ fieldName: "postal-code",
+ },
+ {
+ section: "",
+ addressType: "shipping",
+ contactType: "",
+ fieldName: "country",
+ },
+ ],
+ [
+ {
+ section: "",
+ addressType: "billing",
+ contactType: "",
+ fieldName: "street-address",
+ },
+ {
+ section: "",
+ addressType: "billing",
+ contactType: "",
+ fieldName: "address-level2",
+ },
+ {
+ section: "",
+ addressType: "billing",
+ contactType: "",
+ fieldName: "address-level1",
+ },
+ {
+ section: "",
+ addressType: "billing",
+ contactType: "",
+ fieldName: "postal-code",
+ },
+ {
+ section: "",
+ addressType: "billing",
+ contactType: "",
+ fieldName: "country",
+ },
+ ],
+ [
+ {
+ section: "section-my",
+ addressType: "",
+ contactType: "",
+ fieldName: "street-address",
+ },
+ {
+ section: "section-my",
+ addressType: "",
+ contactType: "",
+ fieldName: "address-level2",
+ },
+ {
+ section: "section-my",
+ addressType: "",
+ contactType: "",
+ fieldName: "address-level1",
+ },
+ {
+ section: "section-my",
+ addressType: "",
+ contactType: "",
+ fieldName: "postal-code",
+ },
+ {
+ section: "section-my",
+ addressType: "",
+ contactType: "",
+ fieldName: "country",
+ },
+ ],
+ ],
+ [
+ [
+ {
+ section: "",
+ addressType: "",
+ contactType: "",
+ fieldName: "name",
+ },
+ {
+ section: "",
+ addressType: "",
+ contactType: "",
+ fieldName: "organization",
+ },
+ {
+ section: "",
+ addressType: "",
+ contactType: "",
+ fieldName: "street-address",
+ },
+ {
+ section: "",
+ addressType: "",
+ contactType: "",
+ fieldName: "address-level2",
+ },
+ {
+ section: "",
+ addressType: "",
+ contactType: "",
+ fieldName: "address-level1",
+ },
+ {
+ section: "",
+ addressType: "",
+ contactType: "",
+ fieldName: "postal-code",
+ },
+ {
+ section: "",
+ addressType: "",
+ contactType: "",
+ fieldName: "country",
+ },
+ ],
+ [
+ {
+ section: "",
+ addressType: "",
+ contactType: "",
+ fieldName: "street-address",
+ },
+ {
+ section: "",
+ addressType: "",
+ contactType: "",
+ fieldName: "address-level2",
+ },
+ {
+ section: "",
+ addressType: "",
+ contactType: "",
+ fieldName: "address-level1",
+ },
+ {
+ section: "",
+ addressType: "",
+ contactType: "",
+ fieldName: "postal-code",
+ },
+ {
+ section: "",
+ addressType: "",
+ contactType: "",
+ fieldName: "country",
+ },
+ ],
+ [
+ {
+ section: "",
+ addressType: "",
+ contactType: "",
+ fieldName: "street-address",
+ },
+ {
+ section: "",
+ addressType: "",
+ contactType: "",
+ fieldName: "address-level2",
+ },
+ {
+ section: "",
+ addressType: "",
+ contactType: "",
+ fieldName: "address-level1",
+ },
+ {
+ section: "",
+ addressType: "",
+ contactType: "",
+ fieldName: "postal-code",
+ },
+ {
+ section: "",
+ addressType: "",
+ contactType: "",
+ fieldName: "country",
+ },
+ {
+ section: "",
+ addressType: "",
+ contactType: "work",
+ fieldName: "tel",
+ },
+ {
+ section: "",
+ addressType: "",
+ contactType: "work",
+ fieldName: "email",
+ },
+ ],
+ [
+ {
+ section: "",
+ addressType: "",
+ contactType: "home",
+ fieldName: "tel",
+ },
+ {
+ section: "",
+ addressType: "",
+ contactType: "home",
+ fieldName: "email",
+ },
+ ],
+ ],
+ ],
+ },
+ ],
+ "../../fixtures/"
+);
diff --git a/browser/extensions/formautofill/test/unit/heuristics/third_party/test_BestBuy.js b/browser/extensions/formautofill/test/unit/heuristics/third_party/test_BestBuy.js
new file mode 100644
index 0000000000..5aa741a729
--- /dev/null
+++ b/browser/extensions/formautofill/test/unit/heuristics/third_party/test_BestBuy.js
@@ -0,0 +1,163 @@
+/* global runHeuristicsTest */
+
+"use strict";
+
+runHeuristicsTest(
+ [
+ {
+ fixturePath: "Checkout_ShippingAddress.html",
+ expectedResult: [
+ [], // Search form
+ [
+ [
+ {
+ section: "",
+ addressType: "",
+ contactType: "",
+ fieldName: "given-name",
+ },
+ {
+ section: "",
+ addressType: "",
+ contactType: "",
+ fieldName: "family-name",
+ },
+ {
+ section: "",
+ addressType: "",
+ contactType: "",
+ fieldName: "street-address",
+ },
+ {
+ section: "",
+ addressType: "",
+ contactType: "",
+ fieldName: "address-level2",
+ }, // city
+ {
+ section: "",
+ addressType: "",
+ contactType: "",
+ fieldName: "address-level1",
+ }, // state
+ {
+ section: "",
+ addressType: "",
+ contactType: "",
+ fieldName: "postal-code",
+ },
+ ],
+ ],
+ [
+ [
+ // Sign up
+ {
+ section: "",
+ addressType: "",
+ contactType: "",
+ fieldName: "email",
+ },
+ ],
+ ],
+ [
+ [
+ // unknown
+ {
+ section: "",
+ addressType: "",
+ contactType: "",
+ fieldName: "email",
+ },
+ { section: "", addressType: "", contactType: "", fieldName: "tel" },
+ ],
+ ],
+ ],
+ },
+ {
+ fixturePath: "Checkout_Payment.html",
+ expectedResult: [
+ [], // 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: "street-address",
+ },
+ {
+ section: "",
+ addressType: "",
+ contactType: "",
+ fieldName: "address-level2",
+ }, // city
+ {
+ section: "",
+ addressType: "",
+ contactType: "",
+ fieldName: "address-level1",
+ }, // state
+ {
+ section: "",
+ addressType: "",
+ contactType: "",
+ fieldName: "postal-code",
+ },
+ ],
+ ],
+ [
+ [
+ // unknown
+ {
+ section: "",
+ addressType: "",
+ contactType: "",
+ fieldName: "email",
+ },
+ { section: "", addressType: "", contactType: "", fieldName: "tel" },
+ ],
+ ],
+ ],
+ },
+ {
+ fixturePath: "SignIn.html",
+ expectedResult: [
+ [
+ [
+ // Sign in
+ {
+ section: "",
+ addressType: "",
+ contactType: "",
+ fieldName: "email",
+ },
+ ],
+ ],
+ ],
+ },
+ ],
+ "../../../fixtures/third_party/BestBuy/"
+);
diff --git a/browser/extensions/formautofill/test/unit/heuristics/third_party/test_CDW.js b/browser/extensions/formautofill/test/unit/heuristics/third_party/test_CDW.js
new file mode 100644
index 0000000000..71a84660d7
--- /dev/null
+++ b/browser/extensions/formautofill/test/unit/heuristics/third_party/test_CDW.js
@@ -0,0 +1,169 @@
+/* global runHeuristicsTest */
+
+"use strict";
+
+runHeuristicsTest(
+ [
+ {
+ fixturePath: "Checkout_ShippingInfo.html",
+ expectedResult: [
+ [
+ [
+ {
+ section: "",
+ addressType: "",
+ contactType: "",
+ fieldName: "given-name",
+ },
+ {
+ section: "",
+ addressType: "",
+ contactType: "",
+ fieldName: "family-name",
+ },
+ {
+ section: "",
+ addressType: "",
+ contactType: "",
+ fieldName: "organization",
+ },
+ {
+ 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: "email",
+ },
+ { section: "", addressType: "", contactType: "", fieldName: "tel" },
+ {
+ section: "",
+ addressType: "",
+ contactType: "",
+ fieldName: "tel-extension",
+ },
+ ],
+ ],
+ [],
+ ],
+ },
+ {
+ fixturePath: "Checkout_BillingPaymentInfo.html",
+ expectedResult: [
+ [
+ [
+ {
+ section: "",
+ addressType: "",
+ contactType: "",
+ fieldName: "given-name",
+ },
+ {
+ section: "",
+ addressType: "",
+ contactType: "",
+ fieldName: "family-name",
+ },
+ {
+ section: "",
+ addressType: "",
+ contactType: "",
+ fieldName: "organization",
+ },
+ {
+ 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: "cc-type",
+ }, // ac-off
+ {
+ 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"},
+ ],
+ ],
+ [],
+ ],
+ },
+ {
+ fixturePath: "Checkout_Logon.html",
+ expectedResult: [[], [], []],
+ },
+ ],
+ "../../../fixtures/third_party/CDW/"
+);
diff --git a/browser/extensions/formautofill/test/unit/heuristics/third_party/test_CostCo.js b/browser/extensions/formautofill/test/unit/heuristics/third_party/test_CostCo.js
new file mode 100644
index 0000000000..049bccc9a9
--- /dev/null
+++ b/browser/extensions/formautofill/test/unit/heuristics/third_party/test_CostCo.js
@@ -0,0 +1,448 @@
+/* global runHeuristicsTest */
+
+"use strict";
+
+runHeuristicsTest(
+ [
+ {
+ fixturePath: "ShippingAddress.html",
+ expectedResult: [
+ [],
+ [],
+ [
+ [
+ {
+ 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",
+ },
+ {
+ 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" },
+ {
+ section: "",
+ addressType: "",
+ contactType: "",
+ fieldName: "email",
+ },
+ ],
+ ],
+ [
+ [
+ {
+ 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",
+ },
+ {
+ 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" },
+ {
+ section: "",
+ addressType: "",
+ contactType: "",
+ fieldName: "email",
+ },
+ ],
+ ],
+ [],
+ [
+ [
+ {
+ section: "",
+ addressType: "",
+ contactType: "",
+ fieldName: "email",
+ },
+ ],
+ ],
+ [],
+ ],
+ },
+ {
+ fixturePath: "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",
+ },
+ {
+ 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",
+ },
+ {
+ 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" },
+ {
+ section: "",
+ addressType: "",
+ contactType: "",
+ fieldName: "email",
+ },
+ ],
+ ],
+ [
+ [
+ {
+ 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",
+ },
+ {
+ section: "",
+ addressType: "",
+ contactType: "",
+ fieldName: "address-level2",
+ },
+ {
+ section: "",
+ addressType: "",
+ contactType: "",
+ fieldName: "address-level1",
+ }, // state
+ {
+ section: "",
+ addressType: "",
+ contactType: "",
+ fieldName: "postal-code",
+ },
+ { section: "", addressType: "", contactType: "", fieldName: "tel" },
+ {
+ section: "",
+ addressType: "",
+ contactType: "",
+ fieldName: "email",
+ },
+ ],
+ ],
+ [],
+ [
+ [
+ {
+ section: "",
+ addressType: "",
+ contactType: "",
+ fieldName: "email",
+ },
+ ],
+ ],
+ [],
+ ],
+ },
+ {
+ fixturePath: "SignIn.html",
+ expectedResult: [
+ [],
+ [],
+ [
+ [
+ {
+ section: "",
+ addressType: "",
+ contactType: "",
+ fieldName: "email",
+ },
+ ],
+ ],
+ [],
+ [
+ [
+ // Forgot password
+ {
+ section: "",
+ addressType: "",
+ contactType: "",
+ fieldName: "email",
+ },
+ ],
+ ],
+ [
+ [
+ {
+ section: "",
+ addressType: "",
+ contactType: "",
+ fieldName: "email",
+ },
+ ],
+ ],
+ [
+ [
+ {
+ section: "",
+ addressType: "",
+ contactType: "",
+ fieldName: "email",
+ },
+ // {"section": "", "addressType": "", "contactType": "", "fieldName": "password"},
+ ],
+ ],
+ [
+ [
+ // Sign up
+ {
+ section: "",
+ addressType: "",
+ contactType: "",
+ fieldName: "email",
+ },
+ ],
+ ],
+ [
+ [
+ {
+ section: "",
+ addressType: "",
+ contactType: "",
+ fieldName: "email",
+ },
+ ],
+ ],
+ [],
+ ],
+ },
+ ],
+ "../../../fixtures/third_party/CostCo/"
+);
diff --git a/browser/extensions/formautofill/test/unit/heuristics/third_party/test_DirectAsda.js b/browser/extensions/formautofill/test/unit/heuristics/third_party/test_DirectAsda.js
new file mode 100644
index 0000000000..32116315f9
--- /dev/null
+++ b/browser/extensions/formautofill/test/unit/heuristics/third_party/test_DirectAsda.js
@@ -0,0 +1,42 @@
+/* global runHeuristicsTest */
+
+"use strict";
+
+runHeuristicsTest(
+ [
+ {
+ fixturePath: "Payment.html",
+ expectedResult: [
+ [
+ [
+ {
+ section: "",
+ addressType: "",
+ contactType: "",
+ fieldName: "cc-number",
+ },
+ {
+ section: "",
+ addressType: "",
+ contactType: "",
+ fieldName: "cc-name"
+ },
+ {
+ section: "",
+ addressType: "",
+ contactType: "",
+ fieldName: "cc-exp-month"
+ },
+ {
+ section: "",
+ addressType: "",
+ contactType: "",
+ fieldName: "cc-exp-year"
+ },
+ ],
+ ],
+ ],
+ },
+ ],
+ "../../../fixtures/third_party/DirectAsda/"
+)
diff --git a/browser/extensions/formautofill/test/unit/heuristics/third_party/test_Ebay.js b/browser/extensions/formautofill/test/unit/heuristics/third_party/test_Ebay.js
new file mode 100644
index 0000000000..ab9c743d4b
--- /dev/null
+++ b/browser/extensions/formautofill/test/unit/heuristics/third_party/test_Ebay.js
@@ -0,0 +1,42 @@
+/* global runHeuristicsTest */
+
+"use strict";
+
+runHeuristicsTest(
+ [
+ {
+ fixturePath: "Checkout_Payment_FR.html",
+ expectedResult: [
+ [
+ [
+ {
+ section: "",
+ addressType: "",
+ contactType: "",
+ fieldName: "cc-number",
+ },
+ {
+ section: "",
+ addressType: "",
+ contactType: "",
+ fieldName: "cc-exp"
+ },
+ {
+ section: "",
+ addressType: "",
+ contactType: "",
+ fieldName: "cc-given-name"
+ },
+ {
+ section: "",
+ addressType: "",
+ contactType: "",
+ fieldName: "cc-family-name"
+ },
+ ],
+ ],
+ ],
+ },
+ ],
+ "../../../fixtures/third_party/Ebay/"
+)
diff --git a/browser/extensions/formautofill/test/unit/heuristics/third_party/test_GlobalDirectAsda.js b/browser/extensions/formautofill/test/unit/heuristics/third_party/test_GlobalDirectAsda.js
new file mode 100644
index 0000000000..f6d6cf423c
--- /dev/null
+++ b/browser/extensions/formautofill/test/unit/heuristics/third_party/test_GlobalDirectAsda.js
@@ -0,0 +1,36 @@
+/* global runHeuristicsTest */
+
+"use strict";
+
+runHeuristicsTest(
+ [
+ {
+ fixturePath: "Payment.html",
+ expectedResult: [
+ [
+ [
+ {
+ section: "",
+ addressType: "",
+ contactType: "",
+ fieldName: "cc-number",
+ },
+ {
+ section: "",
+ addressType: "",
+ contactType: "",
+ fieldName: "cc-exp-month"
+ },
+ {
+ section: "",
+ addressType: "",
+ contactType: "",
+ fieldName: "cc-exp-year"
+ },
+ ],
+ ],
+ ],
+ },
+ ],
+ "../../../fixtures/third_party/GlobalDirectAsda/"
+)
diff --git a/browser/extensions/formautofill/test/unit/heuristics/third_party/test_HomeDepot.js b/browser/extensions/formautofill/test/unit/heuristics/third_party/test_HomeDepot.js
new file mode 100644
index 0000000000..1100c29842
--- /dev/null
+++ b/browser/extensions/formautofill/test/unit/heuristics/third_party/test_HomeDepot.js
@@ -0,0 +1,110 @@
+/* global runHeuristicsTest */
+
+"use strict";
+
+runHeuristicsTest(
+ [
+ {
+ fixturePath: "Checkout_ShippingPayment.html",
+ expectedResult: [
+ [
+ [
+ {
+ section: "",
+ addressType: "",
+ contactType: "",
+ fieldName: "given-name",
+ },
+ {
+ section: "",
+ addressType: "",
+ contactType: "",
+ fieldName: "family-name",
+ },
+ {
+ section: "",
+ addressType: "",
+ contactType: "",
+ fieldName: "email",
+ },
+ { section: "", addressType: "", contactType: "", fieldName: "tel" },
+ {
+ section: "",
+ addressType: "",
+ contactType: "",
+ fieldName: "street-address",
+ },
+ {
+ section: "",
+ addressType: "",
+ contactType: "",
+ fieldName: "postal-code",
+ },
+ ],
+ [
+ // FIXME: bug 1392944 - the uncommented cc-exp-month and cc-exp-year are
+ // both invisible <input> elements, and the following two <select>
+ // elements are the correct ones. BTW, they are both applied
+ // autocomplete attr.
+ {
+ section: "",
+ addressType: "",
+ contactType: "",
+ fieldName: "cc-exp-month",
+ },
+ {
+ section: "",
+ addressType: "",
+ contactType: "",
+ fieldName: "cc-exp-year",
+ },
+ {
+ section: "",
+ addressType: "",
+ contactType: "",
+ fieldName: "cc-number",
+ },
+ // {"section": "", "addressType": "", "contactType": "", "fieldName": "cc-exp-month"},
+ // {"section": "", "addressType": "", "contactType": "", "fieldName": "cc-exp-year"},
+
+ // {"section": "", "addressType": "", "contactType": "", "fieldName": "cc-csc"},
+ ],
+ [
+ {
+ section: "",
+ addressType: "billing",
+ contactType: "",
+ fieldName: "street-address",
+ }, // <select>
+ ],
+ ],
+ ],
+ },
+ {
+ fixturePath: "SignIn.html",
+ expectedResult: [
+ [
+ [
+ {
+ section: "",
+ addressType: "",
+ contactType: "",
+ fieldName: "email",
+ },
+ ],
+ ],
+ [
+ [
+ {
+ section: "",
+ addressType: "",
+ contactType: "",
+ fieldName: "email",
+ },
+ ],
+ ],
+ ],
+ },
+ ],
+ "../../../fixtures/third_party/HomeDepot/"
+);
diff --git a/browser/extensions/formautofill/test/unit/heuristics/third_party/test_Lufthansa.js b/browser/extensions/formautofill/test/unit/heuristics/third_party/test_Lufthansa.js
new file mode 100644
index 0000000000..155f9e38ac
--- /dev/null
+++ b/browser/extensions/formautofill/test/unit/heuristics/third_party/test_Lufthansa.js
@@ -0,0 +1,64 @@
+/* global runHeuristicsTest */
+
+"use strict";
+
+runHeuristicsTest(
+ [
+ {
+ fixturePath: "Checkout_Payment.html",
+ expectedResult: [
+ [
+ [
+ {
+ section: "",
+ addressType: "",
+ contactType: "",
+ fieldName: "cc-type",
+ },
+ {
+ section: "",
+ addressType: "",
+ contactType: "",
+ fieldName: "cc-number",
+ transform: "fullCCNumber => fullCCNumber.slice(0, 4)",
+ },
+ {
+ section: "",
+ addressType: "",
+ contactType: "",
+ fieldName: "cc-number",
+ transform: "fullCCNumber => fullCCNumber.slice(4, 8)",
+ },
+ {
+ section: "",
+ addressType: "",
+ contactType: "",
+ fieldName: "cc-number",
+ transform: "fullCCNumber => fullCCNumber.slice(8, 12)",
+ },
+ {
+ section: "",
+ addressType: "",
+ contactType: "",
+ fieldName: "cc-number",
+ transform: "fullCCNumber => fullCCNumber.slice(12, 16)",
+ },
+ {
+ section: "",
+ addressType: "",
+ contactType: "",
+ fieldName: "cc-exp-month",
+ },
+ {
+ section: "",
+ addressType: "",
+ contactType: "",
+ fieldName: "cc-exp-year",
+ },
+ ],
+ ],
+ ],
+ },
+ ],
+ "../../../fixtures/third_party/Lufthansa/"
+);
diff --git a/browser/extensions/formautofill/test/unit/heuristics/third_party/test_Lush.js b/browser/extensions/formautofill/test/unit/heuristics/third_party/test_Lush.js
new file mode 100644
index 0000000000..ffbe40099b
--- /dev/null
+++ b/browser/extensions/formautofill/test/unit/heuristics/third_party/test_Lush.js
@@ -0,0 +1,56 @@
+/* global runHeuristicsTest */
+
+"use strict";
+
+runHeuristicsTest(
+ [
+ {
+ fixturePath: "index.html",
+ expectedResult: [
+ [
+ [
+ {
+ section: "",
+ addressType: "",
+ contactType: "",
+ fieldName: "cc-name",
+ },
+ {
+ section: "",
+ addressType: "",
+ contactType: "",
+ fieldName: "cc-number",
+ },
+ ],
+ [
+ {
+ section: "",
+ addressType: "",
+ contactType: "",
+ fieldName: "cc-number",
+ },
+ {
+ section: "",
+ addressType: "",
+ contactType: "",
+ fieldName: "cc-name",
+ },
+ {
+ section: "",
+ addressType: "",
+ contactType: "",
+ fieldName: "cc-exp-month",
+ },
+ {
+ section: "",
+ addressType: "",
+ contactType: "",
+ fieldName: "cc-exp-year",
+ },
+ ],
+ ],
+ ],
+ },
+ ],
+ "../../../fixtures/third_party/Lush/"
+);
diff --git a/browser/extensions/formautofill/test/unit/heuristics/third_party/test_Macys.js b/browser/extensions/formautofill/test/unit/heuristics/third_party/test_Macys.js
new file mode 100644
index 0000000000..b496801cd0
--- /dev/null
+++ b/browser/extensions/formautofill/test/unit/heuristics/third_party/test_Macys.js
@@ -0,0 +1,190 @@
+/* global runHeuristicsTest */
+
+"use strict";
+
+runHeuristicsTest(
+ [
+ {
+ fixturePath: "Checkout_ShippingAddress.html",
+ expectedResult: [
+ [
+ [
+ {
+ 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",
+ }, // 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: "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",
+ }, // city
+ {
+ section: "",
+ addressType: "",
+ contactType: "",
+ fieldName: "address-level1",
+ }, // state
+ {
+ section: "",
+ addressType: "",
+ contactType: "",
+ fieldName: "postal-code",
+ },
+ { section: "", addressType: "", contactType: "", fieldName: "tel" },
+ {
+ section: "",
+ addressType: "",
+ contactType: "",
+ fieldName: "email",
+ },
+ ],
+ [
+ {
+ 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
+ {
+ section: "",
+ addressType: "",
+ contactType: "",
+ fieldName: "cc-exp-year",
+ }, // ac-off
+ // {"section": "", "addressType": "", "contactType": "", "fieldName": "cc-csc"}, // ac-off
+ // {"section": "", "addressType": "", "contactType": "", "fieldName": "cc-csc"}, // ac-off
+ ],
+ ],
+ [],
+ ],
+ },
+ {
+ fixturePath: "SignIn.html",
+ expectedResult: [
+ [
+ [
+ // Sign in
+ {
+ section: "",
+ addressType: "",
+ contactType: "",
+ fieldName: "email",
+ },
+ // {"section": "", "addressType": "", "contactType": "", "fieldName": "password"},
+ ],
+ ],
+ [
+ [
+ // Forgot password
+ {
+ section: "",
+ addressType: "",
+ contactType: "",
+ fieldName: "email",
+ },
+ ],
+ ],
+ [
+ [
+ {
+ section: "",
+ addressType: "",
+ contactType: "",
+ fieldName: "email",
+ },
+ ],
+ ],
+ [],
+ [],
+ [],
+ ],
+ },
+ ],
+ "../../../fixtures/third_party/Macys/"
+);
diff --git a/browser/extensions/formautofill/test/unit/heuristics/third_party/test_NewEgg.js b/browser/extensions/formautofill/test/unit/heuristics/third_party/test_NewEgg.js
new file mode 100644
index 0000000000..46ebcf81e5
--- /dev/null
+++ b/browser/extensions/formautofill/test/unit/heuristics/third_party/test_NewEgg.js
@@ -0,0 +1,232 @@
+/* global runHeuristicsTest */
+
+"use strict";
+
+runHeuristicsTest(
+ [
+ {
+ fixturePath: "ShippingInfo.html",
+ expectedResult: [
+ [
+ [
+ {
+ section: "",
+ addressType: "",
+ contactType: "",
+ fieldName: "given-name",
+ },
+ {
+ section: "",
+ addressType: "",
+ contactType: "",
+ fieldName: "family-name",
+ },
+ {
+ 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
+ {
+ section: "",
+ addressType: "",
+ contactType: "",
+ fieldName: "postal-code",
+ },
+ { section: "", addressType: "", contactType: "", fieldName: "tel" },
+ {
+ section: "",
+ addressType: "",
+ contactType: "",
+ fieldName: "email",
+ },
+ ],
+ ],
+ [],
+ ],
+ },
+ {
+ fixturePath: "BillingInfo.html",
+ expectedResult: [
+ [
+ [
+ {
+ section: "",
+ addressType: "",
+ contactType: "",
+ fieldName: "cc-name",
+ },
+ {
+ section: "",
+ addressType: "",
+ contactType: "",
+ fieldName: "cc-number",
+ }, // ac-off
+ ],
+ [
+ {
+ 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
+ {
+ section: "",
+ addressType: "",
+ contactType: "",
+ fieldName: "postal-code",
+ },
+ { section: "", addressType: "", contactType: "", fieldName: "tel" },
+ ],
+ [
+ {
+ 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: "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-name",
+ },
+ {
+ section: "",
+ addressType: "",
+ contactType: "",
+ fieldName: "cc-number",
+ }, // ac-off
+ ],
+ ],
+ ],
+ },
+ {
+ fixturePath: "Login.html",
+ expectedResult: [
+ [
+ [
+ {
+ section: "",
+ addressType: "",
+ contactType: "",
+ fieldName: "email",
+ },
+ ],
+ ],
+ [],
+ [
+ [
+ {
+ section: "",
+ addressType: "",
+ contactType: "",
+ fieldName: "email",
+ },
+ ],
+ ],
+ ],
+ },
+ ],
+ "../../../fixtures/third_party/NewEgg/"
+);
diff --git a/browser/extensions/formautofill/test/unit/heuristics/third_party/test_OfficeDepot.js b/browser/extensions/formautofill/test/unit/heuristics/third_party/test_OfficeDepot.js
new file mode 100644
index 0000000000..0e38b17e8f
--- /dev/null
+++ b/browser/extensions/formautofill/test/unit/heuristics/third_party/test_OfficeDepot.js
@@ -0,0 +1,227 @@
+/* global runHeuristicsTest */
+
+"use strict";
+
+runHeuristicsTest(
+ [
+ {
+ fixturePath: "ShippingAddress.html",
+ expectedResult: [
+ [
+ [
+ {
+ section: "",
+ addressType: "",
+ contactType: "",
+ fieldName: "given-name",
+ },
+ {
+ section: "",
+ addressType: "",
+ contactType: "",
+ fieldName: "family-name",
+ },
+ {
+ section: "",
+ addressType: "",
+ contactType: "",
+ fieldName: "organization",
+ },
+ {
+ section: "",
+ addressType: "",
+ contactType: "",
+ fieldName: "address-line1",
+ },
+ {
+ section: "",
+ addressType: "",
+ contactType: "",
+ fieldName: "address-line2",
+ },
+ {
+ section: "",
+ addressType: "",
+ contactType: "",
+ fieldName: "postal-code",
+ },
+ {
+ section: "",
+ addressType: "",
+ contactType: "",
+ fieldName: "address-level2",
+ },
+ {
+ section: "",
+ addressType: "",
+ contactType: "",
+ fieldName: "address-level1",
+ }, // state
+
+ {
+ 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",
+ },
+
+ {
+ section: "",
+ addressType: "",
+ contactType: "",
+ fieldName: "email",
+ },
+ ],
+ ],
+ [],
+ ],
+ },
+ {
+ fixturePath: "Payment.html",
+ expectedResult: [
+ [
+ [
+ {
+ section: "",
+ addressType: "",
+ contactType: "",
+ fieldName: "given-name",
+ },
+ {
+ section: "",
+ addressType: "",
+ contactType: "",
+ fieldName: "family-name",
+ },
+ {
+ section: "",
+ addressType: "",
+ contactType: "",
+ fieldName: "organization",
+ },
+ {
+ section: "",
+ addressType: "",
+ contactType: "",
+ fieldName: "address-line1",
+ },
+ {
+ section: "",
+ addressType: "",
+ contactType: "",
+ fieldName: "address-line2",
+ },
+ {
+ section: "",
+ addressType: "",
+ contactType: "",
+ fieldName: "postal-code",
+ },
+ {
+ section: "",
+ addressType: "",
+ contactType: "",
+ fieldName: "address-level2",
+ },
+ {
+ section: "",
+ addressType: "",
+ contactType: "",
+ fieldName: "address-level1",
+ }, // state
+
+ {
+ 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",
+ },
+
+ {
+ section: "",
+ addressType: "",
+ contactType: "",
+ fieldName: "email",
+ },
+ ],
+ [
+ {
+ section: "",
+ addressType: "",
+ contactType: "",
+ fieldName: "cc-exp-month",
+ },
+ {
+ section: "",
+ addressType: "",
+ contactType: "",
+ fieldName: "cc-exp-year",
+ },
+ // 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
+ [
+ {
+ section: "",
+ addressType: "",
+ contactType: "",
+ fieldName: "email"
+ },
+ ]
+
+ ],
+ ],
+ },
+ ],
+ "../../../fixtures/third_party/OfficeDepot/"
+);
diff --git a/browser/extensions/formautofill/test/unit/heuristics/third_party/test_QVC.js b/browser/extensions/formautofill/test/unit/heuristics/third_party/test_QVC.js
new file mode 100644
index 0000000000..189622a6e9
--- /dev/null
+++ b/browser/extensions/formautofill/test/unit/heuristics/third_party/test_QVC.js
@@ -0,0 +1,148 @@
+/* global runHeuristicsTest */
+
+"use strict";
+
+runHeuristicsTest(
+ [
+ {
+ fixturePath: "YourInformation.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"},
+ ],
+ [
+ {
+ 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", // txtQvcGiftCardNumber
+ },
+ ],
+ ],
+ [
+ [
+ {
+ 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",
+ }, // ac-off
+ {
+ 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", // txtQvcGiftCardNumber
+ }, // ac-off
+ ],
+ ],
+ [
+ [
+ {
+ section: "",
+ addressType: "",
+ contactType: "",
+ fieldName: "email",
+ },
+ ],
+ ],
+ ],
+ },
+ {
+ fixturePath: "SignIn.html",
+ expectedResult: [
+ [],
+ [
+ [
+ // Sign in
+ {
+ section: "",
+ addressType: "",
+ contactType: "",
+ fieldName: "email",
+ },
+ ],
+ ],
+ [],
+ ],
+ },
+ ],
+ "../../../fixtures/third_party/QVC/"
+);
diff --git a/browser/extensions/formautofill/test/unit/heuristics/third_party/test_Sears.js b/browser/extensions/formautofill/test/unit/heuristics/third_party/test_Sears.js
new file mode 100644
index 0000000000..0f992a2543
--- /dev/null
+++ b/browser/extensions/formautofill/test/unit/heuristics/third_party/test_Sears.js
@@ -0,0 +1,309 @@
+/* global runHeuristicsTest */
+
+"use strict";
+
+runHeuristicsTest(
+ [
+ {
+ fixturePath: "ShippingAddress.html",
+ expectedResult: [
+ [],
+ [], // search form, ac-off
+ [
+ // ac-off
+ [ {"section": "", "addressType": "", "contactType": "", "fieldName": "email"},]
+
+ ],
+ [
+ // 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
+ [
+ {
+ section: "",
+ addressType: "",
+ contactType: "",
+ fieldName: "email"
+ },
+ ]
+
+ ],
+ [
+ // ac-off
+ [
+ {
+ section: "", addressType: "",
+ contactType: "",
+ fieldName: "email"
+ },
+ ]
+ ],
+ ],
+ },
+ {
+ fixturePath: "PaymentOptions.html",
+ expectedResult: [
+ [],
+ [], // search
+ [
+ [
+ // credit card
+ {
+ section: "",
+ addressType: "",
+ contactType: "",
+ fieldName: "cc-number",
+ },
+ {
+ 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",
+ },
+ ],
+ ],
+ [
+ [
+ // Another billing address
+ {
+ 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",
+ }, // city
+ {
+ section: "",
+ addressType: "",
+ contactType: "",
+ fieldName: "address-level1",
+ }, // state
+ {
+ section: "",
+ addressType: "",
+ contactType: "",
+ fieldName: "postal-code",
+ },
+ { section: "", addressType: "", contactType: "", fieldName: "tel" },
+ {
+ section: "",
+ addressType: "",
+ contactType: "",
+ fieldName: "tel-extension",
+ },
+ ],
+ ],
+ [
+ [
+ // check out
+ {
+ section: "",
+ addressType: "",
+ contactType: "",
+ fieldName: "given-name",
+ },
+ {
+ section: "",
+ addressType: "",
+ contactType: "",
+ fieldName: "family-name",
+ },
+
+ // FIXME: bug 1392934 - this should be detected as address-level1 since
+ // it's for Driver's license or state identification.
+ {
+ section: "",
+ addressType: "",
+ contactType: "",
+ fieldName: "address-level1",
+ },
+
+ // {"section": "", "addressType": "", "contactType": "", "fieldName": "bday-month"},
+ // {"section": "", "addressType": "", "contactType": "", "fieldName": "bday-day"},
+ // {"section": "", "addressType": "", "contactType": "", "fieldName": "bday-year"},
+ ],
+ [
+ // FIXME: bug 1392950 - the bank routing number should not be detected
+ // as cc-number.
+ {
+ section: "",
+ addressType: "",
+ contactType: "",
+ fieldName: "cc-number",
+ },
+ ],
+ ],
+ [
+ [
+ {
+ section: "",
+ addressType: "",
+ contactType: "",
+ fieldName: "email",
+ },
+ ],
+ ],
+ ],
+ },
+ ],
+ "../../../fixtures/third_party/Sears/"
+);
diff --git a/browser/extensions/formautofill/test/unit/heuristics/third_party/test_Staples.js b/browser/extensions/formautofill/test/unit/heuristics/third_party/test_Staples.js
new file mode 100644
index 0000000000..318246e743
--- /dev/null
+++ b/browser/extensions/formautofill/test/unit/heuristics/third_party/test_Staples.js
@@ -0,0 +1,146 @@
+/* global runHeuristicsTest */
+
+"use strict";
+
+runHeuristicsTest(
+ [
+ {
+ fixturePath: "Basic.html",
+ expectedResult: [
+ [
+ // 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",
+ },
+ {
+ section: "",
+ addressType: "",
+ contactType: "",
+ fieldName: "email",
+ },
+ {
+ section: "",
+ addressType: "",
+ contactType: "",
+ fieldName: "tel"
+ },
+ // {"section": "", "addressType": "", "contactType": "", "fieldName": "tel-extension"},
+ {
+ section: "",
+ addressType: "",
+ contactType: "",
+ fieldName: "organization",
+ },
+ ],
+ ],
+ ],
+ },
+ {
+ fixturePath: "PaymentBilling.html",
+ expectedResult: [
+ [
+ [
+ {
+ section: "",
+ addressType: "",
+ contactType: "",
+ fieldName: "cc-number",
+ },
+ {
+ section: "",
+ addressType: "",
+ contactType: "",
+ fieldName: "cc-exp",
+ },
+ // {"section": "", "addressType": "", "contactType": "", "fieldName": "cc-csc"},
+ ],
+ ],
+ ],
+ },
+ {
+ fixturePath: "PaymentBilling_ac_on.html",
+ expectedResult: [
+ [
+ [
+ {
+ section: "",
+ addressType: "",
+ contactType: "",
+ fieldName: "cc-number",
+ },
+ {
+ section: "",
+ addressType: "",
+ contactType: "",
+ fieldName: "cc-exp",
+ },
+ // {"section": "", "addressType": "", "contactType": "", "fieldName": "cc-csc"},
+ ],
+ ],
+ ],
+ },
+ ],
+ "../../../fixtures/third_party/Staples/"
+);
diff --git a/browser/extensions/formautofill/test/unit/heuristics/third_party/test_Walmart.js b/browser/extensions/formautofill/test/unit/heuristics/third_party/test_Walmart.js
new file mode 100644
index 0000000000..79cee73bcb
--- /dev/null
+++ b/browser/extensions/formautofill/test/unit/heuristics/third_party/test_Walmart.js
@@ -0,0 +1,173 @@
+/* global runHeuristicsTest */
+
+"use strict";
+
+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",
+ },
+ // ac-off
+ {
+ section: "",
+ addressType: "",
+ contactType: "",
+ fieldName: "email"
+ },
+ // {"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: "tel",
+ },
+ ],
+ [
+ {
+ 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"},
+ ],
+ ],
+ ],
+ },
+ {
+ 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
+ {
+ section: "",
+ addressType: "",
+ contactType: "",
+ fieldName: "postal-code",
+ },
+ ],
+ ],
+ ],
+ },
+ ],
+ "../../../fixtures/third_party/Walmart/"
+);
diff --git a/browser/extensions/formautofill/test/unit/heuristics/third_party/xpcshell.ini b/browser/extensions/formautofill/test/unit/heuristics/third_party/xpcshell.ini
new file mode 100644
index 0000000000..c4fae04117
--- /dev/null
+++ b/browser/extensions/formautofill/test/unit/heuristics/third_party/xpcshell.ini
@@ -0,0 +1,38 @@
+[DEFAULT]
+skip-if = toolkit == 'android' # bug 1730213
+firefox-appdir = browser
+head = ../../head.js
+support-files =
+ ../../../fixtures/**
+
+
+[test_BestBuy.js]
+skip-if = (os == "linux") && ccov # bug 1614100
+[test_CDW.js]
+skip-if = (os == "linux") && ccov # bug 1614100
+[test_CostCo.js]
+skip-if = (os == "linux") && ccov # bug 1614100
+[test_DirectAsda.js]
+skip-if = (os == "linux") && ccov # bug 1614100
+[test_GlobalDirectAsda.js]
+skip-if = (os == "linux") && ccov # bug 1614100
+[test_HomeDepot.js]
+skip-if = (os == "linux") && ccov # bug 1614100
+[test_Lufthansa.js]
+skip-if = (os == "linux") && ccov # bug 1614100
+[test_Macys.js]
+skip-if = (os == "linux") && ccov # bug 1614100
+[test_NewEgg.js]
+skip-if = (os == "linux") && ccov # bug 1614100
+[test_OfficeDepot.js]
+skip-if = (os == "linux") && ccov # bug 1614100
+[test_QVC.js]
+skip-if = (os == "linux") && ccov # bug 1614100
+[test_Sears.js]
+skip-if = (os == "linux") && ccov # bug 1614100
+[test_Staples.js]
+skip-if = (os == "linux") && ccov # bug 1614100
+[test_Walmart.js]
+skip-if = (os == "linux") && ccov # bug 1614100
+[test_Lush.js]
+skip-if = (os == "linux") && ccov # bug 1614100
diff --git a/browser/extensions/formautofill/test/unit/heuristics/xpcshell.ini b/browser/extensions/formautofill/test/unit/heuristics/xpcshell.ini
new file mode 100644
index 0000000000..44d5dd0ca2
--- /dev/null
+++ b/browser/extensions/formautofill/test/unit/heuristics/xpcshell.ini
@@ -0,0 +1,20 @@
+[DEFAULT]
+skip-if = toolkit == 'android' # bug 1730213
+firefox-appdir = browser
+head = ../head.js
+support-files =
+ ../../fixtures/**
+
+[test_autocomplete_off_on_inputs.js]
+[test_autocomplete_off_on_form.js]
+[test_basic.js]
+skip-if = (os == "linux") && ccov # bug 1614100
+[test_cc_exp.js]
+skip-if = (os == "linux") && ccov # bug 1614100
+[test_de_fields.js]
+skip-if = (os == "linux") && ccov # bug 1614100
+[test_fr_fields.js]
+[test_known_strings.js]
+skip-if = (os == "linux") && ccov # bug 1614100
+[test_multiple_section.js]
+skip-if = (os == "linux") && ccov # bug 1614100