mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 1250847: prefix DOMWindowClose and DOMTitleChanged messages with the Social: prefix to assure they won't arrive at the global messageManager instance that TabBrowser is listening to. It mixes things up in twisted, unexpected ways if we don't. r=Standard8
This commit is contained in:
parent
9913b1b669
commit
86128b173d
@ -27,12 +27,13 @@ addEventListener("DOMContentLoaded", function() {
|
||||
var gDOMTitleChangedByUs = false;
|
||||
addEventListener("DOMTitleChanged", function(e) {
|
||||
if (!gDOMTitleChangedByUs) {
|
||||
sendAsyncMessage("DOMTitleChanged", {
|
||||
sendAsyncMessage("Social:DOMTitleChanged", {
|
||||
title: e.target.title
|
||||
});
|
||||
}
|
||||
gDOMTitleChangedByUs = false;
|
||||
});
|
||||
var gHookedWindowCloseForPanelClose = false;
|
||||
|
||||
// Error handling class used to listen for network errors in the social frames
|
||||
// and replace them with a social-specific error page
|
||||
@ -117,6 +118,10 @@ SocialErrorListener = {
|
||||
sendAsyncMessage("Social:FocusEnsured");
|
||||
break;
|
||||
case "Social:HookWindowCloseForPanelClose":
|
||||
if (gHookedWindowCloseForPanelClose) {
|
||||
break;
|
||||
}
|
||||
gHookedWindowCloseForPanelClose = true;
|
||||
// We allow window.close() to close the panel, so add an event handler for
|
||||
// this, then cancel the event (so the window itself doesn't die) and
|
||||
// close the panel instead.
|
||||
@ -127,7 +132,6 @@ SocialErrorListener = {
|
||||
dwu.allowScriptsToClose();
|
||||
|
||||
content.addEventListener("DOMWindowClose", function _mozSocialDOMWindowClose(evt) {
|
||||
sendAsyncMessage("DOMWindowClose");
|
||||
// preventDefault stops the default window.close() function being called,
|
||||
// which doesn't actually close anything but causes things to get into
|
||||
// a bad state (an internal 'closed' flag is set and debug builds start
|
||||
@ -136,6 +140,8 @@ SocialErrorListener = {
|
||||
// default close behaviour, so even if we took no action above, we avoid
|
||||
// the default close from doing anything.
|
||||
evt.preventDefault();
|
||||
|
||||
sendAsyncMessage("Social:DOMWindowClose");
|
||||
}, true);
|
||||
break;
|
||||
case "Social:ListenForEvents":
|
||||
|
@ -81,7 +81,7 @@
|
||||
this._callbacks = null;
|
||||
}
|
||||
|
||||
mm.addMessageListener("DOMTitleChanged", this);
|
||||
mm.addMessageListener("Social:DOMTitleChanged", this);
|
||||
|
||||
mm.sendAsyncMessage("WaitForDOMContentLoaded");
|
||||
mm.addMessageListener("DOMContentLoaded", function DOMContentLoaded(event) {
|
||||
@ -216,7 +216,7 @@
|
||||
// attached to a browser, we'll need to add the message listeners to
|
||||
// the new messageManager. This is not a bug in swapDocShells, merely
|
||||
// a design decision.
|
||||
content.messageManager.addMessageListener("DOMTitleChanged", content);
|
||||
content.messageManager.addMessageListener("Social:DOMTitleChanged", content);
|
||||
]]></body>
|
||||
</method>
|
||||
|
||||
@ -326,7 +326,7 @@
|
||||
<parameter name="aMessage" />
|
||||
<body><![CDATA[
|
||||
switch (aMessage.name) {
|
||||
case "DOMTitleChanged":
|
||||
case "Social:DOMTitleChanged":
|
||||
this.setTitle();
|
||||
break;
|
||||
}
|
||||
|
@ -999,7 +999,7 @@ var MozLoopServiceInternal = {
|
||||
|
||||
// Handle window.close correctly on the chatbox.
|
||||
mm.sendAsyncMessage("Social:HookWindowCloseForPanelClose");
|
||||
messageName = "DOMWindowClose";
|
||||
messageName = "Social:DOMWindowClose";
|
||||
mm.addMessageListener(messageName, listeners[messageName] = () => {
|
||||
// Remove message listeners.
|
||||
for (let name of Object.getOwnPropertyNames(listeners)) {
|
||||
|
@ -198,7 +198,6 @@ var Chat = {
|
||||
// even on platforms where getZOrderDOMWindowEnumerator is broken
|
||||
// (ie. Linux). This will handle most cases, but won't work if the
|
||||
// foreground window is a popup.
|
||||
|
||||
let mostRecent = Services.wm.getMostRecentWindow("navigator:browser");
|
||||
if (isWindowGoodForChats(mostRecent))
|
||||
return mostRecent;
|
||||
|
@ -248,7 +248,7 @@ function hookWindowCloseForPanelClose(targetWindow) {
|
||||
let _mozSocialSwapped;
|
||||
let mm = targetWindow.messageManager;
|
||||
mm.sendAsyncMessage("Social:HookWindowCloseForPanelClose");
|
||||
mm.addMessageListener("DOMWindowClose", _mozSocialDOMWindowClose = function() {
|
||||
mm.addMessageListener("Social:DOMWindowClose", _mozSocialDOMWindowClose = function() {
|
||||
targetWindow.removeEventListener("SwapDocShells", _mozSocialSwapped);
|
||||
closePanel(targetWindow);
|
||||
});
|
||||
@ -257,7 +257,7 @@ function hookWindowCloseForPanelClose(targetWindow) {
|
||||
targetWindow.removeEventListener("SwapDocShells", _mozSocialSwapped);
|
||||
|
||||
targetWindow = ev.detail;
|
||||
targetWindow.messageManager.addMessageListener("DOMWindowClose", _mozSocialDOMWindowClose);
|
||||
targetWindow.messageManager.addMessageListener("Social:DOMWindowClose", _mozSocialDOMWindowClose);
|
||||
});
|
||||
return;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user