Bug 1294733 - Awesomebar search buttons show auto completed text not user input. r?florian
MozReview-Commit-ID: BmxFd7fgdA6
--- a/browser/base/content/urlbarBindings.xml
+++ b/browser/base/content/urlbarBindings.xml
@@ -430,22 +430,17 @@ file, You can obtain one at http://mozil
matchLastLocationChange, mayInheritPrincipal);
return;
}
// If there's a selected one-off button and the input value is a
// search query (or "keyword" in URI-fixup terminology), then load a
// search using the one-off's engine.
if (selectedOneOff && selectedOneOff.engine) {
- // `url` (which is this.value) may be an autofilled string. Search
- // only with the portion that the user typed, if any, by preferring
- // the autocomplete controller's searchString.
- let value = this._searchStringOnHandleEnter ||
- this.mController.searchString ||
- url;
+ let value = this.oneOffSearchQuery;
let fixup;
try {
fixup = Services.uriFixup.getFixupURIInfo(
value,
Services.uriFixup.FIXUP_FLAG_ALLOW_KEYWORD_LOOKUP
);
} catch (ex) {}
if (fixup && fixup.keywordProviderName) {
@@ -466,16 +461,27 @@ file, You can obtain one at http://mozil
gBrowser.selectedBrowser.lastLocationChange;
this._loadURL(url, postData, where, openUILinkParams,
matchLastLocationChange, mayInheritPrincipal);
}
});
]]></body>
</method>
+ <property name="oneOffSearchQuery">
+ <getter><![CDATA[
+ // this.textValue may be an autofilled string. Search only with the
+ // portion that the user typed, if any, by preferring the autocomplete
+ // controller's searchString (including _searchStringOnHandleEnter).
+ return this._searchStringOnHandleEnter ||
+ this.mController.searchString ||
+ this.textValue;
+ ]]></getter>
+ </property>
+
<method name="_loadURL">
<parameter name="url"/>
<parameter name="postData"/>
<parameter name="openUILinkWhere"/>
<parameter name="openUILinkParams"/>
<parameter name="matchLastLocationChange"/>
<parameter name="mayInheritPrincipal"/>
<body><![CDATA[
--- a/browser/components/search/content/search.xml
+++ b/browser/components/search/content/search.xml
@@ -1272,22 +1272,21 @@
<!-- This handles events outside the one-off buttons, like on the popup
and textbox. -->
<method name="handleEvent">
<parameter name="event"/>
<body><![CDATA[
switch (event.type) {
case "input":
- // The urlbar's value property can be a moz-action URI, but we
- // want the value that the user sees, which is textValue. So see
- // if the textbox has a textValue property, and use it if so.
- this.query = typeof(event.target.textValue) == "string" ?
- event.target.textValue :
- event.target.value;
+ // Allow the consumer's input to override its value property with
+ // a oneOffSearchQuery property. That way if the value is not
+ // actually what the user typed (e.g., it's autofilled, or it's a
+ // mozaction URI), the consumer has some way of providing it.
+ this.query = event.target.oneOffSearchQuery || event.target.value;
break;
case "popupshowing":
this._rebuild();
break;
case "popuphidden":
Services.tm.mainThread.dispatch(() => {
this.selectedButton = null;
}, Ci.nsIThread.DISPATCH_NORMAL);