commit 4bab52ded69972f7e3c74e56fa43dbd58a52be0d
parent b30c186974b46dadba8b9efe862adfa3b48554dc
Author: Stephanie Cunnane <scunnane@mozilla.com>
Date: Sat, 13 Dec 2025 02:16:42 +0000
Bug 1972069 - Convert search engine suggestions section of search settings to config-based prefs. r=Standard8,fluent-reviewers,mstriemer,flod
Differential Revision: https://phabricator.services.mozilla.com/D267687
Diffstat:
8 files changed, 284 insertions(+), 196 deletions(-)
diff --git a/browser/components/preferences/main.js b/browser/components/preferences/main.js
@@ -2843,6 +2843,40 @@ SettingGroupManager.registerGroups({
},
],
},
+ searchSuggestions: {
+ l10nId: "search-suggestions-header-2",
+ headingLevel: 2,
+ items: [
+ {
+ id: "suggestionsInSearchFieldsCheckbox",
+ l10nId: "search-show-suggestions-option",
+ items: [
+ {
+ id: "urlBarSuggestionCheckbox",
+ l10nId: "search-show-suggestions-url-bar-option",
+ },
+ {
+ id: "showSearchSuggestionsFirstCheckbox",
+ l10nId: "search-show-suggestions-above-history-option-2",
+ },
+ {
+ id: "showSearchSuggestionsPrivateWindowsCheckbox",
+ l10nId: "search-show-suggestions-private-windows-2",
+ },
+ {
+ id: "showTrendingSuggestionsCheckbox",
+ l10nId: "addressbar-locbar-showtrendingsuggestions-option-2",
+ supportPage: "use-google-trending-search-firefox-address-bar",
+ },
+ {
+ id: "urlBarSuggestionPermanentPBMessage",
+ l10nId: "search-suggestions-cant-show-2",
+ control: "moz-message-bar",
+ },
+ ],
+ },
+ ],
+ },
dnsOverHttpsAdvanced: {
inProgress: true,
l10nId: "preferences-doh-advanced-section",
diff --git a/browser/components/preferences/search.inc.xhtml b/browser/components/preferences/search.inc.xhtml
@@ -19,31 +19,7 @@
<!-- Search Suggestions -->
<groupbox id="searchSuggestionsGroup" data-category="paneSearch" hidden="true">
- <label><html:h2 data-l10n-id="search-suggestions-header" /></label>
- <description id="searchSuggestionsDesc"
- class="description-deemphasized"
- data-l10n-id="search-suggestions-desc" />
-
- <checkbox id="suggestionsInSearchFieldsCheckbox"
- data-l10n-id="search-show-suggestions-option" />
- <vbox class="indent">
- <checkbox id="urlBarSuggestion" data-l10n-id="search-show-suggestions-url-bar-option" />
- <checkbox id="showSearchSuggestionsFirstCheckbox"
- data-l10n-id="search-show-suggestions-above-history-option"
- preference="browser.urlbar.showSearchSuggestionsFirst"/>
- <checkbox id="showSearchSuggestionsPrivateWindows"
- data-l10n-id="search-show-suggestions-private-windows"/>
- <hbox align="center" id="showTrendingSuggestionsBox">
- <checkbox id="showTrendingSuggestions" data-l10n-id="addressbar-locbar-showtrendingsuggestions-option" preference="browser.urlbar.suggest.trending" class="tail-with-learn-more" />
- <html:a is="moz-support-link" support-page="google-trending-searches-on-awesomebar" />
- </hbox>
- <hbox id="urlBarSuggestionPermanentPBLabel"
- align="center" class="indent">
- <label flex="1" data-l10n-id="search-suggestions-cant-show" />
- </hbox>
- </vbox>
- <checkbox id="enableRecentSearches" data-l10n-id="addressbar-locbar-showrecentsearches-option" hidden="true"
- preference="browser.urlbar.suggest.recentsearches" />
+ <html:setting-group groupid="searchSuggestions" />
</groupbox>
<!-- Address Bar -->
@@ -76,6 +52,8 @@
<checkbox id="topSitesSuggestion"
data-l10n-id="addressbar-locbar-shortcuts-option"
preference="browser.urlbar.suggest.topsites"/>
+ <checkbox id="enableRecentSearches" data-l10n-id="addressbar-locbar-showrecentsearches-option-2" hidden="true"
+ preference="browser.urlbar.suggest.recentsearches" />
<checkbox id="enginesSuggestion" data-l10n-id="addressbar-locbar-engines-option-1"
preference="browser.urlbar.suggest.engines"/>
<hbox id="quickActionsBox" align="center" hidden="true">
diff --git a/browser/components/preferences/search.js b/browser/components/preferences/search.js
@@ -179,12 +179,8 @@ Preferences.addSetting({
}
},
};
-
lazy.CustomizableUI.addListener(customizableUIListener);
-
- window.addEventListener("unload", () => {
- lazy.CustomizableUI.removeListener(customizableUIListener);
- });
+ return () => lazy.CustomizableUI.removeListener(customizableUIListener);
},
});
@@ -220,6 +216,180 @@ Preferences.addSetting(
})
);
+Preferences.addSetting({
+ id: "searchSuggestionsEnabledPref",
+ pref: "browser.search.suggest.enabled",
+});
+
+Preferences.addSetting({
+ id: "permanentPBEnabledPref",
+ pref: "browser.privatebrowsing.autostart",
+});
+
+Preferences.addSetting({
+ id: "urlbarSuggestionsEnabledPref",
+ pref: "browser.urlbar.suggest.searches",
+});
+
+Preferences.addSetting({
+ id: "trendingFeaturegatePref",
+ pref: "browser.urlbar.trending.featureGate",
+});
+
+// The show search suggestion box behaves differently depending on whether the
+// separate search bar is shown. When the separate search bar is shown, it
+// controls just the search suggestion preference, and the
+// `urlBarSuggestionCheckbox` handles the urlbar suggestions. When the separate
+// search bar is not shown, this checkbox toggles both preferences to ensure
+// that the urlbar suggestion preference is set correctly, since that will be
+// the only bar visible.
+Preferences.addSetting({
+ id: "suggestionsInSearchFieldsCheckbox",
+ deps: ["searchSuggestionsEnabledPref", "urlbarSuggestionsEnabledPref"],
+ get(_, deps) {
+ let searchBarVisible =
+ !!lazy.CustomizableUI.getPlacementOfWidget("search-container");
+ return (
+ deps.searchSuggestionsEnabledPref.value &&
+ (searchBarVisible || deps.urlbarSuggestionsEnabledPref.value)
+ );
+ },
+ set(newCheckedValue, deps) {
+ let searchBarVisible =
+ !!lazy.CustomizableUI.getPlacementOfWidget("search-container");
+ if (!searchBarVisible) {
+ deps.urlbarSuggestionsEnabledPref.value = newCheckedValue;
+ }
+ deps.searchSuggestionsEnabledPref.value = newCheckedValue;
+ return newCheckedValue;
+ },
+});
+
+Preferences.addSetting({
+ id: "urlBarSuggestionCheckbox",
+ deps: [
+ "urlbarSuggestionsEnabledPref",
+ "suggestionsInSearchFieldsCheckbox",
+ "searchSuggestionsEnabledPref",
+ "permanentPBEnabledPref",
+ ],
+ get: (_, deps) => {
+ let searchBarVisible =
+ !!lazy.CustomizableUI.getPlacementOfWidget("search-container");
+ if (
+ deps.suggestionsInSearchFieldsCheckbox.value &&
+ searchBarVisible &&
+ deps.urlbarSuggestionsEnabledPref.value
+ ) {
+ return true;
+ }
+ return false;
+ },
+ set: (newCheckedValue, deps, setting) => {
+ if (setting.disabled) {
+ deps.urlbarSuggestionsEnabledPref.value = false;
+ return false;
+ }
+
+ let searchBarVisible =
+ !!lazy.CustomizableUI.getPlacementOfWidget("search-container");
+ if (deps.suggestionsInSearchFieldsCheckbox.value && searchBarVisible) {
+ deps.urlbarSuggestionsEnabledPref.value = newCheckedValue;
+ }
+ return newCheckedValue;
+ },
+ setup: onChange => {
+ // Add observer of CustomizableUI as checkbox should be hidden while
+ // searchbar is enabled.
+ let customizableUIListener = {
+ onWidgetAfterDOMChange: node => {
+ if (node.id == "search-container") {
+ onChange();
+ }
+ },
+ };
+ lazy.CustomizableUI.addListener(customizableUIListener);
+ return () => lazy.CustomizableUI.removeListener(customizableUIListener);
+ },
+ disabled: deps => {
+ return (
+ !deps.searchSuggestionsEnabledPref.value ||
+ deps.permanentPBEnabledPref.value
+ );
+ },
+ visible: () => {
+ let searchBarVisible =
+ !!lazy.CustomizableUI.getPlacementOfWidget("search-container");
+ return searchBarVisible;
+ },
+});
+
+Preferences.addSetting({
+ id: "showSearchSuggestionsFirstCheckbox",
+ pref: "browser.urlbar.showSearchSuggestionsFirst",
+ deps: [
+ "suggestionsInSearchFieldsCheckbox",
+ "urlbarSuggestionsEnabledPref",
+ "searchSuggestionsEnabledPref",
+ "permanentPBEnabledPref",
+ ],
+ get: (newCheckedValue, deps) => {
+ if (!deps.searchSuggestionsEnabledPref.value) {
+ return false;
+ }
+ return deps.urlbarSuggestionsEnabledPref.value ? newCheckedValue : false;
+ },
+ disabled: deps => {
+ return (
+ !deps.suggestionsInSearchFieldsCheckbox.value ||
+ !deps.urlbarSuggestionsEnabledPref.value ||
+ deps.permanentPBEnabledPref.value
+ );
+ },
+});
+
+Preferences.addSetting({
+ id: "showSearchSuggestionsPrivateWindowsCheckbox",
+ pref: "browser.search.suggest.enabled.private",
+ deps: ["searchSuggestionsEnabledPref"],
+ disabled: deps => {
+ return !deps.searchSuggestionsEnabledPref.value;
+ },
+});
+
+Preferences.addSetting({
+ id: "showTrendingSuggestionsCheckbox",
+ pref: "browser.urlbar.suggest.trending",
+ deps: [
+ "searchSuggestionsEnabledPref",
+ "permanentPBEnabledPref",
+ // Required to dynamically update the disabled state when the default engine is changed.
+ "defaultEngineNormal",
+ "trendingFeaturegatePref",
+ ],
+ visible: deps => deps.trendingFeaturegatePref.value,
+ disabled: deps => {
+ let trendingSupported = Services.search.defaultEngine.supportsResponseType(
+ lazy.SearchUtils.URL_TYPE.TRENDING_JSON
+ );
+ return (
+ !deps.searchSuggestionsEnabledPref.value ||
+ deps.permanentPBEnabledPref.value ||
+ !trendingSupported
+ );
+ },
+});
+
+Preferences.addSetting({
+ id: "urlBarSuggestionPermanentPBMessage",
+ deps: ["urlBarSuggestionCheckbox", "permanentPBEnabledPref"],
+ visible: deps => {
+ return (
+ deps.urlBarSuggestionCheckbox.visible && deps.permanentPBEnabledPref.value
+ );
+ },
+});
+
const ENGINE_FLAVOR = "text/x-moz-search-engine";
const SEARCH_TYPE = "default_search";
const SEARCH_KEY = "defaultSearch";
@@ -231,7 +401,7 @@ var gSearchPane = {
init() {
initSettingGroup("defaultEngine");
-
+ initSettingGroup("searchSuggestions");
this._engineStore = new EngineStore();
gEngineView = new EngineView(this._engineStore);
@@ -258,59 +428,11 @@ var gSearchPane = {
Services.obs.removeObserver(this, "quicksuggest-dismissals-changed");
});
- let suggestsPref = Preferences.get("browser.search.suggest.enabled");
- let urlbarSuggestsPref = Preferences.get("browser.urlbar.suggest.searches");
- let privateSuggestsPref = Preferences.get(
- "browser.search.suggest.enabled.private"
- );
-
- let updateSuggestionCheckboxes =
- this._updateSuggestionCheckboxes.bind(this);
- suggestsPref.on("change", updateSuggestionCheckboxes);
- urlbarSuggestsPref.on("change", updateSuggestionCheckboxes);
- let customizableUIListener = {
- onWidgetAfterDOMChange: node => {
- if (node.id == "search-container") {
- updateSuggestionCheckboxes();
- }
- },
- };
- lazy.CustomizableUI.addListener(customizableUIListener);
- window.addEventListener("unload", () => {
- lazy.CustomizableUI.removeListener(customizableUIListener);
- });
-
- let urlbarSuggests = document.getElementById("urlBarSuggestion");
- urlbarSuggests.addEventListener("command", () => {
- urlbarSuggestsPref.value = urlbarSuggests.checked;
- });
- let suggestionsInSearchFieldsCheckbox = document.getElementById(
- "suggestionsInSearchFieldsCheckbox"
- );
- // We only want to call _updateSuggestionCheckboxes once after updating
- // all prefs.
- suggestionsInSearchFieldsCheckbox.addEventListener("command", () => {
- this._skipUpdateSuggestionCheckboxesFromPrefChanges = true;
- if (!lazy.CustomizableUI.getPlacementOfWidget("search-container")) {
- urlbarSuggestsPref.value = suggestionsInSearchFieldsCheckbox.checked;
- }
- suggestsPref.value = suggestionsInSearchFieldsCheckbox.checked;
- this._skipUpdateSuggestionCheckboxesFromPrefChanges = false;
- this._updateSuggestionCheckboxes();
- });
- let privateWindowCheckbox = document.getElementById(
- "showSearchSuggestionsPrivateWindows"
- );
- privateWindowCheckbox.addEventListener("command", () => {
- privateSuggestsPref.value = privateWindowCheckbox.checked;
- });
-
Preferences.addSyncFromPrefListener(
document.getElementById("firefoxSuggestAll"),
this._onFirefoxSuggestAllChange.bind(this)
);
- this._updateSuggestionCheckboxes();
this._initRecentSeachesCheckbox();
this._initAddressBar();
},
@@ -326,73 +448,6 @@ var gSearchPane = {
return undefined;
},
- _updateSuggestionCheckboxes() {
- if (this._skipUpdateSuggestionCheckboxesFromPrefChanges) {
- return;
- }
- let suggestsPref = Preferences.get("browser.search.suggest.enabled");
- let permanentPB = Services.prefs.getBoolPref(
- "browser.privatebrowsing.autostart"
- );
- let urlbarSuggests = document.getElementById("urlBarSuggestion");
- let suggestionsInSearchFieldsCheckbox = document.getElementById(
- "suggestionsInSearchFieldsCheckbox"
- );
- let positionCheckbox = document.getElementById(
- "showSearchSuggestionsFirstCheckbox"
- );
- let privateWindowCheckbox = document.getElementById(
- "showSearchSuggestionsPrivateWindows"
- );
- let urlbarSuggestsPref = Preferences.get("browser.urlbar.suggest.searches");
- let searchBarVisible =
- !!lazy.CustomizableUI.getPlacementOfWidget("search-container");
-
- suggestionsInSearchFieldsCheckbox.checked =
- suggestsPref.value && (searchBarVisible || urlbarSuggestsPref.value);
-
- urlbarSuggests.disabled = !suggestsPref.value || permanentPB;
- urlbarSuggests.hidden = !searchBarVisible;
-
- privateWindowCheckbox.disabled = !suggestsPref.value;
- privateWindowCheckbox.checked = Preferences.get(
- "browser.search.suggest.enabled.private"
- ).value;
- if (privateWindowCheckbox.disabled) {
- privateWindowCheckbox.checked = false;
- }
-
- urlbarSuggests.checked = urlbarSuggestsPref.value;
- if (urlbarSuggests.disabled) {
- urlbarSuggests.checked = false;
- }
- if (urlbarSuggests.checked) {
- positionCheckbox.disabled = false;
- // Update the checked state of the show-suggestions-first checkbox. Note
- // that this does *not* also update its pref, it only checks the box.
- positionCheckbox.checked = Preferences.get(
- positionCheckbox.getAttribute("preference")
- ).value;
- } else {
- positionCheckbox.disabled = true;
- positionCheckbox.checked = false;
- }
- if (
- suggestionsInSearchFieldsCheckbox.checked &&
- !searchBarVisible &&
- !urlbarSuggests.checked
- ) {
- urlbarSuggestsPref.value = true;
- }
-
- let permanentPBLabel = document.getElementById(
- "urlBarSuggestionPermanentPBLabel"
- );
- permanentPBLabel.hidden = urlbarSuggests.hidden || !permanentPB;
-
- this._updateTrendingCheckbox(!suggestsPref.value || permanentPB);
- },
-
_initRecentSeachesCheckbox() {
this._recentSearchesEnabledPref = Preferences.get(
"browser.urlbar.recentsearches.featureGate"
@@ -408,17 +463,6 @@ var gSearchPane = {
listener();
},
- async _updateTrendingCheckbox(suggestDisabled) {
- let trendingBox = document.getElementById("showTrendingSuggestionsBox");
- let trendingCheckBox = document.getElementById("showTrendingSuggestions");
- let trendingSupported = (
- await Services.search.getDefault()
- ).supportsResponseType(lazy.SearchUtils.URL_TYPE.TRENDING_JSON);
- trendingBox.hidden = !Preferences.get("browser.urlbar.trending.featureGate")
- .value;
- trendingCheckBox.disabled = suggestDisabled || !trendingSupported;
- },
-
// ADDRESS BAR
/**
@@ -568,7 +612,6 @@ var gSearchPane = {
case "engine-default": {
// Pass through to the engine store to handle updates.
this._engineStore.browserSearchEngineModified(engine, data);
- gSearchPane._updateSuggestionCheckboxes();
break;
}
default:
diff --git a/browser/components/preferences/tests/browser_searchShowSuggestionsFirst.js b/browser/components/preferences/tests/browser_searchShowSuggestionsFirst.js
@@ -29,7 +29,7 @@ add_task(async function openWithSearchSuggestionsShownFirst() {
"Pref should be true initially"
);
- // Open preferences. The checkbox should be checked.
+ // Open preferences. The checkbox should be checked.
await openPreferencesViaOpenPreferencesAPI("search", { leaveOpen: true });
let doc = gBrowser.selectedBrowser.contentDocument;
let checkbox = doc.getElementById(FIRST_CHECKBOX_ID);
@@ -37,8 +37,7 @@ add_task(async function openWithSearchSuggestionsShownFirst() {
Assert.ok(!checkbox.disabled, "Checkbox should be enabled");
// Uncheck the checkbox.
- checkbox.checked = false;
- checkbox.doCommand();
+ checkbox.click();
// The pref should now be false so that history is shown first.
Assert.ok(
@@ -52,6 +51,7 @@ add_task(async function openWithSearchSuggestionsShownFirst() {
// Clear the pref.
Services.prefs.clearUserPref(FIRST_PREF);
+ await checkbox.updateComplete;
// The checkbox should have become checked again.
Assert.ok(
@@ -72,7 +72,7 @@ add_task(async function openWithHistoryShownFirst() {
// Set the pref to show history first.
Services.prefs.setBoolPref(FIRST_PREF, false);
- // Open preferences. The checkbox should be unchecked.
+ // Open preferences. The checkbox should be unchecked.
await openPreferencesViaOpenPreferencesAPI("search", { leaveOpen: true });
let doc = gBrowser.selectedBrowser.contentDocument;
let checkbox = doc.getElementById(FIRST_CHECKBOX_ID);
@@ -80,8 +80,7 @@ add_task(async function openWithHistoryShownFirst() {
Assert.ok(!checkbox.disabled, "Checkbox should be enabled");
// Check the checkbox.
- checkbox.checked = true;
- checkbox.doCommand();
+ checkbox.click();
// Make sure the checkbox state didn't change.
Assert.ok(checkbox.checked, "Checkbox should remain checked");
@@ -95,6 +94,7 @@ add_task(async function openWithHistoryShownFirst() {
// Set the pref to false again.
Services.prefs.setBoolPref(FIRST_PREF, false);
+ await checkbox.updateComplete;
// The checkbox should have become unchecked again.
Assert.ok(
@@ -120,7 +120,7 @@ add_task(async function superprefInteraction() {
"Pref should be true initially"
);
- // Open preferences. The checkbox should be checked.
+ // Open preferences. The checkbox should be checked.
await openPreferencesViaOpenPreferencesAPI("search", { leaveOpen: true });
let doc = gBrowser.selectedBrowser.contentDocument;
let checkbox = doc.getElementById(FIRST_CHECKBOX_ID);
@@ -130,13 +130,14 @@ add_task(async function superprefInteraction() {
await gCUITestUtils.addSearchBar();
// Two superior prefs control the show-suggestion-first pref: URLBAR_PREF and
- // MAIN_PREF. Toggle each and make sure the show-suggestion-first checkbox
+ // MAIN_PREF. Toggle each and make sure the show-suggestion-first checkbox
// reacts appropriately.
for (let superiorPref of [URLBAR_PREF, MAIN_PREF]) {
info(`Testing superior pref ${superiorPref}`);
// Set the superior pref to false.
Services.prefs.setBoolPref(superiorPref, false);
+ await checkbox.updateComplete;
// The pref should remain true.
Assert.ok(
@@ -156,6 +157,7 @@ add_task(async function superprefInteraction() {
// Set the superior pref to true.
Services.prefs.setBoolPref(superiorPref, true);
+ await checkbox.updateComplete;
// The pref should remain true.
Assert.ok(
@@ -175,6 +177,7 @@ add_task(async function superprefInteraction() {
// Set the pref to false.
Services.prefs.setBoolPref(FIRST_PREF, false);
+ await checkbox.updateComplete;
// The checkbox should have become unchecked.
Assert.ok(
@@ -188,6 +191,7 @@ add_task(async function superprefInteraction() {
// Set the superior pref to false again.
Services.prefs.setBoolPref(superiorPref, false);
+ await checkbox.updateComplete;
// The pref should remain false.
Assert.ok(
@@ -207,6 +211,7 @@ add_task(async function superprefInteraction() {
// Set the superior pref to true.
Services.prefs.setBoolPref(superiorPref, true);
+ await checkbox.updateComplete;
// The pref should remain false.
Assert.ok(
@@ -226,6 +231,7 @@ add_task(async function superprefInteraction() {
// Finally, set the pref back to true.
Services.prefs.setBoolPref(FIRST_PREF, true);
+ await checkbox.updateComplete;
// The checkbox should have become checked.
Assert.ok(
diff --git a/browser/components/preferences/tests/browser_searchsuggestions.js b/browser/components/preferences/tests/browser_searchsuggestions.js
@@ -21,6 +21,10 @@ add_setup(async function () {
registerCleanupFunction(() => {
Services.prefs.setBoolPref(SUGGEST_PREF_NAME, originalSuggest);
Services.prefs.setBoolPref(
+ URLBAR_SUGGEST_PREF_NAME,
+ initialUrlbarSuggestValue
+ );
+ Services.prefs.setBoolPref(
PRIVATE_PREF_NAME,
initialSuggestionsInPrivateValue
);
@@ -37,11 +41,8 @@ async function toggleElement(
descPref,
shouldUpdatePref = false
) {
- await BrowserTestUtils.synthesizeMouseAtCenter(
- `#${id}`,
- {},
- gBrowser.selectedBrowser
- );
+ element.click();
+
is(
element.checked,
!initialCheckboxValue,
@@ -60,11 +61,8 @@ async function toggleElement(
} have updated the ${descPref} preference value`
);
- await BrowserTestUtils.synthesizeMouseAtCenter(
- `#${id}`,
- {},
- gBrowser.selectedBrowser
- );
+ element.click();
+
is(
element.checked,
initialCheckboxValue,
@@ -89,8 +87,10 @@ add_task(async function test_suggestions_start_enabled() {
await openPreferencesViaOpenPreferencesAPI("search", { leaveOpen: true });
let doc = gBrowser.selectedBrowser.contentDocument;
- let urlbarBox = doc.getElementById("urlBarSuggestion");
- let privateBox = doc.getElementById("showSearchSuggestionsPrivateWindows");
+ let urlbarBox = doc.getElementById("urlBarSuggestionCheckbox");
+ let privateBox = doc.getElementById(
+ "showSearchSuggestionsPrivateWindowsCheckbox"
+ );
ok(!urlbarBox.disabled, "Should have enabled the urlbar checkbox");
ok(
!privateBox.disabled,
@@ -130,10 +130,11 @@ add_task(async function test_suggestions_start_enabled() {
);
Services.prefs.setBoolPref(SUGGEST_PREF_NAME, false);
+ await urlbarBox.updateComplete;
ok(!urlbarBox.checked, "Should have unchecked the urlbar box");
ok(urlbarBox.disabled, "Should have disabled the urlbar box");
gCUITestUtils.removeSearchBar();
- ok(urlbarBox.hidden, "Should have hidden the urlbar box");
+ ok(!urlbarBox.visible, "Should have hidden the urlbar box");
ok(!privateBox.checked, "Should have unchecked the private suggestions box");
ok(privateBox.disabled, "Should have disabled the private suggestions box");
@@ -147,12 +148,15 @@ add_task(async function test_suggestions_start_disabled() {
await openPreferencesViaOpenPreferencesAPI("search", { leaveOpen: true });
let doc = gBrowser.selectedBrowser.contentDocument;
- let urlbarBox = doc.getElementById("urlBarSuggestion");
+ let urlbarBox = doc.getElementById("urlBarSuggestionCheckbox");
ok(urlbarBox.disabled, "Should have the urlbar box disabled");
- let privateBox = doc.getElementById("showSearchSuggestionsPrivateWindows");
+ let privateBox = doc.getElementById(
+ "showSearchSuggestionsPrivateWindowsCheckbox"
+ );
ok(privateBox.disabled, "Should have the private suggestions box disabled");
Services.prefs.setBoolPref(SUGGEST_PREF_NAME, true);
+ await urlbarBox.updateComplete;
ok(!urlbarBox.disabled, "Should have enabled the urlbar box");
ok(!privateBox.disabled, "Should have enabled the private suggestions box");
@@ -209,6 +213,7 @@ add_task(async function test_sync_search_suggestions_prefs() {
for (let urlbarSuggestsState of urlbarSuggestsPref) {
Services.prefs.setBoolPref(SUGGEST_PREF_NAME, suggestState);
Services.prefs.setBoolPref(URLBAR_SUGGEST_PREF_NAME, urlbarSuggestsState);
+ await suggestionsInSearchFieldsCheckbox.updateComplete;
if (suggestState && urlbarSuggestsState) {
ok(
diff --git a/browser/components/preferences/tests/browser_trendingsuggestions.js b/browser/components/preferences/tests/browser_trendingsuggestions.js
@@ -9,7 +9,7 @@ const MAIN_PREF = "browser.search.suggest.enabled";
const URLBAR_PREF = "browser.urlbar.suggest.searches";
const TRENDING_PREF = "browser.urlbar.trending.featureGate";
-const TRENDING_CHECKBOX_ID = "showTrendingSuggestions";
+const TRENDING_CHECKBOX_ID = "showTrendingSuggestionsCheckbox";
const SUGGESTIONED_CHECKBOX_ID = "suggestionsInSearchFieldsCheckbox";
SearchTestUtils.init(this);
@@ -48,8 +48,7 @@ add_task(async function testSuggestionsDisabled() {
Assert.ok(!trendingCheckbox.disabled, "Checkbox should not be disabled");
// Disable search suggestions.
- suggestionsCheckbox.checked = false;
- suggestionsCheckbox.doCommand();
+ suggestionsCheckbox.click();
await BrowserTestUtils.waitForCondition(
() => trendingCheckbox.disabled,
diff --git a/browser/locales/en-US/browser/preferences/preferences.ftl b/browser/locales/en-US/browser/preferences/preferences.ftl
@@ -901,8 +901,8 @@ search-separate-default-engine-2 =
search-separate-default-engine-dropdown =
.aria-label = Default search engine in private windows
-search-suggestions-header = Search Suggestions
-search-suggestions-desc = Choose how suggestions from search engines appear.
+search-suggestions-header-2 =
+ .label = Search engine suggestions
search-show-suggestions-option =
.label = Show search suggestions
@@ -915,15 +915,16 @@ search-show-suggestions-url-bar-option =
# This string describes what the user will observe when the system
# prioritizes search suggestions over browsing history in the results
# that extend down from the address bar. In the original English string,
-# "ahead" refers to location (appearing most proximate to), not time
+# "before" refers to location (appearing most proximate to), not time
# (appearing before).
-search-show-suggestions-above-history-option =
- .label = Show search suggestions ahead of browsing history in address bar results
+search-show-suggestions-above-history-option-2 =
+ .label = Show search suggestions before browsing history in address bar results
-search-show-suggestions-private-windows =
- .label = Show search suggestions in Private Windows
+search-show-suggestions-private-windows-2 =
+ .label = Search suggestions in private windows
-search-suggestions-cant-show = Search suggestions will not be shown in location bar results because you have configured { -brand-short-name } to never remember history.
+search-suggestions-cant-show-2 =
+ .message = Search suggestions will not be shown in location bar results because you have configured { -brand-short-name } to never remember history.
search-one-click-header2 = Search Shortcuts
@@ -1519,11 +1520,11 @@ addressbar-locbar-engines-option-1 =
addressbar-locbar-quickactions-option =
.label = Quick actions
.accesskey = Q
-addressbar-locbar-showrecentsearches-option =
- .label = Show recent searches
+addressbar-locbar-showrecentsearches-option-2 =
+ .label = Recent searches
.accesskey = r
-addressbar-locbar-showtrendingsuggestions-option =
- .label = Show trending search suggestions
+addressbar-locbar-showtrendingsuggestions-option-2 =
+ .label = Trending search suggestions
.accesskey = t
# Toggles whether suggestions are obtained from Firefox Suggest or not (local or online).
diff --git a/python/l10n/fluent_migrations/bug_1972069_search_suggestions.py b/python/l10n/fluent_migrations/bug_1972069_search_suggestions.py
@@ -0,0 +1,22 @@
+# Any copyright is dedicated to the Public Domain.
+# http://creativecommons.org/publicdomain/zero/1.0/
+
+from fluent.migrate.helpers import transforms_from
+
+
+def migrate(ctx):
+ """Bug 1972069 - Convert search engine suggestions section of search settings to config-based prefs, part {index}."""
+
+ target = "browser/browser/preferences/preferences.ftl"
+
+ ctx.add_transforms(
+ target,
+ target,
+ transforms_from(
+ """
+search-suggestions-cant-show-2 =
+ .message = {COPY_PATTERN(from_path, "search-suggestions-cant-show.message")}
+""",
+ from_path=target,
+ ),
+ )