diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 17:32:43 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 17:32:43 +0000 |
commit | 6bf0a5cb5034a7e684dcc3500e841785237ce2dd (patch) | |
tree | a68f146d7fa01f0134297619fbe7e33db084e0aa /devtools/server/tests/xpcshell/test_breakpoint-20.js | |
parent | Initial commit. (diff) | |
download | thunderbird-59f4b6b6d49b15c5a468f3fe34f3cfa4dd956ce2.tar.xz thunderbird-59f4b6b6d49b15c5a468f3fe34f3cfa4dd956ce2.zip |
Adding upstream version 1:115.7.0.upstream/1%115.7.0upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'devtools/server/tests/xpcshell/test_breakpoint-20.js')
-rw-r--r-- | devtools/server/tests/xpcshell/test_breakpoint-20.js | 109 |
1 files changed, 109 insertions, 0 deletions
diff --git a/devtools/server/tests/xpcshell/test_breakpoint-20.js b/devtools/server/tests/xpcshell/test_breakpoint-20.js new file mode 100644 index 0000000000..886d44164d --- /dev/null +++ b/devtools/server/tests/xpcshell/test_breakpoint-20.js @@ -0,0 +1,109 @@ +/* Any copyright is dedicated to the Public Domain. + http://creativecommons.org/publicdomain/zero/1.0/ */ + +"use strict"; + +/** + * Verify that when two of the "same" source are loaded concurrently (like e10s + * frame scripts), breakpoints get hit in scripts defined by all sources. + */ + +var gDebuggee; + +add_task( + threadFrontTest(async ({ threadFront, debuggee }) => { + gDebuggee = debuggee; + await testBreakpoint(threadFront); + }) +); + +const testBreakpoint = async function (threadFront) { + evalSetupCode(); + + // Load the test source once. + + evalTestCode(); + equal( + gDebuggee.functions.length, + 1, + "The test code should have added a function." + ); + + // Set a breakpoint in the test source. + + const source = await getSource(threadFront, "test.js"); + setBreakpoint(threadFront, { sourceUrl: source.url, line: 3 }); + + // Load the test source again. + + evalTestCode(); + equal( + gDebuggee.functions.length, + 2, + "The test code should have added another function." + ); + + // Should hit our breakpoint in a script defined by the first instance of the + // test source. + + const bpPause1 = await executeOnNextTickAndWaitForPause( + gDebuggee.functions[0], + threadFront + ); + equal( + bpPause1.why.type, + "breakpoint", + "Should pause because of hitting our breakpoint (not debugger statement)." + ); + const dbgStmtPause1 = await executeOnNextTickAndWaitForPause( + () => resume(threadFront), + threadFront + ); + equal( + dbgStmtPause1.why.type, + "debuggerStatement", + "And we should hit the debugger statement after the pause." + ); + await resume(threadFront); + + // Should also hit our breakpoint in a script defined by the second instance + // of the test source. + + const bpPause2 = await executeOnNextTickAndWaitForPause( + gDebuggee.functions[1], + threadFront + ); + equal( + bpPause2.why.type, + "breakpoint", + "Should pause because of hitting our breakpoint (not debugger statement)." + ); + const dbgStmtPause2 = await executeOnNextTickAndWaitForPause( + () => resume(threadFront), + threadFront + ); + equal( + dbgStmtPause2.why.type, + "debuggerStatement", + "And we should hit the debugger statement after the pause." + ); +}; + +function evalSetupCode() { + Cu.evalInSandbox("this.functions = [];", gDebuggee, "1.8", "setup.js", 1); +} + +function evalTestCode() { + Cu.evalInSandbox( + ` // 1 + this.functions.push(function () { // 2 + var setBreakpointHere = 1; // 3 + debugger; // 4 + }); // 5 + `, + gDebuggee, + "1.8", + "test.js", + 1 + ); +} |