Bug 1102050 - Set consumeoutsideclicks="false" whenever the popup is opened. r=felipe, a=sledru
authorDave Townsend <dtownsend@oxymoronical.com>
Wed, 31 Dec 2014 13:36:28 -0800
changeset 242837 a33308dd5af8
parent 242836 3abc61cb0abd
child 242838 f6d5f2303fea
push id4319
push userryanvm@gmail.com
push date2015-01-14 14:36 +0000
treeherdermozilla-beta@f6d5f2303fea [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersfelipe, sledru
bugs1102050
milestone36.0
Bug 1102050 - Set consumeoutsideclicks="false" whenever the popup is opened. r=felipe, a=sledru showHistoryPopup in autocomplete.xml always sets consumeoutsideclicks to true so we have to override that when the popup is actually opened. The test here isn't a very good one. For some reason the events generated by EventUtils aren't consumed regardless of consumeoutsideclicks, I'm not sure there is a great way to test this automatically.
browser/base/content/urlbarBindings.xml
browser/components/search/content/search.xml
browser/components/search/test/browser_searchbar_openpopup.js
--- a/browser/base/content/urlbarBindings.xml
+++ b/browser/base/content/urlbarBindings.xml
@@ -963,17 +963,17 @@
     </implementation>
   </binding>
 
   <!-- Note: this binding is applied to the autocomplete popup used in the Search bar -->
   <binding id="browser-search-autocomplete-result-popup" extends="chrome://browser/content/urlbarBindings.xml#browser-autocomplete-result-popup">
     <resources>
       <stylesheet src="chrome://browser/skin/searchbar.css"/>
     </resources>
-    <content ignorekeys="true" level="top" consumeoutsideclicks="false">
+    <content ignorekeys="true" level="top">
       <xul:hbox xbl:inherits="collapsed=showonlysettings" anonid="searchbar-engine"
                 class="search-panel-header search-panel-current-engine">
         <xul:image class="searchbar-engine-image" xbl:inherits="src"/>
         <xul:label anonid="searchbar-engine-name" flex="1" crop="end"
                    role="presentation"/>
       </xul:hbox>
       <xul:tree anonid="tree" flex="1"
                 class="autocomplete-tree plain search-panel-tree"
--- a/browser/components/search/content/search.xml
+++ b/browser/components/search/content/search.xml
@@ -867,16 +867,20 @@
             // in browser.xul) is hidden to avoid impacting startup / new
             // window performance. The base binding's openPopup would normally
             // call the overriden openAutocompletePopup in urlbarBindings.xml's
             // browser-autocomplete-result-popup binding to unhide the popup,
             // but since we're overriding openPopup we need to unhide the panel
             // ourselves.
             popup.hidden = false;
 
+            // showHistoryPopup sets consumeoutsideclicks to true so reset it
+            // here
+            popup.setAttribute("consumeoutsideclicks", "false");
+
             popup.mInput = this;
             popup.view = this.controller.QueryInterface(Components.interfaces.nsITreeView);
             popup.invalidate();
 
             popup.showCommentColumn = this.showCommentColumn;
             popup.showImageColumn = this.showImageColumn;
 
             document.popupNode = null;
--- a/browser/components/search/test/browser_searchbar_openpopup.js
+++ b/browser/components/search/test/browser_searchbar_openpopup.js
@@ -217,16 +217,39 @@ add_no_popup_task(function* tab_doesnt_o
 
   is(Services.focus.focusedElement, textbox.inputField, "Should have focused the search bar");
   is(textbox.selectionStart, 0, "Should have selected all of the text");
   is(textbox.selectionEnd, 3, "Should have selected all of the text");
 
   textbox.value = "";
 });
 
+// Clicks outside the search popup should close the popup but not consume the click.
+add_task(function* dont_consume_clicks() {
+  gURLBar.focus();
+  textbox.value = "foo";
+
+  let promise = promiseEvent(searchPopup, "popupshown");
+  EventUtils.synthesizeMouseAtCenter(textbox, {});
+  yield promise;
+  isnot(searchPopup.getAttribute("showonlysettings"), "true", "Should show the full popup");
+
+  is(Services.focus.focusedElement, textbox.inputField, "Should have focused the search bar");
+  is(textbox.selectionStart, 0, "Should have selected all of the text");
+  is(textbox.selectionEnd, 3, "Should have selected all of the text");
+
+  promise = promiseEvent(searchPopup, "popuphidden");
+  EventUtils.synthesizeMouseAtCenter(gURLBar, {});
+  yield promise;
+
+  is(Services.focus.focusedElement, gURLBar.inputField, "Should have focused the URL bar");
+
+  textbox.value = "";
+});
+
 // Switching back to the window when the search box has focus from mouse should not open the popup.
 add_task(function* refocus_window_doesnt_open_popup_mouse() {
   gURLBar.focus();
   textbox.value = "foo";
 
   let promise = promiseEvent(searchPopup, "popupshown");
   EventUtils.synthesizeMouseAtCenter(searchbar, {});
   yield promise;