Bug 1391594 - If a browser window unloads, make sure ProcessHangMonitor removes event handlers. r?billm
MozReview-Commit-ID: IgA7vQSOCtp
--- a/browser/modules/ProcessHangMonitor.jsm
+++ b/browser/modules/ProcessHangMonitor.jsm
@@ -391,31 +391,41 @@ var ProcessHangMonitor = {
/**
* Install event handlers on |win| to watch for events that would
* cause a different hang report to be displayed.
*/
trackWindow(win) {
win.gBrowser.tabContainer.addEventListener("TabSelect", this, true);
win.gBrowser.tabContainer.addEventListener("TabRemotenessChange", this, true);
+ win.addEventListener("unload", this, true);
},
untrackWindow(win) {
win.gBrowser.tabContainer.removeEventListener("TabSelect", this, true);
win.gBrowser.tabContainer.removeEventListener("TabRemotenessChange", this, true);
+ win.removeEventListener("unload", this, true);
},
handleEvent(event) {
let win = event.target.ownerGlobal;
- // If a new tab is selected or if a tab changes remoteness, then
- // we may need to show or hide a hang notification.
-
- if (event.type == "TabSelect" || event.type == "TabRemotenessChange") {
- this.updateWindow(win);
+ switch (event.type) {
+ // If a new tab is selected or if a tab changes remoteness, then
+ // we may need to show or hide a hang notification.
+ case "TabSelect":
+ // intentional fall-through
+ case "TabRemotenessChange": {
+ this.updateWindow(win);
+ break;
+ }
+ case "unload": {
+ this.untrackWindow(win);
+ break;
+ }
}
},
/**
* Handle a potentially new hang report. If it hasn't been seen
* before, show a notification for it in all open XUL windows.
*/
reportHang(report) {