summaryrefslogtreecommitdiffstats
path: root/devtools/server/tests/xpcshell/test_stepping-15.js
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-28 14:29:10 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-28 14:29:10 +0000
commit2aa4a82499d4becd2284cdb482213d541b8804dd (patch)
treeb80bf8bf13c3766139fbacc530efd0dd9d54394c /devtools/server/tests/xpcshell/test_stepping-15.js
parentInitial commit. (diff)
downloadfirefox-2aa4a82499d4becd2284cdb482213d541b8804dd.tar.xz
firefox-2aa4a82499d4becd2284cdb482213d541b8804dd.zip
Adding upstream version 86.0.1.upstream/86.0.1upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'devtools/server/tests/xpcshell/test_stepping-15.js')
-rw-r--r--devtools/server/tests/xpcshell/test_stepping-15.js79
1 files changed, 79 insertions, 0 deletions
diff --git a/devtools/server/tests/xpcshell/test_stepping-15.js b/devtools/server/tests/xpcshell/test_stepping-15.js
new file mode 100644
index 0000000000..6981758b8f
--- /dev/null
+++ b/devtools/server/tests/xpcshell/test_stepping-15.js
@@ -0,0 +1,79 @@
+/* Any copyright is dedicated to the Public Domain.
+ http://creativecommons.org/publicdomain/zero/1.0/ */
+
+"use strict";
+
+/**
+ * Test stepping from inside a blackboxed function
+ * test-page: https://dbg-blackbox-stepping.glitch.me/
+ */
+
+async function invokeAndPause({ global, threadFront }, expression, url) {
+ return executeOnNextTickAndWaitForPause(
+ () => Cu.evalInSandbox(expression, global, "1.8", url, 1),
+ threadFront
+ );
+}
+add_task(
+ threadFrontTest(async ({ threadFront, targetFront, debuggee }) => {
+ const consoleFront = await targetFront.getFront("console");
+ const dbg = { global: debuggee, threadFront };
+
+ // Test stepping from a blackboxed location
+ async function testStepping(action, expectedLine) {
+ consoleFront.evaluateJSAsync(`outermost()`);
+ await waitForPause(threadFront);
+ await blackBox(blackboxedSourceFront);
+ const packet = await action(threadFront);
+ const { line, actor } = packet.frame.where;
+ equal(actor, unblackboxedActor, "paused in unblackboxed source");
+ equal(line, expectedLine, "paused at correct line");
+ await threadFront.resume();
+ await unBlackBox(blackboxedSourceFront);
+ }
+
+ invokeAndPause(
+ dbg,
+ `function outermost() {
+ const value = blackboxed1();
+ return value + 1;
+ }
+ function innermost() {
+ return 1;
+ }`,
+ "http://example.com/unblackboxed.js"
+ );
+ invokeAndPause(
+ dbg,
+ `function blackboxed1() {
+ return blackboxed2();
+ }
+ function blackboxed2() {
+ return innermost();
+ }`,
+ "http://example.com/blackboxed.js"
+ );
+
+ const { sources } = await getSources(threadFront);
+ const blackboxedSourceFront = threadFront.source(
+ sources.find(source => source.url == "http://example.com/blackboxed.js")
+ );
+ const unblackboxedActor = sources.find(
+ source => source.url == "http://example.com/unblackboxed.js"
+ ).actor;
+
+ await setBreakpoint(threadFront, {
+ sourceUrl: blackboxedSourceFront.url,
+ line: 5,
+ });
+
+ info("Step Out to outermost");
+ await testStepping(stepOut, 3);
+
+ info("Step Over to outermost");
+ await testStepping(stepOver, 3);
+
+ info("Step In to innermost");
+ await testStepping(stepIn, 6);
+ })
+);