Merge branch 'sgravrock-global-errors-rethrow'
- Merges #1347 from @sgravrock
This commit is contained in:
@@ -2168,7 +2168,12 @@ getJasmineRequireObj().GlobalErrors = function(j$) {
|
|||||||
|
|
||||||
var onerror = function onerror() {
|
var onerror = function onerror() {
|
||||||
var handler = handlers[handlers.length - 1];
|
var handler = handlers[handlers.length - 1];
|
||||||
handler.apply(null, Array.prototype.slice.call(arguments, 0));
|
|
||||||
|
if (handler) {
|
||||||
|
handler.apply(null, Array.prototype.slice.call(arguments, 0));
|
||||||
|
} else {
|
||||||
|
throw arguments[0];
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
this.uninstall = function noop() {};
|
this.uninstall = function noop() {};
|
||||||
|
|||||||
@@ -62,6 +62,22 @@ describe("GlobalErrors", function() {
|
|||||||
expect(fakeGlobal.onerror).toBe(originalCallback);
|
expect(fakeGlobal.onerror).toBe(originalCallback);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it("rethrows the original error when there is no handler", function() {
|
||||||
|
var fakeGlobal = { },
|
||||||
|
errors = new jasmineUnderTest.GlobalErrors(fakeGlobal),
|
||||||
|
originalError = new Error('nope');
|
||||||
|
|
||||||
|
errors.install();
|
||||||
|
|
||||||
|
try {
|
||||||
|
fakeGlobal.onerror(originalError);
|
||||||
|
} catch (e) {
|
||||||
|
expect(e).toBe(originalError);
|
||||||
|
}
|
||||||
|
|
||||||
|
errors.uninstall();
|
||||||
|
});
|
||||||
|
|
||||||
it("works in node.js", function() {
|
it("works in node.js", function() {
|
||||||
var fakeGlobal = {
|
var fakeGlobal = {
|
||||||
process: {
|
process: {
|
||||||
|
|||||||
@@ -5,7 +5,12 @@ getJasmineRequireObj().GlobalErrors = function(j$) {
|
|||||||
|
|
||||||
var onerror = function onerror() {
|
var onerror = function onerror() {
|
||||||
var handler = handlers[handlers.length - 1];
|
var handler = handlers[handlers.length - 1];
|
||||||
handler.apply(null, Array.prototype.slice.call(arguments, 0));
|
|
||||||
|
if (handler) {
|
||||||
|
handler.apply(null, Array.prototype.slice.call(arguments, 0));
|
||||||
|
} else {
|
||||||
|
throw arguments[0];
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
this.uninstall = function noop() {};
|
this.uninstall = function noop() {};
|
||||||
|
|||||||
Reference in New Issue
Block a user