diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-28 14:29:10 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-28 14:29:10 +0000 |
commit | 2aa4a82499d4becd2284cdb482213d541b8804dd (patch) | |
tree | b80bf8bf13c3766139fbacc530efd0dd9d54394c /devtools/server/tests/xpcshell/test_breakpoint-14.js | |
parent | Initial commit. (diff) | |
download | firefox-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_breakpoint-14.js')
-rw-r--r-- | devtools/server/tests/xpcshell/test_breakpoint-14.js | 92 |
1 files changed, 92 insertions, 0 deletions
diff --git a/devtools/server/tests/xpcshell/test_breakpoint-14.js b/devtools/server/tests/xpcshell/test_breakpoint-14.js new file mode 100644 index 0000000000..8c6289b2ab --- /dev/null +++ b/devtools/server/tests/xpcshell/test_breakpoint-14.js @@ -0,0 +1,92 @@ +/* Any copyright is dedicated to the Public Domain. + http://creativecommons.org/publicdomain/zero/1.0/ */ +/* eslint-disable no-shadow */ + +"use strict"; + +/** + * Check that a breakpoint or a debugger statement cause execution to pause even + * in a stepped-over function. + */ + +add_task( + threadFrontTest(async ({ threadFront, client, debuggee }) => { + const packet = await executeOnNextTickAndWaitForPause( + () => evaluateTestCode(debuggee), + threadFront + ); + const source = await getSourceById(threadFront, packet.frame.where.actor); + const location = { + sourceUrl: source.url, + line: debuggee.line0 + 2, + }; + + //Pause at debugger statement. + Assert.equal(packet.frame.where.line, debuggee.line0 + 4); + Assert.equal(packet.why.type, "debuggerStatement"); + + threadFront.setBreakpoint(location, {}); + + const testCallbacks = [ + function(packet) { + // Check that the stepping worked. + Assert.equal(packet.frame.where.line, debuggee.line0 + 5); + Assert.equal(packet.why.type, "resumeLimit"); + }, + function(packet) { + // Reached the breakpoint. + Assert.equal(packet.frame.where.line, location.line); + Assert.equal(packet.why.type, "breakpoint"); + Assert.notEqual(packet.why.type, "resumeLimit"); + }, + function(packet) { + // The frame is about to be popped while stepping. + Assert.equal(packet.frame.where.line, debuggee.line0 + 3); + Assert.notEqual(packet.why.type, "breakpoint"); + Assert.equal(packet.why.type, "resumeLimit"); + Assert.equal(packet.why.frameFinished.return.type, "undefined"); + }, + function(packet) { + // Check that the debugger statement wasn't the reason for this pause. + Assert.equal(debuggee.a, 1); + Assert.equal(debuggee.b, undefined); + Assert.equal(packet.frame.where.line, debuggee.line0 + 6); + Assert.notEqual(packet.why.type, "debuggerStatement"); + Assert.equal(packet.why.type, "resumeLimit"); + Assert.equal(packet.poppedFrames.length, 1); + }, + function(packet) { + // Check that the debugger statement wasn't the reason for this pause. + Assert.equal(packet.frame.where.line, debuggee.line0 + 7); + Assert.notEqual(packet.why.type, "debuggerStatement"); + Assert.equal(packet.why.type, "resumeLimit"); + }, + ]; + + for (const callback of testCallbacks) { + const waiter = waitForPause(threadFront); + threadFront.stepOver(); + const packet = await waiter; + callback(packet); + } + + // Remove the breakpoint and finish. + threadFront.removeBreakpoint(location); + + await threadFront.resume(); + }) +); + +function evaluateTestCode(debuggee) { + /* eslint-disable */ + Cu.evalInSandbox("var line0 = Error().lineNumber;\n" + + "function foo() {\n" + // line0 + 1 + " this.a = 1;\n" + // line0 + 2 <-- Breakpoint is set here. + "}\n" + // line0 + 3 + "debugger;\n" + // line0 + 4 + "foo();\n" + // line0 + 5 + "debugger;\n" + // line0 + 6 + "var b = 2;\n", // line0 + 7 + debuggee); + /* eslint-enable */ +} |