Bug 1353831 - OneOff block in search bar doesn't update text if Customize was opened at least once. r?florian
MozReview-Commit-ID: Iu7xhCbCh6B
--- a/browser/components/search/content/search.xml
+++ b/browser/components/search/content/search.xml
@@ -67,18 +67,16 @@
</xul:hbox>
</xul:textbox>
</content>
<implementation implements="nsIObserver">
<constructor><![CDATA[
if (this.parentNode.parentNode.localName == "toolbarpaletteitem")
return;
- // Make sure we rebuild the popup in onpopupshowing
- this._needToBuildPopup = true;
Services.obs.addObserver(this, "browser-search-engine-modified", false);
this._initialized = true;
Services.search.init((function search_init_cb(aStatus) {
// Bail out if the binding's been destroyed
if (!this._initialized)
@@ -87,16 +85,24 @@
if (Components.isSuccessCode(aStatus)) {
// Refresh the display (updating icon, etc)
this.updateDisplay();
BrowserSearch.updateOpenSearchBadge();
} else {
Components.utils.reportError("Cannot initialize search service, bailing out: " + aStatus);
}
}).bind(this));
+
+ // Some accessibility tests create their own <searchbar> that doesn't
+ // use the popup binding below, so null-check oneOffButtons.
+ if (this.textbox.popup.oneOffButtons) {
+ this.textbox.popup.oneOffButtons.telemetryOrigin = "searchbar";
+ this.textbox.popup.oneOffButtons.popup = this.textbox.popup;
+ this.textbox.popup.oneOffButtons.textbox = this.textbox;
+ }
]]></constructor>
<destructor><![CDATA[
this.destroy();
]]></destructor>
<method name="destroy">
<body><![CDATA[
@@ -1061,36 +1067,31 @@
let searchbar = document.getElementById("searchbar");
searchbar.handleSearchCommandWhere(event, engine, where, params);
]]></body>
</method>
</implementation>
<handlers>
<handler event="popupshowing"><![CDATA[
- if (!this.oneOffButtons.popup) {
+ if (!this._computedMinWidth) {
// The panel width only spans to the textbox size, but we also want it
// to include the magnifier icon's width.
let ltr = getComputedStyle(this).direction == "ltr";
let magnifierWidth = parseInt(getComputedStyle(this)[
ltr ? "marginLeft" : "marginRight"
]) * -1;
// Ensure the panel is wide enough to fit at least 3 engines.
let minWidth = Math.max(
parseInt(this.width) + magnifierWidth,
this.oneOffButtons.buttonWidth * 3
);
this.style.minWidth = minWidth + "px";
- // Set the origin before assigning the popup, as the assignment does
- // a rebuild and would miss the origin.
- this.oneOffButtons.telemetryOrigin = "searchbar";
- // Set popup after setting the minWidth since it builds the buttons.
- this.oneOffButtons.popup = this;
- this.oneOffButtons.textbox = this.input;
+ this._computedMinWidth = true;
}
// First handle deciding if we are showing the reduced version of the
// popup containing only the preferences button. We do this if the
// glass icon has been clicked if the text field is empty.
let searchbar = document.getElementById("searchbar");
let tree = document.getAnonymousElementByAttribute(this, "anonid",
"tree")