diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 09:22:09 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 09:22:09 +0000 |
commit | 43a97878ce14b72f0981164f87f2e35e14151312 (patch) | |
tree | 620249daf56c0258faa40cbdcf9cfba06de2a846 /devtools/server/tests/xpcshell/test_breakpoint-25.js | |
parent | Initial commit. (diff) | |
download | firefox-43a97878ce14b72f0981164f87f2e35e14151312.tar.xz firefox-43a97878ce14b72f0981164f87f2e35e14151312.zip |
Adding upstream version 110.0.1.upstream/110.0.1upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'devtools/server/tests/xpcshell/test_breakpoint-25.js')
-rw-r--r-- | devtools/server/tests/xpcshell/test_breakpoint-25.js | 79 |
1 files changed, 79 insertions, 0 deletions
diff --git a/devtools/server/tests/xpcshell/test_breakpoint-25.js b/devtools/server/tests/xpcshell/test_breakpoint-25.js new file mode 100644 index 0000000000..f155234c96 --- /dev/null +++ b/devtools/server/tests/xpcshell/test_breakpoint-25.js @@ -0,0 +1,79 @@ +/* Any copyright is dedicated to the Public Domain. + http://creativecommons.org/publicdomain/zero/1.0/ */ + +"use strict"; + +/** + * Ensure that the debugger resume page execution when the connection drops + * and when the target is detached. + */ + +add_task( + threadFrontTest(({ threadFront, debuggee, targetFront }) => { + return new Promise(resolve => { + (async () => { + await executeOnNextTickAndWaitForPause(evalCode, threadFront); + + ok(true, "The page is paused"); + ok(!debuggee.foo, "foo is still false after we hit the breakpoint"); + + await targetFront.detach(); + + // Closing the connection will force the thread actor to resume page + // execution + ok(debuggee.foo, "foo is true after target's detach request"); + + resolve(); + })(); + + function evalCode() { + /* eslint-disable */ + Cu.evalInSandbox("var foo = false;\n", debuggee); + /* eslint-enable */ + ok(!debuggee.foo, "foo is false at startup"); + + /* eslint-disable */ + Cu.evalInSandbox("debugger;\n" + "foo = true;\n", debuggee); + /* eslint-enable */ + } + }); + }) +); + +add_task( + threadFrontTest(({ threadFront, client, debuggee }) => { + return new Promise(resolve => { + (async () => { + await executeOnNextTickAndWaitForPause(evalCode, threadFront); + + ok(true, "The page is paused"); + ok(!debuggee.foo, "foo is still false after we hit the breakpoint"); + + await client.close(); + + // `close` will force the destruction of the thread actor, which, + // will resume the page execution. But all of that seems to be + // synchronous and we have to spin the event loop in order to ensure + // having the content javascript to execute the resumed code. + await new Promise(executeSoon); + + // Closing the connection will force the thread actor to resume page + // execution + ok(debuggee.foo, "foo is true after client close"); + executeSoon(resolve); + dump("resolved\n"); + })(); + + function evalCode() { + /* eslint-disable */ + Cu.evalInSandbox("var foo = false;\n", debuggee); + /* eslint-enable */ + ok(!debuggee.foo, "foo is false at startup"); + + /* eslint-disable */ + Cu.evalInSandbox("debugger;\n" + "foo = true;\n", debuggee); + /* eslint-enable */ + } + }); + }) +); |