Bug 1073259 - Print more descriptive errors when SettingsManager tries to make a request with an invalid window. r=bent
--- 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;