node/deps/v8/test/inspector/debugger/terminate-execution-on-pause.js
Michaël Zasso 09a8440b45
deps: update V8 to 12.2.281.27
PR-URL: https://github.com/nodejs/node/pull/51362
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
Reviewed-By: Rafael Gonzaga <rafael.nunu@hotmail.com>
2024-03-31 15:36:07 +02:00

66 lines
2.1 KiB
JavaScript

// Copyright 2018 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('Tests Runtime.terminateExecution on pause');
Protocol.Runtime.enable();
Protocol.Runtime.onConsoleAPICalled(
message => InspectorTest.logMessage(message.params.args[0]));
Protocol.Debugger.enable();
InspectorTest.runAsyncTestSuite([
async function testTerminateOnDebugger() {
Protocol.Runtime.evaluate({expression: `
function callback() {
debugger;
console.log(42);
setTimeout(callback, 0);
}
callback();
//# sourceURL=test.js`});
await Protocol.Debugger.oncePaused();
const terminated = Protocol.Runtime.terminateExecution();
await Protocol.Debugger.resume();
await terminated;
},
async function testTerminateAtBreakpoint() {
Protocol.Debugger.setBreakpointByUrl({url: 'test.js', lineNumber: 2});
const result = Protocol.Runtime.evaluate({expression: `
function callback() {
console.log(42);
setTimeout(callback, 0);
}
callback();
//# sourceURL=test.js`}).then(InspectorTest.logMessage);
await Protocol.Debugger.oncePaused();
const terminated = Protocol.Runtime.terminateExecution();
await Protocol.Debugger.resume();
await terminated;
await result;
},
async function testTerminateRuntimeEvaluateOnCallFrame() {
Protocol.Runtime.evaluate({expression: `
function callback() {
let a = 1;
debugger;
console.log(43);
}
callback();
//# sourceURL=test.js`});
let message = await Protocol.Debugger.oncePaused();
let topFrameId = message.params.callFrames[0].callFrameId;
await Protocol.Debugger.evaluateOnCallFrame({callFrameId: topFrameId, expression: "a"})
.then(InspectorTest.logMessage)
await Promise.all([
Protocol.Runtime.terminateExecution().then(InspectorTest.logMessage),
Protocol.Debugger.evaluateOnCallFrame({callFrameId: topFrameId, expression: "a"})
.then(InspectorTest.logMessage)
]);
await Protocol.Debugger.resume();
},
]);