Bug 1415077 - Modify FormAutofill test to satisfy the section support feature. r=lchang,ralin
authorSean Lee <selee@mozilla.com>
Fri, 17 Nov 2017 18:16:56 +0800
changeset 437743 e78023ba8b130b3c6fe0b8ee0018e0c9ef231136
parent 437742 e1667b83dc102e673ddcc0a58ac64df28901b033
child 437744 d827c67e862e58622225d7768b42bc613cc29afb
push id117
push userfmarier@mozilla.com
push dateTue, 28 Nov 2017 20:17:16 +0000
reviewerslchang, ralin
bugs1415077
milestone59.0a1
Bug 1415077 - Modify FormAutofill test to satisfy the section support feature. r=lchang,ralin MozReview-Commit-ID: B0hjUqwZA1g
browser/extensions/formautofill/test/unit/head.js
browser/extensions/formautofill/test/unit/heuristics/test_basic.js
browser/extensions/formautofill/test/unit/heuristics/test_cc_exp.js
browser/extensions/formautofill/test/unit/heuristics/third_party/test_BestBuy.js
browser/extensions/formautofill/test/unit/heuristics/third_party/test_CDW.js
browser/extensions/formautofill/test/unit/heuristics/third_party/test_CostCo.js
browser/extensions/formautofill/test/unit/heuristics/third_party/test_HomeDepot.js
browser/extensions/formautofill/test/unit/heuristics/third_party/test_Macys.js
browser/extensions/formautofill/test/unit/heuristics/third_party/test_NewEgg.js
browser/extensions/formautofill/test/unit/heuristics/third_party/test_OfficeDepot.js
browser/extensions/formautofill/test/unit/heuristics/third_party/test_QVC.js
browser/extensions/formautofill/test/unit/heuristics/third_party/test_Sears.js
browser/extensions/formautofill/test/unit/heuristics/third_party/test_Staples.js
browser/extensions/formautofill/test/unit/heuristics/third_party/test_Walmart.js
browser/extensions/formautofill/test/unit/test_collectFormFields.js
--- a/browser/extensions/formautofill/test/unit/head.js
+++ b/browser/extensions/formautofill/test/unit/head.js
@@ -73,16 +73,33 @@ async function initProfileStorage(fileNa
   for (let record of records) {
     do_check_true(profileStorage[collectionName].add(record));
     await onChanged;
   }
   await profileStorage._saveImmediately();
   return profileStorage;
 }
 
+function verifySectionFieldDetails(sections, expectedResults) {
+  Assert.equal(sections.length, expectedResults.length, "Expected section count.");
+  sections.forEach((sectionInfo, sectionIndex) => {
+    let expectedSectionInfo = expectedResults[sectionIndex];
+    do_print("FieldName Prediction Results: " + sectionInfo.map(i => i.fieldName));
+    do_print("FieldName Expected Results:   " + expectedSectionInfo.map(i => i.fieldName));
+    Assert.equal(sectionInfo.length, expectedSectionInfo.length, "Expected field count.");
+
+    sectionInfo.forEach((field, fieldIndex) => {
+      let expectedField = expectedSectionInfo[fieldIndex];
+      delete field._reason;
+      delete field.elementWeakRef;
+      Assert.deepEqual(field, expectedField);
+    });
+  });
+}
+
 function runHeuristicsTest(patterns, fixturePathPrefix) {
   Cu.import("resource://formautofill/FormAutofillHeuristics.jsm");
   Cu.import("resource://formautofill/FormAutofillUtils.jsm");
 
   patterns.forEach(testPattern => {
     add_task(async function() {
       do_print("Starting test fixture: " + testPattern.fixturePath);
       let file = do_get_file(fixturePathPrefix + testPattern.fixturePath);
@@ -96,31 +113,17 @@ function runHeuristicsTest(patterns, fix
           forms.push(formLike);
         }
       }
 
       Assert.equal(forms.length, testPattern.expectedResult.length, "Expected form count.");
 
       forms.forEach((form, formIndex) => {
         let sections = FormAutofillHeuristics.getFormInfo(form);
-        if (testPattern.expectedResult[formIndex].length == 0) {
-          return;
-        }
-        // TODO [Bug 1415077] the test should be able to support traversing all
-        // sections.
-        let formInfo = sections[0];
-        do_print("FieldName Prediction Results: " + formInfo.map(i => i.fieldName));
-        do_print("FieldName Expected Results:   " + testPattern.expectedResult[formIndex].map(i => i.fieldName));
-        Assert.equal(formInfo.length, testPattern.expectedResult[formIndex].length, "Expected field count.");
-        formInfo.forEach((field, fieldIndex) => {
-          let expectedField = testPattern.expectedResult[formIndex][fieldIndex];
-          delete field._reason;
-          expectedField.elementWeakRef = field.elementWeakRef;
-          Assert.deepEqual(field, expectedField);
-        });
+        verifySectionFieldDetails(sections, testPattern.expectedResult[formIndex]);
       });
     });
   });
 }
 
 /**
  * Returns the Sync change counter for a profile storage record. Synced records
  * store additional metadata for tracking changes and resolving merge conflicts.
@@ -168,17 +171,17 @@ function objectMatches(object, fields) {
   }
   return ObjectUtils.deepEqual(actual, fields);
 }
 
 add_task(async function head_initialize() {
   Services.prefs.setStringPref("extensions.formautofill.available", "on");
   Services.prefs.setBoolPref("extensions.formautofill.creditCards.available", true);
   Services.prefs.setBoolPref("extensions.formautofill.heuristics.enabled", true);
-  Services.prefs.setBoolPref("extensions.formautofill.section.enabled", false);
+  Services.prefs.setBoolPref("extensions.formautofill.section.enabled", true);
   Services.prefs.setBoolPref("dom.forms.autocomplete.formautofill", true);
 
   // Clean up after every test.
   do_register_cleanup(function head_cleanup() {
     Services.prefs.clearUserPref("extensions.formautofill.available");
     Services.prefs.clearUserPref("extensions.formautofill.creditCards.available");
     Services.prefs.clearUserPref("extensions.formautofill.heuristics.enabled");
     Services.prefs.clearUserPref("extensions.formautofill.section.enabled");
--- a/browser/extensions/formautofill/test/unit/heuristics/test_basic.js
+++ b/browser/extensions/formautofill/test/unit/heuristics/test_basic.js
@@ -1,38 +1,38 @@
 /* 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"},
-      ],
+      ]],
     ],
   },
 ], "../../fixtures/");
 
--- a/browser/extensions/formautofill/test/unit/heuristics/test_cc_exp.js
+++ b/browser/extensions/formautofill/test/unit/heuristics/test_cc_exp.js
@@ -1,36 +1,36 @@
 /* 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-csc"},
-      ],
-      [
+      ]],
+      [[
         {"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/");
 
--- a/browser/extensions/formautofill/test/unit/heuristics/third_party/test_BestBuy.js
+++ b/browser/extensions/formautofill/test/unit/heuristics/third_party/test_BestBuy.js
@@ -1,56 +1,56 @@
 /* global runHeuristicsTest */
 
 "use strict";
 
 runHeuristicsTest([
   {
     fixturePath: "Checkout_ShippingAddress.html",
     expectedResult: [
-      [], // Search form
-      [
+      [[]], // Search form
+      [[
         {"section": "", "addressType": "", "contactType": "", "fieldName": "given-name"},
         {"section": "", "addressType": "", "contactType": "", "fieldName": "family-name"},
         {"section": "", "addressType": "", "contactType": "", "fieldName": "address-line1"},
         {"section": "", "addressType": "", "contactType": "", "fieldName": "address-level2"}, // city
         {"section": "", "addressType": "", "contactType": "", "fieldName": "address-level1"}, // state
         {"section": "", "addressType": "", "contactType": "", "fieldName": "postal-code"},
-      ],
-      [ // Sign up
+      ]],
+      [[ // Sign up
         {"section": "", "addressType": "", "contactType": "", "fieldName": "email"},
-      ],
-      [ // unknown
+      ]],
+      [[ // unknown
         {"section": "", "addressType": "", "contactType": "", "fieldName": "email"},
         {"section": "", "addressType": "", "contactType": "", "fieldName": "tel"},
-      ],
+      ]],
     ],
   }, {
     fixturePath: "Checkout_Payment.html",
     expectedResult: [
-      [], // Search form
-      [ // Sign up
+      [[]], // 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"}, // state
         {"section": "", "addressType": "", "contactType": "", "fieldName": "postal-code"},
-      ],
-      [
+      ]],
+      [[
         // unknown
         {"section": "", "addressType": "", "contactType": "", "fieldName": "email"},
         {"section": "", "addressType": "", "contactType": "", "fieldName": "tel"},
-      ],
+      ]],
     ],
   }, {
     fixturePath: "SignIn.html",
     expectedResult: [
-      [ // Sign in
+      [[ // Sign in
         {"section": "", "addressType": "", "contactType": "", "fieldName": "email"},
-      ],
+      ]],
     ],
   },
 ], "../../../fixtures/third_party/BestBuy/");
 
