Detect global error handler stack corruption

This commit is contained in:
Steve Gravrock
2020-09-02 14:43:17 -07:00
parent 00feef8632
commit 0b81705c11
4 changed files with 40 additions and 4 deletions
+18 -1
View File
@@ -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 },
-1
View File
@@ -974,7 +974,6 @@ describe("Env integration", function() {
env.execute(null, function() {
expect(delayedFunctionForMockClock).toHaveBeenCalled();
expect(globalSetTimeout).toHaveBeenCalledWith(delayedFunctionForGlobalClock, 100);
done();
});
});