mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 1126756 - Listen for |message-manager-disconnect| instead of |TabClose| to teardown UITour. r=Unfocused
This commit is contained in:
parent
a46b33658d
commit
645ff9f53f
@ -676,10 +676,7 @@ this.UITour = {
|
||||
}
|
||||
this.tourBrowsersByWindow.get(window).add(browser);
|
||||
|
||||
// We don't have a tab if we're in a <browser> without a tab.
|
||||
if (tab) {
|
||||
tab.addEventListener("TabClose", this);
|
||||
}
|
||||
Services.obs.addObserver(this, "message-manager-disconnect", false);
|
||||
|
||||
window.addEventListener("SSWindowClosing", this);
|
||||
|
||||
@ -695,13 +692,6 @@ this.UITour = {
|
||||
break;
|
||||
}
|
||||
|
||||
case "TabClose": {
|
||||
let tab = aEvent.target;
|
||||
let window = tab.ownerDocument.defaultView;
|
||||
this.teardownTourForBrowser(window, tab.linkedBrowser, true);
|
||||
break;
|
||||
}
|
||||
|
||||
case "TabSelect": {
|
||||
let window = aEvent.target.ownerDocument.defaultView;
|
||||
|
||||
@ -733,6 +723,37 @@ this.UITour = {
|
||||
}
|
||||
},
|
||||
|
||||
observe: function(aSubject, aTopic, aData) {
|
||||
log.debug("observe: aTopic =", aTopic);
|
||||
switch (aTopic) {
|
||||
// The browser message manager is disconnected when the <browser> is
|
||||
// destroyed and we want to teardown at that point.
|
||||
case "message-manager-disconnect": {
|
||||
let winEnum = Services.wm.getEnumerator("navigator:browser");
|
||||
while (winEnum.hasMoreElements()) {
|
||||
let window = winEnum.getNext();
|
||||
if (window.closed)
|
||||
continue;
|
||||
|
||||
let tourBrowsers = this.tourBrowsersByWindow.get(window);
|
||||
if (!tourBrowsers)
|
||||
continue;
|
||||
|
||||
for (let browser of tourBrowsers) {
|
||||
let messageManager = browser.messageManager;
|
||||
if (aSubject != messageManager) {
|
||||
continue;
|
||||
}
|
||||
|
||||
this.teardownTourForBrowser(window, browser, true);
|
||||
return;
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
setTelemetryBucket: function(aPageID) {
|
||||
let bucket = BUCKET_NAME + BrowserUITelemetry.BUCKET_SEPARATOR + aPageID;
|
||||
BrowserUITelemetry.setBucket(bucket);
|
||||
@ -766,14 +787,8 @@ this.UITour = {
|
||||
}
|
||||
|
||||
let openTourBrowsers = this.tourBrowsersByWindow.get(aWindow);
|
||||
if (aTourPageClosing) {
|
||||
let tab = aWindow.gBrowser.getTabForBrowser(aBrowser);
|
||||
if (tab) { // Handle standalone <browser>
|
||||
tab.removeEventListener("TabClose", this);
|
||||
if (openTourBrowsers) {
|
||||
openTourBrowsers.delete(aBrowser);
|
||||
}
|
||||
}
|
||||
if (aTourPageClosing && openTourBrowsers) {
|
||||
openTourBrowsers.delete(aBrowser);
|
||||
}
|
||||
|
||||
this.hideHighlight(aWindow);
|
||||
@ -814,9 +829,6 @@ this.UITour = {
|
||||
let pageID = this.pageIDSourceBrowsers.get(browser);
|
||||
this.setExpiringTelemetryBucket(pageID, "closed");
|
||||
}
|
||||
|
||||
let tab = aWindow.gBrowser.getTabForBrowser(browser);
|
||||
tab.removeEventListener("TabClose", this);
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user