--- a/browser/extensions/formautofill/test/unit/heuristics/third_party/test_CDW.js
+++ b/browser/extensions/formautofill/test/unit/heuristics/third_party/test_CDW.js
@@ -1,40 +1,40 @@
 /* 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"},
 
         // FIXME: bug 1392932 - misdetect ZIP ext string
         {"section": "", "addressType": "", "contactType": "", "fieldName": "tel-extension"},
         {"section": "", "addressType": "", "contactType": "", "fieldName": "email"},
         {"section": "", "addressType": "", "contactType": "", "fieldName": "tel"},
         // The below "tel-extension" is correct and removed due to the
         // duplicated field above.
 //      {"section": "", "addressType": "", "contactType": "", "fieldName": "tel-extension"},
-      ],
+      ]],
       [],
     ],
   }, {
     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"},
@@ -42,21 +42,21 @@ runHeuristicsTest([
         // FIXME: bug 1392932 - misdetect ZIP ext string
         {"section": "", "addressType": "", "contactType": "", "fieldName": "tel-extension"},
 //      {"section": "", "addressType": "", "contactType": "", "fieldName": "cc-type"},
         {"section": "", "addressType": "", "contactType": "", "fieldName": "cc-number"}, // ac-off
         {"section": "", "addressType": "", "contactType": "", "fieldName": "cc-exp-month"},
         {"section": "", "addressType": "", "contactType": "", "fieldName": "cc-exp-year"},
 
 //      {"section": "", "addressType": "", "contactType": "", "fieldName": "cc-csc"},
-      ],
+      ]],
       [],
     ],
   }, {
     fixturePath: "Checkout_Logon.html",
     expectedResult: [
       [],
-      [],
+      [[]],
       [],
     ],
   },
 ], "../../../fixtures/third_party/CDW/");
 
--- a/browser/extensions/formautofill/test/unit/heuristics/third_party/test_CostCo.js
+++ b/browser/extensions/formautofill/test/unit/heuristics/third_party/test_CostCo.js
@@ -3,123 +3,123 @@
 "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"},
         {"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
+      [[ // Forgot password
         {"section": "", "addressType": "", "contactType": "", "fieldName": "email"},
-      ],
-      [
+      ]],
+      [[
         {"section": "", "addressType": "", "contactType": "", "fieldName": "email"},
-      ],
-      [
+      ]],
+      [[
         {"section": "", "addressType": "", "contactType": "", "fieldName": "email"},
 //      {"section": "", "addressType": "", "contactType": "", "fieldName": "password"},
-      ],
-      [ // Sign up
+      ]],
+      [[ // Sign up
         {"section": "", "addressType": "", "contactType": "", "fieldName": "email"},
-      ],
-      [
+      ]],
+      [[
         {"section": "", "addressType": "", "contactType": "", "fieldName": "email"},
-      ],
+      ]],
       [],
     ],
   },
 ], "../../../fixtures/third_party/CostCo/");
 
--- a/browser/extensions/formautofill/test/unit/heuristics/third_party/test_HomeDepot.js
+++ b/browser/extensions/formautofill/test/unit/heuristics/third_party/test_HomeDepot.js
@@ -2,42 +2,45 @@
 
 "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": "billing", "contactType": "", "fieldName": "street-address"}, // <select>
+        [
+          {"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"},
 
-        // 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"},
+          // 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": "", "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/");
 
--- a/browser/extensions/formautofill/test/unit/heuristics/third_party/test_Macys.js
+++ b/browser/extensions/formautofill/test/unit/heuristics/third_party/test_Macys.js
@@ -1,65 +1,65 @@
 /* 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": "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"}, // city
         {"section": "", "addressType": "", "contactType": "", "fieldName": "address-level1"}, // state
         {"section": "", "addressType": "", "contactType": "", "fieldName": "postal-code"},
         {"section": "", "addressType": "", "contactType": "", "fieldName": "tel"},
         {"section": "", "addressType": "", "contactType": "", "fieldName": "email"},
-      ],
+      ]],
       [],
     ],
   }, {
     fixturePath: "SignIn.html",
     expectedResult: [
-      [ // Sign in
+      [[ // Sign in
         {"section": "", "addressType": "", "contactType": "", "fieldName": "email"},
 //      {"section": "", "addressType": "", "contactType": "", "fieldName": "password"},
-      ],
-      [ // Forgot password
+      ]],
+      [[ // Forgot password
         {"section": "", "addressType": "", "contactType": "", "fieldName": "email"},
-      ],
-      [
+      ]],
+      [[
         {"section": "", "addressType": "", "contactType": "", "fieldName": "email"},
-      ],
-      [],
+      ]],
+      [[]],
       [],
       [],
     ],
   },
 ], "../../../fixtures/third_party/Macys/");
 
--- a/browser/extensions/formautofill/test/unit/heuristics/third_party/test_NewEgg.js
+++ b/browser/extensions/formautofill/test/unit/heuristics/third_party/test_NewEgg.js
@@ -1,65 +1,65 @@
 /* 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": "cc-exp-month"},
         {"section": "", "addressType": "", "contactType": "", "fieldName": "cc-exp-year"},
 //      {"section": "", "addressType": "", "contactType": "", "fieldName": "cc-csc"},
         {"section": "", "addressType": "", "contactType": "", "fieldName": "country"},
         {"section": "", "addressType": "", "contactType": "", "fieldName": "address-line1"},
         {"section": "", "addressType": "", "contactType": "", "fieldName": "address-line2"},
         {"section": "", "addressType": "", "contactType": "", "fieldName": "address-level2"},
         {"section": "", "addressType": "", "contactType": "", "fieldName": "address-level1"}, // state
         {"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-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/");
 
--- a/browser/extensions/formautofill/test/unit/heuristics/third_party/test_OfficeDepot.js
+++ b/browser/extensions/formautofill/test/unit/heuristics/third_party/test_OfficeDepot.js
@@ -1,39 +1,39 @@
 /* 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": "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"},
@@ -45,20 +45,20 @@ runHeuristicsTest([
         {"section": "", "addressType": "", "contactType": "", "fieldName": "tel-local-suffix"},
         {"section": "", "addressType": "", "contactType": "", "fieldName": "tel-extension"},
 
         {"section": "", "addressType": "", "contactType": "", "fieldName": "email"},
 
         // FIXME: bug 1392950 - the membership number should not be detected
         // as cc-number.
         {"section": "", "addressType": "", "contactType": "", "fieldName": "cc-number"},
-      ],
+      ]],
     ],
   }, {
     fixturePath: "SignIn.html",
     expectedResult: [
-      [ // ac-off
+      [[ // ac-off
 //      {"section": "", "addressType": "", "contactType": "", "fieldName": "email"},
-      ],
+      ]],
     ],
   },
 ], "../../../fixtures/third_party/OfficeDepot/");
 
--- a/browser/extensions/formautofill/test/unit/heuristics/third_party/test_QVC.js
+++ b/browser/extensions/formautofill/test/unit/heuristics/third_party/test_QVC.js
@@ -1,59 +1,57 @@
 /* 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": "email"},
-      ],
+      ]],
     ],
   }, {
     fixturePath: "PaymentMethod.html",
     expectedResult: [
-      [
+      [[
 //      {"section": "", "addressType": "", "contactType": "", "fieldName": "tel"}, // ac-off
         {"section": "", "addressType": "", "contactType": "", "fieldName": "email"},
 //      {"section": "", "addressType": "", "contactType": "", "fieldName": "bday-month"}, // select
 //      {"section": "", "addressType": "", "contactType": "", "fieldName": "bday-day"}, // select
 //      {"section": "", "addressType": "", "contactType": "", "fieldName": "bday-year"}, // select
 //      {"section": "", "addressType": "", "contactType": "", "fieldName": "cc-type"}, // select
 
         {"section": "", "addressType": "", "contactType": "", "fieldName": "cc-number"}, // ac-off
         {"section": "", "addressType": "", "contactType": "", "fieldName": "cc-exp"},
 
 //      {"section": "", "addressType": "", "contactType": "", "fieldName": "cc-csc"},
-      ],
-      [
+      ]],
+      [[
         {"section": "", "addressType": "", "contactType": "", "fieldName": "email"},
-      ],
+      ]],
     ],
   }, {
     fixturePath: "SignIn.html",
     expectedResult: [
-      [
-        // Unknown
-      ],
-      [ // Sign in
+      [[]],
+      [[ // Sign in
         {"section": "", "addressType": "", "contactType": "", "fieldName": "email"},
-      ],
+      ]],
       [],
     ],
   },
 ], "../../../fixtures/third_party/QVC/");
 
--- a/browser/extensions/formautofill/test/unit/heuristics/third_party/test_Sears.js
+++ b/browser/extensions/formautofill/test/unit/heuristics/third_party/test_Sears.js
@@ -2,95 +2,95 @@
 
 "use strict";
 
 runHeuristicsTest([
   {
     fixturePath: "ShippingAddress.html",
     expectedResult: [
       [],
-      [], // search form, ac-off
-      [ // ac-off
+      [[]], // search form, ac-off
+      [[ // ac-off
 //      {"section": "", "addressType": "", "contactType": "", "fieldName": "email"},
-      ],
-      [ // check-out, ac-off
+      ]],
+      [[ // check-out, ac-off
 /*
         {"section": "", "addressType": "", "contactType": "", "fieldName": "given-name"},
         {"section": "", "addressType": "", "contactType": "", "fieldName": "family-name"},
         {"section": "", "addressType": "", "contactType": "", "fieldName": "address-line1"},
         {"section": "", "addressType": "", "contactType": "", "fieldName": "address-line2"},
         {"section": "", "addressType": "", "contactType": "", "fieldName": "address-level2"},
         {"section": "", "addressType": "", "contactType": "", "fieldName": "address-level1"},
         {"section": "", "addressType": "", "contactType": "", "fieldName": "postal-code"},
         {"section": "", "addressType": "", "contactType": "", "fieldName": "tel"},
 //      {"section": "", "addressType": "", "contactType": "", "fieldName": "tel-extension"},
         {"section": "", "addressType": "", "contactType": "", "fieldName": "email"},
 */
