Bug 1370475 - Part 1: address-line[1-3] should be recognized as "street-address" in the secondary label order. r=lchang draft
authorSean Lee <selee@mozilla.com>
Mon, 19 Jun 2017 13:10:34 +0800
changeset 600559 3ee05d0ac9b034f72d112666a7b6739035929f03
parent 600491 a584b41ad399e648c99a43e41fa5138b2ccfd491
child 600560 20abaf7c8a0e9ad65d53fa5eb5be8578910059f2
push id65790
push userbmo:selee@mozilla.com
push dateTue, 27 Jun 2017 10:27:58 +0000
reviewerslchang
bugs1370475
milestone56.0a1
Bug 1370475 - Part 1: address-line[1-3] should be recognized as "street-address" in the secondary label order. r=lchang MozReview-Commit-ID: 5pLWCeNoryE
browser/extensions/formautofill/ProfileAutoCompleteResult.jsm
browser/extensions/formautofill/test/unit/test_profileAutocompleteResult.js
--- a/browser/extensions/formautofill/ProfileAutoCompleteResult.jsm
+++ b/browser/extensions/formautofill/ProfileAutoCompleteResult.jsm
@@ -97,16 +97,22 @@ ProfileAutoCompleteResult.prototype = {
     // field in the same group as the secondary label.
     const GROUP_FIELDS = {
       "name": [
         "name",
         "given-name",
         "additional-name",
         "family-name",
       ],
+      "street-address": [
+        "street-address",
+        "address-line1",
+        "address-line2",
+        "address-line3",
+      ],
       "country-name": [
         "country",
         "country-name",
       ],
     };
 
     const secondaryLabelOrder = [
       "street-address",  // Street address
--- a/browser/extensions/formautofill/test/unit/test_profileAutocompleteResult.js
+++ b/browser/extensions/formautofill/test/unit/test_profileAutocompleteResult.js
@@ -4,33 +4,47 @@ Cu.import("resource://formautofill/Profi
 
 let matchingProfiles = [{
   guid: "test-guid-1",
   "given-name": "Timothy",
   "family-name": "Berners-Lee",
   name: "Timothy Berners-Lee",
   organization: "Sesame Street",
   "street-address": "123 Sesame Street.",
+  "address-line1": "123 Sesame Street.",
   tel: "1-345-345-3456.",
 }, {
   guid: "test-guid-2",
   "given-name": "John",
   "family-name": "Doe",
   name: "John Doe",
   organization: "Mozilla",
   "street-address": "331 E. Evelyn Avenue",
+  "address-line1": "331 E. Evelyn Avenue",
   tel: "1-650-903-0800",
 }, {
   guid: "test-guid-3",
   organization: "",
-  "street-address": "321, No Name St.",
+  "street-address": "321, No Name St. 2nd line 3rd line",
+  "address-line1": "321, No Name St.",
+  "address-line2": "2nd line",
+  "address-line3": "3rd line",
   tel: "1-000-000-0000",
 }];
 
-let allFieldNames = ["given-name", "family-name", "street-address", "organization", "tel"];
+let allFieldNames = [
+  "given-name",
+  "family-name",
+  "street-address",
+  "address-line1",
+  "address-line2",
+  "address-line3",
+  "organization",
+  "tel",
+];
 
 let testCases = [{
   description: "Focus on an `organization` field",
   options: {},
   matchingProfiles,
   allFieldNames,
   searchString: "",
   fieldName: "organization",
@@ -86,17 +100,17 @@ let testCases = [{
       }),
       image: "",
     }, {
       value: "1-000-000-0000",
       style: "autofill-profile",
       comment: JSON.stringify(matchingProfiles[2]),
       label: JSON.stringify({
         primary: "1-000-000-0000",
-        secondary: "321, No Name St.",
+        secondary: "321, No Name St. 2nd line 3rd line",
       }),
       image: "",
     }],
   },
 }, {
   description: "Focus on an `street-address` field",
   options: {},
   matchingProfiles,
@@ -120,16 +134,55 @@ let testCases = [{
       style: "autofill-profile",
       comment: JSON.stringify(matchingProfiles[1]),
       label: JSON.stringify({
         primary: "331 E. Evelyn Avenue",
         secondary: "John Doe",
       }),
       image: "",
     }, {
+      value: "321, No Name St. 2nd line 3rd line",
+      style: "autofill-profile",
+      comment: JSON.stringify(matchingProfiles[2]),
+      label: JSON.stringify({
+        primary: "321, No Name St. 2nd line 3rd line",
+        secondary: "1-000-000-0000",
+      }),
+      image: "",
+    }],
+  },
+}, {
+  description: "Focus on an `address-line1` field",
+  options: {},
+  matchingProfiles,
+  allFieldNames,
+  searchString: "",
+  fieldName: "address-line1",
+  expected: {
+    searchResult: Ci.nsIAutoCompleteResult.RESULT_SUCCESS,
+    defaultIndex: 0,
+    items: [{
+      value: "123 Sesame Street.",
+      style: "autofill-profile",
+      comment: JSON.stringify(matchingProfiles[0]),
+      label: JSON.stringify({
+        primary: "123 Sesame Street.",
+        secondary: "Timothy Berners-Lee",
+      }),
+      image: "",
+    }, {
+      value: "331 E. Evelyn Avenue",
+      style: "autofill-profile",
+      comment: JSON.stringify(matchingProfiles[1]),
+      label: JSON.stringify({
+        primary: "331 E. Evelyn Avenue",
+        secondary: "John Doe",
+      }),
+      image: "",
+    }, {
       value: "321, No Name St.",
       style: "autofill-profile",
       comment: JSON.stringify(matchingProfiles[2]),
       label: JSON.stringify({
         primary: "321, No Name St.",
         secondary: "1-000-000-0000",
       }),
       image: "",