v8/test/inspector/debugger/evaluate-with-await-on-breakpoint.js
Tim van der Lippe 52b4aae2d9 Improve error message when using await in DebugEvaluate
When evaluating a top-level expression while paused on a breakpoint, we
don't support an await expression as top-level statement. In these
cases, the error was not informative and could be improved.

To do so, we now propagate the information from DebugEvaluate to
ParseInfo and use the parse_info in parser-base to throw a more
informative error while parsing.

R=jarin@chromium.org

Fixed: chromium:1132245
Change-Id: I200c5af7391258256d1d86a09cbcae326327a0d9
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/3247037
Reviewed-by: Leszek Swirski <leszeks@chromium.org>
Reviewed-by: Simon Zünd <szuend@chromium.org>
Reviewed-by: Jakob Gruber <jgruber@chromium.org>
Reviewed-by: Jaroslav Sevcik <jarin@chromium.org>
Commit-Queue: Tim van der Lippe <tvanderlippe@chromium.org>
Cr-Commit-Position: refs/heads/main@{#77587}
2021-10-28 09:56:40 +00:00

40 lines
1.2 KiB
JavaScript

// Copyright 2021 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('Test evaluating await expression on a breakpoint');
contextGroup.addScript(`
async function run() {
debugger;
}`);
InspectorTest.runAsyncTestSuite([async function testScopesPaused() {
Protocol.Debugger.enable();
Protocol.Runtime.evaluate({expression: 'run()'});
let {params: {callFrames}} =
await Protocol.Debugger.oncePaused(); // inside a.fn()
({result} = await Protocol.Debugger.evaluateOnCallFrame({
expression: 'await Promise.resolve(0)',
callFrameId: callFrames[0].callFrameId
}));
InspectorTest.log('Evaluating await expression');
InspectorTest.logObject(result);
({result} = await Protocol.Debugger.evaluateOnCallFrame({
expression:
'async function nested() { await fetch(\'http://google.com\'); } nested()',
callFrameId: callFrames[0].callFrameId
}));
InspectorTest.log('Evaluating await expression in async function');
InspectorTest.logObject(result);
Protocol.Debugger.resume();
Protocol.Debugger.disable();
}]);