Bug 1119450 - Clicks on the search go button shouldn't open the search popup. r=felipe, a=sledru
authorDave Townsend <dtownsend@oxymoronical.com>
Fri, 09 Jan 2015 11:05:50 -0800
changeset 242865 17b6018c53f0
parent 242864 c7e58ab0e1f6
child 242866 82cce51fb174
push id4322
push userryanvm@gmail.com
push date2015-01-14 15:18 +0000
treeherdermozilla-beta@82cce51fb174 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersfelipe, sledru
bugs1119450
milestone36.0
Bug 1119450 - Clicks on the search go button shouldn't open the search popup. r=felipe, a=sledru
browser/components/search/content/search.xml
browser/components/search/test/browser_searchbar_openpopup.js
--- a/browser/components/search/content/search.xml
+++ b/browser/components/search/content/search.xml
@@ -717,16 +717,21 @@
         if (Services.focus.getLastFocusMethod(window) == Services.focus.FLAG_BYMOUSE)
           return;
 
         this.openSuggestionsPanel();
       ]]></handler>
 
       <handler event="click" button="0">
       <![CDATA[
+        // Ignore clicks on the search go button.
+        if (event.originalTarget.getAttribute("anonid") == "search-go-button") {
+          return;
+        }
+
         // Open the suggestions whenever clicking on the search icon or if there
         // is text in the textbox.
         if (event.originalTarget.getAttribute("anonid") == "searchbar-search-button" ||
             this._textbox.value) {
           this.openSuggestionsPanel(true);
         }
       ]]></handler>
 
--- a/browser/components/search/test/browser_searchbar_openpopup.js
+++ b/browser/components/search/test/browser_searchbar_openpopup.js
@@ -1,13 +1,14 @@
 // Tests that the suggestion popup appears at the right times in response to
 // focus and clicks.
 
 const searchbar = document.getElementById("searchbar");
 const searchIcon = document.getAnonymousElementByAttribute(searchbar, "anonid", "searchbar-search-button");
+const goButton = document.getAnonymousElementByAttribute(searchbar, "anonid", "search-go-button");
 const textbox = searchbar._textbox;
 const searchPopup = document.getElementById("PopupSearchAutoComplete");
 
 function promiseNewEngine(basename) {
   return new Promise((resolve, reject) => {
     info("Waiting for engine to be added: " + basename);
     Services.search.init({
       onInitComplete: function() {
@@ -313,8 +314,24 @@ add_task(function* refocus_window_doesnt
   // Wait a few ticks to allow any focus handlers to show the popup if they are going to.
   yield new Promise(resolve => executeSoon(resolve));
   yield new Promise(resolve => executeSoon(resolve));
   yield new Promise(resolve => executeSoon(resolve));
 
   searchPopup.removeEventListener("popupshowing", listener, false);
   textbox.value = "";
 });
+
+// Clicking the search go button shouldn't open the popup
+add_no_popup_task(function* search_go_doesnt_open_popup() {
+  gBrowser.selectedTab = gBrowser.addTab();
+
+  gURLBar.focus();
+  textbox.value = "foo";
+  searchbar.inputChanged();
+
+  let promise = promiseOnLoad();
+  EventUtils.synthesizeMouseAtCenter(goButton, {});
+  yield promise;
+
+  textbox.value = "";
+  gBrowser.removeCurrentTab();
+});