diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 19:33:14 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 19:33:14 +0000 |
commit | 36d22d82aa202bb199967e9512281e9a53db42c9 (patch) | |
tree | 105e8c98ddea1c1e4784a60a5a6410fa416be2de /devtools/client/debugger/test/mochitest/browser_dbg-breakpoints.js | |
parent | Initial commit. (diff) | |
download | firefox-esr-36d22d82aa202bb199967e9512281e9a53db42c9.tar.xz firefox-esr-36d22d82aa202bb199967e9512281e9a53db42c9.zip |
Adding upstream version 115.7.0esr.upstream/115.7.0esr
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'devtools/client/debugger/test/mochitest/browser_dbg-breakpoints.js')
-rw-r--r-- | devtools/client/debugger/test/mochitest/browser_dbg-breakpoints.js | 102 |
1 files changed, 102 insertions, 0 deletions
diff --git a/devtools/client/debugger/test/mochitest/browser_dbg-breakpoints.js b/devtools/client/debugger/test/mochitest/browser_dbg-breakpoints.js new file mode 100644 index 0000000000..9a68c5ba39 --- /dev/null +++ b/devtools/client/debugger/test/mochitest/browser_dbg-breakpoints.js @@ -0,0 +1,102 @@ +/* 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/>. */ + +// Test enabling and disabling a breakpoint using the check boxes + +"use strict"; + +add_task(async function () { + const dbg = await initDebugger("doc-scripts.html", "simple2.js"); + + // Create two breakpoints + await selectSource(dbg, "simple2.js"); + await addBreakpoint(dbg, "simple2.js", 3); + await addBreakpoint(dbg, "simple2.js", 5); + + // Disable the first one + await disableBreakpoint(dbg, 0); + let bp1 = findBreakpoint(dbg, "simple2.js", 3); + let bp2 = findBreakpoint(dbg, "simple2.js", 5); + is(bp1.disabled, true, "first breakpoint is disabled"); + is(bp2.disabled, false, "second breakpoint is enabled"); + + // Disable and Re-Enable the second one + await disableBreakpoint(dbg, 1); + await enableBreakpoint(dbg, 1); + bp2 = findBreakpoint(dbg, "simple2.js", 5); + is(bp2.disabled, false, "second breakpoint is enabled"); + + // Cleanup + await cleanupBreakpoints(dbg); + + // Test enabling and disabling a breakpoint using the context menu + await selectSource(dbg, "simple2.js"); + await addBreakpoint(dbg, "simple2.js", 3); + await addBreakpoint(dbg, "simple2.js", 5); + + assertBreakpointSnippet(dbg, 3, "return x + y;"); + + rightClickElement(dbg, "breakpointItem", 2); + await waitForContextMenu(dbg); + const disableBreakpointDispatch = waitForDispatch( + dbg.store, + "SET_BREAKPOINT" + ); + selectContextMenuItem(dbg, selectors.breakpointContextMenu.disableSelf); + await disableBreakpointDispatch; + + bp1 = findBreakpoint(dbg, "simple2.js", 3); + bp2 = findBreakpoint(dbg, "simple2.js", 5); + is(bp1.disabled, true, "first breakpoint is disabled"); + is(bp2.disabled, false, "second breakpoint is enabled"); + + rightClickElement(dbg, "breakpointItem", 2); + await waitForContextMenu(dbg); + const enableBreakpointDispatch = waitForDispatch(dbg.store, "SET_BREAKPOINT"); + selectContextMenuItem(dbg, selectors.breakpointContextMenu.enableSelf); + await enableBreakpointDispatch; + + bp1 = findBreakpoint(dbg, "simple2.js", 3); + bp2 = findBreakpoint(dbg, "simple2.js", 5); + is(bp1.disabled, false, "first breakpoint is enabled"); + is(bp2.disabled, false, "second breakpoint is enabled"); + + // Cleanup + await cleanupBreakpoints(dbg); + + // Test creation of disabled breakpoint with shift-click + await shiftClickElement(dbg, "gutter", 3); + await waitForBreakpoint(dbg, "simple2.js", 3); + + const bp = findBreakpoint(dbg, "simple2.js", 3); + is(bp.disabled, true, "breakpoint is disabled"); + + // Cleanup + await cleanupBreakpoints(dbg); +}); + +function toggleBreakpoint(dbg, index) { + const bp = findAllElements(dbg, "breakpointItems")[index]; + const input = bp.querySelector("input"); + input.click(); +} + +async function disableBreakpoint(dbg, index) { + const disabled = waitForDispatch(dbg.store, "SET_BREAKPOINT"); + toggleBreakpoint(dbg, index); + await disabled; +} + +async function enableBreakpoint(dbg, index) { + const enabled = waitForDispatch(dbg.store, "SET_BREAKPOINT"); + toggleBreakpoint(dbg, index); + await enabled; +} + +async function cleanupBreakpoints(dbg) { + clickElement(dbg, "gutter", 3); + clickElement(dbg, "gutter", 5); + await waitForBreakpointRemoved(dbg, "simple2.js", 3); + await waitForBreakpointRemoved(dbg, "simple2.js", 5); +} |