commit aeb9e95ec41054e480a2b3056b3f42046677656f
parent 4ebde477b91ca17bde6837c052f3fbd00828ce30
Author: Mark Banner <standard8@mozilla.com>
Date: Tue, 28 Oct 2025 10:13:28 +0000
Bug 1995577 - Update the settings UI for the new browser.urlbar.suggest.quicksuggest.all pref. r=adw,fluent-reviewers,mstriemer,bolsson
Differential Revision: https://phabricator.services.mozilla.com/D270007
Diffstat:
7 files changed, 161 insertions(+), 31 deletions(-)
diff --git a/browser/components/enterprisepolicies/Policies.sys.mjs b/browser/components/enterprisepolicies/Policies.sys.mjs
@@ -1629,7 +1629,7 @@ export var Policies = {
await lazy.QuickSuggest.initPromise;
if ("WebSuggestions" in param) {
PoliciesUtils.setDefaultPref(
- "browser.urlbar.suggest.quicksuggest.nonsponsored",
+ "browser.urlbar.suggest.quicksuggest.all",
param.WebSuggestions,
param.Locked
);
diff --git a/browser/components/enterprisepolicies/tests/browser/browser_policy_firefoxsuggest.js b/browser/components/enterprisepolicies/tests/browser/browser_policy_firefoxsuggest.js
@@ -19,10 +19,9 @@ add_task(async function test_firefox_suggest_with_policy() {
"about:preferences#search",
async browser => {
is(
- browser.contentDocument.getElementById("firefoxSuggestNonsponsored")
- .checked,
+ browser.contentDocument.getElementById("firefoxSuggestAll").checked,
false,
- "Web suggestions is disabled"
+ "All suggestions are turned off"
);
is(
browser.contentDocument.getElementById("firefoxSuggestSponsored")
@@ -38,10 +37,9 @@ add_task(async function test_firefox_suggest_with_policy() {
"Suggest online checkbox is checked"
);
is(
- browser.contentDocument.getElementById("firefoxSuggestNonsponsored")
- .disabled,
+ browser.contentDocument.getElementById("firefoxSuggestAll").disabled,
true,
- "Web suggestions is disabled"
+ "All suggestions checkbox is disabled"
);
is(
browser.contentDocument.getElementById("firefoxSuggestSponsored")
diff --git a/browser/components/preferences/search.inc.xhtml b/browser/components/preferences/search.inc.xhtml
@@ -109,30 +109,32 @@
/>
</hbox>
<vbox id="firefoxSuggestContainer" hidden="true">
- <checkbox id="firefoxSuggestNonsponsored"
- data-l10n-id="addressbar-locbar-suggest-nonsponsored-option"
- preference="browser.urlbar.suggest.quicksuggest.nonsponsored"
+ <checkbox id="firefoxSuggestAll"
+ data-l10n-id="addressbar-locbar-suggest-all-option"
+ preference="browser.urlbar.suggest.quicksuggest.all"
/>
<description class="indent tip-caption"
- data-l10n-id="addressbar-locbar-suggest-nonsponsored-desc"
+ data-l10n-id="addressbar-locbar-suggest-all-option-desc"
/>
- <checkbox id="firefoxSuggestSponsored"
- data-l10n-id="addressbar-locbar-suggest-sponsored-option"
- preference="browser.urlbar.suggest.quicksuggest.sponsored"
- />
- <description class="indent tip-caption"
- data-l10n-id="addressbar-locbar-suggest-sponsored-desc"
- />
- <hbox id="firefoxSuggestOnlineBox" align="center">
- <checkbox id="firefoxSuggestOnlineEnabledToggle"
- class="tail-with-learn-more"
- data-l10n-id="addressbar-firefox-suggest-online"
- preference="browser.urlbar.quicksuggest.online.enabled" />
- <html:a is="moz-support-link"
- data-l10n-id="addressbar-quickactions-learn-more"
- support-page="firefox-suggest#w_what-setting-is-opt-in"
+ <vbox class="indent">
+ <checkbox id="firefoxSuggestSponsored"
+ data-l10n-id="addressbar-locbar-suggest-sponsored-option"
+ preference="browser.urlbar.suggest.quicksuggest.sponsored"
/>
- </hbox>
+ <description class="indent tip-caption"
+ data-l10n-id="addressbar-locbar-suggest-sponsored-desc"
+ />
+ <hbox id="firefoxSuggestOnlineBox" align="center">
+ <checkbox id="firefoxSuggestOnlineEnabledToggle"
+ class="tail-with-learn-more"
+ data-l10n-id="addressbar-firefox-suggest-online"
+ preference="browser.urlbar.quicksuggest.online.enabled" />
+ <html:a is="moz-support-link"
+ data-l10n-id="addressbar-quickactions-learn-more"
+ support-page="firefox-suggest#w_what-setting-is-opt-in"
+ />
+ </hbox>
+ </vbox>
<hbox id="dismissedSuggestions" align="center">
<vbox flex="1">
<label data-l10n-id="addressbar-dismissed-suggestions-label"/>
diff --git a/browser/components/preferences/search.js b/browser/components/preferences/search.js
@@ -39,7 +39,7 @@ Preferences.addAll([
{ id: "browser.urlbar.suggest.openpage", type: "bool" },
{ id: "browser.urlbar.suggest.topsites", type: "bool" },
{ id: "browser.urlbar.suggest.engines", type: "bool" },
- { id: "browser.urlbar.suggest.quicksuggest.nonsponsored", type: "bool" },
+ { id: "browser.urlbar.suggest.quicksuggest.all", type: "bool" },
{ id: "browser.urlbar.suggest.quicksuggest.sponsored", type: "bool" },
{ id: "browser.urlbar.quicksuggest.online.enabled", type: "bool" },
]);
@@ -138,6 +138,11 @@ var gSearchPane = {
privateSuggestsPref.value = privateWindowCheckbox.checked;
});
+ Preferences.addSyncFromPrefListener(
+ document.getElementById("firefoxSuggestAll"),
+ this._onFirefoxSuggestAllChange.bind(this)
+ );
+
setEventListener(
"browserSeparateDefaultEngine",
"command",
@@ -216,6 +221,17 @@ var gSearchPane = {
vbox.hidden = !separateEnabled || !separateDefault;
},
+ _onFirefoxSuggestAllChange() {
+ var prefValue = Preferences.get(
+ "browser.urlbar.suggest.quicksuggest.all"
+ ).value;
+ document.getElementById("firefoxSuggestSponsored").disabled = !prefValue;
+ document.getElementById("firefoxSuggestOnlineEnabledToggle").disabled =
+ !prefValue;
+ // Don't override pref value in the UI.
+ return undefined;
+ },
+
_onBrowserSeparateDefaultEngineChange(event) {
this._separatePrivateDefaultPref.value = !event.target.checked;
},
diff --git a/browser/components/preferences/tests/browser_search_firefoxSuggest.js b/browser/components/preferences/tests/browser_search_firefoxSuggest.js
@@ -210,6 +210,96 @@ add_task(async function initiallyEnabled_settingsUiOfflineOnly() {
});
});
+add_task(async function toggling_all_firefoxsuggest_disables_other_options() {
+ // Enable quicksuggest since it could be off by default depending on location.
+ await SpecialPowers.pushPrefEnv({
+ set: [["browser.urlbar.suggest.quicksuggest.all", true]],
+ });
+
+ await openPreferencesViaOpenPreferencesAPI("search", { leaveOpen: true });
+
+ let doc = gBrowser.selectedBrowser.contentDocument;
+ let allCheckbox = doc.getElementById("firefoxSuggestAll");
+ let sponsoredCheckbox = doc.getElementById("firefoxSuggestSponsored");
+ let onlineEnabledCheckbox = doc.getElementById(
+ "firefoxSuggestOnlineEnabledToggle"
+ );
+
+ // Initial state.
+ Assert.ok(
+ allCheckbox.checked,
+ "firefoxSuggestAll should initially be checked"
+ );
+ Assert.ok(
+ !sponsoredCheckbox.disabled,
+ "sponsoredCheckbox should initially be enabled"
+ );
+ Assert.ok(
+ !onlineEnabledCheckbox.disabled,
+ "onlineEnabledCheckbox should initially be enabled"
+ );
+
+ allCheckbox.click();
+
+ Assert.ok(!allCheckbox.checked, "firefoxSuggestAll should now be unchecked");
+ Assert.ok(sponsoredCheckbox.disabled, "sponsoredCheckbox should be disabled");
+ Assert.ok(
+ onlineEnabledCheckbox.disabled,
+ "onlineEnabledCheckbox should be disabled"
+ );
+
+ allCheckbox.click();
+
+ Assert.ok(allCheckbox.checked, "firefoxSuggestAll should be checked");
+ Assert.ok(
+ !sponsoredCheckbox.disabled,
+ "sponsoredCheckbox should be enabled again"
+ );
+ Assert.ok(
+ !onlineEnabledCheckbox.disabled,
+ "onlineEnabledCheckbox should be enabled again"
+ );
+
+ gBrowser.removeCurrentTab();
+});
+
+add_task(
+ async function all_firefoxsuggest_disabled_disables_other_options_on_open() {
+ // Disable the "all" preference and enable the others before opening settings.
+ await SpecialPowers.pushPrefEnv({
+ set: [
+ ["browser.urlbar.suggest.quicksuggest.all", false],
+ ["browser.urlbar.suggest.quicksuggest.sponsored", true],
+ ["browser.urlbar.quicksuggest.online.enabled", true],
+ ],
+ });
+
+ await openPreferencesViaOpenPreferencesAPI("search", { leaveOpen: true });
+
+ let doc = gBrowser.selectedBrowser.contentDocument;
+ let allCheckbox = doc.getElementById("firefoxSuggestAll");
+ let sponsoredCheckbox = doc.getElementById("firefoxSuggestSponsored");
+ let onlineEnabledCheckbox = doc.getElementById(
+ "firefoxSuggestOnlineEnabledToggle"
+ );
+
+ // Initial state.
+ Assert.ok(!allCheckbox.checked, "firefoxSuggestAll should not be checked");
+ Assert.ok(
+ sponsoredCheckbox.disabled,
+ "sponsoredCheckbox should initially be disabled"
+ );
+ Assert.ok(
+ onlineEnabledCheckbox.disabled,
+ "onlineEnabledCheckbox should initially be disabled"
+ );
+
+ gBrowser.removeCurrentTab();
+
+ await SpecialPowers.popPrefEnv();
+ }
+);
+
// Tests the "Restore" button for dismissed suggestions.
add_task(async function restoreDismissedSuggestions() {
// Start with no dismissed suggestions.
diff --git a/browser/locales/en-US/browser/preferences/preferences.ftl b/browser/locales/en-US/browser/preferences/preferences.ftl
@@ -1341,10 +1341,10 @@ addressbar-locbar-showtrendingsuggestions-option =
.label = Show trending search suggestions
.accesskey = t
-# Nonsponsored suggestions refers to Firefox Suggest suggestions like Wikipedia.
-addressbar-locbar-suggest-nonsponsored-option =
+# Toggles whether suggestions are obtained from Firefox Suggest or not (local or online).
+addressbar-locbar-suggest-all-option =
.label = Suggestions from { -brand-short-name }
-addressbar-locbar-suggest-nonsponsored-desc = Get suggestions from the web related to your search.
+addressbar-locbar-suggest-all-option-desc = Get suggestions from the web related to your search.
addressbar-locbar-suggest-sponsored-option =
.label = Suggestions from sponsors
diff --git a/python/l10n/fluent_migrations/bug_1995577_rename_preferences_addressbar_suggest_all.py b/python/l10n/fluent_migrations/bug_1995577_rename_preferences_addressbar_suggest_all.py
@@ -0,0 +1,24 @@
+# Any copyright is dedicated to the Public Domain.
+# http://creativecommons.org/publicdomain/zero/1.0/
+
+from fluent.migrate import COPY_PATTERN
+from fluent.migrate.helpers import transforms_from
+
+
+def migrate(ctx):
+ """Bug 1995577 - Update the settings UI for the new `browser.urlbar.suggest.quicksuggest.all` pref, part {index}."""
+ source = "browser/browser/preferences/preferences.ftl"
+ target = source
+
+ ctx.add_transforms(
+ target,
+ source,
+ transforms_from(
+ """
+addressbar-locbar-suggest-all-option =
+ .label = {COPY_PATTERN(from_path, "addressbar-locbar-suggest-nonsponsored-option.label")}
+addressbar-locbar-suggest-all-option-desc = {COPY_PATTERN(from_path, "addressbar-locbar-suggest-nonsponsored-desc")}
+""",
+ from_path=source,
+ ),
+ )