commit 18b66ea8b7e4bda797bf8af8f32808125c3a2a95
parent d2ca96a6a97d71211856873af694ded67e63e961
Author: Dharma Ong <dharmaong00@gmail.com>
Date: Thu, 27 Nov 2025 17:04:00 +0000
Bug 1922114 - Update icon in address bar when keyword.enabled is false. r=daleharvey,fluent-reviewers,bolsson
Differential Revision: https://phabricator.services.mozilla.com/D252559
Diffstat:
4 files changed, 34 insertions(+), 19 deletions(-)
diff --git a/browser/components/urlbar/SearchModeSwitcher.sys.mjs b/browser/components/urlbar/SearchModeSwitcher.sys.mjs
@@ -35,6 +35,7 @@ const DEFAULT_ENGINE_ICON =
*/
export class SearchModeSwitcher {
static DEFAULT_ICON = lazy.UrlbarUtils.ICON.SEARCH_GLASS;
+ static DEFAULT_ICON_KEYWORD_DISABLED = lazy.UrlbarUtils.ICON.GLOBE;
#popup;
#input;
#toolbarbutton;
@@ -287,7 +288,7 @@ export class SearchModeSwitcher {
if (!lazy.UrlbarPrefs.get("unifiedSearchButton.always")) {
const keywordEnabled = lazy.UrlbarPrefs.get("keyword.enabled");
if (!keywordEnabled && !inSearchMode) {
- icon = SearchModeSwitcher.DEFAULT_ICON;
+ icon = SearchModeSwitcher.DEFAULT_ICON_KEYWORD_DISABLED;
}
} else if (!inSearchMode) {
// Use default icon set in CSS.
@@ -322,6 +323,14 @@ export class SearchModeSwitcher {
} else {
labelEl.textContent = label;
}
+
+ // If keyword.enabled is true, then the tooltip is already set.
+ if (!lazy.UrlbarPrefs.get("keyword.enabled")) {
+ this.#input.document.l10n.setAttributes(
+ this.#toolbarbutton,
+ "urlbar-searchmode-no-keyword"
+ );
+ }
}
async #getSearchModeLabel(source) {
diff --git a/browser/components/urlbar/UrlbarUtils.sys.mjs b/browser/components/urlbar/UrlbarUtils.sys.mjs
@@ -160,6 +160,7 @@ export var UrlbarUtils = {
SEARCH_GLASS: "chrome://global/skin/icons/search-glass.svg",
TRENDING: "chrome://global/skin/icons/trending.svg",
TIP: "chrome://global/skin/icons/lightbulb.svg",
+ GLOBE: "chrome://global/skin/icons/defaultFavicon.svg",
},
// The number of results by which Page Up/Down move the selection.
diff --git a/browser/components/urlbar/tests/browser/browser_searchModeSwitcher_basic.js b/browser/components/urlbar/tests/browser/browser_searchModeSwitcher_basic.js
@@ -274,13 +274,13 @@ add_task(async function test_search_icon_change() {
});
let newWin = await BrowserTestUtils.openNewBrowserWindow();
- const searchGlassIconUrl = UrlbarUtils.ICON.SEARCH_GLASS;
+ const globeIconUrl = UrlbarUtils.ICON.GLOBE;
+ const searchIconUrl = UrlbarUtils.ICON.SEARCH_GLASS;
Assert.equal(
- getSeachModeSwitcherIcon(newWin),
- searchGlassIconUrl,
- "The search mode switcher should have the search glass icon url since \
- we are not in search mode."
+ await getSearchModeSwitcherIcon(newWin),
+ searchIconUrl,
+ "The search mode switcher should have the default (search icon) url since we are not in search mode."
);
let popup = UrlbarTestUtils.searchModeSwitcherPopup(newWin);
@@ -301,7 +301,7 @@ add_task(async function test_search_icon_change() {
.getIconURL();
Assert.equal(
- getSeachModeSwitcherIcon(newWin),
+ await getSearchModeSwitcherIcon(newWin),
bingSearchEngineIconUrl,
"The search mode switcher should have the bing icon url since we are in \
search mode"
@@ -317,15 +317,14 @@ add_task(async function test_search_icon_change() {
await UrlbarTestUtils.assertSearchMode(newWin, null);
let searchModeSwitcherIconUrl = await BrowserTestUtils.waitForCondition(
- () => getSeachModeSwitcherIcon(newWin),
+ () => getSearchModeSwitcherIcon(newWin),
"Waiting for the search mode switcher icon to update after exiting search mode."
);
Assert.equal(
searchModeSwitcherIconUrl,
- searchGlassIconUrl,
- "The search mode switcher should have the search glass icon url since \
- keyword.enabled is false"
+ globeIconUrl,
+ "The search mode switcher should have the globe icon url since keyword.enabled is false"
);
await BrowserTestUtils.closeWindow(newWin);
@@ -723,14 +722,14 @@ add_task(async function test_search_service_fail() {
});
let searchModeSwitcherIconUrl = await BrowserTestUtils.waitForCondition(
- () => getSeachModeSwitcherIcon(newWin),
+ () => getSearchModeSwitcherIcon(newWin),
"Waiting for the search mode switcher icon to update after exiting search mode."
);
Assert.equal(
searchModeSwitcherIconUrl,
- UrlbarUtils.ICON.SEARCH_GLASS,
- "The search mode switcher should have the search glass icon url since the search service init failed."
+ UrlbarUtils.ICON.GLOBE,
+ "The search mode switcher should have the globe icon url since the search service init failed."
);
info("Open search mode switcher");
@@ -777,7 +776,7 @@ add_task(async function test_search_mode_switcher_engine_no_icon() {
await popupHidden;
Assert.equal(
- getSeachModeSwitcherIcon(window),
+ await getSearchModeSwitcherIcon(window),
UrlbarUtils.ICON.SEARCH_GLASS,
"The search mode switcher should display the default search glass icon when the engine has no icon."
);
@@ -833,7 +832,7 @@ add_task(async function test_search_mode_switcher_private_engine_icon() {
);
Assert.equal(
- getSeachModeSwitcherIcon(window),
+ await getSearchModeSwitcherIcon(window),
defaultEngineIcon,
"Is the icon of the default engine."
);
@@ -850,7 +849,7 @@ add_task(async function test_search_mode_switcher_private_engine_icon() {
});
Assert.equal(
- getSeachModeSwitcherIcon(privateWin),
+ await getSearchModeSwitcherIcon(privateWin),
defaultPrivateEngineIcon,
"Is the icon of the default private engine."
);
@@ -863,7 +862,7 @@ add_task(async function test_search_mode_switcher_private_engine_icon() {
info("Waiting for the icon to be updated.");
await TestUtils.waitForCondition(
- () => getSeachModeSwitcherIcon(privateWin) == defaultEngineIcon
+ () => getSearchModeSwitcherIcon(privateWin) == defaultEngineIcon
);
Assert.ok(true, "The icon was updated.");
@@ -891,7 +890,7 @@ add_task(async function open_with_option() {
await popupHidden;
});
-function getSeachModeSwitcherIcon(window) {
+function getSearchModeSwitcherIcon(window) {
let searchModeSwitcherButton = window.gURLBar.querySelector(
".searchmode-switcher-icon"
);
diff --git a/browser/locales/en-US/browser/browser.ftl b/browser/locales/en-US/browser/browser.ftl
@@ -761,6 +761,12 @@ urlbar-searchmode-button2 =
urlbar-searchmode-button-no-engine =
.label = No shortcut selected, pick a shortcut
.tooltiptext = No shortcut selected, pick a shortcut
+
+# Refers to the ability to search using keywords in the address bar
+urlbar-searchmode-no-keyword =
+ .label = Keyword search is disabled
+ .tooltiptext = Keyword search is disabled
+
urlbar-searchmode-dropmarker =
.tooltiptext = Pick a Search Engine
urlbar-searchmode-bookmarks =