зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1852051 - Remove the Search Bar from the toolbar for users who haven't used it in 120 days. r=dao,Gijs
Differential Revision: https://phabricator.services.mozilla.com/D195001
This commit is contained in:
Родитель
cef8996c0f
Коммит
c0ef1d2a55
|
@ -742,6 +742,10 @@ pref("browser.search.serpEventTelemetry.enabled", true);
|
|||
// Enables search SERP telemetry page categorization.
|
||||
pref("browser.search.serpEventTelemetryCategorization.enabled", false);
|
||||
|
||||
// Search Bar removal from the toolbar for users who haven’t used it in 120
|
||||
// days
|
||||
pref("browser.search.widget.removeAfterDaysUnused", 120);
|
||||
|
||||
// Enable new experimental shopping features. This is solely intended as a
|
||||
// rollout/"emergency stop" button - it will go away once the feature has
|
||||
// rolled out. There will be separate controls for user opt-in/opt-out.
|
||||
|
|
|
@ -31,6 +31,7 @@ export const SearchWidgetTracker = {
|
|||
Services.prefs.addObserver(PREF_NAME, () =>
|
||||
this.syncWidgetWithPreference()
|
||||
);
|
||||
this._updateSearchBarVisibilityBasedOnUsage();
|
||||
},
|
||||
|
||||
onWidgetAdded(widgetId, area) {
|
||||
|
@ -94,6 +95,23 @@ export const SearchWidgetTracker = {
|
|||
}
|
||||
},
|
||||
|
||||
_updateSearchBarVisibilityBasedOnUsage() {
|
||||
let searchBarLastUsed = Services.prefs.getStringPref(
|
||||
"browser.search.widget.lastUsed",
|
||||
""
|
||||
);
|
||||
if (searchBarLastUsed) {
|
||||
const removeAfterDaysUnused = Services.prefs.getIntPref(
|
||||
"browser.search.widget.removeAfterDaysUnused"
|
||||
);
|
||||
let saerchBarUnusedThreshold =
|
||||
removeAfterDaysUnused * 24 * 60 * 60 * 1000;
|
||||
if (new Date() - new Date(searchBarLastUsed) > saerchBarUnusedThreshold) {
|
||||
Services.prefs.setBoolPref("browser.search.widget.inNavBar", false);
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
removePersistedWidths() {
|
||||
Services.xulStore.removeValue(
|
||||
AppConstants.BROWSER_CHROME_URL,
|
||||
|
|
|
@ -341,6 +341,8 @@ skip-if = ["(verify && debug && (os == 'linux' || os == 'mac'))"]
|
|||
|
||||
["browser_screenshot_button_disabled.js"]
|
||||
|
||||
["browser_searchbar_removal.js"]
|
||||
|
||||
["browser_sidebar_toggle.js"]
|
||||
skip-if = ["verify"]
|
||||
|
||||
|
|
|
@ -0,0 +1,36 @@
|
|||
/* Any copyright is dedicated to the Public Domain.
|
||||
* http://creativecommons.org/publicdomain/zero/1.0/ */
|
||||
|
||||
"use strict";
|
||||
|
||||
const { SearchWidgetTracker } = ChromeUtils.importESModule(
|
||||
"resource:///modules/SearchWidgetTracker.sys.mjs"
|
||||
);
|
||||
|
||||
const SEARCH_BAR_PREF_NAME = "browser.search.widget.inNavBar";
|
||||
const SEARCH_BAR_LAST_USED_PREF_NAME = "browser.search.widget.lastUsed";
|
||||
|
||||
add_task(async function checkSearchBarPresent() {
|
||||
Services.prefs.setBoolPref(SEARCH_BAR_PREF_NAME, true);
|
||||
Services.prefs.setStringPref(
|
||||
SEARCH_BAR_LAST_USED_PREF_NAME,
|
||||
new Date("2022").toISOString()
|
||||
);
|
||||
|
||||
Assert.ok(
|
||||
BrowserSearch.searchBar,
|
||||
"Search bar should be present in the Nav bar"
|
||||
);
|
||||
SearchWidgetTracker._updateSearchBarVisibilityBasedOnUsage();
|
||||
Assert.ok(
|
||||
!BrowserSearch.searchBar,
|
||||
"Search bar should not be present in the Nav bar"
|
||||
);
|
||||
Assert.equal(
|
||||
Services.prefs.getBoolPref(SEARCH_BAR_PREF_NAME),
|
||||
false,
|
||||
"Should remove the search bar"
|
||||
);
|
||||
Services.prefs.clearUserPref(SEARCH_BAR_LAST_USED_PREF_NAME);
|
||||
Services.prefs.clearUserPref(SEARCH_BAR_PREF_NAME);
|
||||
});
|
Загрузка…
Ссылка в новой задаче