Bug 1557869 - do not deinitialize searchbar internals if the searchbar was not yet initialized r=mak

Differential Revision: https://phabricator.services.mozilla.com/D34368

--HG--
extra : moz-landing-system : lando
This commit is contained in:
Alexander Surkov 2019-06-12 08:21:38 +00:00
Родитель c70deb1b4b
Коммит 861987223e
1 изменённых файлов: 10 добавлений и 18 удалений

Просмотреть файл

@ -56,7 +56,8 @@ class MozSearchbar extends MozXULElement {
connectedCallback() {
// Don't initialize if this isn't going to be visible
if (this.closest("#BrowserToolbarPalette")) {
if (this.closest("#BrowserToolbarPalette") ||
this.parentNode.parentNode.localName == "toolbarpaletteitem") {
return;
}
@ -76,10 +77,6 @@ class MozSearchbar extends MozXULElement {
this.FormHistory = (ChromeUtils.import("resource://gre/modules/FormHistory.jsm", {})).FormHistory;
if (this.parentNode.parentNode.localName == "toolbarpaletteitem") {
return;
}
Services.obs.addObserver(this.observer, "browser-search-engine-modified");
Services.obs.addObserver(this.observer, "browser-search-service");
@ -148,14 +145,16 @@ class MozSearchbar extends MozXULElement {
}
destroy() {
if (this._initialized) {
this._initialized = false;
window.removeEventListener("unload", this.destroy);
Services.obs.removeObserver(this.observer, "browser-search-engine-modified");
Services.obs.removeObserver(this.observer, "browser-search-service");
if (!this._initialized) {
return;
}
this._initialized = false;
window.removeEventListener("unload", this.destroy);
Services.obs.removeObserver(this.observer, "browser-search-engine-modified");
Services.obs.removeObserver(this.observer, "browser-search-service");
// Make sure to break the cycle from _textbox to us. Otherwise we leak
// the world. But make sure it's actually pointing to us.
// Also make sure the textbox has ever been constructed, otherwise the
@ -164,13 +163,6 @@ class MozSearchbar extends MozXULElement {
if (this._textbox.mController && this._textbox.mController.input == this) {
this._textbox.mController.input = null;
}
// If the context menu has never been opened, there won't be anything
// to remove here. Also, XBL and the customize toolbar code sometimes
// interact poorly.
try {
this.controllers.removeController(this.searchbarController);
} catch (ex) {}
}
focus() {