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/client/debugger/test/mochitest/browser_dbg-breakpoint-skipping.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/client/debugger/test/mochitest/browser_dbg-breakpoint-skipping.js')
-rw-r--r-- | devtools/client/debugger/test/mochitest/browser_dbg-breakpoint-skipping.js | 85 |
1 files changed, 85 insertions, 0 deletions
diff --git a/devtools/client/debugger/test/mochitest/browser_dbg-breakpoint-skipping.js b/devtools/client/debugger/test/mochitest/browser_dbg-breakpoint-skipping.js new file mode 100644 index 0000000000..f4237ccddd --- /dev/null +++ b/devtools/client/debugger/test/mochitest/browser_dbg-breakpoint-skipping.js @@ -0,0 +1,85 @@ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at <http://mozilla.org/MPL/2.0/>. */ + +/* + * Tests toggling the skip pausing button and + * invoking functions without pausing. + */ + +add_task(async function() { + const dbg = await initDebugger("doc-scripts.html"); + await selectSource(dbg, "simple3"); + + info("Adding a breakpoint should remove the skipped pausing state"); + await skipPausing(dbg); + await waitForState(dbg, state => dbg.selectors.getSkipPausing()); + await addBreakpoint(dbg, "simple3", 2); + await waitForState(dbg, state => !dbg.selectors.getSkipPausing()); + invokeInTab("simple"); + await waitForPaused(dbg); + resume(dbg); + ok(true, "The breakpoint has been hit after a breakpoint was created"); + + info("Toggling a breakpoint should remove the skipped pausing state"); + // First disable the breakpoint to ensure skip pausing gets turned off + // during a disable + await skipPausing(dbg); + await disableBreakpoint(dbg, 0); + await waitForState(dbg, state => !dbg.selectors.getSkipPausing()); + // Then re-enable the breakpoint to ensure skip pausing gets turned off + // during an enable + await skipPausing(dbg); + await waitForState(dbg, state => dbg.selectors.getSkipPausing()); + toggleBreakpoint(dbg, 0); + await waitForState(dbg, state => !dbg.selectors.getSkipPausing()); + await waitForDispatch(dbg, "SET_BREAKPOINT"); + invokeInTab("simple"); + await waitForPaused(dbg); + resume(dbg); + ok(true, "The breakpoint has been hit after skip pausing was disabled"); + + info("Disabling a breakpoint should remove the skipped pausing state"); + await addBreakpoint(dbg, "simple3", 3); + await skipPausing(dbg); + await disableBreakpoint(dbg, 0); + await waitForState(dbg, state => !dbg.selectors.getSkipPausing()); + invokeInTab("simple"); + await waitForPaused(dbg); + resume(dbg); + ok(true, "The breakpoint has been hit after skip pausing was disabled again"); + + info("Removing a breakpoint should remove the skipped pause state"); + toggleBreakpoint(dbg, 0); + await skipPausing(dbg); + const source = findSource(dbg, "simple3.js"); + removeBreakpoint(dbg, source.id, 3); + const wait = waitForDispatch(dbg, "TOGGLE_SKIP_PAUSING"); + await waitForState(dbg, state => !dbg.selectors.getSkipPausing()); + await wait; + invokeInTab("simple"); + await waitForPaused(dbg); + // Unfortunately required as the test harness throws if preview doesn't + // complete before the end of the test. + await waitForDispatch(dbg, "ADD_INLINE_PREVIEW"); + resume(dbg); + ok(true, "Breakpoint is hit after a breakpoint was removed"); +}); + +function skipPausing(dbg) { + clickElementWithSelector(dbg, ".command-bar-skip-pausing"); + return waitForState(dbg, state => dbg.selectors.getSkipPausing()); +} + +function toggleBreakpoint(dbg, index) { + const breakpoints = findAllElements(dbg, "breakpointItems"); + const bp = breakpoints[index]; + const input = bp.querySelector("input"); + input.click(); +} + +async function disableBreakpoint(dbg, index) { + const disabled = waitForDispatch(dbg, "SET_BREAKPOINT"); + toggleBreakpoint(dbg, index); + await disabled; +} |