-      ],
+      ]],
       [ // ac-off
 /*
         {"section": "", "addressType": "", "contactType": "", "fieldName": "email"},
         {"section": "", "addressType": "", "contactType": "", "fieldName": "given-name"},
         {"section": "", "addressType": "", "contactType": "", "fieldName": "family-name"},
         {"section": "", "addressType": "", "contactType": "", "fieldName": "address-line1"},
         {"section": "", "addressType": "", "contactType": "", "fieldName": "address-line2"},
         {"section": "", "addressType": "", "contactType": "", "fieldName": "address-level2"},
         {"section": "", "addressType": "", "contactType": "", "fieldName": "address-level1"},
         {"section": "", "addressType": "", "contactType": "", "fieldName": "postal-code"},
         {"section": "", "addressType": "", "contactType": "", "fieldName": "tel"},
         {"section": "", "addressType": "", "contactType": "", "fieldName": "tel-extension"},
 //      {"section": "", "addressType": "", "contactType": "", "fieldName": "new-password"},
 */
       ],
-      [ // ac-off
+      [[ // ac-off
 //      {"section": "", "addressType": "", "contactType": "", "fieldName": "email"},
-      ],
-      [ // ac-off
+      ]],
+      [[ // ac-off
 //      {"section": "", "addressType": "", "contactType": "", "fieldName": "email"},
-      ],
+      ]],
     ],
   }, {
     fixturePath: "PaymentOptions.html",
     expectedResult: [
       [],
-      [], // search
-      [ // credit card
+      [[]], // search
+      [[ // credit card
         {"section": "", "addressType": "", "contactType": "", "fieldName": "cc-number"},
         // FIXME: bug 1392958 - Cardholder name field should be detected as cc-name
 //      {"section": "", "addressType": "", "contactType": "", "fieldName": "cc-name"},
 //      {"section": "", "addressType": "", "contactType": "", "fieldName": "cc-csc"},
         {"section": "", "addressType": "", "contactType": "", "fieldName": "cc-exp-month"},
         {"section": "", "addressType": "", "contactType": "", "fieldName": "cc-exp-year"},
-      ],
-      [ // Another billing address
+      ]],
+      [[ // 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
+      ]],
+      [[ // check out
         {"section": "", "addressType": "", "contactType": "", "fieldName": "given-name"},
         {"section": "", "addressType": "", "contactType": "", "fieldName": "family-name"},
 
         // FIXME: bug 1392950 - the bank routing number should not be detected
         // as cc-number.
         {"section": "", "addressType": "", "contactType": "", "fieldName": "cc-number"},
 
         // 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"},
-      ],
-      [
+      ]],
+      [[
         {"section": "", "addressType": "", "contactType": "", "fieldName": "email"},
-      ],
+      ]],
     ],
   },
 ], "../../../fixtures/third_party/Sears/");
 
