Bug 1362937 - [Form Autofill] autofill's autocomplete popup filtering is broken. r=MattN
authorsteveck-chung <schung@mozilla.com>
Wed, 10 May 2017 15:12:59 +0800
changeset 357527 773f2202cf94f570373d52de4d28e3d4237b5d35
parent 357526 6f41cbcef051008450e664e75afb64681e50bc6a
child 357528 09259740487bb1a95a70e2e4bfd5183f28fc0d56
push id31795
push userkwierso@gmail.com
push dateWed, 10 May 2017 22:26:00 +0000
treeherdermozilla-central@3df2494ade45 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersMattN
bugs1362937
milestone55.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
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
@@ -274,17 +274,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();