diff --git a/browser/base/content/browser.js b/browser/base/content/browser.js index 827a5f60438..60de9b5da94 100644 --- a/browser/base/content/browser.js +++ b/browser/base/content/browser.js @@ -2950,13 +2950,11 @@ const BrowserSearch = { openSearchPageIfFieldIsNotActive(searchBar); }; if (placement && placement.area == CustomizableUI.AREA_PANEL) { - PanelUI.show().then(() => { - // The panel is not constructed until the first time it is shown. - focusSearchBar(); - }); + // The panel is not constructed until the first time it is shown. + PanelUI.show().then(focusSearchBar); return; } - if (placement.area == CustomizableUI.AREA_NAVBAR && searchBar && + if (placement && placement.area == CustomizableUI.AREA_NAVBAR && searchBar && searchBar.parentNode.classList.contains("overflowedItem")) { let navBar = document.getElementById(CustomizableUI.AREA_NAVBAR); navBar.overflowable.show().then(() => { diff --git a/browser/components/customizableui/test/browser_901207_searchbar_in_panel.js b/browser/components/customizableui/test/browser_901207_searchbar_in_panel.js index b16d214c6d6..f32511c154b 100644 --- a/browser/components/customizableui/test/browser_901207_searchbar_in_panel.js +++ b/browser/components/customizableui/test/browser_901207_searchbar_in_panel.js @@ -86,6 +86,30 @@ add_task(function() { is(document.activeElement, searchbar.textbox.inputField, "The searchbar should be focused"); }); +// Ctrl+K should open the search page if the search bar has been customized out. +add_task(function() { + this.originalOpenUILinkIn = openUILinkIn; + try { + CustomizableUI.removeWidgetFromArea("search-container"); + let placement = CustomizableUI.getPlacementOfWidget("search-container"); + is(placement, null, "Search container should be in palette"); + + let openUILinkInCalled = false; + openUILinkIn = (aUrl, aWhichTab) => { + is(aUrl, Services.search.defaultEngine.searchForm, "Search page should be requested to open."); + is(aWhichTab, "current", "Should use the current tab for the search page."); + openUILinkInCalled = true; + }; + sendWebSearchKeyCommand(); + yield waitForCondition(function() openUILinkInCalled); + ok(openUILinkInCalled, "The search page should have been opened.") + } catch (e) { + ok(false, e); + } + openUILinkIn = this.originalOpenUILinkIn; + CustomizableUI.reset(); +}); + function sendWebSearchKeyCommand() { if (Services.appinfo.OS === "Darwin") EventUtils.synthesizeKey("k", { accelKey: true });