diff --git a/browser/extensions/formautofill/FormAutofillHeuristics.jsm b/browser/extensions/formautofill/FormAutofillHeuristics.jsm
index bfa9272b71e8..0ce5138a7f03 100644
--- a/browser/extensions/formautofill/FormAutofillHeuristics.jsm
+++ b/browser/extensions/formautofill/FormAutofillHeuristics.jsm
@@ -12,6 +12,11 @@ this.EXPORTED_SYMBOLS = ["FormAutofillHeuristics"];
const {classes: Cc, interfaces: Ci, utils: Cu, results: Cr} = Components;
+Cu.import("resource://formautofill/FormAutofillUtils.jsm");
+
+this.log = null;
+FormAutofillUtils.defineLazyLogGetter(this, this.EXPORTED_SYMBOLS[0]);
+
/**
* Returns the autocomplete information of fields according to heuristics.
*/
diff --git a/browser/extensions/formautofill/test/fixtures/autocomplete_basic.html b/browser/extensions/formautofill/test/fixtures/autocomplete_basic.html
new file mode 100644
index 000000000000..bb74c9da920c
--- /dev/null
+++ b/browser/extensions/formautofill/test/fixtures/autocomplete_basic.html
@@ -0,0 +1,23 @@
+
+
+
+
+ Form Autofill Demo Page
+
+
+ Form Autofill Demo Page
+
+
+
+
diff --git a/browser/extensions/formautofill/test/fixtures/third_party/BestBuy/Checkout_Payment.html b/browser/extensions/formautofill/test/fixtures/third_party/BestBuy/Checkout_Payment.html
new file mode 100644
index 000000000000..e987ef59cac1
--- /dev/null
+++ b/browser/extensions/formautofill/test/fixtures/third_party/BestBuy/Checkout_Payment.html
@@ -0,0 +1,283 @@
+
+
+
+ Checkout – Best Buy
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ -
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/browser/extensions/formautofill/test/fixtures/third_party/BestBuy/Checkout_ShippingAddress.html b/browser/extensions/formautofill/test/fixtures/third_party/BestBuy/Checkout_ShippingAddress.html
new file mode 100644
index 000000000000..36760a26108e
--- /dev/null
+++ b/browser/extensions/formautofill/test/fixtures/third_party/BestBuy/Checkout_ShippingAddress.html
@@ -0,0 +1,326 @@
+
+
+
+ Checkout – Best Buy
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ -
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/browser/extensions/formautofill/test/fixtures/third_party/BestBuy/SignIn.html b/browser/extensions/formautofill/test/fixtures/third_party/BestBuy/SignIn.html
new file mode 100644
index 000000000000..8111d49c3725
--- /dev/null
+++ b/browser/extensions/formautofill/test/fixtures/third_party/BestBuy/SignIn.html
@@ -0,0 +1,21 @@
+
+
+
+ Sign In to BestBuy.com
+
+
+
+
+
diff --git a/browser/extensions/formautofill/test/fixtures/third_party/CDW/Checkout_BillingPaymentInfo.html b/browser/extensions/formautofill/test/fixtures/third_party/CDW/Checkout_BillingPaymentInfo.html
new file mode 100644
index 000000000000..3258417b78cd
--- /dev/null
+++ b/browser/extensions/formautofill/test/fixtures/third_party/CDW/Checkout_BillingPaymentInfo.html
@@ -0,0 +1,515 @@
+
+
+
+
+
+ Checkout
+
+
+
+
+
+
+
diff --git a/browser/extensions/formautofill/test/fixtures/third_party/CDW/Checkout_Logon.html b/browser/extensions/formautofill/test/fixtures/third_party/CDW/Checkout_Logon.html
new file mode 100644
index 000000000000..6ee46c88731b
--- /dev/null
+++ b/browser/extensions/formautofill/test/fixtures/third_party/CDW/Checkout_Logon.html
@@ -0,0 +1,118 @@
+
+
+
+
+
+ Logon Checkout
+
+
+
+
+
+
+
+
+
+
diff --git a/browser/extensions/formautofill/test/fixtures/third_party/CDW/Checkout_ShippingInfo.html b/browser/extensions/formautofill/test/fixtures/third_party/CDW/Checkout_ShippingInfo.html
new file mode 100644
index 000000000000..d461a0050b86
--- /dev/null
+++ b/browser/extensions/formautofill/test/fixtures/third_party/CDW/Checkout_ShippingInfo.html
@@ -0,0 +1,376 @@
+
+
+
+
+
+ Checkout
+
+
+
+
+
+
+
+
+
diff --git a/browser/extensions/formautofill/test/fixtures/third_party/CostCo/Payment.html b/browser/extensions/formautofill/test/fixtures/third_party/CostCo/Payment.html
new file mode 100644
index 000000000000..e45176cabc26
--- /dev/null
+++ b/browser/extensions/formautofill/test/fixtures/third_party/CostCo/Payment.html
@@ -0,0 +1,892 @@
+
+
+
+
+
+ Costco - Payment
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/browser/extensions/formautofill/test/fixtures/third_party/CostCo/ShippingAddress.html b/browser/extensions/formautofill/test/fixtures/third_party/CostCo/ShippingAddress.html
new file mode 100644
index 000000000000..b9b72eb3385c
--- /dev/null
+++ b/browser/extensions/formautofill/test/fixtures/third_party/CostCo/ShippingAddress.html
@@ -0,0 +1,527 @@
+
+
+
+
+
+
+ Shipping
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/browser/extensions/formautofill/test/fixtures/third_party/CostCo/SignIn.html b/browser/extensions/formautofill/test/fixtures/third_party/CostCo/SignIn.html
new file mode 100644
index 000000000000..afcd5fe6f09b
--- /dev/null
+++ b/browser/extensions/formautofill/test/fixtures/third_party/CostCo/SignIn.html
@@ -0,0 +1,374 @@
+
+
+
+
+
+ Sign In
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ ???LANGUAGE_REGION_MODAL_TITLE???
+
+
+
+
+
diff --git a/browser/extensions/formautofill/test/fixtures/third_party/HomeDepot/Checkout_ShippingPayment.html b/browser/extensions/formautofill/test/fixtures/third_party/HomeDepot/Checkout_ShippingPayment.html
new file mode 100644
index 000000000000..182535065101
--- /dev/null
+++ b/browser/extensions/formautofill/test/fixtures/third_party/HomeDepot/Checkout_ShippingPayment.html
@@ -0,0 +1,381 @@
+
+
+
+
+
+
+ The Home Depot - Checkout
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Create an account to track your order history and check out faster - all we need is a password.
+
+
Check out faster, access past orders, and organize products into lists.
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
Passwords are case sensitive and must be at least 8 characters.
+
+
Create a strong password by:
+
+ - Including numbers or symbols
+ - Mixing upper/lowercase
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Add an apartment, suite, building, etc.
+
+
+
+
+
+
+
+
+
+
+
+
+MOUNTAIN VIEW, CA
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Expiration
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Apply a Gift Card
+ |
+ Have a PO/Job Code for this order?
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Have a promo code?
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/browser/extensions/formautofill/test/fixtures/third_party/HomeDepot/SignIn.html b/browser/extensions/formautofill/test/fixtures/third_party/HomeDepot/SignIn.html
new file mode 100644
index 000000000000..b741ce5f0c20
--- /dev/null
+++ b/browser/extensions/formautofill/test/fixtures/third_party/HomeDepot/SignIn.html
@@ -0,0 +1,83 @@
+
+
+
+
+ The Home Depot - SignIn
+
+
+
+
+
+
+
+
+
+
+
diff --git a/browser/extensions/formautofill/test/fixtures/third_party/Macys/Checkout_Payment.html b/browser/extensions/formautofill/test/fixtures/third_party/Macys/Checkout_Payment.html
new file mode 100644
index 000000000000..4ec11c2b857f
--- /dev/null
+++ b/browser/extensions/formautofill/test/fixtures/third_party/Macys/Checkout_Payment.html
@@ -0,0 +1,478 @@
+
+
+
+
+ Macy's Checkout
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/browser/extensions/formautofill/test/fixtures/third_party/Macys/Checkout_ShippingAddress.html b/browser/extensions/formautofill/test/fixtures/third_party/Macys/Checkout_ShippingAddress.html
new file mode 100644
index 000000000000..7ed68344fa90
--- /dev/null
+++ b/browser/extensions/formautofill/test/fixtures/third_party/Macys/Checkout_ShippingAddress.html
@@ -0,0 +1,439 @@
+
+
+
+
+ Macy's Checkout
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/browser/extensions/formautofill/test/fixtures/third_party/Macys/SignIn.html b/browser/extensions/formautofill/test/fixtures/third_party/Macys/SignIn.html
new file mode 100644
index 000000000000..51dff05d0464
--- /dev/null
+++ b/browser/extensions/formautofill/test/fixtures/third_party/Macys/SignIn.html
@@ -0,0 +1,208 @@
+
+
+
+
+ Sign In - Macy's Checkout
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/browser/extensions/formautofill/test/fixtures/third_party/NewEgg/BillingInfo.html b/browser/extensions/formautofill/test/fixtures/third_party/NewEgg/BillingInfo.html
new file mode 100644
index 000000000000..c614660e1093
--- /dev/null
+++ b/browser/extensions/formautofill/test/fixtures/third_party/NewEgg/BillingInfo.html
@@ -0,0 +1,1083 @@
+
+
+
+
+ Newegg.com - Billing Info
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/browser/extensions/formautofill/test/fixtures/third_party/NewEgg/Login.html b/browser/extensions/formautofill/test/fixtures/third_party/NewEgg/Login.html
new file mode 100644
index 000000000000..a5f149b68362
--- /dev/null
+++ b/browser/extensions/formautofill/test/fixtures/third_party/NewEgg/Login.html
@@ -0,0 +1,156 @@
+
+
+
+
+ Newegg.com - Login
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/browser/extensions/formautofill/test/fixtures/third_party/NewEgg/ShippingInfo.html b/browser/extensions/formautofill/test/fixtures/third_party/NewEgg/ShippingInfo.html
new file mode 100644
index 000000000000..14bd9502afe4
--- /dev/null
+++ b/browser/extensions/formautofill/test/fixtures/third_party/NewEgg/ShippingInfo.html
@@ -0,0 +1,270 @@
+
+
+
+
+ Newegg.com - Shipping Info
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/browser/extensions/formautofill/test/fixtures/third_party/OfficeDepot/Payment.html b/browser/extensions/formautofill/test/fixtures/third_party/OfficeDepot/Payment.html
new file mode 100644
index 000000000000..06b9f8e7632b
--- /dev/null
+++ b/browser/extensions/formautofill/test/fixtures/third_party/OfficeDepot/Payment.html
@@ -0,0 +1,672 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Office Supplies, Furniture, Technology at Offic Depot
+
+
+
+
+
+
diff --git a/browser/extensions/formautofill/test/fixtures/third_party/OfficeDepot/ShippingAddress.html b/browser/extensions/formautofill/test/fixtures/third_party/OfficeDepot/ShippingAddress.html
new file mode 100644
index 000000000000..849e3be49559
--- /dev/null
+++ b/browser/extensions/formautofill/test/fixtures/third_party/OfficeDepot/ShippingAddress.html
@@ -0,0 +1,347 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Office Supplies, Furniture, Technology at Office Depot
+
+
+
+
+
+
+
diff --git a/browser/extensions/formautofill/test/fixtures/third_party/OfficeDepot/SignIn.html b/browser/extensions/formautofill/test/fixtures/third_party/OfficeDepot/SignIn.html
new file mode 100644
index 000000000000..70b55fedddb3
--- /dev/null
+++ b/browser/extensions/formautofill/test/fixtures/third_party/OfficeDepot/SignIn.html
@@ -0,0 +1,44 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Office Supplies, Furniture, Technology at Office Depot
+
+
+
+
+
+
diff --git a/browser/extensions/formautofill/test/fixtures/third_party/QVC/PaymentMethod.html b/browser/extensions/formautofill/test/fixtures/third_party/QVC/PaymentMethod.html
new file mode 100644
index 000000000000..9d51db7c5d8c
--- /dev/null
+++ b/browser/extensions/formautofill/test/fixtures/third_party/QVC/PaymentMethod.html
@@ -0,0 +1,527 @@
+
+
+
+
+
+
+
+
+ Payment Method
+
+
+
+
+
+
diff --git a/browser/extensions/formautofill/test/fixtures/third_party/QVC/SignIn.html b/browser/extensions/formautofill/test/fixtures/third_party/QVC/SignIn.html
new file mode 100644
index 000000000000..a056ccfc5cc5
--- /dev/null
+++ b/browser/extensions/formautofill/test/fixtures/third_party/QVC/SignIn.html
@@ -0,0 +1,80 @@
+
+
+
+
+
+
+
+ QVC.com Sign In
+
+
+
+
+
+
+
diff --git a/browser/extensions/formautofill/test/fixtures/third_party/QVC/YourInformation.html b/browser/extensions/formautofill/test/fixtures/third_party/QVC/YourInformation.html
new file mode 100644
index 000000000000..7af160e354cc
--- /dev/null
+++ b/browser/extensions/formautofill/test/fixtures/third_party/QVC/YourInformation.html
@@ -0,0 +1,522 @@
+
+
+
+
+
+
+
+
+ Payment Method
+
+
+
+
+
+
diff --git a/browser/extensions/formautofill/test/fixtures/third_party/README b/browser/extensions/formautofill/test/fixtures/third_party/README
new file mode 100644
index 000000000000..ca4750ec08cf
--- /dev/null
+++ b/browser/extensions/formautofill/test/fixtures/third_party/README
@@ -0,0 +1,4 @@
+This directory contains pages downloaded from the web for the purpose of testing
+Form Autofill against pages from the real world. These files are not made
+available under an open source license.
+
diff --git a/browser/extensions/formautofill/test/fixtures/third_party/Sears/PaymentOptions.html b/browser/extensions/formautofill/test/fixtures/third_party/Sears/PaymentOptions.html
new file mode 100644
index 000000000000..5f6ecd24d9d7
--- /dev/null
+++ b/browser/extensions/formautofill/test/fixtures/third_party/Sears/PaymentOptions.html
@@ -0,0 +1,566 @@
+
+
+
+
+
+
+
+
+
+
+ Payment Options | Sears PartsDirect
+
+
+
+
+
+
+
+
+
+
+
diff --git a/browser/extensions/formautofill/test/fixtures/third_party/Sears/ShippingAddress.html b/browser/extensions/formautofill/test/fixtures/third_party/Sears/ShippingAddress.html
new file mode 100644
index 000000000000..a9d1f5cd0f3f
--- /dev/null
+++ b/browser/extensions/formautofill/test/fixtures/third_party/Sears/ShippingAddress.html
@@ -0,0 +1,447 @@
+
+
+
+
+
+
+
+
+
+
+ Shipping address | Sears PartsDirect
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/browser/extensions/formautofill/test/fixtures/third_party/Staples/Basic.html b/browser/extensions/formautofill/test/fixtures/third_party/Staples/Basic.html
new file mode 100644
index 000000000000..cf9e892cb2b2
--- /dev/null
+++ b/browser/extensions/formautofill/test/fixtures/third_party/Staples/Basic.html
@@ -0,0 +1,117 @@
+
+
+
+
+ It's easy to find the Office Supplies, Copy Paper,
+ Furniture, Ink, Toner, Cleaning Products, Electronics and the
+ Technology you need | Staples®
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/browser/extensions/formautofill/test/fixtures/third_party/Staples/Basic_ac_on.html b/browser/extensions/formautofill/test/fixtures/third_party/Staples/Basic_ac_on.html
new file mode 100644
index 000000000000..d3ba1116aabf
--- /dev/null
+++ b/browser/extensions/formautofill/test/fixtures/third_party/Staples/Basic_ac_on.html
@@ -0,0 +1,117 @@
+
+
+
+
+ It's easy to find the Office Supplies, Copy Paper,
+ Furniture, Ink, Toner, Cleaning Products, Electronics and the
+ Technology you need | Staples®
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/browser/extensions/formautofill/test/fixtures/third_party/Staples/PaymentBilling.html b/browser/extensions/formautofill/test/fixtures/third_party/Staples/PaymentBilling.html
new file mode 100644
index 000000000000..37dadeb514a9
--- /dev/null
+++ b/browser/extensions/formautofill/test/fixtures/third_party/Staples/PaymentBilling.html
@@ -0,0 +1,99 @@
+
+
+
+
+ It's easy to find the Office Supplies, Copy Paper,
+ Furniture, Ink, Toner, Cleaning Products, Electronics and the
+ Technology you need | Staples®
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/browser/extensions/formautofill/test/fixtures/third_party/Staples/PaymentBilling_ac_on.html b/browser/extensions/formautofill/test/fixtures/third_party/Staples/PaymentBilling_ac_on.html
new file mode 100644
index 000000000000..98c9fb85555b
--- /dev/null
+++ b/browser/extensions/formautofill/test/fixtures/third_party/Staples/PaymentBilling_ac_on.html
@@ -0,0 +1,98 @@
+
+
+
+
+ It's easy to find the Office Supplies, Copy Paper,
+ Furniture, Ink, Toner, Cleaning Products, Electronics and the
+ Technology you need | Staples®
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/browser/extensions/formautofill/test/fixtures/third_party/Walmart/Checkout.html b/browser/extensions/formautofill/test/fixtures/third_party/Walmart/Checkout.html
new file mode 100644
index 000000000000..0d59eec17280
--- /dev/null
+++ b/browser/extensions/formautofill/test/fixtures/third_party/Walmart/Checkout.html
@@ -0,0 +1,243 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/browser/extensions/formautofill/test/fixtures/third_party/Walmart/Payment.html b/browser/extensions/formautofill/test/fixtures/third_party/Walmart/Payment.html
new file mode 100644
index 000000000000..26936843291a
--- /dev/null
+++ b/browser/extensions/formautofill/test/fixtures/third_party/Walmart/Payment.html
@@ -0,0 +1,235 @@
+
+
+
+
+
+
+
+
+ Checkout
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/browser/extensions/formautofill/test/fixtures/third_party/Walmart/Shipping.html b/browser/extensions/formautofill/test/fixtures/third_party/Walmart/Shipping.html
new file mode 100644
index 000000000000..908453b7f1e0
--- /dev/null
+++ b/browser/extensions/formautofill/test/fixtures/third_party/Walmart/Shipping.html
@@ -0,0 +1,234 @@
+
+
+
+
+
+
+
+
+ Checkout
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/browser/extensions/formautofill/test/unit/head.js b/browser/extensions/formautofill/test/unit/head.js
index a49757a340ba..0bf3608ba4e4 100644
--- a/browser/extensions/formautofill/test/unit/head.js
+++ b/browser/extensions/formautofill/test/unit/head.js
@@ -2,7 +2,7 @@
* Provides infrastructure for automated formautofill components tests.
*/
-/* exported loadFormAutofillContent, getTempFile, sinon */
+/* exported getTempFile, loadFormAutofillContent, runHeuristicsTest, sinon */
"use strict";
@@ -79,6 +79,45 @@ function getTempFile(leafName) {
return file;
}
+function runHeuristicsTest(patterns, fixturePathPrefix) {
+ Cu.import("resource://gre/modules/FormLikeFactory.jsm");
+ Cu.import("resource://formautofill/FormAutofillHeuristics.jsm");
+
+ // TODO: "select" and "textarea" will be included eventually.
+ const QUERY_STRING = ["input"];
+ patterns.forEach(testPattern => {
+ add_task(function* () {
+ do_print("Starting test fixture: " + testPattern.fixturePath);
+ let file = do_get_file(fixturePathPrefix + testPattern.fixturePath);
+ let doc = MockDocument.createTestDocumentFromFile("http://localhost:8080/test/", file);
+
+ let forms = [];
+
+ for (let query of QUERY_STRING) {
+ for (let field of doc.querySelectorAll(query)) {
+ let formLike = FormLikeFactory.createFromField(field);
+ if (!forms.some(form => form.rootElement === formLike.rootElement)) {
+ forms.push(formLike);
+ }
+ }
+ }
+
+ Assert.equal(forms.length, testPattern.expectedResult.length, "Expected form count.");
+
+ forms.forEach((form, formIndex) => {
+ let formInfo = FormAutofillHeuristics.getFormInfo(form);
+ // TODO: This line should be uncommented to make sure every field are verified.
+ // Assert.equal(formInfo.length, testPattern.expectedResult[formIndex].length, "Expected field count.");
+ formInfo.forEach((field, fieldIndex) => {
+ let expectedField = testPattern.expectedResult[formIndex][fieldIndex];
+ expectedField.elementWeakRef = field.elementWeakRef;
+ Assert.deepEqual(field, expectedField);
+ });
+ });
+ });
+ });
+}
+
add_task(function* head_initialize() {
Services.prefs.setBoolPref("browser.formautofill.experimental", true);
Services.prefs.setBoolPref("dom.forms.autocomplete.experimental", true);
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 000000000000..5f3c7759c85e
--- /dev/null
+++ b/browser/extensions/formautofill/test/unit/heuristics/test_basic.js
@@ -0,0 +1,22 @@
+/* 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"},
+ ],
+ ],
+ },
+], "../../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 000000000000..60df0f661a29
--- /dev/null
+++ b/browser/extensions/formautofill/test/unit/heuristics/third_party/test_BestBuy.js
@@ -0,0 +1,56 @@
+/* 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": "address-line1"},
+ {"section": "", "addressType": "", "contactType": "", "fieldName": "address-level2"}, // city
+// {"section": "", "addressType": "", "contactType": "", "fieldName": "address-level1"}, // TODO:select,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": "address-line1"},
+ {"section": "", "addressType": "", "contactType": "", "fieldName": "address-level2"}, // city
+// {"section": "", "addressType": "", "contactType": "", "fieldName": "address-level1"}, // TODO:select,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 000000000000..6c7a5fe0d2b8
--- /dev/null
+++ b/browser/extensions/formautofill/test/unit/heuristics/third_party/test_CDW.js
@@ -0,0 +1,55 @@
+/* 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"}, // TODO: select,state
+ {"section": "", "addressType": "", "contactType": "", "fieldName": "postal-code"},
+ {"section": "", "addressType": "", "contactType": "", "fieldName": "email"},
+ {"section": "", "addressType": "", "contactType": "", "fieldName": "tel"},
+ ],
+ [],
+ ],
+ }, {
+ 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"}, // TODO: select,state
+ {"section": "", "addressType": "", "contactType": "", "fieldName": "postal-code"},
+ ],
+ [
+ /* TODO: Credit Card
+ {"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-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 000000000000..f5e77d42fe77
--- /dev/null
+++ b/browser/extensions/formautofill/test/unit/heuristics/third_party/test_CostCo.js
@@ -0,0 +1,124 @@
+/* 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"}, // TODO: select,country
+ {"section": "", "addressType": "", "contactType": "", "fieldName": "address-line1"},
+// {"section": "", "addressType": "", "contactType": "", "fieldName": "address-line2"}, // TODO: fix the regexp
+ {"section": "", "addressType": "", "contactType": "", "fieldName": "address-level2"}, // city
+// {"section": "", "addressType": "", "contactType": "", "fieldName": "address-level1"}, // TODO: select,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"}, // TODO: select,country
+ {"section": "", "addressType": "", "contactType": "", "fieldName": "address-line1"},
+// {"section": "", "addressType": "", "contactType": "", "fieldName": "address-line2"}, // TODO: fix the regexp
+ {"section": "", "addressType": "", "contactType": "", "fieldName": "address-level2"}, // city
+// {"section": "", "addressType": "", "contactType": "", "fieldName": "address-level1"}, // TODO: select,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: [
+ [
+/* TODO: credit card
+ {"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": "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"}, // TODO: select, country
+ {"section": "", "addressType": "", "contactType": "", "fieldName": "address-line1"},
+// {"section": "", "addressType": "", "contactType": "", "fieldName": "address-line2"}, // TODO: fix the regexp
+ {"section": "", "addressType": "", "contactType": "", "fieldName": "address-level2"}, // city
+// {"section": "", "addressType": "", "contactType": "", "fieldName": "address-level1"}, // TODO: select, 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"}, // TODO: select, country
+ {"section": "", "addressType": "", "contactType": "", "fieldName": "address-line1"},
+// {"section": "", "addressType": "", "contactType": "", "fieldName": "address-line2"}, // TODO: fix the regexp
+ {"section": "", "addressType": "", "contactType": "", "fieldName": "address-level2"},
+// {"section": "", "addressType": "", "contactType": "", "fieldName": "address-level1"}, // TODO: select, 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_HomeDepot.js b/browser/extensions/formautofill/test/unit/heuristics/third_party/test_HomeDepot.js
new file mode 100644
index 000000000000..77993b6c66a9
--- /dev/null
+++ b/browser/extensions/formautofill/test/unit/heuristics/third_party/test_HomeDepot.js
@@ -0,0 +1,34 @@
+/* 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": "address-line1"},
+ {"section": "", "addressType": "", "contactType": "", "fieldName": "postal-code"},
+// {"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-csc"},
+ ],
+ ],
+ }, {
+ 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_Macys.js b/browser/extensions/formautofill/test/unit/heuristics/third_party/test_Macys.js
new file mode 100644
index 000000000000..6885819df561
--- /dev/null
+++ b/browser/extensions/formautofill/test/unit/heuristics/third_party/test_Macys.js
@@ -0,0 +1,67 @@
+/* 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"},
+// {"section": "", "addressType": "", "contactType": "", "fieldName": "address-level1"}, // select
+ {"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
+ {"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
+*/
+ {"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"}, // select
+ {"section": "", "addressType": "", "contactType": "", "fieldName": "postal-code"},
+ {"section": "", "addressType": "", "contactType": "", "fieldName": "tel"},
+ {"section": "", "addressType": "", "contactType": "", "fieldName": "email"},
+ ],
+ [],
+ ],
+ }, {
+ 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 000000000000..d5479f364d52
--- /dev/null
+++ b/browser/extensions/formautofill/test/unit/heuristics/third_party/test_NewEgg.js
@@ -0,0 +1,66 @@
+/* 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"}, // TODO: select, 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"}, // TODO: select, state
+ {"section": "", "addressType": "", "contactType": "", "fieldName": "postal-code"},
+ {"section": "", "addressType": "", "contactType": "", "fieldName": "tel"},
+ {"section": "", "addressType": "", "contactType": "", "fieldName": "email"},
+ ],
+ [],
+ ],
+ }, {
+ fixturePath: "BillingInfo.html",
+ expectedResult: [
+ [
+/* TODO: Should match the following fields.
+ {"section": "", "addressType": "", "contactType": "", "fieldName": "cc-name"},
+ {"section": "", "addressType": "", "contactType": "", "fieldName": "cc-number"},
+ {"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-csc"},
+*/
+// {"section": "", "addressType": "", "contactType": "", "fieldName": "country"}, // TODO: select, 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"}, // TODO: select, country
+ {"section": "", "addressType": "", "contactType": "", "fieldName": "postal-code"},
+ {"section": "", "addressType": "", "contactType": "", "fieldName": "tel"},
+// {"section": "", "addressType": "", "contactType": "", "fieldName": "cc-name"}, // TODO
+// {"section": "", "addressType": "", "contactType": "", "fieldName": "cc-number"}, // TODO
+// {"section": "", "addressType": "", "contactType": "", "fieldName": "cc-exp-month"}, // TODO
+// {"section": "", "addressType": "", "contactType": "", "fieldName": "cc-exp-year"}, // TODO
+ ],
+ [],
+ [],
+ [],
+ ],
+ }, {
+ 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 000000000000..c553615c765f
--- /dev/null
+++ b/browser/extensions/formautofill/test/unit/heuristics/third_party/test_OfficeDepot.js
@@ -0,0 +1,64 @@
+/* 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"}, // TODO: select, state
+
+ // TODO: telphone relative fields should be fixed:
+ {"section": "", "addressType": "", "contactType": "", "fieldName": "tel"},
+// {"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": "cc-exp-month"},
+// {"section": "", "addressType": "", "contactType": "", "fieldName": "cc-exp-year"},
+ {"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"}, // TODO: select, state
+
+ // TODO: telphone relative fields should be fixed:
+ {"section": "", "addressType": "", "contactType": "", "fieldName": "tel"},
+// {"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: "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 000000000000..d2b088ca9d49
--- /dev/null
+++ b/browser/extensions/formautofill/test/unit/heuristics/third_party/test_QVC.js
@@ -0,0 +1,54 @@
+/* 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-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"},
+// {"section": "", "addressType": "", "contactType": "", "fieldName": "cc-exp"}, // select
+// {"section": "", "addressType": "", "contactType": "", "fieldName": "cc-csc"},
+ ],
+ [
+ {"section": "", "addressType": "", "contactType": "", "fieldName": "email"},
+ ],
+ ],
+ }, {
+ fixturePath: "SignIn.html",
+ expectedResult: [
+ [
+ // Unknown
+ ],
+ [ // 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 000000000000..60fe39e55ad2
--- /dev/null
+++ b/browser/extensions/formautofill/test/unit/heuristics/third_party/test_Sears.js
@@ -0,0 +1,87 @@
+/* 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"},
+// {"section": "", "addressType": "", "contactType": "", "fieldName": "address-level1"}, // TODO: select, 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"},
+ {"section": "", "addressType": "", "contactType": "", "fieldName": "address-level1"}, // TODO: Wrong. This is for Driver's license.
+// {"section": "", "addressType": "", "contactType": "", "fieldName": "bday-month"},
+// {"section": "", "addressType": "", "contactType": "", "fieldName": "bday-day"},
+// {"section": "", "addressType": "", "contactType": "", "fieldName": "bday-year"},
+ ],
+ [
+ {"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 000000000000..240aa0fbbea3
--- /dev/null
+++ b/browser/extensions/formautofill/test/unit/heuristics/third_party/test_Staples.js
@@ -0,0 +1,48 @@
+/* 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: [
+ [],
+ ],
+ }, {
+ 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 000000000000..4d8d67953a63
--- /dev/null
+++ b/browser/extensions/formautofill/test/unit/heuristics/third_party/test_Walmart.js
@@ -0,0 +1,62 @@
+/* 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"},
+// {"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": "", "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": "section-payment", "addressType": "", "contactType": "", "fieldName": "tel"},
+ ],
+ ],
+ }, {
+ 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"}, // TODO: fix the regexp
+ {"section": "", "addressType": "", "contactType": "", "fieldName": "address-level2"}, // city
+// {"section": "", "addressType": "", "contactType": "", "fieldName": "address-level1"}, // TODO: select, state
+ {"section": "", "addressType": "", "contactType": "", "fieldName": "postal-code"},
+ ],
+ ],
+ },
+], "../../../fixtures/third_party/Walmart/");
+
diff --git a/browser/extensions/formautofill/test/unit/xpcshell.ini b/browser/extensions/formautofill/test/unit/xpcshell.ini
index 78c472186503..724e799c2e71 100644
--- a/browser/extensions/formautofill/test/unit/xpcshell.ini
+++ b/browser/extensions/formautofill/test/unit/xpcshell.ini
@@ -2,7 +2,20 @@
firefox-appdir = browser
head = head.js
support-files =
+ ../fixtures/**
+[heuristics/test_basic.js]
+[heuristics/third_party/test_BestBuy.js]
+[heuristics/third_party/test_CDW.js]
+[heuristics/third_party/test_CostCo.js]
+[heuristics/third_party/test_HomeDepot.js]
+[heuristics/third_party/test_Macys.js]
+[heuristics/third_party/test_NewEgg.js]
+[heuristics/third_party/test_OfficeDepot.js]
+[heuristics/third_party/test_QVC.js]
+[heuristics/third_party/test_Sears.js]
+[heuristics/third_party/test_Staples.js]
+[heuristics/third_party/test_Walmart.js]
[test_autofillFormFields.js]
[test_collectFormFields.js]
[test_enabledStatus.js]
diff --git a/toolkit/modules/tests/modules/MockDocument.jsm b/toolkit/modules/tests/modules/MockDocument.jsm
index 3cae9bb910e0..a4048dac9a01 100644
--- a/toolkit/modules/tests/modules/MockDocument.jsm
+++ b/toolkit/modules/tests/modules/MockDocument.jsm
@@ -10,6 +10,8 @@ const {classes: Cc, interfaces: Ci, utils: Cu, results: Cr} = Components;
Cu.importGlobalProperties(["URL"]);
+const { NetUtil } = Cu.import("resource://gre/modules/NetUtil.jsm", {});
+
const MockDocument = {
/**
* Create a document for the given URL containing the given HTML with the ownerDocument of all