Bug 1362937 - [Form Autofill] autofill's autocomplete popup filtering is broken. r?MattN draft
authorsteveck-chung <schung@mozilla.com>
Wed, 10 May 2017 15:12:59 +0800
changeset 575257 2f0ab12501213958ec0d25107fdeb832ba9a03c2
parent 575133 120d8562d4a53e4f78bd86c6f5076f6db265e5a3
child 627879 a5312a3295c29bf368a4179116dcde1c93554388
push id58015
push userbmo:schung@mozilla.com
push dateWed, 10 May 2017 07:13:38 +0000
reviewersMattN
bugs1362937
milestone55.0a1
Bug 1362937 - [Form Autofill] autofill's autocomplete popup filtering is broken. r?MattN MozReview-Commit-ID: MELFVC5Q2V
browser/extensions/formautofill/ProfileStorage.jsm
browser/extensions/formautofill/test/unit/test_profileStorage.js
--- a/browser/extensions/formautofill/ProfileStorage.jsm
+++ b/browser/extensions/formautofill/ProfileStorage.jsm
@@ -266,17 +266,17 @@ ProfileStorage.prototype = {
       // TODO: We'll need to check if the address is for billing or shipping.
       //       (Bug 1358941)
       let name = address[info.fieldName];
 
       if (!searchString) {
         return !!name;
       }
 
-      return name.toLowerCase().startsWith(lcSearchString);
+      return name && name.toLowerCase().startsWith(lcSearchString);
     });
 
     log.debug("getByFilter: Returning", result.length, "result(s)");
     return result;
   },
 
   _clone(record) {
     return Object.assign({}, record);
--- a/browser/extensions/formautofill/test/unit/test_profileStorage.js
+++ b/browser/extensions/formautofill/test/unit/test_profileStorage.js
@@ -138,16 +138,21 @@ add_task(function* test_getByFilter() {
   filter = {info: {fieldName: "street-address"}, searchString: ""};
   addresses = profileStorage.getByFilter(filter);
   do_check_eq(addresses.length, 2);
 
   // Check if the filtering logic is free from searching special chars.
   filter = {info: {fieldName: "street-address"}, searchString: ".*"};
   addresses = profileStorage.getByFilter(filter);
   do_check_eq(addresses.length, 0);
+
+  // Prevent broken while searching the property that does not exist.
+  filter = {info: {fieldName: "tel"}, searchString: "1"};
+  addresses = profileStorage.getByFilter(filter);
+  do_check_eq(addresses.length, 0);
 });
 
 add_task(function* test_add() {
   let path = getTempFile(TEST_STORE_FILE_NAME).path;
   yield prepareTestRecords(path);
 
   let profileStorage = new ProfileStorage(path);
   yield profileStorage.initialize();