62bd0c9958
Previously we'd predict exceptions thrown in [[Reject]] handlers as always caught (by PromiseRejectReactionJob), but that's not what is actually specified in ECMAScript. The PromiseRejectReactionJob will turn any exception thrown into a promise rejection just like we do in the case of PromiseFulfillReactionJob, and so the catch prediction should match that behavior. Fixed: chromium:1290861 Change-Id: Id992708b009666da7c6bf1b6e3cf30752ca0a227 Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/3423775 Auto-Submit: Benedikt Meurer <bmeurer@chromium.org> Reviewed-by: Jaroslav Sevcik <jarin@chromium.org> Commit-Queue: Jaroslav Sevcik <jarin@chromium.org> Cr-Commit-Position: refs/heads/main@{#78864}
40 lines
1.2 KiB
JavaScript
40 lines
1.2 KiB
JavaScript
// Copyright 2022 the V8 project authors. All rights reserved.
|
|
// Use of this source code is governed by a BSD-style license that can be
|
|
// found in the LICENSE file.
|
|
|
|
let {session, contextGroup, Protocol} = InspectorTest.start(
|
|
'Ensure that catch prediction is correct for [[Reject]] handlers.');
|
|
|
|
contextGroup.addScript(`function throwInPromiseCaughtAndRethrown() {
|
|
var reject;
|
|
var promise = new Promise(function(res, rej) { reject = rej; }).catch(
|
|
function rejectHandler(e) {
|
|
throw e;
|
|
}
|
|
);
|
|
reject(new Error());
|
|
return promise;
|
|
}`);
|
|
|
|
Protocol.Debugger.onPaused(({params: {callFrames, data}}) => {
|
|
InspectorTest.log(`${data.uncaught ? 'Uncaught' : 'Caught'} exception in ${
|
|
callFrames[0].functionName}`);
|
|
Protocol.Debugger.resume();
|
|
});
|
|
|
|
InspectorTest.runAsyncTestSuite([async function test() {
|
|
await Promise.all([
|
|
Protocol.Runtime.enable(),
|
|
Protocol.Debugger.enable(),
|
|
Protocol.Debugger.setPauseOnExceptions({state: 'uncaught'}),
|
|
]);
|
|
await Protocol.Runtime.evaluate({
|
|
awaitPromise: true,
|
|
expression: 'throwInPromiseCaughtAndRethrown()',
|
|
});
|
|
await Promise.all([
|
|
Protocol.Runtime.disable(),
|
|
Protocol.Debugger.disable(),
|
|
]);
|
|
}]);
|