commit eac139398c374e80e8c82ae73cde765d5a64a869 parent 3d9885918ecd02ba6a7837e45e21ca50e33caea5 Author: Stephanie Cunnane <scunnane@mozilla.com> Date: Tue, 23 Dec 2025 17:49:19 +0000 Bug 1972072 - Convert Address Bar - Firefox Suggest section of search settings to config-based prefs. r=Standard8,fluent-reviewers,desktop-theme-reviewers,bolsson,hjones Differential Revision: https://phabricator.services.mozilla.com/D274789 Diffstat:
11 files changed, 392 insertions(+), 361 deletions(-)
diff --git a/browser/components/preferences/main.js b/browser/components/preferences/main.js @@ -4151,6 +4151,88 @@ SettingGroupManager.registerGroups({ }, ], }, + firefoxSuggest: { + id: "locationBarGroup", + items: [ + { + id: "locationBarGroupHeader", + l10nId: "addressbar-header-1", + supportPage: "firefox-suggest", + control: "moz-fieldset", + controlAttrs: { + headinglevel: 2, + }, + items: [ + { + id: "historySuggestion", + l10nId: "addressbar-locbar-history-option", + }, + { + id: "bookmarkSuggestion", + l10nId: "addressbar-locbar-bookmarks-option", + }, + { + id: "clipboardSuggestion", + l10nId: "addressbar-locbar-clipboard-option", + }, + { + id: "openpageSuggestion", + l10nId: "addressbar-locbar-openpage-option", + }, + { + id: "topSitesSuggestion", + l10nId: "addressbar-locbar-shortcuts-option", + }, + { + id: "enableRecentSearches", + l10nId: "addressbar-locbar-showrecentsearches-option-2", + }, + { + id: "enginesSuggestion", + l10nId: "addressbar-locbar-engines-option-1", + }, + { + id: "enableQuickActions", + l10nId: "addressbar-locbar-quickactions-option", + supportPage: "quick-actions-firefox-search-bar", + }, + { + id: "firefoxSuggestAll", + l10nId: "addressbar-locbar-suggest-all-option-2", + items: [ + { + id: "firefoxSuggestSponsored", + l10nId: "addressbar-locbar-suggest-sponsored-option-2", + }, + { + id: "firefoxSuggestOnlineEnabledToggle", + l10nId: "addressbar-firefox-suggest-online", + supportPage: "firefox-suggest", + subcategory: "w_what-is-firefox-suggest", + }, + ], + }, + { + id: "dismissedSuggestionsDescription", + l10nId: "addressbar-dismissed-suggestions-label-2", + control: "moz-fieldset", + controlAttrs: { + headinglevel: 3, + }, + items: [ + { + id: "restoreDismissedSuggestions", + l10nId: "addressbar-restore-dismissed-suggestions-button-2", + control: "moz-button", + iconSrc: + "chrome://global/skin/icons/arrow-counterclockwise-16.svg", + }, + ], + }, + ], + }, + ], + }, }); /** diff --git a/browser/components/preferences/preferences.js b/browser/components/preferences/preferences.js @@ -99,7 +99,6 @@ ChromeUtils.defineESModuleGetters(this, { NimbusFeatures: "resource://nimbus/ExperimentAPI.sys.mjs", OSKeyStore: "resource://gre/modules/OSKeyStore.sys.mjs", PlacesUtils: "resource://gre/modules/PlacesUtils.sys.mjs", - QuickSuggest: "moz-src:///browser/components/urlbar/QuickSuggest.sys.mjs", Region: "resource://gre/modules/Region.sys.mjs", SelectionChangedMenulist: "resource:///modules/SelectionChangedMenulist.sys.mjs", @@ -108,7 +107,6 @@ ChromeUtils.defineESModuleGetters(this, { TransientPrefs: "resource:///modules/TransientPrefs.sys.mjs", UIState: "resource://services-sync/UIState.sys.mjs", UpdateUtils: "resource://gre/modules/UpdateUtils.sys.mjs", - UrlbarPrefs: "moz-src:///browser/components/urlbar/UrlbarPrefs.sys.mjs", UrlbarUtils: "moz-src:///browser/components/urlbar/UrlbarUtils.sys.mjs", }); diff --git a/browser/components/preferences/privacy.js b/browser/components/preferences/privacy.js @@ -268,10 +268,6 @@ Preferences.addAll([ // Windows SSO { id: "network.http.windows-sso.enabled", type: "bool" }, - // Quick Actions - { id: "browser.urlbar.quickactions.showPrefs", type: "bool" }, - { id: "browser.urlbar.suggest.quickactions", type: "bool" }, - // Cookie Banner Handling { id: "cookiebanners.ui.desktop.enabled", type: "bool" }, { id: "cookiebanners.service.mode.privateBrowsing", type: "int" }, diff --git a/browser/components/preferences/search.inc.xhtml b/browser/components/preferences/search.inc.xhtml @@ -22,95 +22,8 @@ <html:setting-group groupid="searchSuggestions" /> </groupbox> - <!-- Address Bar --> - <groupbox id="locationBarGroup" - data-category="paneSearch" - hidden="true" - data-subcategory="locationBar"> - <label><html:h2 id="locationBarGroupHeader" data-l10n-id="addressbar-header"/></label> - <description flex="1"> - <html:span id="locationBarSuggestionLabel" - class="description-deemphasized" - data-l10n-id="addressbar-suggest-1" - /> - <html:a hidden="true" - is="moz-support-link" - id="firefoxSuggestLearnMore" - class="learnMore firefoxSuggestLearnMore" - data-l10n-id="addressbar-locbar-firefox-suggest-learn-more" - support-page="firefox-suggest" - /> - </description> - <checkbox id="historySuggestion" data-l10n-id="addressbar-locbar-history-option" - preference="browser.urlbar.suggest.history"/> - <checkbox id="bookmarkSuggestion" data-l10n-id="addressbar-locbar-bookmarks-option" - preference="browser.urlbar.suggest.bookmark"/> - <checkbox id="clipboardSuggestion" data-l10n-id="addressbar-locbar-clipboard-option" hidden="true" - preference="browser.urlbar.suggest.clipboard"/> - <checkbox id="openpageSuggestion" data-l10n-id="addressbar-locbar-openpage-option" - preference="browser.urlbar.suggest.openpage"/> - <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"> - <checkbox id="enableQuickActions" - class="tail-with-learn-more" - data-l10n-id="addressbar-locbar-quickactions-option" - preference="browser.urlbar.suggest.quickactions" /> - <html:a is="moz-support-link" - id="quickActionsLink" - data-l10n-id="addressbar-quickactions-learn-more" - support-page="quick-actions-firefox-search-bar" - /> - </hbox> - <vbox id="firefoxSuggestContainer" hidden="true"> - <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-all-option-desc" - /> - <vbox class="indent"> - <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 id="firefoxSuggestOnlineEnabledLearnMore" - is="moz-support-link" - data-l10n-id="addressbar-quickactions-learn-more" - support-page="firefox-suggest#w_what-is-firefox-suggest" - /> - </hbox> - </vbox> - <hbox id="dismissedSuggestions" align="center"> - <vbox flex="1"> - <label data-l10n-id="addressbar-dismissed-suggestions-label"/> - <description id="dismissedSuggestionsDescription" - class="tip-caption" - data-l10n-id="addressbar-restore-dismissed-suggestions-description" - /> - </vbox> - <button id="restoreDismissedSuggestions" - is="highlightable-button" - class="accessory-button" - data-l10n-id="addressbar-restore-dismissed-suggestions-button" - aria-describedby="dismissedSuggestionsDescription"/> - </hbox> - </vbox> - </groupbox> + <!-- Firefox Suggest / Address Bar --> + <html:setting-group groupid="firefoxSuggest" data-category="paneSearch" hidden="true" data-subcategory="locationBar" /> <!-- Search Shortcuts --> <groupbox id="oneClickSearchProvidersGroup" data-category="paneSearch" hidden="true"> diff --git a/browser/components/preferences/search.js b/browser/components/preferences/search.js @@ -12,8 +12,10 @@ ChromeUtils.defineESModuleGetters(lazy, { "moz-src:///toolkit/components/search/AddonSearchEngine.sys.mjs", CustomizableUI: "moz-src:///browser/components/customizableui/CustomizableUI.sys.mjs", + QuickSuggest: "moz-src:///browser/components/urlbar/QuickSuggest.sys.mjs", SearchUIUtils: "moz-src:///browser/components/search/SearchUIUtils.sys.mjs", SearchUtils: "moz-src:///toolkit/components/search/SearchUtils.sys.mjs", + UrlbarPrefs: "moz-src:///browser/components/urlbar/UrlbarPrefs.sys.mjs", UserSearchEngine: "moz-src:///toolkit/components/search/UserSearchEngine.sys.mjs", }); @@ -36,10 +38,15 @@ Preferences.addAll([ // Suggest Section. { id: "browser.urlbar.suggest.bookmark", type: "bool" }, { id: "browser.urlbar.suggest.clipboard", type: "bool" }, + { id: "browser.urlbar.clipboard.featureGate", type: "bool" }, { id: "browser.urlbar.suggest.history", type: "bool" }, { id: "browser.urlbar.suggest.openpage", type: "bool" }, { id: "browser.urlbar.suggest.topsites", type: "bool" }, { id: "browser.urlbar.suggest.engines", type: "bool" }, + { id: "browser.urlbar.quickactions.showPrefs", type: "bool" }, + { id: "browser.urlbar.suggest.quickactions", type: "bool" }, + { id: "browser.urlbar.quicksuggest.settingsUi", type: "int" }, + { id: "browser.urlbar.quicksuggest.enabled", 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" }, @@ -390,6 +397,172 @@ Preferences.addSetting({ }, }); +Preferences.addSetting({ + id: "quickSuggestEnabledPref", + pref: "browser.urlbar.quicksuggest.enabled", +}); + +Preferences.addSetting({ + id: "quickSuggestSettingsUiPref", + pref: "browser.urlbar.quicksuggest.settingsUi", +}); + +Preferences.addSetting({ + id: "nimbusListener", + setup(onChange) { + NimbusFeatures.urlbar.onUpdate(onChange); + return () => NimbusFeatures.urlbar.offUpdate(onChange); + }, +}); + +Preferences.addSetting({ + id: "locationBarGroupHeader", + deps: [ + "quickSuggestEnabledPref", + "quickSuggestSettingsUiPref", + "nimbusListener", + ], + getControlConfig(config) { + let l10nId = + lazy.UrlbarPrefs.get("quickSuggestEnabled") && + lazy.UrlbarPrefs.get("quickSuggestSettingsUi") != + lazy.QuickSuggest.SETTINGS_UI.NONE + ? "addressbar-header-firefox-suggest-2" + : "addressbar-header-1"; + + return { ...config, l10nId }; + }, +}); + +Preferences.addSetting({ + id: "historySuggestion", + pref: "browser.urlbar.suggest.history", +}); + +Preferences.addSetting({ + id: "bookmarkSuggestion", + pref: "browser.urlbar.suggest.bookmark", +}); + +Preferences.addSetting({ + id: "clipboardFeaturegate", + pref: "browser.urlbar.clipboard.featureGate", +}); + +Preferences.addSetting({ + id: "clipboardSuggestion", + pref: "browser.urlbar.suggest.clipboard", + deps: ["clipboardFeaturegate"], + visible: deps => { + return deps.clipboardFeaturegate.value; + }, +}); + +Preferences.addSetting({ + id: "openpageSuggestion", + pref: "browser.urlbar.suggest.openpage", +}); + +Preferences.addSetting({ + id: "topSitesSuggestion", + pref: "browser.urlbar.suggest.topsites", +}); + +Preferences.addSetting({ + id: "enableRecentSearchesFeatureGate", + pref: "browser.urlbar.recentsearches.featureGate", +}); + +Preferences.addSetting({ + id: "enableRecentSearches", + pref: "browser.urlbar.suggest.recentsearches", + deps: ["enableRecentSearchesFeatureGate"], + visible: deps => { + return deps.enableRecentSearchesFeatureGate.value; + }, +}); + +Preferences.addSetting({ + id: "enginesSuggestion", + pref: "browser.urlbar.suggest.engines", +}); + +Preferences.addSetting({ + id: "quickActionsShowPrefs", + pref: "browser.urlbar.quickactions.showPrefs", +}); + +Preferences.addSetting({ + id: "enableQuickActions", + pref: "browser.urlbar.suggest.quickactions", + deps: ["quickActionsShowPrefs", "scotchBonnetEnabled"], + visible: deps => { + return deps.quickActionsShowPrefs.value || deps.scotchBonnetEnabled.value; + }, +}); + +Preferences.addSetting({ + id: "firefoxSuggestAll", + pref: "browser.urlbar.suggest.quicksuggest.all", +}); + +Preferences.addSetting({ + id: "firefoxSuggestSponsored", + pref: "browser.urlbar.suggest.quicksuggest.sponsored", + deps: ["firefoxSuggestAll"], + disabled: deps => { + return !deps.firefoxSuggestAll.value; + }, +}); + +Preferences.addSetting({ + id: "firefoxSuggestOnlineEnabledToggle", + pref: "browser.urlbar.quicksuggest.online.enabled", + deps: [ + "firefoxSuggestAll", + "quickSuggestEnabledPref", + "quickSuggestSettingsUiPref", + "nimbusListener", + ], + visible: () => { + return ( + lazy.UrlbarPrefs.get("quickSuggestSettingsUi") == + lazy.QuickSuggest.SETTINGS_UI.FULL + ); + }, + disabled: deps => { + return !deps.firefoxSuggestAll.value; + }, +}); + +Preferences.addSetting( + class extends Preferences.AsyncSetting { + static id = "restoreDismissedSuggestions"; + setup() { + Services.obs.addObserver( + this.emitChange, + "quicksuggest-dismissals-changed" + ); + return () => { + Services.obs.removeObserver( + this.emitChange, + "quicksuggest-dismissals-changed" + ); + }; + } + async disabled() { + return !(await lazy.QuickSuggest.canClearDismissedSuggestions()); + } + onUserClick() { + lazy.QuickSuggest.clearDismissedSuggestions(); + } + } +); + +Preferences.addSetting({ + id: "dismissedSuggestionsDescription", +}); + const ENGINE_FLAVOR = "text/x-moz-search-engine"; const SEARCH_TYPE = "default_search"; const SEARCH_KEY = "defaultSearch"; @@ -402,6 +575,7 @@ var gSearchPane = { init() { initSettingGroup("defaultEngine"); initSettingGroup("searchSuggestions"); + initSettingGroup("firefoxSuggest"); this._engineStore = new EngineStore(); gEngineView = new EngineView(this._engineStore); @@ -421,153 +595,13 @@ var gSearchPane = { Services.obs.addObserver(this, "browser-search-engine-modified"); Services.obs.addObserver(this, "intl:app-locales-changed"); - Services.obs.addObserver(this, "quicksuggest-dismissals-changed"); window.addEventListener("unload", () => { Services.obs.removeObserver(this, "browser-search-engine-modified"); Services.obs.removeObserver(this, "intl:app-locales-changed"); - Services.obs.removeObserver(this, "quicksuggest-dismissals-changed"); }); - - Preferences.addSyncFromPrefListener( - document.getElementById("firefoxSuggestAll"), - this._onFirefoxSuggestAllChange.bind(this) - ); - - this._initRecentSeachesCheckbox(); - this._initAddressBar(); - }, - - _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; - }, - - _initRecentSeachesCheckbox() { - this._recentSearchesEnabledPref = Preferences.get( - "browser.urlbar.recentsearches.featureGate" - ); - let recentSearchesCheckBox = document.getElementById( - "enableRecentSearches" - ); - const listener = () => { - recentSearchesCheckBox.hidden = !this._recentSearchesEnabledPref.value; - }; - - this._recentSearchesEnabledPref.on("change", listener); - listener(); }, // ADDRESS BAR - - /** - * Initializes the address bar section. - */ - _initAddressBar() { - // Update the Firefox Suggest section when its Nimbus config changes. - let onNimbus = () => this._updateFirefoxSuggestSection(); - NimbusFeatures.urlbar.onUpdate(onNimbus); - window.addEventListener("unload", () => { - NimbusFeatures.urlbar.offUpdate(onNimbus); - }); - - document.getElementById("clipboardSuggestion").hidden = !UrlbarPrefs.get( - "clipboard.featureGate" - ); - - this._updateFirefoxSuggestSection(true); - this._initQuickActionsSection(); - }, - - /** - * Updates the Firefox Suggest section (in the address bar section) depending - * on whether the user is enrolled in a Firefox Suggest rollout. - * - * @param {boolean} [onInit] - * Pass true when calling this when initializing the pane. - */ - _updateFirefoxSuggestSection(onInit = false) { - let container = document.getElementById("firefoxSuggestContainer"); - - if ( - UrlbarPrefs.get("quickSuggestEnabled") && - UrlbarPrefs.get("quickSuggestSettingsUi") != QuickSuggest.SETTINGS_UI.NONE - ) { - // Update the l10n IDs of text elements. - let l10nIdByElementId = { - locationBarGroupHeader: "addressbar-header-firefox-suggest-1", - locationBarSuggestionLabel: "addressbar-suggest-firefox-suggest-1", - }; - for (let [elementId, l10nId] of Object.entries(l10nIdByElementId)) { - let element = document.getElementById(elementId); - element.dataset.l10nIdOriginal ??= element.dataset.l10nId; - element.dataset.l10nId = l10nId; - } - - // Update the learn more link in the section's description. - document - .getElementById("locationBarSuggestionLabel") - .classList.add("tail-with-learn-more"); - document.getElementById("firefoxSuggestLearnMore").hidden = false; - - document.getElementById("firefoxSuggestOnlineBox").hidden = - UrlbarPrefs.get("quickSuggestSettingsUi") != - QuickSuggest.SETTINGS_UI.FULL; - - this._updateDismissedSuggestionsStatus(); - setEventListener("restoreDismissedSuggestions", "command", () => - QuickSuggest.clearDismissedSuggestions() - ); - - container.hidden = false; - } else if (!onInit) { - // Firefox Suggest is not enabled. This is the default, so to avoid - // accidentally messing anything up, only modify the doc if we're being - // called due to a change in the rollout-enabled status (!onInit). - document - .getElementById("locationBarSuggestionLabel") - .classList.remove("tail-with-learn-more"); - document.getElementById("firefoxSuggestLearnMore").hidden = true; - container.hidden = true; - let elementIds = ["locationBarGroupHeader", "locationBarSuggestionLabel"]; - for (let id of elementIds) { - let element = document.getElementById(id); - if (element.dataset.l10nIdOriginal) { - document.l10n.setAttributes(element, element.dataset.l10nIdOriginal); - delete element.dataset.l10nIdOriginal; - } - } - } - }, - - _initQuickActionsSection() { - let showPref = Preferences.get("browser.urlbar.quickactions.showPrefs"); - let scotchBonnet = Preferences.get( - "browser.urlbar.scotchBonnet.enableOverride" - ); - let showQuickActionsGroup = () => { - document.getElementById("quickActionsBox").hidden = !( - showPref.value || scotchBonnet.value - ); - }; - showPref.on("change", showQuickActionsGroup); - showQuickActionsGroup(); - }, - - /** - * Enables/disables the "Restore" button for dismissed Firefox Suggest - * suggestions. - */ - async _updateDismissedSuggestionsStatus() { - document.getElementById("restoreDismissedSuggestions").disabled = - !(await QuickSuggest.canClearDismissedSuggestions()); - }, - handleEvent(aEvent) { if (aEvent.type != "command") { return; @@ -619,9 +653,6 @@ var gSearchPane = { } break; } - case "quicksuggest-dismissals-changed": - this._updateDismissedSuggestionsStatus(); - break; } }, @@ -968,7 +999,7 @@ class EngineView { this._engineList = document.getElementById("engineList"); this._engineList.view = this; - UrlbarPrefs.addObserver(this); + lazy.UrlbarPrefs.addObserver(this); aEngineStore.addListener(this); this.loadL10nNames(); @@ -1380,7 +1411,7 @@ class EngineView { // nsITreeView get rowCount() { let localModes = UrlbarUtils.LOCAL_SEARCH_MODES; - if (!UrlbarPrefs.get("scotchBonnet.enableOverride")) { + if (!lazy.UrlbarPrefs.get("scotchBonnet.enableOverride")) { localModes = localModes.filter( mode => mode.source != UrlbarUtils.RESULT_SOURCE.ACTIONS ); @@ -1412,7 +1443,9 @@ class EngineView { let shortcut = this._getLocalShortcut(index); if (shortcut) { if ( - UrlbarPrefs.getScotchBonnetPref("searchRestrictKeywords.featureGate") + lazy.UrlbarPrefs.getScotchBonnetPref( + "searchRestrictKeywords.featureGate" + ) ) { let keywords = this._localShortcutL10nNames .get(shortcut.source) @@ -1517,7 +1550,7 @@ class EngineView { if (column.id == "engineShown") { let shortcut = this._getLocalShortcut(index); if (shortcut) { - return UrlbarPrefs.get(shortcut.pref); + return lazy.UrlbarPrefs.get(shortcut.pref); } return !this._engineStore.engines[index].originalEngine.hideOneOffButton; } @@ -1539,7 +1572,7 @@ class EngineView { if (column.id == "engineShown") { let shortcut = this._getLocalShortcut(index); if (shortcut) { - UrlbarPrefs.set(shortcut.pref, value == "true"); + lazy.UrlbarPrefs.set(shortcut.pref, value == "true"); this.invalidate(); return; } diff --git a/browser/components/preferences/tests/browser_search_firefoxSuggest.js b/browser/components/preferences/tests/browser_search_firefoxSuggest.js @@ -9,50 +9,27 @@ ChromeUtils.defineESModuleGetters(this, { QuickSuggest: "moz-src:///browser/components/urlbar/QuickSuggest.sys.mjs", }); -const CONTAINER_ID = "firefoxSuggestContainer"; const ONLINE_ENABLED_TOGGLE_ID = "firefoxSuggestOnlineEnabledToggle"; -const ONLINE_ENABLED_LEARN_MORE_ID = "firefoxSuggestOnlineEnabledLearnMore"; -const LEARN_MORE_ID = "firefoxSuggestLearnMore"; const BUTTON_RESTORE_DISMISSED_ID = "restoreDismissedSuggestions"; // Maps `SETTINGS_UI` values to expected visibility state objects. See // `assertSuggestVisibility()` in `head.js` for info on the state objects. const EXPECTED = { [QuickSuggest.SETTINGS_UI.FULL]: { - [LEARN_MORE_ID]: { isVisible: true }, - [CONTAINER_ID]: { isVisible: true }, [ONLINE_ENABLED_TOGGLE_ID]: { isVisible: true }, - [ONLINE_ENABLED_LEARN_MORE_ID]: { isVisible: true }, locationBarGroupHeader: { isVisible: true, - l10nId: "addressbar-header-firefox-suggest-1", - }, - locationBarSuggestionLabel: { - isVisible: true, - l10nId: "addressbar-suggest-firefox-suggest-1", + l10nId: "addressbar-header-firefox-suggest-2", }, }, [QuickSuggest.SETTINGS_UI.NONE]: { - [LEARN_MORE_ID]: { isVisible: false }, - [CONTAINER_ID]: { isVisible: false }, - locationBarGroupHeader: { isVisible: true, l10nId: "addressbar-header" }, - locationBarSuggestionLabel: { - isVisible: true, - l10nId: "addressbar-suggest-1", - }, + locationBarGroupHeader: { isVisible: true, l10nId: "addressbar-header-1" }, }, [QuickSuggest.SETTINGS_UI.OFFLINE_ONLY]: { - [LEARN_MORE_ID]: { isVisible: true }, - [CONTAINER_ID]: { isVisible: true }, [ONLINE_ENABLED_TOGGLE_ID]: { isVisible: false }, - [ONLINE_ENABLED_LEARN_MORE_ID]: { isVisible: false }, locationBarGroupHeader: { isVisible: true, - l10nId: "addressbar-header-firefox-suggest-1", - }, - locationBarSuggestionLabel: { - isVisible: true, - l10nId: "addressbar-suggest-firefox-suggest-1", + l10nId: "addressbar-header-firefox-suggest-2", }, }, }; @@ -243,6 +220,7 @@ add_task(async function toggling_all_firefoxsuggest_disables_other_options() { ); allCheckbox.click(); + await allCheckbox.parentElement.updateComplete; Assert.ok(!allCheckbox.checked, "firefoxSuggestAll should now be unchecked"); Assert.ok(sponsoredCheckbox.disabled, "sponsoredCheckbox should be disabled"); @@ -252,6 +230,7 @@ add_task(async function toggling_all_firefoxsuggest_disables_other_options() { ); allCheckbox.click(); + await allCheckbox.parentElement.updateComplete; Assert.ok(allCheckbox.checked, "firefoxSuggestAll should be checked"); Assert.ok( diff --git a/browser/components/preferences/tests/browser_search_quickactions.js b/browser/components/preferences/tests/browser_search_quickactions.js @@ -26,14 +26,6 @@ add_setup(async function setup() { }); }); -async function isGroupHidden(tab) { - return SpecialPowers.spawn( - tab.linkedBrowser, - [], - async () => content.document.getElementById("quickActionsBox").hidden - ); -} - add_task(async function test_show_prefs() { Services.prefs.setBoolPref( "browser.urlbar.scotchBonnet.enableOverride", @@ -41,26 +33,35 @@ add_task(async function test_show_prefs() { ); Services.prefs.setBoolPref("browser.urlbar.quickactions.showPrefs", false); - let tab = await BrowserTestUtils.openNewForegroundTab( - gBrowser, - "about:preferences#search" - ); - + await openPreferencesViaOpenPreferencesAPI("search", { leaveOpen: true }); + let doc = gBrowser.selectedBrowser.contentDocument; + let quickActionsCheckbox = doc.getElementById("enableQuickActions"); Assert.ok( - await isGroupHidden(tab), - "The preferences are hidden when pref disabled" + !BrowserTestUtils.isVisible(quickActionsCheckbox), + "Quick actions checkbox should be hidden when both prefs are false" ); Services.prefs.setBoolPref("browser.urlbar.quickactions.showPrefs", true); + await quickActionsCheckbox.parentElement.updateComplete; + Assert.ok( + BrowserTestUtils.isVisible(quickActionsCheckbox), + "Quick actions checkbox should be shown again" + ); + Services.prefs.setBoolPref("browser.urlbar.quickactions.showPrefs", false); + Services.prefs.setBoolPref( + "browser.urlbar.scotchBonnet.enableOverride", + true + ); + await quickActionsCheckbox.parentElement.updateComplete; Assert.ok( - !(await isGroupHidden(tab)), - "The preferences are shown when pref enabled" + BrowserTestUtils.isVisible(quickActionsCheckbox), + "Quick actions checkbox should still be shown" ); Services.prefs.clearUserPref("browser.urlbar.scotchBonnet.enableOverride"); Services.prefs.clearUserPref("browser.urlbar.quickactions.showPrefs"); - await BrowserTestUtils.removeTab(tab); + gBrowser.removeCurrentTab(); }); async function testActionIsShown(window, name) { diff --git a/browser/components/preferences/widgets/setting-control/setting-control.css b/browser/components/preferences/widgets/setting-control/setting-control.css @@ -7,7 +7,7 @@ margin-block: var(--space-large); } -setting-control[hidden]:has(> moz-message-bar) { +setting-control[hidden]:has(> moz-message-bar):not([slot="nested"]) { display: block; margin-block-start: calc(-1 * var(--space-large)); } diff --git a/browser/locales/en-US/browser/preferences/preferences.ftl b/browser/locales/en-US/browser/preferences/preferences.ftl @@ -1024,6 +1024,72 @@ search-show-suggestions-private-windows-2 = 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. + +addressbar-header-1 = + .label = Address Bar + .description = Choose which suggestions display in your address bar + +# When Firefox Suggest is enabled, this replaces `addressbar-header-1`. +addressbar-header-firefox-suggest-2 = + .label = { -firefox-suggest-brand-name } + .description = Suggestions from { -brand-short-name } and our partners in your address bar. + +addressbar-locbar-history-option = + .label = Browsing history + .accesskey = h +addressbar-locbar-bookmarks-option = + .label = Bookmarks + .accesskey = k +addressbar-locbar-clipboard-option = + .label = Clipboard + .accesskey = C +addressbar-locbar-openpage-option = + .label = Open tabs + .accesskey = O +# Shortcuts refers to the shortcut tiles on the new tab page, previously known as top sites. Translation should be consistent. +addressbar-locbar-shortcuts-option = + .label = Shortcuts + .accesskey = S +addressbar-locbar-topsites-option = + .label = Top sites + .accesskey = T +addressbar-locbar-showrecentsearches-option-2 = + .label = Recent searches + .accesskey = r +addressbar-locbar-engines-option-1 = + .label = Suggest search engines to use + .accesskey = a +addressbar-locbar-quickactions-option = + .label = Quick actions + .accesskey = Q +addressbar-locbar-showtrendingsuggestions-option-2 = + .label = Trending search suggestions + .accesskey = t + +# Toggles whether suggestions are obtained from Firefox Suggest or not (local or online). +addressbar-locbar-suggest-all-option-2 = + .label = Suggestions from { -brand-short-name } + .description = Get suggestions from the web related to your search. + +addressbar-locbar-suggest-sponsored-option-2 = + .label = Suggestions from sponsors + .description = Support { -brand-short-name } with occasional sponsored suggestions. + +# This string is used for a checkbox in the settings UI that opts the +# user into "online" Firefox Suggest, allowing them to receive suggestions from +# Mozilla's Merino server. +# "Mozilla" is intentionally hardcoded to prevent forks from replacing it +# with their own vendor name, since the online suggest is created and maintained +# by Mozilla. +addressbar-firefox-suggest-online = + .label = Retrieve suggestions from Mozilla as you type + +addressbar-dismissed-suggestions-label-2 = + .label = Dismissed suggestions + .description = Restore dismissed suggestions from sponsors and { -brand-short-name }. +addressbar-restore-dismissed-suggestions-button-2 = + .label = Restore suggestions + search-one-click-header2 = Search Shortcuts search-one-click-desc = Choose the alternative search engines that appear below the address bar and search bar when you start to enter a keyword. @@ -1641,79 +1707,6 @@ cookie-banner-learn-more = Learn more cookie-banner-blocker-checkbox-label = .label = Automatically refuse cookie banners -## Privacy Section - Address Bar - -addressbar-header = Address Bar - -addressbar-suggest-1 = Choose which suggestions display in your address bar - -# When Firefox Suggest is enabled, this replaces `addressbar-header`. -addressbar-header-firefox-suggest-1 = { -firefox-suggest-brand-name } - -# When Firefox Suggest is enabled, this replaces `addressbar-suggest`. -addressbar-suggest-firefox-suggest-1 = Suggestions from { -brand-short-name } and our partners in your address bar. - -# When Firefox Suggest is enabled, a "Learn more" link appears at the end of -# `addressbar-suggest-firefox-suggest`. -addressbar-locbar-firefox-suggest-learn-more = Learn more - -addressbar-locbar-history-option = - .label = Browsing history - .accesskey = h -addressbar-locbar-bookmarks-option = - .label = Bookmarks - .accesskey = k -addressbar-locbar-clipboard-option = - .label = Clipboard - .accesskey = C -addressbar-locbar-openpage-option = - .label = Open tabs - .accesskey = O -# Shortcuts refers to the shortcut tiles on the new tab page, previously known as top sites. Translation should be consistent. -addressbar-locbar-shortcuts-option = - .label = Shortcuts - .accesskey = S -addressbar-locbar-topsites-option = - .label = Top sites - .accesskey = T -addressbar-locbar-engines-option-1 = - .label = Suggest search engines to use - .accesskey = a -addressbar-locbar-quickactions-option = - .label = Quick actions - .accesskey = Q -addressbar-locbar-showrecentsearches-option-2 = - .label = Recent searches - .accesskey = r -addressbar-locbar-showtrendingsuggestions-option-2 = - .label = Trending search suggestions - .accesskey = t - -# 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-all-option-desc = Get suggestions from the web related to your search. - -addressbar-locbar-suggest-sponsored-option = - .label = Suggestions from sponsors -addressbar-locbar-suggest-sponsored-desc = Support { -brand-short-name } with occasional sponsored suggestions. - -# This string is used for a checkbox in the settings UI that opts the -# user into "online" Firefox Suggest, allowing them to receive suggestions from -# Mozilla's Merino server. -# "Mozilla" is intentionally hardcoded to prevent forks from replacing it -# with their own vendor name, since the online suggest is created and maintained -# by Mozilla. -addressbar-firefox-suggest-online = - .label = Retrieve suggestions from Mozilla as you type - -addressbar-quickactions-learn-more = Learn more - -addressbar-dismissed-suggestions-label = Dismissed suggestions -addressbar-restore-dismissed-suggestions-description = Restore dismissed suggestions from sponsors and { -brand-short-name }. -addressbar-restore-dismissed-suggestions-button = - .label = Restore - ## Privacy Section - Content Blocking content-blocking-enhanced-tracking-protection = Enhanced Tracking Protection diff --git a/python/l10n/fluent_migrations/bug_1972072_address_bar_firefox_suggest.py b/python/l10n/fluent_migrations/bug_1972072_address_bar_firefox_suggest.py @@ -0,0 +1,35 @@ +# 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 1972072 - Convert Address Bar - Firefox Suggest to config-based prefs, part {index}.""" + + target = "browser/browser/preferences/preferences.ftl" + + ctx.add_transforms( + target, + target, + transforms_from( + """ +addressbar-header-1 = + .label = {COPY_PATTERN(from_path, "addressbar-header")} + .description = {COPY_PATTERN(from_path, "addressbar-suggest-1")} +addressbar-header-firefox-suggest-2 = + .label = {COPY_PATTERN(from_path, "addressbar-header-firefox-suggest-1")} + .description = {COPY_PATTERN(from_path, "addressbar-suggest-firefox-suggest-1")} +addressbar-locbar-suggest-all-option-2 = + .label = {COPY_PATTERN(from_path, "addressbar-locbar-suggest-all-option.label")} + .description = {COPY_PATTERN(from_path, "addressbar-locbar-suggest-all-option-desc")} +addressbar-locbar-suggest-sponsored-option-2 = + .label = {COPY_PATTERN(from_path, "addressbar-locbar-suggest-sponsored-option.label")} + .description = {COPY_PATTERN(from_path, "addressbar-locbar-suggest-sponsored-desc")} +addressbar-dismissed-suggestions-label-2 = + .label = {COPY_PATTERN(from_path, "addressbar-dismissed-suggestions-label")} + .description = {COPY_PATTERN(from_path, "addressbar-restore-dismissed-suggestions-description")} +""", + from_path=target, + ), + ) diff --git a/toolkit/themes/shared/desktop-jar.inc.mn b/toolkit/themes/shared/desktop-jar.inc.mn @@ -118,6 +118,7 @@ skin/classic/global/icons/trophy.svg (../../shared/icons/trophy.svg) skin/classic/global/icons/tab-notes-12.svg (../../shared/icons/tab-notes-12.svg) skin/classic/global/icons/update-icon.svg (../../shared/icons/update-icon.svg) + skin/classic/global/icons/arrow-counterclockwise-16.svg (../../shared/icons/arrow-counterclockwise-16.svg) skin/classic/global/icons/arrow-down-12.svg (../../shared/icons/arrow-down-12.svg) skin/classic/global/icons/arrow-down.svg (../../shared/icons/arrow-down.svg) skin/classic/global/icons/arrow-left-12.svg (../../shared/icons/arrow-left-12.svg)