17536f94d6
The ExceptionDetails structure allows the association of requests and issues with JavaScript errors. These are currently only reported when an exception goes through `Runtime#exceptionThrown`, but we also want the metadata available when the ExceptionDetails are requested explicitly for any Error object. R=bmeurer@chromium.org Bug: chromium:1280141 Change-Id: I1b1514207b9e146fda3452c3f7991cd7dc9a387b Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/3477098 Reviewed-by: Benedikt Meurer <bmeurer@chromium.org> Commit-Queue: Simon Zünd <szuend@chromium.org> Cr-Commit-Position: refs/heads/main@{#79199}
50 lines
1.8 KiB
JavaScript
50 lines
1.8 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.
|
|
|
|
const {session, contextGroup, Protocol} =
|
|
InspectorTest.start('Tests that Runtime.getExceptionDetails works');
|
|
|
|
const expression = `
|
|
function foo() {
|
|
return new Error("error 1");
|
|
}
|
|
foo();
|
|
`;
|
|
|
|
const expressionWithMeta = `
|
|
function foo() {
|
|
return new inspector.newExceptionWithMetaData('myerror', 'foo', 'bar');
|
|
}
|
|
foo();
|
|
`;
|
|
|
|
InspectorTest.runAsyncTestSuite([
|
|
async function itShouldReturnExceptionDetailsForJSErrorObjects() {
|
|
await Protocol.Runtime.enable(); // Enable detailed stacktrace capturing.
|
|
const {result} = await Protocol.Runtime.evaluate({expression});
|
|
InspectorTest.logMessage(await Protocol.Runtime.getExceptionDetails(
|
|
{errorObjectId: result.result.objectId}));
|
|
},
|
|
|
|
async function itShouldReturnIncompleteDetailsForJSErrorWithNoStack() {
|
|
await Protocol.Runtime.disable(); // Disable detailed stacktrace capturing.
|
|
const {result} = await Protocol.Runtime.evaluate({expression});
|
|
InspectorTest.logMessage(await Protocol.Runtime.getExceptionDetails(
|
|
{errorObjectId: result.result.objectId}));
|
|
},
|
|
|
|
async function itShouldReportAnErrorForNonJSErrorObjects() {
|
|
const {result} = await Protocol.Runtime.evaluate({expression: '() =>({})'});
|
|
InspectorTest.logMessage(await Protocol.Runtime.getExceptionDetails(
|
|
{errorObjectId: result.result.objectId}));
|
|
},
|
|
|
|
async function itShouldIncludeMetaData() {
|
|
await Protocol.Runtime.enable(); // Enable detailed stacktrace capturing.
|
|
const {result} = await Protocol.Runtime.evaluate({expression: expressionWithMeta});
|
|
InspectorTest.logMessage(await Protocol.Runtime.getExceptionDetails(
|
|
{errorObjectId: result.result.objectId}));
|
|
}
|
|
]);
|