v8/test/inspector/debugger/set-script-source-top-frame-with-additional-activations.js

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

52 lines
1.8 KiB
JavaScript
Raw Normal View History

Reland "[inspector] Allow Debugger.setScriptSource to edit top-most function" This is a reland of commit dac61556497c6268db0f2960e67e26116300b314 This is a straight-up reland with no changes, because: 1) The failure doesn't reproduce locally 2) The failing flaky test that triggered the revert is not related to the code modified by this CL and should (in theory) not be impacted. Original change's description: > [inspector] Allow Debugger.setScriptSource to edit top-most function > > This CL adds a new boolean flag on the Debugger.setScriptSource CDP > method that gets piped all the way through to the live-edit mechanism. > The new flag enables live-editing of the top-most function while > paused. > > The CL adds a couple of tests that cover the new core use cases for > this flag. > > R=jarin@chromium.org > > Bug: chromium:1334484 > Change-Id: I12fec591b2b6550d89748714620e629548e1b9c1 > Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/3695354 > Reviewed-by: Kim-Anh Tran <kimanh@chromium.org> > Reviewed-by: Jaroslav Sevcik <jarin@chromium.org> > Commit-Queue: Simon Zünd <szuend@chromium.org> > Cr-Commit-Position: refs/heads/main@{#81127} Bug: chromium:1334484 Change-Id: I9a9bf7e03d81c86adb4819b9756dd9afcf6fa021 Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/3706398 Reviewed-by: Kim-Anh Tran <kimanh@chromium.org> Bot-Commit: Rubber Stamper <rubber-stamper@appspot.gserviceaccount.com> Commit-Queue: Simon Zünd <szuend@chromium.org> Cr-Commit-Position: refs/heads/main@{#81171}
2022-06-14 05:16:27 +00:00
// 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 setScriptSource fails when editing the top-most stack frame, but that function also has an activation further down the stack');
const script = `
function callsTestExpression(a, b) {
return testExpression(a, b);
}
function testExpression(a, b) {
debugger;
if (!a && !b) {
return callsTestExpression(5, 3);
}
return a + b;
}`;
const replacementScript = script.replace('a + b', 'a * b');
contextGroup.addScript(script);
session.setupScriptMap();
(async () => {
Protocol.Debugger.enable();
const { params: { scriptId } } = await Protocol.Debugger.onceScriptParsed();
const evaluatePromise = Protocol.Runtime.evaluate({ expression: 'callsTestExpression()' });
let { params: { callFrames: pausedCallFrames } } = await Protocol.Debugger.oncePaused();
InspectorTest.log('First pause at (before live edit):');
await session.logSourceLocation(pausedCallFrames[0].location);
Protocol.Debugger.resume();
({ params: { callFrames: pausedCallFrames } } = await Protocol.Debugger.oncePaused());
InspectorTest.log('Second pause at (before live edit):');
await session.logSourceLocation(pausedCallFrames[0].location);
const response = await Protocol.Debugger.setScriptSource({ scriptId, scriptSource: replacementScript, allowTopFrameEditing: true })
InspectorTest.log('Debugger.setScriptSource result:');
InspectorTest.logMessage(response.result);
Protocol.Debugger.resume();
const { result: { result } } = await evaluatePromise;
InspectorTest.log('Evaluation result:');
InspectorTest.logMessage(result);
InspectorTest.completeTest();
})();