--- a/browser/extensions/formautofill/test/unit/heuristics/third_party/test_Staples.js
+++ b/browser/extensions/formautofill/test/unit/heuristics/third_party/test_Staples.js
@@ -1,52 +1,52 @@
 /* global runHeuristicsTest */
 
 "use strict";
 
 runHeuristicsTest([
   {
     fixturePath: "Basic.html",
     expectedResult: [
-      [ // ac-off
+      [[ // ac-off
 //      {"section": "", "addressType": "", "contactType": "", "fieldName": "given-name"},
 //      {"section": "", "addressType": "", "contactType": "", "fieldName": "family-name"},
 //      {"section": "", "addressType": "", "contactType": "", "fieldName": "address-line1"},
 //      {"section": "", "addressType": "", "contactType": "", "fieldName": "email"},
 //      {"section": "", "addressType": "", "contactType": "", "fieldName": "tel"},
 //      {"section": "", "addressType": "", "contactType": "", "fieldName": "tel-extension"},
 //      {"section": "", "addressType": "", "contactType": "", "fieldName": "organization"},
-      ],
+      ]],
     ],
   }, {
     fixturePath: "Basic_ac_on.html",
     expectedResult: [
-      [
+      [[
         {"section": "", "addressType": "", "contactType": "", "fieldName": "given-name"},
         {"section": "", "addressType": "", "contactType": "", "fieldName": "family-name"},
         {"section": "", "addressType": "", "contactType": "", "fieldName": "address-line1"},
         {"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/");
 
--- a/browser/extensions/formautofill/test/unit/heuristics/third_party/test_Walmart.js
+++ b/browser/extensions/formautofill/test/unit/heuristics/third_party/test_Walmart.js
@@ -1,66 +1,67 @@
 /* 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": "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"},
-        // FIXME bug 1392932 - the following field shouldn't be recognized as
-        // "tel-extension".
-        // The wrong prediction is caused by the name attr "brwsrAutofillText"
-        // which matches the regexp "ext\\b".
-        {"section": "", "addressType": "", "contactType": "", "fieldName": "tel-extension"},
-//      {"section": "", "addressType": "", "contactType": "", "fieldName": "cc-csc"},
-        {"section": "section-payment", "addressType": "", "contactType": "", "fieldName": "tel"},
+        [
+          {"section": "section-payment", "addressType": "", "contactType": "", "fieldName": "given-name"},
+          {"section": "section-payment", "addressType": "", "contactType": "", "fieldName": "family-name"},
+          {"section": "section-payment", "addressType": "", "contactType": "", "fieldName": "cc-number"},
+          {"section": "section-payment", "addressType": "", "contactType": "", "fieldName": "cc-exp-month"},
+          {"section": "section-payment", "addressType": "", "contactType": "", "fieldName": "cc-exp-year"},
+//        {"section": "section-payment", "addressType": "", "contactType": "", "fieldName": "cc-csc"},
+          {"section": "section-payment", "addressType": "", "contactType": "", "fieldName": "tel"},
+        ], [
+          // FIXME bug 1392932 - the following field shouldn't be recognized as
+          // "tel-extension".
+          // The wrong prediction is caused by the name attr "brwsrAutofillText"
+          // which matches the regexp "ext\\b".
+          {"section": "", "addressType": "", "contactType": "", "fieldName": "tel-extension"},
+        ],
       ],
     ],
   }, {
     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/");
 
--- a/browser/extensions/formautofill/test/unit/test_collectFormFields.js
+++ b/browser/extensions/formautofill/test/unit/test_collectFormFields.js
@@ -7,26 +7,28 @@
 Cu.import("resource://formautofill/FormAutofillHandler.jsm");
 
 const TESTCASES = [
   {
     description: "Form without autocomplete property",
     document: `<form><input id="given-name"><input id="family-name">
                <input id="street-addr"><input id="city"><select id="country"></select>
                <input id='email'><input id="phone"></form>`,
-    addressFieldDetails: [
-      {"section": "", "addressType": "", "contactType": "", "fieldName": "given-name"},
-      {"section": "", "addressType": "", "contactType": "", "fieldName": "family-name"},
-      {"section": "", "addressType": "", "contactType": "", "fieldName": "address-line1"},
-      {"section": "", "addressType": "", "contactType": "", "fieldName": "address-level2"},
-      {"section": "", "addressType": "", "contactType": "", "fieldName": "country"},
-      {"section": "", "addressType": "", "contactType": "", "fieldName": "email"},
-      {"section": "", "addressType": "", "contactType": "", "fieldName": "tel"},
-    ],
-    creditCardFieldDetails: [],
+    sections: [{
+      addressFieldDetails: [
+        {"section": "", "addressType": "", "contactType": "", "fieldName": "given-name"},
+        {"section": "", "addressType": "", "contactType": "", "fieldName": "family-name"},
+        {"section": "", "addressType": "", "contactType": "", "fieldName": "address-line1"},
+        {"section": "", "addressType": "", "contactType": "", "fieldName": "address-level2"},
+        {"section": "", "addressType": "", "contactType": "", "fieldName": "country"},
+        {"section": "", "addressType": "", "contactType": "", "fieldName": "email"},
+        {"section": "", "addressType": "", "contactType": "", "fieldName": "tel"},
+      ],
+      creditCardFieldDetails: [],
+    }],
     validFieldDetails: [
       {"section": "", "addressType": "", "contactType": "", "fieldName": "given-name"},
       {"section": "", "addressType": "", "contactType": "", "fieldName": "family-name"},
       {"section": "", "addressType": "", "contactType": "", "fieldName": "address-line1"},
       {"section": "", "addressType": "", "contactType": "", "fieldName": "address-level2"},
       {"section": "", "addressType": "", "contactType": "", "fieldName": "country"},
       {"section": "", "addressType": "", "contactType": "", "fieldName": "email"},
       {"section": "", "addressType": "", "contactType": "", "fieldName": "tel"},
@@ -43,31 +45,33 @@ const TESTCASES = [
                <select id="country" autocomplete="country"></select>
                <input id="email" autocomplete="email">
                <input id="tel" autocomplete="tel">
                <input id="cc-number" autocomplete="cc-number">
                <input id="cc-name" autocomplete="cc-name">
                <input id="cc-exp-month" autocomplete="cc-exp-month">
                <input id="cc-exp-year" autocomplete="cc-exp-year">
                </form>`,
-    addressFieldDetails: [
-      {"section": "", "addressType": "", "contactType": "", "fieldName": "given-name"},
-      {"section": "", "addressType": "", "contactType": "", "fieldName": "family-name"},
-      {"section": "", "addressType": "", "contactType": "", "fieldName": "street-address"},
-      {"section": "", "addressType": "", "contactType": "", "fieldName": "address-level2"},
-      {"section": "", "addressType": "", "contactType": "", "fieldName": "country"},
-      {"section": "", "addressType": "", "contactType": "", "fieldName": "email"},
-      {"section": "", "addressType": "", "contactType": "", "fieldName": "tel"},
-    ],
-    creditCardFieldDetails: [
-      {"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"},
-    ],
+    sections: [{
+      addressFieldDetails: [
+        {"section": "", "addressType": "", "contactType": "", "fieldName": "given-name"},
+        {"section": "", "addressType": "", "contactType": "", "fieldName": "family-name"},
+        {"section": "", "addressType": "", "contactType": "", "fieldName": "street-address"},
+        {"section": "", "addressType": "", "contactType": "", "fieldName": "address-level2"},
+        {"section": "", "addressType": "", "contactType": "", "fieldName": "country"},
+        {"section": "", "addressType": "", "contactType": "", "fieldName": "email"},
+        {"section": "", "addressType": "", "contactType": "", "fieldName": "tel"},
+      ],
+      creditCardFieldDetails: [
+        {"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"},
+      ],
+    }],
     validFieldDetails: [
       {"section": "", "addressType": "", "contactType": "", "fieldName": "given-name"},
       {"section": "", "addressType": "", "contactType": "", "fieldName": "family-name"},
       {"section": "", "addressType": "", "contactType": "", "fieldName": "street-address"},
       {"section": "", "addressType": "", "contactType": "", "fieldName": "address-level2"},
       {"section": "", "addressType": "", "contactType": "", "fieldName": "country"},
       {"section": "", "addressType": "", "contactType": "", "fieldName": "email"},
       {"section": "", "addressType": "", "contactType": "", "fieldName": "tel"},
@@ -81,26 +85,28 @@ const TESTCASES = [
     description: "An address form with autocomplete properties and 2 tokens",
     document: `<form><input id="given-name" autocomplete="shipping given-name">
                <input id="family-name" autocomplete="shipping family-name">
                <input id="street-addr" autocomplete="shipping street-address">
                <input id="city" autocomplete="shipping address-level2">
                <input id="country" autocomplete="shipping country">
                <input id='email' autocomplete="shipping email">
                <input id="tel" autocomplete="shipping tel"></form>`,
-    addressFieldDetails: [
-      {"section": "", "addressType": "shipping", "contactType": "", "fieldName": "given-name"},
-      {"section": "", "addressType": "shipping", "contactType": "", "fieldName": "family-name"},
-      {"section": "", "addressType": "shipping", "contactType": "", "fieldName": "street-address"},
-      {"section": "", "addressType": "shipping", "contactType": "", "fieldName": "address-level2"},
-      {"section": "", "addressType": "shipping", "contactType": "", "fieldName": "country"},
-      {"section": "", "addressType": "shipping", "contactType": "", "fieldName": "email"},
-      {"section": "", "addressType": "shipping", "contactType": "", "fieldName": "tel"},
-    ],
-    creditCardFieldDetails: [],
+    sections: [{
+      addressFieldDetails: [
+        {"section": "", "addressType": "shipping", "contactType": "", "fieldName": "given-name"},
+        {"section": "", "addressType": "shipping", "contactType": "", "fieldName": "family-name"},
+        {"section": "", "addressType": "shipping", "contactType": "", "fieldName": "street-address"},
+        {"section": "", "addressType": "shipping", "contactType": "", "fieldName": "address-level2"},
+        {"section": "", "addressType": "shipping", "contactType": "", "fieldName": "country"},
+        {"section": "", "addressType": "shipping", "contactType": "", "fieldName": "email"},
+        {"section": "", "addressType": "shipping", "contactType": "", "fieldName": "tel"},
+      ],
+      creditCardFieldDetails: [],
+    }],
     validFieldDetails: [
       {"section": "", "addressType": "shipping", "contactType": "", "fieldName": "given-name"},
       {"section": "", "addressType": "shipping", "contactType": "", "fieldName": "family-name"},
       {"section": "", "addressType": "shipping", "contactType": "", "fieldName": "street-address"},
       {"section": "", "addressType": "shipping", "contactType": "", "fieldName": "address-level2"},
       {"section": "", "addressType": "shipping", "contactType": "", "fieldName": "country"},
       {"section": "", "addressType": "shipping", "contactType": "", "fieldName": "email"},
       {"section": "", "addressType": "shipping", "contactType": "", "fieldName": "tel"},
@@ -110,26 +116,28 @@ const TESTCASES = [
     description: "Form with autocomplete properties and profile is partly matched",
     document: `<form><input id="given-name" autocomplete="shipping given-name">
                <input id="family-name" autocomplete="shipping family-name">
                <input id="street-addr" autocomplete="shipping street-address">
                <input autocomplete="shipping address-level2">
                <select autocomplete="shipping country"></select>
                <input id='email' autocomplete="shipping email">
                <input id="tel" autocomplete="shipping tel"></form>`,
-    addressFieldDetails: [
-      {"section": "", "addressType": "shipping", "contactType": "", "fieldName": "given-name"},
-      {"section": "", "addressType": "shipping", "contactType": "", "fieldName": "family-name"},
-      {"section": "", "addressType": "shipping", "contactType": "", "fieldName": "street-address"},
-      {"section": "", "addressType": "shipping", "contactType": "", "fieldName": "address-level2"},
-      {"section": "", "addressType": "shipping", "contactType": "", "fieldName": "country"},
-      {"section": "", "addressType": "shipping", "contactType": "", "fieldName": "email"},
-      {"section": "", "addressType": "shipping", "contactType": "", "fieldName": "tel"},
-    ],
-    creditCardFieldDetails: [],
+    sections: [{
+      addressFieldDetails: [
+        {"section": "", "addressType": "shipping", "contactType": "", "fieldName": "given-name"},
+        {"section": "", "addressType": "shipping", "contactType": "", "fieldName": "family-name"},
+        {"section": "", "addressType": "shipping", "contactType": "", "fieldName": "street-address"},
+        {"section": "", "addressType": "shipping", "contactType": "", "fieldName": "address-level2"},
+        {"section": "", "addressType": "shipping", "contactType": "", "fieldName": "country"},
+        {"section": "", "addressType": "shipping", "contactType": "", "fieldName": "email"},
+        {"section": "", "addressType": "shipping", "contactType": "", "fieldName": "tel"},
+      ],
+      creditCardFieldDetails: [],
+    }],
     validFieldDetails: [
       {"section": "", "addressType": "shipping", "contactType": "", "fieldName": "given-name"},
       {"section": "", "addressType": "shipping", "contactType": "", "fieldName": "family-name"},
       {"section": "", "addressType": "shipping", "contactType": "", "fieldName": "street-address"},
       {"section": "", "addressType": "shipping", "contactType": "", "fieldName": "address-level2"},
       {"section": "", "addressType": "shipping", "contactType": "", "fieldName": "country"},
       {"section": "", "addressType": "shipping", "contactType": "", "fieldName": "email"},
       {"section": "", "addressType": "shipping", "contactType": "", "fieldName": "tel"},
@@ -138,108 +146,122 @@ const TESTCASES = [
   {
     description: "It's a valid address and credit card form.",
     document: `<form>
                <input id="given-name" autocomplete="shipping given-name">
                <input id="family-name" autocomplete="shipping family-name">
                <input id="street-addr" autocomplete="shipping street-address">
                <input id="cc-number" autocomplete="shipping cc-number">
                </form>`,
-    addressFieldDetails: [
-      {"section": "", "addressType": "shipping", "contactType": "", "fieldName": "given-name"},
-      {"section": "", "addressType": "shipping", "contactType": "", "fieldName": "family-name"},
-      {"section": "", "addressType": "shipping", "contactType": "", "fieldName": "street-address"},
-    ],
-    creditCardFieldDetails: [
-      {"section": "", "addressType": "shipping", "contactType": "", "fieldName": "cc-number"},
-    ],
+    sections: [{
+      addressFieldDetails: [
+        {"section": "", "addressType": "shipping", "contactType": "", "fieldName": "given-name"},
+        {"section": "", "addressType": "shipping", "contactType": "", "fieldName": "family-name"},
+        {"section": "", "addressType": "shipping", "contactType": "", "fieldName": "street-address"},
+      ],
+      creditCardFieldDetails: [
+        {"section": "", "addressType": "shipping", "contactType": "", "fieldName": "cc-number"},
+      ],
+    }],
     validFieldDetails: [
       {"section": "", "addressType": "shipping", "contactType": "", "fieldName": "given-name"},
       {"section": "", "addressType": "shipping", "contactType": "", "fieldName": "family-name"},
       {"section": "", "addressType": "shipping", "contactType": "", "fieldName": "street-address"},
       {"section": "", "addressType": "shipping", "contactType": "", "fieldName": "cc-number"},
     ],
   },
   {
     description: "An invalid address form due to less than 3 fields.",
     document: `<form>
                <input id="given-name" autocomplete="shipping given-name">
                <input autocomplete="shipping address-level2">
                </form>`,
-    addressFieldDetails: [],
-    creditCardFieldDetails: [],
+    sections: [{
+      addressFieldDetails: [],
+      creditCardFieldDetails: [],
+    }],
     validFieldDetails: [],
   },
   {
     description: "An invalid credit card form due to omitted cc-number.",
     document: `<form>
                <input id="cc-name" autocomplete="cc-name">
                <input id="cc-exp-month" autocomplete="cc-exp-month">
                <input id="cc-exp-year" autocomplete="cc-exp-year">
                </form>`,
-    addressFieldDetails: [],
-    creditCardFieldDetails: [],
+    sections: [{
+      addressFieldDetails: [],
+      creditCardFieldDetails: [],
+    }],
     validFieldDetails: [],
   },
   {
     description: "An invalid credit card form due to non-autocomplete-attr cc-number and omitted cc-exp-*.",
     document: `<form>
                <input id="cc-name" autocomplete="cc-name">
                <input id="cc-number" name="card-number">
                </form>`,
-    addressFieldDetails: [],
-    creditCardFieldDetails: [],
+    sections: [{
+      addressFieldDetails: [],
+      creditCardFieldDetails: [],
+    }],
     validFieldDetails: [],
   },
   {
     description: "A valid credit card form with autocomplete-attr cc-number only.",
     document: `<form>
                <input id="cc-number" autocomplete="cc-number">
                </form>`,
-    addressFieldDetails: [],
-    creditCardFieldDetails: [
-      {"section": "", "addressType": "", "contactType": "", "fieldName": "cc-number"},
-    ],
+    sections: [{
+      addressFieldDetails: [],
+      creditCardFieldDetails: [
+        {"section": "", "addressType": "", "contactType": "", "fieldName": "cc-number"},
+      ],
+    }],
     validFieldDetails: [
       {"section": "", "addressType": "", "contactType": "", "fieldName": "cc-number"},
     ],
   },
   {
     description: "A valid credit card form with non-autocomplete-attr cc-number and cc-exp.",
     document: `<form>
                <input id="cc-number" name="card-number">
                <input id="cc-exp" autocomplete="cc-exp">
                </form>`,
-    addressFieldDetails: [],
-    creditCardFieldDetails: [
-      {"section": "", "addressType": "", "contactType": "", "fieldName": "cc-number"},
-      {"section": "", "addressType": "", "contactType": "", "fieldName": "cc-exp"},
-    ],
+    sections: [{
+      addressFieldDetails: [],
+      creditCardFieldDetails: [
+        {"section": "", "addressType": "", "contactType": "", "fieldName": "cc-number"},
+        {"section": "", "addressType": "", "contactType": "", "fieldName": "cc-exp"},
+      ],
+    }],
     validFieldDetails: [
       {"section": "", "addressType": "", "contactType": "", "fieldName": "cc-number"},
       {"section": "", "addressType": "", "contactType": "", "fieldName": "cc-exp"},
     ],
     ids: [
       "cc-number",
       "cc-exp",
     ],
   },
   {
     description: "A valid credit card form with non-autocomplete-attr cc-number and cc-exp-month/cc-exp-year.",
     document: `<form>
                <input id="cc-number" name="card-number">
                <input id="cc-exp-month" autocomplete="cc-exp-month">
                <input id="cc-exp-year" autocomplete="cc-exp-year">
                </form>`,
-    addressFieldDetails: [],
-    creditCardFieldDetails: [
-      {"section": "", "addressType": "", "contactType": "", "fieldName": "cc-number"},
-      {"section": "", "addressType": "", "contactType": "", "fieldName": "cc-exp-month"},
-      {"section": "", "addressType": "", "contactType": "", "fieldName": "cc-exp-year"},
-    ],
+    sections: [{
+      addressFieldDetails: [],
+      creditCardFieldDetails: [
+        {"section": "", "addressType": "", "contactType": "", "fieldName": "cc-number"},
+        {"section": "", "addressType": "", "contactType": "", "fieldName": "cc-exp-month"},
+        {"section": "", "addressType": "", "contactType": "", "fieldName": "cc-exp-year"},
+      ],
+    }],
     validFieldDetails: [
       {"section": "", "addressType": "", "contactType": "", "fieldName": "cc-number"},
       {"section": "", "addressType": "", "contactType": "", "fieldName": "cc-exp-month"},
       {"section": "", "addressType": "", "contactType": "", "fieldName": "cc-exp-year"},
     ],
     ids: [
       "cc-number",
       "cc-exp-month",
@@ -259,30 +281,32 @@ const TESTCASES = [
                  <input id="billingSuffix" name="phone" maxlength="4">
 
                  <input id="otherCC" name="phone" maxlength="3">
                  <input id="otherAC" name="phone" maxlength="3">
                  <input id="otherPrefix" name="phone" maxlength="3">
                  <input id="otherSuffix" name="phone" maxlength="4">
                </form>`,
     allowDuplicates: true,
-    addressFieldDetails: [
-      {"section": "", "addressType": "", "contactType": "", "fieldName": "tel-area-code"},
-      {"section": "", "addressType": "", "contactType": "", "fieldName": "tel-local-prefix"},
-      {"section": "", "addressType": "", "contactType": "", "fieldName": "tel-local-suffix"},
-      {"section": "", "addressType": "", "contactType": "", "fieldName": "tel-extension"},
-      {"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-country-code"},
-      {"section": "", "addressType": "", "contactType": "", "fieldName": "tel-area-code"},
-      {"section": "", "addressType": "", "contactType": "", "fieldName": "tel-local-prefix"},
-      {"section": "", "addressType": "", "contactType": "", "fieldName": "tel-local-suffix"},
-    ],
-    creditCardFieldDetails: [],
+    sections: [{
+      addressFieldDetails: [
+        {"section": "", "addressType": "", "contactType": "", "fieldName": "tel-area-code"},
+        {"section": "", "addressType": "", "contactType": "", "fieldName": "tel-local-prefix"},
+        {"section": "", "addressType": "", "contactType": "", "fieldName": "tel-local-suffix"},
+        {"section": "", "addressType": "", "contactType": "", "fieldName": "tel-extension"},
+        {"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-country-code"},
+        {"section": "", "addressType": "", "contactType": "", "fieldName": "tel-area-code"},
+        {"section": "", "addressType": "", "contactType": "", "fieldName": "tel-local-prefix"},
+        {"section": "", "addressType": "", "contactType": "", "fieldName": "tel-local-suffix"},
+      ],
+      creditCardFieldDetails: [],
+    }],
     validFieldDetails: [
       {"section": "", "addressType": "", "contactType": "", "fieldName": "tel-area-code"},
       {"section": "", "addressType": "", "contactType": "", "fieldName": "tel-local-prefix"},
       {"section": "", "addressType": "", "contactType": "", "fieldName": "tel-local-suffix"},
       {"section": "", "addressType": "", "contactType": "", "fieldName": "tel-extension"},
       {"section": "", "addressType": "", "contactType": "", "fieldName": "tel-area-code"},
       {"section": "", "addressType": "", "contactType": "", "fieldName": "tel-local-prefix"},
       {"section": "", "addressType": "", "contactType": "", "fieldName": "tel-local-suffix"},
@@ -295,69 +319,73 @@ const TESTCASES = [
       "shippingAC", "shippingPrefix", "shippingSuffix", "shippingTelExt",
       "billingAC", "billingPrefix", "billingSuffix",
       "otherCC", "otherAC", "otherPrefix", "otherSuffix",
     ],
   },
   {
     description: "Dedup the same field names of the different telephone fields.",
     document: `<form>
-                 <input id="i1" autocomplete="shipping given-name">
-                 <input id="i2" autocomplete="shipping family-name">
-                 <input id="i3" autocomplete="shipping street-address">
-                 <input id="i4" autocomplete="shipping email">
+                 <input id="i1" autocomplete="given-name">
+                 <input id="i2" autocomplete="family-name">
+                 <input id="i3" autocomplete="street-address">
+                 <input id="i4" autocomplete="email">
 
                  <input id="homePhone" maxlength="10">
                  <input id="mobilePhone" maxlength="10">
                  <input id="officePhone" maxlength="10">
                </form>`,
-    addressFieldDetails: [
-      {"section": "", "addressType": "shipping", "contactType": "", "fieldName": "given-name"},
-      {"section": "", "addressType": "shipping", "contactType": "", "fieldName": "family-name"},
-      {"section": "", "addressType": "shipping", "contactType": "", "fieldName": "street-address"},
-      {"section": "", "addressType": "shipping", "contactType": "", "fieldName": "email"},
-      {"section": "", "addressType": "", "contactType": "", "fieldName": "tel"},
-    ],
-    creditCardFieldDetails: [],
+    sections: [{
+      addressFieldDetails: [
+        {"section": "", "addressType": "", "contactType": "", "fieldName": "given-name"},
+        {"section": "", "addressType": "", "contactType": "", "fieldName": "family-name"},
+        {"section": "", "addressType": "", "contactType": "", "fieldName": "street-address"},
+        {"section": "", "addressType": "", "contactType": "", "fieldName": "email"},
+        {"section": "", "addressType": "", "contactType": "", "fieldName": "tel"},
+      ],
+      creditCardFieldDetails: [],
+    }],
     validFieldDetails: [
-      {"section": "", "addressType": "shipping", "contactType": "", "fieldName": "given-name"},
-      {"section": "", "addressType": "shipping", "contactType": "", "fieldName": "family-name"},
-      {"section": "", "addressType": "shipping", "contactType": "", "fieldName": "street-address"},
-      {"section": "", "addressType": "shipping", "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": "email"},
       {"section": "", "addressType": "", "contactType": "", "fieldName": "tel"},
     ],
     ids: ["i1", "i2", "i3", "i4", "homePhone"],
   },
   {
     description: "The duplicated phones of a single one and a set with ac, prefix, suffix.",
     document: `<form>
                  <input id="i1" autocomplete="shipping given-name">
                  <input id="i2" autocomplete="shipping family-name">
                  <input id="i3" autocomplete="shipping street-address">
                  <input id="i4" autocomplete="shipping email">
                  <input id="singlePhone" autocomplete="shipping tel">
                  <input id="shippingAreaCode" autocomplete="shipping tel-area-code">
                  <input id="shippingPrefix" autocomplete="shipping tel-local-prefix">
                  <input id="shippingSuffix" autocomplete="shipping tel-local-suffix">
                </form>`,
-    addressFieldDetails: [
-      {"section": "", "addressType": "shipping", "contactType": "", "fieldName": "given-name"},
-      {"section": "", "addressType": "shipping", "contactType": "", "fieldName": "family-name"},
-      {"section": "", "addressType": "shipping", "contactType": "", "fieldName": "street-address"},
-      {"section": "", "addressType": "shipping", "contactType": "", "fieldName": "email"},
+    sections: [{
+      addressFieldDetails: [
+        {"section": "", "addressType": "shipping", "contactType": "", "fieldName": "given-name"},
+        {"section": "", "addressType": "shipping", "contactType": "", "fieldName": "family-name"},
+        {"section": "", "addressType": "shipping", "contactType": "", "fieldName": "street-address"},
+        {"section": "", "addressType": "shipping", "contactType": "", "fieldName": "email"},
 
-      // NOTES: Ideally, there is only one full telephone field(s) in a form for
-      // this case. We can see if there is any better solution later.
-      {"section": "", "addressType": "shipping", "contactType": "", "fieldName": "tel"},
+        // NOTES: Ideally, there is only one full telephone field(s) in a form for
+        // this case. We can see if there is any better solution later.
+        {"section": "", "addressType": "shipping", "contactType": "", "fieldName": "tel"},
 
-      {"section": "", "addressType": "shipping", "contactType": "", "fieldName": "tel-area-code"},
-      {"section": "", "addressType": "shipping", "contactType": "", "fieldName": "tel-local-prefix"},
-      {"section": "", "addressType": "shipping", "contactType": "", "fieldName": "tel-local-suffix"},
-    ],
-    creditCardFieldDetails: [],
+        {"section": "", "addressType": "shipping", "contactType": "", "fieldName": "tel-area-code"},
+        {"section": "", "addressType": "shipping", "contactType": "", "fieldName": "tel-local-prefix"},
+        {"section": "", "addressType": "shipping", "contactType": "", "fieldName": "tel-local-suffix"},
+      ],
+      creditCardFieldDetails: [],
+    }],
     validFieldDetails: [
       {"section": "", "addressType": "shipping", "contactType": "", "fieldName": "given-name"},
       {"section": "", "addressType": "shipping", "contactType": "", "fieldName": "family-name"},
       {"section": "", "addressType": "shipping", "contactType": "", "fieldName": "street-address"},
       {"section": "", "addressType": "shipping", "contactType": "", "fieldName": "email"},
       {"section": "", "addressType": "shipping", "contactType": "", "fieldName": "tel"},
       {"section": "", "addressType": "shipping", "contactType": "", "fieldName": "tel-area-code"},
       {"section": "", "addressType": "shipping", "contactType": "", "fieldName": "tel-local-prefix"},
@@ -370,22 +398,24 @@ const TESTCASES = [
     description: "Always adopt the info from autocomplete attribute.",
     document: `<form>
                  <input id="given-name" autocomplete="shipping given-name">
                  <input id="family-name" autocomplete="shipping family-name">
                  <input id="dummyAreaCode" autocomplete="shipping tel" maxlength="3">
                  <input id="dummyPrefix" autocomplete="shipping tel" maxlength="3">
                  <input id="dummySuffix" autocomplete="shipping tel" maxlength="4">
                </form>`,
-    addressFieldDetails: [
-      {"section": "", "addressType": "shipping", "contactType": "", "fieldName": "given-name"},
-      {"section": "", "addressType": "shipping", "contactType": "", "fieldName": "family-name"},
-      {"section": "", "addressType": "shipping", "contactType": "", "fieldName": "tel"},
-    ],
-    creditCardFieldDetails: [],
+    sections: [{
+      addressFieldDetails: [
+        {"section": "", "addressType": "shipping", "contactType": "", "fieldName": "given-name"},
+        {"section": "", "addressType": "shipping", "contactType": "", "fieldName": "family-name"},
+        {"section": "", "addressType": "shipping", "contactType": "", "fieldName": "tel"},
+      ],
+      creditCardFieldDetails: [],
+    }],
     validFieldDetails: [
       {"section": "", "addressType": "shipping", "contactType": "", "fieldName": "given-name"},
       {"section": "", "addressType": "shipping", "contactType": "", "fieldName": "family-name"},
       {"section": "", "addressType": "shipping", "contactType": "", "fieldName": "tel"},
     ],
     ids: ["given-name", "family-name", "dummyAreaCode"],
   },
 ];
@@ -426,26 +456,30 @@ for (let tc of TESTCASES) {
         handlerDetails.forEach((detail, index) => {
           Assert.equal(detail.fieldName, testCaseDetails[index].fieldName, "fieldName");
           Assert.equal(detail.section, testCaseDetails[index].section, "section");
           Assert.equal(detail.addressType, testCaseDetails[index].addressType, "addressType");
           Assert.equal(detail.contactType, testCaseDetails[index].contactType, "contactType");
           Assert.equal(detail.elementWeakRef.get(), testCaseDetails[index].elementWeakRef.get(), "DOM reference");
         });
       }
-      [
-        testcase.addressFieldDetails,
-        testcase.creditCardFieldDetails,
-        testcase.validFieldDetails,
-      ].forEach(details => setElementWeakRef(details));
+      for (let i = 0; i < testcase.sections.length; i++) {
+        let section = testcase.sections[i];
+        [
+          section.addressFieldDetails,
+          section.creditCardFieldDetails,
+        ].forEach(details => setElementWeakRef(details));
+      }
+      setElementWeakRef(testcase.validFieldDetails);
 
       let handler = new FormAutofillHandler(formLike);
       let validFieldDetails = handler.collectFormFields(testcase.allowDuplicates);
 
-      // TODO [Bug 1415077] We can assume all test cases with only one section
-      // should be filled. Eventually, the test needs to verify the filling
-      // feature in a multiple section case.
-      verifyDetails(handler.sections[0].address.fieldDetails, testcase.addressFieldDetails);
-      verifyDetails(handler.sections[0].creditCard.fieldDetails, testcase.creditCardFieldDetails);
+      Assert.equal(handler.sections.length, testcase.sections.length);
+      for (let i = 0; i < handler.sections.length; i++) {
+        let section = handler.sections[i];
+        verifyDetails(section.address.fieldDetails, testcase.sections[i].addressFieldDetails);
+        verifyDetails(section.creditCard.fieldDetails, testcase.sections[i].creditCardFieldDetails);
+      }
       verifyDetails(validFieldDetails, testcase.validFieldDetails);
     });
   })();
 }