Bug 1501410 - Part 4 - Make the filter case insensitive. r=bgrins
authorPaolo Amadini <paolo.mozmail@amadzone.org>
Tue, 08 Jan 2019 15:08:04 +0000
changeset 511137 cd0401ea98ff98343f1f207fd74071de60ce4622
parent 511136 2039967a0b3b7f98bf7ffc70047a99cf85d08860
child 511138 062ab37367fb624f974b115a5153661a87983e60
push id10547
push userffxbld-merge
push dateMon, 21 Jan 2019 13:03:58 +0000
treeherdermozilla-beta@24ec1916bffe [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbgrins
bugs1501410
milestone66.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 1501410 - Part 4 - Make the filter case insensitive. r=bgrins Differential Revision: https://phabricator.services.mozilla.com/D15947
browser/components/aboutconfig/content/aboutconfig.js
browser/components/aboutconfig/test/browser/browser_search.js
--- a/browser/components/aboutconfig/content/aboutconfig.js
+++ b/browser/components/aboutconfig/content/aboutconfig.js
@@ -21,17 +21,17 @@ let gDeletedPrefs = new Map();
 let gElementToPrefMap = new WeakMap();
 
 /**
  * Reference to the PrefRow currently being edited, if any.
  */
 let gPrefInEdit = null;
 
 /**
- * Substring that should be contained in the preference name.
+ * Lowercase substring that should be contained in the preference name.
  */
 let gFilterString = null;
 
 class PrefRow {
   constructor(name) {
     this.name = name;
     this.value = true;
     this.refreshValue();
@@ -76,17 +76,17 @@ class PrefRow {
     return this.value.constructor.name;
   }
 
   get exists() {
     return this.hasDefaultValue || this.hasUserValue;
   }
 
   get matchesFilter() {
-    return !gFilterString || this.name.includes(gFilterString);
+    return !gFilterString || this.name.toLowerCase().includes(gFilterString);
   }
 
   _setupElement() {
     this.element.textContent = "";
     let nameCell = document.createElement("td");
     this.element.append(
       nameCell,
       this.valueCell = document.createElement("td"),
@@ -321,17 +321,17 @@ function loadPrefs() {
 
 function filterPrefs() {
   if (gPrefInEdit) {
     gPrefInEdit.endEdit();
   }
   gDeletedPrefs.clear();
 
   let searchName = document.getElementById("search").value.trim();
-  gFilterString = searchName;
+  gFilterString = searchName.toLowerCase();
   let prefArray = [...gExistingPrefs.values()];
   if (gFilterString) {
     prefArray = prefArray.filter(pref => pref.matchesFilter);
   }
   prefArray.sort((a, b) => a.name > b.name);
   if (searchName && !gExistingPrefs.has(searchName)) {
     prefArray.push(new PrefRow(searchName));
   }
--- a/browser/components/aboutconfig/test/browser/browser_search.js
+++ b/browser/components/aboutconfig/test/browser/browser_search.js
@@ -20,17 +20,17 @@ add_task(async function test_search() {
     // The change in count would be because of one or two added preferences,
     // but we tolerate a difference of up to 50 preferences just to be safe.
     // We want thousands of prefs instead of a few dozen that are filtered.
     Assert.greater(this.rows.length, prefArray.length - 50);
 
     // Filter a subset of preferences. The "browser.download." branch is
     // chosen because it is very unlikely that its preferences would be
     // modified by other code during the execution of this test.
-    this.search("wser.down   ");
+    this.search("Wser.down   ");
 
     let filteredPrefArray =
         prefArray.filter(pref => pref.includes("wser.down"));
     // Adding +1 to the list since button does not match an exact
     // preference name then a row is added for the user to add a
     // new button preference if desired
     Assert.equal(this.rows.length, filteredPrefArray.length + 1);
 
@@ -44,13 +44,18 @@ add_task(async function test_search() {
     // We want thousands of prefs instead of a few dozen that are filtered.
     Assert.greater(this.rows.length, prefArray.length - 50);
 
     // Test invalid search returns no preferences.
     // Expecting 1 row to be returned since it offers the ability to add.
     this.search("aJunkValueasdf");
     Assert.equal(this.rows.length, 1);
 
-    // Test added preferences search returns 2 preferences.
+    // Two preferences match this filter, and one of those matches exactly.
     this.search("test.aboutconfig.a");
     Assert.equal(this.rows.length, 2);
+
+    // When searching case insensitively, there is an additional row to add a
+    // new preference with the same name but a different case.
+    this.search("TEST.aboutconfig.a");
+    Assert.equal(this.rows.length, 3);
   });
 });