Skip to content

Commit

Permalink
Bug 1835308 - [devtools] Ignore line context menu should be enabled f…
Browse files Browse the repository at this point in the history
…or unignore sources or lines r=devtools-reviewers,ochameau

Differential Revision: https://phabricator.services.mozilla.com/D179236
  • Loading branch information
bomsy committed May 30, 2023
1 parent 968ef96 commit f974f3d
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -131,15 +131,17 @@ export const blackBoxLineMenuItem = (
? blackboxRange.start.line == blackboxRange.end.line
: startLine == endLine;

const isSourceFullyBlackboxed =
blackboxedRanges[selectedSource.url] &&
!blackboxedRanges[selectedSource.url].length;

// The ignore/unignore line context menu item should be disabled when
// 1) The source is on the sourcemap ignore list
// 2) The whole source is blackboxed or
// 3) Multiple lines are blackboxed or
// 4) Multiple lines are selected in the editor
const shouldDisable =
isSourceOnIgnoreList ||
!blackboxedRanges[selectedSource.url]?.length ||
!isSingleLine;
isSourceOnIgnoreList || isSourceFullyBlackboxed || !isSingleLine;

return {
id: "node-menu-blackbox-line",
Expand Down
18 changes: 17 additions & 1 deletion devtools/client/debugger/test/mochitest/browser_dbg-blackbox.js
Original file line number Diff line number Diff line change
Expand Up @@ -490,6 +490,17 @@ async function resumeAndWaitForPauseCounter(dbg) {
);
}

async function assertContextMenuDisabled(dbg, selector, shouldBeDisabled) {
const item = await waitFor(() => findContextMenu(dbg, selector));
is(
item.disabled,
shouldBeDisabled,
`The the context menu item is ${
shouldBeDisabled ? "disabled" : "not disabled"
}`
);
}

/**
* Asserts that the gutter blackbox context menu items which are visible are correct
* @params {Object} dbg
Expand Down Expand Up @@ -517,6 +528,11 @@ async function assertGutterBlackBoxBoxContextMenuItems(dbg, testFixtures) {
: contextMenuItems.unignoreLine;

await assertContextMenuLabel(dbg, item.selector, item.label);
await assertContextMenuDisabled(
dbg,
item.selector,
blackboxedSourceState == SOURCE_IS_FULLY_IGNORED
);
await closeContextMenu(dbg, popup);
}

Expand All @@ -531,7 +547,7 @@ async function assertGutterBlackBoxBoxContextMenuItems(dbg, testFixtures) {
);
const item = contextMenuItems.ignoreLine;
await assertContextMenuLabel(dbg, item.selector, item.label);

await assertContextMenuDisabled(dbg, item.selector, false);
await closeContextMenu(dbg, popup);
}
}
Expand Down

0 comments on commit f974f3d

Please sign in to comment.