Bug 1359056 - Don't open the search panel when entering customization mode. r=Gijs
MozReview-Commit-ID: XmNZMrizET
--- a/browser/components/search/content/search.xml
+++ b/browser/components/search/content/search.xml
@@ -697,16 +697,23 @@
<!--
This method overrides the autocomplete binding's openPopup (essentially
duplicating the logic from the autocomplete popup binding's
openAutocompletePopup method), modifying it so that the popup is aligned with
the inner textbox, but sized to not extend beyond the search bar border.
-->
<method name="openPopup">
<body><![CDATA[
+ // Entering customization mode after the search bar had focus causes
+ // the popup to appear again, due to focus returning after the
+ // hamburger panel closes. Don't open in that spurious event.
+ if (document.documentElement.getAttribute("customizing") == "true") {
+ return;
+ }
+
var popup = this.popup;
if (!popup.mPopupOpen) {
// Initially the panel used for the searchbar (PopupSearchAutoComplete
// in browser.xul) is hidden to avoid impacting startup / new
// window performance. The base binding's openPopup would normally
// call the overriden openAutocompletePopup in
// browser-search-autocomplete-result-popup binding to unhide the popup,
// but since we're overriding openPopup we need to unhide the panel
--- a/browser/components/search/test/browser_searchbar_openpopup.js
+++ b/browser/components/search/test/browser_searchbar_openpopup.js
@@ -37,16 +37,36 @@ function synthesizeNativeMouseClick(aEle
aElement.addEventListener("mouseup", eventOccurred, true);
utils.sendNativeMouseEvent(x * scale, y * scale, mouseDown, 0, null);
utils.sendNativeMouseEvent(x * scale, y * scale, mouseUp, 0, null);
});
}
+async function endCustomizing(aWindow = window) {
+ if (aWindow.document.documentElement.getAttribute("customizing") != "true") {
+ return true;
+ }
+ await SpecialPowers.pushPrefEnv({set: [["browser.uiCustomization.disableAnimation", true]]});
+ let eventPromise = BrowserTestUtils.waitForEvent(aWindow.gNavToolbox, "aftercustomization");
+ aWindow.gCustomizeMode.exit();
+ return eventPromise;
+}
+
+async function startCustomizing(aWindow = window) {
+ if (aWindow.document.documentElement.getAttribute("customizing") == "true") {
+ return true;
+ }
+ await SpecialPowers.pushPrefEnv({set: [["browser.uiCustomization.disableAnimation", true]]});
+ let eventPromise = BrowserTestUtils.waitForEvent(aWindow.gNavToolbox, "customizationready");
+ aWindow.gCustomizeMode.enter();
+ return eventPromise;
+}
+
add_task(async function init() {
await promiseNewEngine("testEngine.xml");
// First cleanup the form history in case other tests left things there.
await new Promise((resolve, reject) => {
info("cleanup the search history");
searchbar.FormHistory.update({op: "remove", fieldname: "searchbar-history"},
{handleCompletion: resolve,
@@ -515,8 +535,36 @@ add_task(async function dont_rollup_onca
// Close the popup again
promise = promiseEvent(searchPopup, "popuphidden");
EventUtils.synthesizeKey("VK_ESCAPE", {});
await promise;
textbox.value = "";
});
+
+// Entering customization mode shouldn't open the popup.
+add_task(async function dont_open_in_customization() {
+ gURLBar.focus();
+ textbox.value = "foo";
+
+ let promise = promiseEvent(searchPopup, "popupshown");
+ EventUtils.synthesizeKey("VK_TAB", {});
+ await promise;
+ isnot(searchPopup.getAttribute("showonlysettings"), "true", "Should show the full popup");
+
+ info("Entering customization mode");
+ let sawPopup = false;
+ function listener() {
+ sawPopup = true;
+ }
+ searchPopup.addEventListener("popupshowing", listener);
+ await PanelUI.show();
+ promise = promiseEvent(searchPopup, "popuphidden");
+ await startCustomizing();
+ await promise;
+
+ searchPopup.removeEventListener("popupshowing", listener);
+ ok(!sawPopup, "Shouldn't have seen the suggestions popup");
+
+ await endCustomizing();
+ textbox.value = "";
+});