From 628fd9f94daeb13788ade55032e36255af0dd142 Mon Sep 17 00:00:00 2001 From: Michal Fox Date: Fri, 25 Sep 2026 12:59:34 +0200 Subject: [PATCH] Bug 1944506 - Add Remove condition and Remove log items to the debugger gutter breakpoint context menu. r?bomsy --- .../context-menus/editor-breakpoint.js | 34 ++++++++++++++ .../browser_dbg-breakpoints-cond-ui-state.js | 45 +++++++++++++++++++ .../debugger/test/mochitest/shared-head.js | 1 + 3 files changed, 80 insertions(+) diff --git a/devtools/client/debugger/src/actions/context-menus/editor-breakpoint.js b/devtools/client/debugger/src/actions/context-menus/editor-breakpoint.js index f867ee3..9223483 100644 --- a/devtools/client/debugger/src/actions/context-menus/editor-breakpoint.js +++ b/devtools/client/debugger/src/actions/context-menus/editor-breakpoint.js @@ -76,7 +76,13 @@ export function showEditorEditBreakpointContextMenu(event, breakpoint) { items.push( conditionalBreakpointItem(breakpoint, selectedLocation, dispatch) ); + if (breakpoint.options.condition) { + items.push(removeConditionItem(breakpoint, selectedLocation, dispatch)); + } items.push(logPointItem(breakpoint, selectedLocation, dispatch)); + if (breakpoint.options.logValue) { + items.push(removeLogPointItem(breakpoint, selectedLocation, dispatch)); + } showMenu(event, items, { accesskeyConflictsBug: 2073896 }); }; @@ -159,6 +165,20 @@ const conditionalBreakpointItem = (breakpoint, location, dispatch) => { : addConditionalBreakpointItem(location, dispatch); }; +const removeConditionItem = (breakpoint, location, dispatch) => ({ + id: "node-menu-remove-condition", + label: L10N.getStr("breakpointMenuItem.removeCondition2.label"), + accesskey: L10N.getStr("breakpointMenuItem.removeCondition2.accesskey"), + disabled: false, + click: () => + dispatch( + setBreakpointOptions(location, { + ...breakpoint.options, + condition: null, + }) + ), +}); + const addLogPointItem = (location, dispatch) => ({ id: "node-menu-add-log-point", label: L10N.getStr("editor.addLogPoint"), @@ -190,6 +210,20 @@ const logPointItem = (breakpoint, location, dispatch) => { : addLogPointItem(location, dispatch); }; +const removeLogPointItem = (breakpoint, location, dispatch) => ({ + id: "node-menu-remove-log", + label: L10N.getStr("editor.removeLogPoint.label"), + accesskey: L10N.getStr("editor.removeLogPoint.accesskey"), + disabled: false, + click: () => + dispatch( + setBreakpointOptions(location, { + ...breakpoint.options, + logValue: null, + }) + ), +}); + const toggleDisabledBreakpointItem = ( breakpoint, blackboxedRangesForSelectedSource, diff --git a/devtools/client/debugger/test/mochitest/browser_dbg-breakpoints-cond-ui-state.js b/devtools/client/debugger/test/mochitest/browser_dbg-breakpoints-cond-ui-state.js index c1d40e6..d129165 100644 --- a/devtools/client/debugger/test/mochitest/browser_dbg-breakpoints-cond-ui-state.js +++ b/devtools/client/debugger/test/mochitest/browser_dbg-breakpoints-cond-ui-state.js @@ -129,6 +129,51 @@ add_task(async function () { pressKey(dbg, "Enter"); bp = findBreakpoint(dbg, "simple2.js", 5); is(bp.options.logValue, null, "The log value was removed"); + + info("The gutter context menu has no remove items for a plain breakpoint"); + rightClickElement(dbg, "gutterElement", 5); + const popup = await waitForContextMenu(dbg); + ok( + !findContextMenu(dbg, selectors.breakpointContextMenu.removeCondition), + "Remove condition is not shown" + ); + ok(!findContextMenu(dbg, selectors.removeLogItem), "Remove log is not shown"); + await closeContextMenu(dbg, popup); + + info("The condition can be removed using the gutter context menu"); + await setConditionalBreakpoint(dbg, 5, "1"); + await waitForCondition(dbg, 1); + await assertConditionBreakpoint(dbg, 5); + + rightClickElement(dbg, "gutterElement", 5); + await waitForContextMenu(dbg); + ok( + !findContextMenu(dbg, selectors.removeLogItem), + "Remove log is not shown for a conditional breakpoint" + ); + selectContextMenuItem(dbg, selectors.breakpointContextMenu.removeCondition); + await waitForBreakpointWithoutCondition(dbg, "simple2.js", 5); + bp = findBreakpoint(dbg, "simple2.js", 5); + is(bp.options.condition, null, "The condition was removed"); + + info("The log value can be removed using the gutter context menu"); + await setLogPoint(dbg, 5, "44"); + await waitForLog(dbg, 44); + await assertLogBreakpoint(dbg, 5); + + rightClickElement(dbg, "gutterElement", 5); + await waitForContextMenu(dbg); + ok( + !findContextMenu(dbg, selectors.breakpointContextMenu.removeCondition), + "Remove condition is not shown for a log point" + ); + selectContextMenuItem(dbg, selectors.removeLogItem); + await waitForState(dbg, () => { + const breakpoint = findBreakpoint(dbg, "simple2.js", 5); + return breakpoint && !breakpoint.options.logValue; + }); + bp = findBreakpoint(dbg, "simple2.js", 5); + is(bp.options.logValue, null, "The log value was removed"); }); function waitForBreakpointWithoutCondition(dbg, url, line) { diff --git a/devtools/client/debugger/test/mochitest/shared-head.js b/devtools/client/debugger/test/mochitest/shared-head.js index 40ae6c6..3dbdc22 100644 --- a/devtools/client/debugger/test/mochitest/shared-head.js +++ b/devtools/client/debugger/test/mochitest/shared-head.js @@ -1909,6 +1909,7 @@ const selectors = { "#node-menu-edit-condition, #node-menu-edit-conditional-breakpoint", addLogItem: "#node-menu-add-log-point", editLogItem: "#node-menu-edit-log-point", + removeLogItem: "#node-menu-remove-log", disableItem: "#node-menu-disable-breakpoint", breakpoint: ".cm-gutter > .cm6-gutter-breakpoint", highlightLine: ".cm-content > .highlight-line",