From 6bf0a5cb5034a7e684dcc3500e841785237ce2dd Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Sun, 7 Apr 2024 19:32:43 +0200 Subject: Adding upstream version 1:115.7.0. Signed-off-by: Daniel Baumann --- devtools/server/tests/xpcshell/test_stepping-18.js | 100 +++++++++++++++++++++ 1 file changed, 100 insertions(+) create mode 100644 devtools/server/tests/xpcshell/test_stepping-18.js (limited to 'devtools/server/tests/xpcshell/test_stepping-18.js') diff --git a/devtools/server/tests/xpcshell/test_stepping-18.js b/devtools/server/tests/xpcshell/test_stepping-18.js new file mode 100644 index 0000000000..e8581835d3 --- /dev/null +++ b/devtools/server/tests/xpcshell/test_stepping-18.js @@ -0,0 +1,100 @@ +/* Any copyright is dedicated to the Public Domain. + http://creativecommons.org/publicdomain/zero/1.0/ */ + +"use strict"; + +/** + * Check scenarios where we're leaving function a and + * going to the function b's call-site. + */ + +async function testFinish({ threadFront, devToolsClient }) { + await close(devToolsClient); + + do_test_finished(); +} + +async function invokeAndPause({ global, threadFront }, expression) { + return executeOnNextTickAndWaitForPause( + () => Cu.evalInSandbox(expression, global), + threadFront + ); +} + +async function steps(threadFront, sequence) { + const locations = []; + for (const cmd of sequence) { + const packet = await step(threadFront, cmd); + locations.push(getPauseLocation(packet)); + } + return locations; +} + +async function step(threadFront, cmd) { + return cmd(threadFront); +} + +function getPauseLocation(packet) { + const { line, column } = packet.frame.where; + return { line, column }; +} + +async function stepOutOfA(dbg, func, frameIndex, expectedLocation) { + const { threadFront } = dbg; + + info("pause and step into a()"); + await invokeAndPause(dbg, `${func}()`); + await steps(threadFront, [stepOver, stepIn, stepIn]); + + const { frames } = await threadFront.frames(0, 5); + const frameActorID = frames[frameIndex].actorID; + const packet = await stepOut(threadFront, frameActorID); + + deepEqual( + getPauseLocation(packet), + expectedLocation, + `step over location in ${func}` + ); + + await dbg.threadFront.resume(); +} + +async function stepOverInA(dbg, func, frameIndex, expectedLocation) { + const { threadFront } = dbg; + + info("pause and step into a()"); + await invokeAndPause(dbg, `${func}()`); + await steps(threadFront, [stepOver, stepIn]); + + const { frames } = await threadFront.frames(0, 5); + const frameActorID = frames[frameIndex].actorID; + const packet = await stepOver(threadFront, frameActorID); + + deepEqual( + getPauseLocation(packet), + expectedLocation, + `step over location in ${func}` + ); + + await dbg.threadFront.resume(); +} + +function run_test() { + return (async function () { + const dbg = await setupTestFromUrl("stepping.js"); + + info(`Test step over with the 1st frame`); + await stepOverInA(dbg, "arithmetic", 0, { line: 8, column: 0 }); + + info(`Test step over with the 2nd frame`); + await stepOverInA(dbg, "arithmetic", 1, { line: 17, column: 0 }); + + info(`Test step out with the 1st frame`); + await stepOutOfA(dbg, "nested", 0, { line: 31, column: 0 }); + + info(`Test step out with the 2nd frame`); + await stepOutOfA(dbg, "nested", 1, { line: 36, column: 0 }); + + await testFinish(dbg); + })(); +} -- cgit v1.2.3