From a9c4650c1d61e1c4be9b754e138e4c297692473c Mon Sep 17 00:00:00 2001 From: steveck-chung Date: Mon, 8 May 2017 16:48:40 +0800 Subject: [PATCH] Bug 1362937 - [Form Autofill] Handle undefined profile fields in autocomplete filtering. r=MattN MozReview-Commit-ID: JvETH3KBjxY --HG-- extra : rebase_source : 8c0b4087e4ec3f323bcbd1d3acbd0153bca31164 --- browser/extensions/formautofill/ProfileStorage.jsm | 2 +- .../extensions/formautofill/test/unit/test_profileStorage.js | 5 +++++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/browser/extensions/formautofill/ProfileStorage.jsm b/browser/extensions/formautofill/ProfileStorage.jsm index 2b0617158884..9a70487a53ac 100644 --- a/browser/extensions/formautofill/ProfileStorage.jsm +++ b/browser/extensions/formautofill/ProfileStorage.jsm @@ -284,7 +284,7 @@ ProfileStorage.prototype = { return !!name; } - return name.toLowerCase().startsWith(lcSearchString); + return name && name.toLowerCase().startsWith(lcSearchString); }); log.debug("getByFilter: Returning", result.length, "result(s)"); diff --git a/browser/extensions/formautofill/test/unit/test_profileStorage.js b/browser/extensions/formautofill/test/unit/test_profileStorage.js index 52c7a8e203a7..3ec5ffe0bd94 100644 --- a/browser/extensions/formautofill/test/unit/test_profileStorage.js +++ b/browser/extensions/formautofill/test/unit/test_profileStorage.js @@ -143,6 +143,11 @@ add_task(function* test_getByFilter() { filter = {info: {fieldName: "street-address"}, searchString: ".*"}; profiles = profileStorage.getByFilter(filter); do_check_eq(profiles.length, 0); + + // Prevent broken while searching the property that is not existed. + filter = {info: {fieldName: "tel"}, searchString: "1"}; + profiles = profileStorage.getByFilter(filter); + do_check_eq(profiles.length, 0); }); add_task(function* test_add() {