Bug 1065128 - Make Identity API use dom-window-destroyed for shutdown; r=ferjmoreno a=bbajaj
authorKyle Machulis <kyle@nonpolynomial.com>
Fri, 19 Sep 2014 10:25:35 -0700
changeset 226222 63382fe8225ee0144df0a649403ce46fb9b6c9a3
parent 226221 f83fde4ed9f4362281c7a10d67b31b26830c82be
child 226223 bfb75367ae2490e75f282bb51623a8c49e606534
push id583
push userbhearsum@mozilla.com
push dateMon, 24 Nov 2014 19:04:58 +0000
treeherdermozilla-release@c107e74250f4 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersferjmoreno, bbajaj
bugs1065128
milestone34.0a2
Bug 1065128 - Make Identity API use dom-window-destroyed for shutdown; r=ferjmoreno a=bbajaj
dom/identity/nsDOMIdentity.js
--- a/dom/identity/nsDOMIdentity.js
+++ b/dom/identity/nsDOMIdentity.js
@@ -702,24 +702,24 @@ nsDOMIdentityInternal.prototype = {
     if (msg.id != this._id) {
       return;
     }
     this._identity._receiveMessage(aMessage);
   },
 
   // nsIObserver
   observe: function nsDOMIdentityInternal_observe(aSubject, aTopic, aData) {
-    let wId = aSubject.QueryInterface(Ci.nsISupportsPRUint64).data;
-    if (wId != this._innerWindowID) {
+    let window = aSubject.QueryInterface(Ci.nsIDOMWindow);
+    if(window != this._window) {
       return;
     }
 
     this._identity.uninit();
 
-    Services.obs.removeObserver(this, "inner-window-destroyed");
+    Services.obs.removeObserver(this, "dom-window-destroyed");
     this._identity._initializeState();
     this._identity = null;
 
     // TODO: Also send message to DOMIdentity notifiying window is no longer valid
     // ie. in the case that the user closes the auth. window and we need to know.
 
     try {
       for (let msgName of this._messages) {
@@ -748,16 +748,17 @@ nsDOMIdentityInternal.prototype = {
 
     // To avoid cross-process windowId collisions, use a uuid as an
     // almost certainly unique identifier.
     //
     // XXX Bug 869182 - use a combination of child process id and
     // innerwindow id to construct the unique id.
     this._id = uuidgen.generateUUID().toString();
     this._innerWindowID = util.currentInnerWindowID;
+    this._window = aWindow;
 
     // nsDOMIdentity needs to know our _id, so this goes after
     // its creation.
     this._identity = new nsDOMIdentity(this);
     this._identity._init(aWindow);
 
     this._log("init was called from " + aWindow.document.location);
 
@@ -775,17 +776,17 @@ nsDOMIdentityInternal.prototype = {
       "Identity:IDP:CallGenKeyPairCallback",
       "Identity:IDP:CallBeginAuthenticationCallback"
     ];
     this._messages.forEach(function(msgName) {
       this._mm.addMessageListener(msgName, this);
     }, this);
 
     // Setup observers so we can remove message listeners.
-    Services.obs.addObserver(this, "inner-window-destroyed", false);
+    Services.obs.addObserver(this, "dom-window-destroyed", false);
 
     return this._identity;
   },
 
   // Private.
   _log: function nsDOMIdentityInternal__log(msg) {
     if (!this._debug) {
       return;