зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1812152 - Add pref to control minimum chars needed to match quickaction. r=daisuke
Differential Revision: https://phabricator.services.mozilla.com/D167713
This commit is contained in:
Родитель
e7fa71f013
Коммит
5e2cc8e1ea
|
@ -405,7 +405,6 @@ pref("browser.urlbar.suggest.calculator", false);
|
|||
pref("browser.urlbar.suggest.quickactions", true);
|
||||
pref("browser.urlbar.shortcuts.quickactions", true);
|
||||
pref("browser.urlbar.quickactions.showPrefs", true);
|
||||
pref("browser.urlbar.quickactions.showInZeroPrefix", false);
|
||||
#endif
|
||||
|
||||
// Feature gate pref for weather suggestions in the urlbar.
|
||||
|
|
|
@ -244,12 +244,14 @@ const PREF_URLBAR_DEFAULTS = new Map([
|
|||
// Whether we will match QuickActions within a phrase and not only a prefix.
|
||||
["quickactions.matchInPhrase", true],
|
||||
|
||||
// Whether we show QuickActions when in zero-prefix.
|
||||
["quickactions.showInZeroPrefix", false],
|
||||
|
||||
// Show multiple actions in a random order.
|
||||
["quickactions.randomOrderActions", false],
|
||||
|
||||
// The minumum amount of characters required for the user to input before
|
||||
// matching actions. Setting this to 0 will show the actions in the
|
||||
// zero prefix state.
|
||||
["quickactions.minimumSearchString", 3],
|
||||
|
||||
// Whether results will include non-sponsored quick suggest suggestions.
|
||||
["suggest.quicksuggest.nonsponsored", false],
|
||||
|
||||
|
|
|
@ -19,7 +19,7 @@ ChromeUtils.defineESModuleGetters(lazy, {
|
|||
const ENABLED_PREF = "quickactions.enabled";
|
||||
const SUGGEST_PREF = "suggest.quickactions";
|
||||
const MATCH_IN_PHRASE_PREF = "quickactions.matchInPhrase";
|
||||
const SHOW_IN_ZERO_PREFIX_PREF = "quickactions.showInZeroPrefix";
|
||||
const MIN_SEARCH_PREF = "quickactions.minimumSearchString";
|
||||
const DYNAMIC_TYPE_NAME = "quickactions";
|
||||
|
||||
// When the urlbar is first focused and no search term has been
|
||||
|
@ -100,8 +100,7 @@ class ProviderQuickActions extends UrlbarProvider {
|
|||
|
||||
if (
|
||||
!queryContext.searchMode &&
|
||||
!lazy.UrlbarPrefs.get(SHOW_IN_ZERO_PREFIX_PREF) &&
|
||||
!input
|
||||
input.length < lazy.UrlbarPrefs.get(MIN_SEARCH_PREF)
|
||||
) {
|
||||
return;
|
||||
}
|
||||
|
|
|
@ -17,7 +17,7 @@ add_setup(async function() {
|
|||
["browser.urlbar.searchEngagementTelemetry.enabled", true],
|
||||
["browser.urlbar.quickactions.enabled", true],
|
||||
["browser.urlbar.suggest.quickactions", true],
|
||||
["browser.urlbar.quickactions.showInZeroPrefix", true],
|
||||
["browser.urlbar.quickactions.minimumSearchString", 0],
|
||||
],
|
||||
});
|
||||
registerCleanupFunction(async function() {
|
||||
|
|
|
@ -150,9 +150,6 @@ add_task(async function enter_search_mode_oneoff_by_key() {
|
|||
});
|
||||
|
||||
add_task(async function enter_search_mode_key() {
|
||||
await SpecialPowers.pushPrefEnv({
|
||||
set: [["browser.urlbar.quickactions.showInZeroPrefix", false]],
|
||||
});
|
||||
await UrlbarTestUtils.promiseAutocompleteResultPopup({
|
||||
window,
|
||||
value: "> ",
|
||||
|
@ -736,10 +733,17 @@ async function hasQuickActions(win) {
|
|||
}
|
||||
|
||||
add_task(async function test_show_in_zero_prefix() {
|
||||
for (const showInZeroPrefix of [false, true]) {
|
||||
info(`Test when quickactions.showInZeroPrefix pref is ${showInZeroPrefix}`);
|
||||
for (const minimumSearchString of [0, 3]) {
|
||||
info(
|
||||
`Test when quickactions.minimumSearchString pref is ${minimumSearchString}`
|
||||
);
|
||||
await SpecialPowers.pushPrefEnv({
|
||||
set: [["browser.urlbar.quickactions.showInZeroPrefix", showInZeroPrefix]],
|
||||
set: [
|
||||
[
|
||||
"browser.urlbar.quickactions.minimumSearchString",
|
||||
minimumSearchString,
|
||||
],
|
||||
],
|
||||
});
|
||||
await UrlbarTestUtils.promiseAutocompleteResultPopup({
|
||||
window,
|
||||
|
@ -748,7 +752,7 @@ add_task(async function test_show_in_zero_prefix() {
|
|||
|
||||
Assert.equal(
|
||||
await hasQuickActions(window),
|
||||
showInZeroPrefix,
|
||||
!minimumSearchString,
|
||||
"Result for quick actions is as expected"
|
||||
);
|
||||
await SpecialPowers.popPrefEnv();
|
||||
|
|
|
@ -363,7 +363,7 @@ async function setup() {
|
|||
set: [
|
||||
["browser.urlbar.searchEngagementTelemetry.enabled", true],
|
||||
["browser.urlbar.quickactions.enabled", true],
|
||||
["browser.urlbar.quickactions.showInZeroPrefix", true],
|
||||
["browser.urlbar.quickactions.minimumSearchString", 0],
|
||||
["browser.urlbar.suggest.quickactions", true],
|
||||
["browser.urlbar.shortcuts.quickactions", true],
|
||||
[
|
||||
|
|
|
@ -107,3 +107,20 @@ add_task(async function remove_action() {
|
|||
matches: [],
|
||||
});
|
||||
});
|
||||
|
||||
add_task(async function minimum_search_string() {
|
||||
let searchString = "newa";
|
||||
for (let minimumSearchString of [0, 3]) {
|
||||
UrlbarPrefs.set("quickactions.minimumSearchString", minimumSearchString);
|
||||
for (let i = 1; i < 4; i++) {
|
||||
let context = createContext(searchString.substring(0, i), {
|
||||
providers: [UrlbarProviderQuickActions.name],
|
||||
isPrivate: false,
|
||||
});
|
||||
let matches =
|
||||
i >= minimumSearchString ? [expectedMatch("newaction", i)] : [];
|
||||
await check_results({ context, matches });
|
||||
}
|
||||
}
|
||||
UrlbarPrefs.clear("quickactions.minimumSearchString");
|
||||
});
|
||||
|
|
Загрузка…
Ссылка в новой задаче