Bug 1362937 - [Form Autofill] autofill's autocomplete popup filtering is broken. r?MattN
MozReview-Commit-ID: MELFVC5Q2V
--- 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();