Bug 1335992 - Search with default search engine stops working. r?florian
MozReview-Commit-ID: 9GnA9Y3YvTS
--- 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);
});