mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 1229471 - LoopUI shouldn't try to use toolbar buttons in the hidden window. r=mikedeboer
This commit is contained in:
parent
31da47be6c
commit
f4cfcf44c1
41
browser/extensions/loop/bootstrap.js
vendored
41
browser/extensions/loop/bootstrap.js
vendored
@ -40,7 +40,8 @@ var WindowListener = {
|
||||
var LoopUI = {
|
||||
/**
|
||||
* @var {XULWidgetSingleWrapper} toolbarButton Getter for the Loop toolbarbutton
|
||||
* instance for this window.
|
||||
* instance for this window. This should
|
||||
* not be used in the hidden window.
|
||||
*/
|
||||
get toolbarButton() {
|
||||
delete this.toolbarButton;
|
||||
@ -263,18 +264,10 @@ var WindowListener = {
|
||||
},
|
||||
|
||||
/**
|
||||
* Triggers the initialization of the loop service. Called by
|
||||
* delayedStartup.
|
||||
* Triggers the initialization of the loop service if necessary.
|
||||
* Also adds appropraite observers for the UI.
|
||||
*/
|
||||
init: function() {
|
||||
// Cleanup when the window unloads.
|
||||
window.addEventListener("unload", () => {
|
||||
this.uninit();
|
||||
});
|
||||
|
||||
// Add observer notifications before the service is initialized
|
||||
Services.obs.addObserver(this, "loop-status-changed", false);
|
||||
|
||||
// This is a promise for test purposes, but we don't want to be logging
|
||||
// expected errors to the console, so we catch them here.
|
||||
this.MozLoopService.initialize().catch(ex => {
|
||||
@ -284,11 +277,21 @@ var WindowListener = {
|
||||
console.error(ex);
|
||||
}
|
||||
});
|
||||
this.updateToolbarState();
|
||||
},
|
||||
|
||||
uninit: function() {
|
||||
// Don't do the rest if this is for the hidden window - we don't
|
||||
// have a toolbar there.
|
||||
if (window == Services.appShell.hiddenDOMWindow) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Cleanup when the window unloads.
|
||||
window.addEventListener("unload", () => {
|
||||
Services.obs.removeObserver(this, "loop-status-changed");
|
||||
});
|
||||
|
||||
Services.obs.addObserver(this, "loop-status-changed", false);
|
||||
|
||||
this.updateToolbarState();
|
||||
},
|
||||
|
||||
// Implements nsIObserver
|
||||
@ -300,7 +303,8 @@ var WindowListener = {
|
||||
},
|
||||
|
||||
/**
|
||||
* Updates the toolbar/menu-button state to reflect Loop status.
|
||||
* Updates the toolbar/menu-button state to reflect Loop status. This should
|
||||
* not be called from the hidden window.
|
||||
*
|
||||
* @param {string} [aReason] Some states are only shown if
|
||||
* a related reason is provided.
|
||||
@ -352,7 +356,8 @@ var WindowListener = {
|
||||
},
|
||||
|
||||
/**
|
||||
* Updates the tootltiptext to reflect Loop status.
|
||||
* Updates the tootltiptext to reflect Loop status. This should not be called
|
||||
* from the hidden window.
|
||||
*
|
||||
* @param {string} [mozL10nId] l10n ID that refelct the current
|
||||
* Loop status.
|
||||
@ -759,6 +764,7 @@ function startup() {
|
||||
createLoopButton();
|
||||
|
||||
// Attach to hidden window (for OS X).
|
||||
if (AppConstants.platform == "macosx") {
|
||||
try {
|
||||
WindowListener.setupBrowserUI(Services.appShell.hiddenDOMWindow);
|
||||
} catch (ex) {
|
||||
@ -769,6 +775,7 @@ function startup() {
|
||||
WindowListener.setupBrowserUI(Services.appShell.hiddenDOMWindow);
|
||||
}, topic, false);
|
||||
}
|
||||
}
|
||||
|
||||
// Attach to existing browser windows, for modifying UI.
|
||||
let wm = Cc["@mozilla.org/appshell/window-mediator;1"].getService(Ci.nsIWindowMediator);
|
||||
@ -814,7 +821,9 @@ function shutdown() {
|
||||
});
|
||||
|
||||
// Detach from hidden window (for OS X).
|
||||
if (AppConstants.platform == "macosx") {
|
||||
WindowListener.tearDownBrowserUI(Services.appShell.hiddenDOMWindow);
|
||||
}
|
||||
|
||||
// Detach from browser windows.
|
||||
let wm = Cc["@mozilla.org/appshell/window-mediator;1"].getService(Ci.nsIWindowMediator);
|
||||
|
Loading…
Reference in New Issue
Block a user