Bug 707507 - Zombie compartment at AMO in Nightly
authorFabrice Desré <fabrice@mozilla.com>
Wed, 07 Dec 2011 18:15:42 -0800
changeset 82225 26a3ca3d8cdc6bfbd555c6a0f93cac2e8f90d579
parent 82224 0d7b275a3d6e170d1d56cb87edaf8cc8f9b4bf87
child 82226 34b8fe0283576a3771e804b6d0c1d609eb1013c1
push id21587
push userbmo@edmorley.co.uk
push dateThu, 08 Dec 2011 15:13:43 +0000
treeherdermozilla-central@98db2311a44c [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
bugs707507
milestone11.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 707507 - Zombie compartment at AMO in Nightly
dom/base/Webapps.js
--- a/dom/base/Webapps.js
+++ b/dom/base/Webapps.js
@@ -232,41 +232,42 @@ WebappsRegistry.prototype = {
   
   enumerate: function(aSuccess, aError) {
     this.mm.sendAsyncMessage("Webapps:Enumerate", { from: this._window.location.href,
                                                     origin: this._getOrigin(this._window.location.href),
                                                     oid: this._id,
                                                     callbackID:  this.getCallbackId({ success: aSuccess, error: aError }) });
   },
 
-  handleEvent: function(aEvent) {
-    if (aEvent.type == "unload") {
-      // remove all callbacks and event handlers so we don't call anything on a cleared scope
-      try {
-        this._oninstall = null;
-        this._onuninstall = null;
-        this._onerror = null;
-        this._callbacks = [];
-      } catch(e) {
-        dump("WebappsRegistry error:" + e + "\n");
-      }
+  observe: function(aSubject, aTopic, aData) {
+    let wId = aSubject.QueryInterface(Ci.nsISupportsPRUint64).data;
+    if (wId == this.innerWindowID) {
+      Services.obs.removeObserver(this, "inner-window-destroyed");
+      this._oninstall = null;
+      this._onuninstall = null;
+      this._onerror = null;
+      this._callbacks = [];
+      this._window = null;
     }
   },
-  
+
   // nsIDOMGlobalPropertyInitializer implementation
   init: function(aWindow) {
     dump("DOMApplicationRegistry::init() " + aWindow + "\n");
     this._window = aWindow;
-    this._window.addEventListener("unload", this, false);
     this._window.appId = this._id;
     let from = Services.io.newURI(this._window.location.href, null, null);
     let perm = Services.perms.testExactPermission(from, "webapps-manage");
 
     //only pages with perm set and chrome or about pages can uninstall, enumerate all set oninstall an onuninstall
     this.hasPrivileges = perm == Ci.nsIPermissionManager.ALLOW_ACTION || from.schemeIs("chrome") || from.schemeIs("about");
+
+    Services.obs.addObserver(this, "inner-window-destroyed", false);
+    let util = this._window.QueryInterface(Ci.nsIInterfaceRequestor).getInterface(Ci.nsIDOMWindowUtils);
+    this.innerWindowID = util.currentInnerWindowID;
   },
   
   classID: Components.ID("{fff440b3-fae2-45c1-bf03-3b5a2e432270}"),
 
   QueryInterface: XPCOMUtils.generateQI([Ci.mozIDOMApplicationRegistry, Ci.nsIDOMGlobalPropertyInitializer]),
   
   classInfo: XPCOMUtils.generateCI({classID: Components.ID("{fff440b3-fae2-45c1-bf03-3b5a2e432270}"),
                                     contractID: "@mozilla.org/webapps;1",