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

View File

@@ -96,7 +96,17 @@ getJasmineRequireObj().GlobalErrors = function(j$) {
handlers.push(listener);
};
this.popListener = function popListener() {
this.popListener = function popListener(listener) {
if (!listener) {
throw new Error('popListener expects a listener');
}
if (listener !== handlers[handlers.length - 1]) {
throw new Error(
'popListener was passed a different listener than the current one'
);
}
handlers.pop();
};
}