Skip to content

Commit

Permalink
Do not override Promise prorotype in layout test infrastructure
Browse files Browse the repository at this point in the history
We can use the same fix as in https://crrev.com/c/1964310
and listen for "unhandledrejection" events instead.

[email protected]

Bug: none
Change-Id: I9e00f50f36d5cf9f2e54b2d1ce467ad6589afaff
Reviewed-on: https://chromium-review.googlesource.com/c/devtools/devtools-frontend/+/2919952
Auto-Submit: Tim van der Lippe <[email protected]>
Reviewed-by: Jack Franklin <[email protected]>
Commit-Queue: Jack Franklin <[email protected]>
Commit-Queue: Tim van der Lippe <[email protected]>
  • Loading branch information
TimvdLippe authored and Devtools-frontend LUCI CQ committed May 26, 2021
1 parent 8175250 commit f2cebf1
Showing 1 changed file with 3 additions and 21 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -37,28 +37,10 @@ SourcesTestRunner.completeDebuggerTest = function() {
});
};

(function() {
const origThen = Promise.prototype.then;
const origCatch = Promise.prototype.catch;

Promise.prototype.then = function() {
const result = origThen.apply(this, arguments);
origThen.call(result, undefined, onUncaughtPromiseReject.bind(null, new Error().stack));
return result;
};

Promise.prototype.catch = function() {
const result = origCatch.apply(this, arguments);
origThen.call(result, undefined, onUncaughtPromiseReject.bind(null, new Error().stack));
return result;
};

function onUncaughtPromiseReject(stack, e) {
const message = typeof e === 'object' && e.stack || e;
TestRunner.addResult('FAIL: Uncaught exception in promise: ' + message + ' ' + stack);
window.addEventListener('unhandledrejection', e => {
TestRunner.addResult('FAIL: Uncaught exception in promise: ' + e + ' ' + e.stack);
SourcesTestRunner.completeDebuggerTest();
}
})();
});

SourcesTestRunner.runDebuggerTestSuite = function(testSuite) {
const testSuiteTests = testSuite.slice();
Expand Down

0 comments on commit f2cebf1

Please sign in to comment.