From 638039808822bcba5303920c98b405cb756ebfeb Mon Sep 17 00:00:00 2001 From: Felipe Gomes Date: Thu, 21 Feb 2019 17:58:33 +0000 Subject: [PATCH] Bug 1520075 - Store the window reference on the child actors as a weak reference. r=mconley Differential Revision: https://phabricator.services.mozilla.com/D19850 --HG-- extra : moz-landing-system : lando --- toolkit/modules/ActorManagerChild.jsm | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/toolkit/modules/ActorManagerChild.jsm b/toolkit/modules/ActorManagerChild.jsm index 8e715fd321ee..d1672ecb4e2c 100644 --- a/toolkit/modules/ActorManagerChild.jsm +++ b/toolkit/modules/ActorManagerChild.jsm @@ -63,6 +63,8 @@ class Dispatcher { for (let topic of this.observers.keys()) { Services.obs.removeObserver(this, topic); } + + this.mm.removeEventListener("unload", this); } get window() { @@ -187,7 +189,7 @@ class SingletonDispatcher extends Dispatcher { window.addEventListener("pageshow", this, {mozSystemGroup: true}); window.addEventListener("pagehide", this, {mozSystemGroup: true}); - this._window = window; + this._window = Cu.getWeakReference(window); this.listeners = []; } @@ -227,7 +229,7 @@ class SingletonDispatcher extends Dispatcher { } get window() { - return this._window; + return this._window.get(); } handleEvent(event) {