Use 'self' instead of 'global' as global object in Bluebird

This fixes an error when other errors occur in recent versions of Bluebird.
This commit is contained in:
Dan Stillman 2015-02-03 15:31:37 -05:00
parent d660a84f47
commit 91d14fc04c

View file

@ -33,10 +33,10 @@
EXPORTED_SYMBOLS = ["Promise"]; EXPORTED_SYMBOLS = ["Promise"];
// Set BackstagePass (which contains .Error, etc.) as global object // Set BackstagePass (which contains .Error, etc.) as global object
global = this; self = this;
// Provide an implementation of setTimeout // Provide an implementation of setTimeout
global.setTimeout = new function() { self.setTimeout = new function() {
// We need to maintain references to running nsITimers. Otherwise, they can // We need to maintain references to running nsITimers. Otherwise, they can
// get garbage collected before they fire. // get garbage collected before they fire.
var _runningTimers = []; var _runningTimers = [];
@ -70,15 +70,15 @@
Components.classes["@mozilla.org/consoleservice;1"] Components.classes["@mozilla.org/consoleservice;1"]
.getService(Components.interfaces.nsIConsoleService) .getService(Components.interfaces.nsIConsoleService)
.logMessage(scriptError); .logMessage(scriptError);
global.debug(err, 1); self.debug(err, 1);
global.debug(err.stack, 1); self.debug(err.stack, 1);
} }
}}, ms, Components.interfaces.nsITimer.TYPE_ONE_SHOT); }}, ms, Components.interfaces.nsITimer.TYPE_ONE_SHOT);
_runningTimers.push(timer); _runningTimers.push(timer);
} }
}; };
global.debug = function (msg) { self.debug = function (msg) {
dump(msg + "\n\n"); dump(msg + "\n\n");
}; };
@ -86,9 +86,9 @@
// TEMP: Only turn on if debug logging enabled? // TEMP: Only turn on if debug logging enabled?
Promise.longStackTraces(); Promise.longStackTraces();
Promise.onPossiblyUnhandledRejection(function(error) { Promise.onPossiblyUnhandledRejection(function(error) {
global.debug('==========='); self.debug('===========');
global.debug(error); self.debug(error);
global.debug(error.stack); self.debug(error.stack);
throw error; throw error;
}); });
return; return;