Detect global error handler stack corruption
This commit is contained in:
@@ -58,7 +58,7 @@ describe('GlobalErrors', function() {
|
||||
errors.pushListener(handler1);
|
||||
errors.pushListener(handler2);
|
||||
|
||||
errors.popListener();
|
||||
errors.popListener(handler2);
|
||||
|
||||
fakeGlobal.onerror('foo');
|
||||
|
||||
@@ -66,6 +66,23 @@ describe('GlobalErrors', function() {
|
||||
expect(handler2).not.toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it('throws when no listener is passed to #popListener', function() {
|
||||
var errors = new jasmineUnderTest.GlobalErrors({});
|
||||
expect(function() {
|
||||
errors.popListener();
|
||||
}).toThrowError('popListener expects a listener');
|
||||
});
|
||||
|
||||
it('throws when the argument to #popListener is not the current listener', function() {
|
||||
var errors = new jasmineUnderTest.GlobalErrors({});
|
||||
errors.pushListener(function() {});
|
||||
expect(function() {
|
||||
errors.popListener(function() {});
|
||||
}).toThrowError(
|
||||
'popListener was passed a different listener than the current one'
|
||||
);
|
||||
});
|
||||
|
||||
it('uninstalls itself, putting back a previous callback', function() {
|
||||
var originalCallback = jasmine.createSpy('error'),
|
||||
fakeGlobal = { onerror: originalCallback },
|
||||
|
||||
@@ -974,7 +974,6 @@ describe("Env integration", function() {
|
||||
env.execute(null, function() {
|
||||
expect(delayedFunctionForMockClock).toHaveBeenCalled();
|
||||
expect(globalSetTimeout).toHaveBeenCalledWith(delayedFunctionForGlobalClock, 100);
|
||||
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user