Bug 1335992 - Search with default search engine stops working. r=florian
authorDrew Willcoxon <adw@mozilla.com>
Wed, 01 Mar 2017 09:53:24 -0800
changeset 394554 11eb095a371528eabfd3efbbe57c80c67fd5f58c
parent 394553 d4ce6c0007c2a7e6e26033c1c85f893e30ff243b
child 394555 817f09e9fae73131a7c33dbd844005a15a523879
push id1468
push userasasaki@mozilla.com
push dateMon, 05 Jun 2017 19:31:07 +0000
treeherdermozilla-release@0641fc6ee9d1 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersflorian
bugs1335992
milestone54.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1335992 - Search with default search engine stops working. r=florian 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
@@ -1109,16 +1109,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"/>
@@ -2218,17 +2233,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);
 });