Bug 1335992 - Search with default search engine stops working. r=florian, a=lizzard
authorDrew Willcoxon <adw@mozilla.com>
Wed, 01 Mar 2017 09:53:24 -0800
changeset 378899 06f51944867c197d2237f107f541ef470c563b40
parent 378898 6139d75fe055e310a4b436223d126f3690eda896
child 378900 b71eda2d078a990763e14e29f3dad757b6426441
push id1419
push userjlund@mozilla.com
push dateMon, 10 Apr 2017 20:44:07 +0000
treeherdermozilla-release@5e6801b73ef6 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersflorian, lizzard
bugs1335992
milestone53.0a2
Bug 1335992 - Search with default search engine stops working. r=florian, a=lizzard MozReview-Commit-ID: 9GnA9Y3YvTS
browser/components/search/content/search.xml
browser/components/search/test/browser_oneOffHeader.js
--- a/browser/components/search/content/search.xml
+++ b/browser/components/search/content/search.xml
@@ -1107,16 +1107,31 @@
       ]]></handler>
 
       <handler event="popuphiding"><![CDATA[
         this._isHiding = true;
         setTimeout(() => {
           this._isHiding = false;
         }, 0);
       ]]></handler>
+
+      <!-- This handles clicks on the topmost "Foo Search" header in the
+           popup (hbox[anonid="searchbar-engine"]). -->
+      <handler event="click"><![CDATA[
+        if (event.button == 2) {
+          // Ignore right clicks.
+          return;
+        }
+        let button = event.originalTarget;
+        let engine = button.parentNode.engine;
+        if (!engine) {
+          return;
+        }
+        this.oneOffButtons.handleSearchCommand(event, engine);
+      ]]></handler>
     </handlers>
 
   </binding>
 
   <!-- Used for additional open search providers in the search panel. -->
   <binding id="addengine-icon" extends="xul:box">
     <content>
       <xul:image class="addengine-icon" xbl:inherits="src"/>
@@ -2215,17 +2230,17 @@
         }
       ]]></handler>
 
       <handler event="click"><![CDATA[
         if (event.button == 2)
           return; // ignore right clicks.
 
         let button = event.originalTarget;
-        let engine = button.engine || button.parentNode.engine;
+        let engine = button.engine;
 
         if (!engine)
           return;
 
         // Select the clicked button so that consumers can easily tell which
         // button was acted on.
         this.selectedButton = button;
         this.handleSearchCommand(event, engine);
--- a/browser/components/search/test/browser_oneOffHeader.js
+++ b/browser/components/search/test/browser_oneOffHeader.js
@@ -117,16 +117,25 @@ add_task(function* test_text() {
      "Is the header text correct when search terms are entered after a search engine has been selected.");
 
   yield synthesizeNativeMouseMove(searchSettings);
   is(header.getAttribute("selectedIndex"), 1,
      "Header has the correct index selected when search terms have been entered and the Change Search Settings button is selected.");
   is(getHeaderText(), "Search for foo with:",
      "Header has the correct text when search terms have been entered and the Change Search Settings button is selected.");
 
-  promise = promiseEvent(searchPopup, "popuphidden");
-  info("Closing search panel");
-  EventUtils.synthesizeKey("VK_ESCAPE", {});
-  yield promise;
+  // Click the "Foo Search" header at the top of the popup and make sure it
+  // loads the search results.
+  let searchbarEngine =
+    document.getAnonymousElementByAttribute(searchPopup, "anonid",
+                                            "searchbar-engine");
+
+  yield synthesizeNativeMouseMove(searchbarEngine);
+  SimpleTest.executeSoon(() => {
+    EventUtils.synthesizeMouseAtCenter(searchbarEngine, {});
+  });
+
+  let url = Services.search.currentEngine.getSubmission(textbox.value).uri.spec;
+  yield promiseTabLoadEvent(gBrowser.selectedTab, url);
 
   // Move the cursor out of the panel area to avoid messing with other tests.
   yield synthesizeNativeMouseMove(searchbar);
 });