Bug 1073259 - Print more descriptive errors when SettingsManager tries to make a request with an invalid window. r=bent
authorKyle Machulis <kyle@nonpolynomial.com>
Fri, 17 Oct 2014 05:24:00 -0400
changeset 210920 b73bb9d2c9e1bda1804bea88894f60186ec42a96
parent 210919 80a92f907fbd0de7c56aae6f3882f5fa7f157497
child 210921 3bd9a78ed4446ff07601c7b107a58fbe0dba55df
push id1
push userroot
push dateMon, 20 Oct 2014 17:29:22 +0000
reviewersbent
bugs1073259
milestone36.0a1
Bug 1073259 - Print more descriptive errors when SettingsManager tries to make a request with an invalid window. r=bent
dom/settings/SettingsManager.js
--- a/dom/settings/SettingsManager.js
+++ b/dom/settings/SettingsManager.js
@@ -81,24 +81,16 @@ SettingsLock.prototype = {
   },
 
   get closed() {
     return !this._open;
   },
 
   _closeHelper: function() {
     if (DEBUG) debug("closing lock " + this._id);
-    // sendMessage can get queued to run later in a thread via
-    // _closeHelper, but the SettingsManager may have died in between
-    // the time it was scheduled and the time it runs. Make sure our
-    // window is valid before sending, otherwise just ignore.
-    if (!this._settingsManager._window) {
-      if (DEBUG) debug("SettingsManager died, cannot send " + aMessageName + " message window principal.");
-      return;
-    }
     this._open = false;
     this._closeCalled = false;
     if (!this._requests || Object.keys(this._requests).length == 0) {
       if (DEBUG) debug("Requests exhausted, finalizing " + this._id);
       this._settingsManager.unregisterLock(this._id);
       this.sendMessage("Settings:Finalize", {lockID: this._id});
     } else {
       if (DEBUG) debug("Requests left: " + Object.keys(this._requests).length);
@@ -107,16 +99,28 @@ SettingsLock.prototype = {
   },
 
 
   _wrap: function _wrap(obj) {
     return Cu.cloneInto(obj, this._settingsManager._window);
   },
 
   sendMessage: function(aMessageName, aData) {
+    // sendMessage can be called after our window has died, or get
+    // queued to run later in a thread via _closeHelper, but the
+    // SettingsManager may have died in between the time it was
+    // scheduled and the time it runs. Make sure our window is valid
+    // before sending, otherwise just ignore.
+    if (!this._settingsManager._window) {
+      Cu.reportError(
+        "SettingsManager window died, cannot run settings transaction." +
+        " SettingsMessage: " + aMessageName +
+        " SettingsData: " + JSON.stringify(aData));
+      return;
+    }
     cpmm.sendAsyncMessage(aMessageName,
                           aData,
                           undefined,
                           this._settingsManager._window.document.nodePrincipal);
   },
 
   receiveMessage: function(aMessage) {
     let msg = aMessage.data;