mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-10 03:45:46 +00:00
Bug 1544195 - Support wildcard on about:config r=mconley
Differential Revision: https://phabricator.services.mozilla.com/D35981 --HG-- extra : moz-landing-system : lando
This commit is contained in:
parent
32899fcfad
commit
a41b01fed5
@ -49,6 +49,11 @@ let gPrefInEdit = null;
|
||||
*/
|
||||
let gFilterString = null;
|
||||
|
||||
/**
|
||||
* RegExp that should be matched to the preference name.
|
||||
*/
|
||||
let gFilterPattern = null;
|
||||
|
||||
/**
|
||||
* True if we were requested to show all preferences.
|
||||
*/
|
||||
@ -121,6 +126,7 @@ class PrefRow {
|
||||
|
||||
get matchesFilter() {
|
||||
return gFilterShowAll ||
|
||||
(gFilterPattern && gFilterPattern.test(this.name)) ||
|
||||
(gFilterString && this.name.toLowerCase().includes(gFilterString));
|
||||
}
|
||||
|
||||
@ -452,7 +458,13 @@ function filterPrefs(options = {}) {
|
||||
gFilterString = searchName.toLowerCase();
|
||||
gFilterShowAll = !!options.showAll;
|
||||
|
||||
let showResults = gFilterString || gFilterShowAll;
|
||||
gFilterPattern = null;
|
||||
if (gFilterString.includes("*")) {
|
||||
gFilterPattern = new RegExp(gFilterString.replace(/\*+/g, ".*"), "i");
|
||||
gFilterString = "";
|
||||
}
|
||||
|
||||
let showResults = gFilterString || gFilterPattern || gFilterShowAll;
|
||||
document.getElementById("show-all").classList.toggle("hidden", showResults);
|
||||
|
||||
let prefArray = [];
|
||||
|
@ -81,6 +81,30 @@ add_task(async function test_search() {
|
||||
});
|
||||
});
|
||||
|
||||
add_task(async function test_search_wildcard() {
|
||||
await AboutConfigTest.withNewTab(async function() {
|
||||
const extra = 1; // "Add" row
|
||||
|
||||
// A trailing wildcard
|
||||
this.search("test.about*");
|
||||
Assert.equal(this.rows.length, 3 + extra);
|
||||
|
||||
// A wildcard in middle
|
||||
this.search("test.about*a");
|
||||
Assert.equal(this.rows.length, 2 + extra);
|
||||
this.search("test.about*ab");
|
||||
Assert.equal(this.rows.length, 1 + extra);
|
||||
this.search("test.aboutcon*fig");
|
||||
Assert.equal(this.rows.length, 3 + extra);
|
||||
|
||||
// Multiple wildcards in middle
|
||||
this.search("test.about*fig*ab");
|
||||
Assert.equal(this.rows.length, 1 + extra);
|
||||
this.search("test.about*config*ab");
|
||||
Assert.equal(this.rows.length, 1 + extra);
|
||||
});
|
||||
});
|
||||
|
||||
add_task(async function test_search_delayed() {
|
||||
await AboutConfigTest.withNewTab(async function() {
|
||||
// Start with the initial empty page.
|
||||
|
Loading…
Reference in New Issue
Block a user