Bug 1335992 - Search with default search engine stops working. r?florian draft
authorDrew Willcoxon <adw@mozilla.com>
Wed, 01 Mar 2017 09:53:24 -0800
changeset 490996 34ff7c2573a3584260c8ce7ca48d40bb2dc9f266
parent 490871 34c6c2f302e7b48e3ad2cec575cbd34d423a9d32
child 547449 61240d298efdb0a7bfa674e66906a50eaa42a3f8
push id47304
push userdwillcoxon@mozilla.com
push dateWed, 01 Mar 2017 17:54:07 +0000
reviewersflorian
bugs1335992
milestone54.0a1
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"/>
@@ -2217,17 +2232,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);
 });