v8/test/inspector/debugger/restart-frame/restart-various-frames.js
Simon Zünd 29c4cf0e3c [inspector] Move restart-frame test helpers into protocol-test.js
R=bmeurer@chromium.org

Bug: chromium:1303521
Change-Id: Iff7247fda94037ff4f9d37f334d386eb4e63ce62
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/3595819
Commit-Queue: Simon Zünd <szuend@chromium.org>
Auto-Submit: Simon Zünd <szuend@chromium.org>
Reviewed-by: Benedikt Meurer <bmeurer@chromium.org>
Commit-Queue: Benedikt Meurer <bmeurer@chromium.org>
Cr-Commit-Position: refs/heads/main@{#80038}
2022-04-20 08:02:34 +00:00

70 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('Checks that restarting every frame on the stack works.');
session.setupScriptMap();
contextGroup.addScript(`
function A() {
console.log('A');
debugger;
return 'Magic value';
}
function B(param1, param2) {
console.log('B');
return A();
}
function C() {
console.log('C');
// Function call with argument adapter is intentional.
return B();
}
function D() {
console.log('D');
// Function call with argument adapter is intentional.
return C(42, 'foo');
}
function E() {
console.log('E');
return D();
}
function F() {
console.log('F');
return E();
}
`, 0, 0, 'test.js');
async function testCase(frameIndex) {
const { callFrames, evaluatePromise } = await InspectorTest.evaluateAndWaitForPause('F()');
await InspectorTest.restartFrameAndWaitForPause(callFrames, frameIndex);
Protocol.Debugger.resume(); // Resuming hits the 'debugger' stmt again.
await Protocol.Debugger.oncePaused();
await Protocol.Debugger.resume();
const { result: { result: { value } } } = await evaluatePromise;
InspectorTest.log(`Evaluating to: ${value}`);
}
(async () => {
await Protocol.Debugger.enable();
await Protocol.Runtime.enable();
const consoleMessages = [];
Protocol.Runtime.onConsoleAPICalled(({ params }) => {
consoleMessages.push(params.args[0].value);
});
for (let index = 0; index < 6; ++index) {
InspectorTest.log(`\n---- Restarting at frame index ${index} ----`);
await testCase(index);
InspectorTest.log(`Called functions: ${consoleMessages.join()}`);
consoleMessages.splice(0);
}
InspectorTest.completeTest();
})();