Upstream mozilla-firefox/firefox state of the touched files before 32c8324f58
This commit is contained in:
1 parent
afb7e05d7b
commit
400ba3fb5e
3 files changed
+4062
No files matched your search
@@ -0,0 +1,283 @@
|
||||
/* 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/>. */
|
||||
|
||||
import { showMenu } from "../../context-menu/menu";
|
||||
import { getSelectedLocation } from "../../utils/selected-location";
|
||||
import { features } from "../../utils/prefs";
|
||||
import { isLineBlackboxed } from "../../utils/source";
|
||||
const {
|
||||
stringifyFromElectronKey,
|
||||
} = require("resource://devtools/client/shared/key-shortcuts.js");
|
||||
|
||||
import {
|
||||
getSelectedSource,
|
||||
getBlackBoxRanges,
|
||||
isSourceMapIgnoreListEnabled,
|
||||
isSourceOnSourceMapIgnoreList,
|
||||
} from "../../selectors/index";
|
||||
import {
|
||||
addBreakpoint,
|
||||
removeBreakpoint,
|
||||
setBreakpointOptions,
|
||||
} from "../../actions/breakpoints/modify";
|
||||
import {
|
||||
enableBreakpointsAtLine,
|
||||
disableBreakpointsAtLine,
|
||||
toggleDisabledBreakpoint,
|
||||
removeBreakpointsAtLine,
|
||||
} from "../../actions/breakpoints/index";
|
||||
import { openConditionalPanel } from "../../actions/ui";
|
||||
|
||||
export function showEditorEditBreakpointContextMenu(event, breakpoint) {
|
||||
return async ({ dispatch, getState }) => {
|
||||
const state = getState();
|
||||
const selectedSource = getSelectedSource(state);
|
||||
const selectedLocation = getSelectedLocation(breakpoint, selectedSource);
|
||||
const blackboxedRanges = getBlackBoxRanges(state);
|
||||
const blackboxedRangesForSelectedSource =
|
||||
blackboxedRanges[selectedSource.url];
|
||||
const isSelectedSourceOnIgnoreList =
|
||||
selectedSource &&
|
||||
isSourceMapIgnoreListEnabled(state) &&
|
||||
isSourceOnSourceMapIgnoreList(state, selectedSource);
|
||||
|
||||
const items = [
|
||||
removeBreakpointItem(breakpoint, dispatch),
|
||||
toggleDisabledBreakpointItem(
|
||||
breakpoint,
|
||||
blackboxedRangesForSelectedSource,
|
||||
isSelectedSourceOnIgnoreList,
|
||||
dispatch
|
||||
),
|
||||
];
|
||||
|
||||
if (breakpoint.originalText.startsWith("debugger")) {
|
||||
items.push(
|
||||
{ type: "separator" },
|
||||
toggleDbgStatementItem(selectedLocation, breakpoint, dispatch)
|
||||
);
|
||||
}
|
||||
|
||||
items.push(
|
||||
{ type: "separator" },
|
||||
removeBreakpointsOnLineItem(selectedLocation, dispatch),
|
||||
breakpoint.disabled
|
||||
? enableBreakpointsOnLineItem(
|
||||
selectedLocation,
|
||||
blackboxedRangesForSelectedSource,
|
||||
isSelectedSourceOnIgnoreList,
|
||||
dispatch
|
||||
)
|
||||
: disableBreakpointsOnLineItem(selectedLocation, dispatch),
|
||||
{ type: "separator" }
|
||||
);
|
||||
|
||||
items.push(
|
||||
conditionalBreakpointItem(breakpoint, selectedLocation, dispatch)
|
||||
);
|
||||
items.push(logPointItem(breakpoint, selectedLocation, dispatch));
|
||||
|
||||
showMenu(event, items, { accesskeyConflictsBug: 2073896 });
|
||||
};
|
||||
}
|
||||
|
||||
export function showEditorCreateBreakpointContextMenu(
|
||||
event,
|
||||
location,
|
||||
lineText
|
||||
) {
|
||||
return async ({ dispatch }) => {
|
||||
const items = createBreakpointItems(location, lineText, dispatch);
|
||||
|
||||
showMenu(event, items, { accesskeyConflictsBug: 2073896 });
|
||||
};
|
||||
}
|
||||
|
||||
export function createBreakpointItems(location, lineText, dispatch) {
|
||||
const items = [
|
||||
addBreakpointItem(location, dispatch),
|
||||
addConditionalBreakpointItem(location, dispatch),
|
||||
];
|
||||
|
||||
if (features.logPoints) {
|
||||
items.push(addLogPointItem(location, dispatch));
|
||||
}
|
||||
|
||||
if (lineText && lineText.startsWith("debugger")) {
|
||||
items.push(toggleDbgStatementItem(location, null, dispatch));
|
||||
}
|
||||
return items;
|
||||
}
|
||||
|
||||
const addBreakpointItem = (location, dispatch) => ({
|
||||
id: "node-menu-add-breakpoint",
|
||||
label: L10N.getStr("editor.addBreakpoint"),
|
||||
accesskey: L10N.getStr("shortcuts.toggleBreakpoint.accesskey"),
|
||||
disabled: false,
|
||||
click: () => dispatch(addBreakpoint(location)),
|
||||
accelerator: stringifyFromElectronKey(L10N.getStr("toggleBreakpoint.key")),
|
||||
});
|
||||
|
||||
const removeBreakpointItem = (breakpoint, dispatch) => ({
|
||||
id: "node-menu-remove-breakpoint",
|
||||
label: L10N.getStr("editor.removeBreakpoint"),
|
||||
accesskey: L10N.getStr("shortcuts.toggleBreakpoint.accesskey"),
|
||||
disabled: false,
|
||||
click: () => dispatch(removeBreakpoint(breakpoint)),
|
||||
accelerator: stringifyFromElectronKey(L10N.getStr("toggleBreakpoint.key")),
|
||||
});
|
||||
|
||||
const addConditionalBreakpointItem = (location, dispatch) => ({
|
||||
id: "node-menu-add-conditional-breakpoint",
|
||||
label: L10N.getStr("editor.addConditionBreakpoint"),
|
||||
accelerator: stringifyFromElectronKey(
|
||||
L10N.getStr("toggleCondPanel.breakpoint.key")
|
||||
),
|
||||
accesskey: L10N.getStr("editor.addConditionBreakpoint.accesskey"),
|
||||
disabled: false,
|
||||
click: () => dispatch(openConditionalPanel(location)),
|
||||
});
|
||||
|
||||
const editConditionalBreakpointItem = (location, dispatch) => ({
|
||||
id: "node-menu-edit-conditional-breakpoint",
|
||||
label: L10N.getStr("editor.editConditionBreakpoint"),
|
||||
accelerator: stringifyFromElectronKey(
|
||||
L10N.getStr("toggleCondPanel.breakpoint.key")
|
||||
),
|
||||
accesskey: L10N.getStr("editor.addConditionBreakpoint.accesskey"),
|
||||
disabled: false,
|
||||
click: () => dispatch(openConditionalPanel(location)),
|
||||
});
|
||||
|
||||
const conditionalBreakpointItem = (breakpoint, location, dispatch) => {
|
||||
const {
|
||||
options: { condition },
|
||||
} = breakpoint;
|
||||
return condition
|
||||
? editConditionalBreakpointItem(location, dispatch)
|
||||
: addConditionalBreakpointItem(location, dispatch);
|
||||
};
|
||||
|
||||
const addLogPointItem = (location, dispatch) => ({
|
||||
id: "node-menu-add-log-point",
|
||||
label: L10N.getStr("editor.addLogPoint"),
|
||||
accesskey: L10N.getStr("editor.addLogPoint.accesskey"),
|
||||
disabled: false,
|
||||
click: () => dispatch(openConditionalPanel(location, true)),
|
||||
accelerator: stringifyFromElectronKey(
|
||||
L10N.getStr("toggleCondPanel.logPoint.key")
|
||||
),
|
||||
});
|
||||
|
||||
const editLogPointItem = (location, dispatch) => ({
|
||||
id: "node-menu-edit-log-point",
|
||||
label: L10N.getStr("editor.editLogPoint"),
|
||||
accesskey: L10N.getStr("editor.editLogPoint.accesskey"),
|
||||
disabled: false,
|
||||
click: () => dispatch(openConditionalPanel(location, true)),
|
||||
accelerator: stringifyFromElectronKey(
|
||||
L10N.getStr("toggleCondPanel.logPoint.key")
|
||||
),
|
||||
});
|
||||
|
||||
const logPointItem = (breakpoint, location, dispatch) => {
|
||||
const {
|
||||
options: { logValue },
|
||||
} = breakpoint;
|
||||
return logValue
|
||||
? editLogPointItem(location, dispatch)
|
||||
: addLogPointItem(location, dispatch);
|
||||
};
|
||||
|
||||
const toggleDisabledBreakpointItem = (
|
||||
breakpoint,
|
||||
blackboxedRangesForSelectedSource,
|
||||
isSelectedSourceOnIgnoreList,
|
||||
dispatch
|
||||
) => {
|
||||
return {
|
||||
accesskey: L10N.getStr("editor.disableBreakpoint.accesskey"),
|
||||
disabled: isLineBlackboxed(
|
||||
blackboxedRangesForSelectedSource,
|
||||
breakpoint.location.line,
|
||||
isSelectedSourceOnIgnoreList
|
||||
),
|
||||
click: () => dispatch(toggleDisabledBreakpoint(breakpoint)),
|
||||
...(breakpoint.disabled
|
||||
? {
|
||||
id: "node-menu-enable-breakpoint",
|
||||
label: L10N.getStr("editor.enableBreakpoint"),
|
||||
}
|
||||
: {
|
||||
id: "node-menu-disable-breakpoint",
|
||||
label: L10N.getStr("editor.disableBreakpoint"),
|
||||
}),
|
||||
};
|
||||
};
|
||||
|
||||
const toggleDbgStatementItem = (location, breakpoint, dispatch) => {
|
||||
if (breakpoint && breakpoint.options.condition === "false") {
|
||||
return {
|
||||
disabled: false,
|
||||
id: "node-menu-enable-dbgStatement",
|
||||
label: L10N.getStr("breakpointMenuItem.enabledbg.label"),
|
||||
click: () =>
|
||||
dispatch(
|
||||
setBreakpointOptions(location, {
|
||||
...breakpoint.options,
|
||||
condition: null,
|
||||
})
|
||||
),
|
||||
};
|
||||
}
|
||||
|
||||
return {
|
||||
disabled: false,
|
||||
id: "node-menu-disable-dbgStatement",
|
||||
label: L10N.getStr("breakpointMenuItem.disabledbg.label"),
|
||||
click: () =>
|
||||
dispatch(
|
||||
setBreakpointOptions(location, {
|
||||
condition: "false",
|
||||
})
|
||||
),
|
||||
};
|
||||
};
|
||||
|
||||
// ToDo: Only enable if there are more than one breakpoints on a line?
|
||||
const removeBreakpointsOnLineItem = (location, dispatch) => ({
|
||||
id: "node-menu-remove-breakpoints-on-line",
|
||||
label: L10N.getStr("breakpointMenuItem.removeAllAtLine.label"),
|
||||
accesskey: L10N.getStr("breakpointMenuItem.removeAllAtLine.accesskey"),
|
||||
disabled: false,
|
||||
click: () =>
|
||||
dispatch(removeBreakpointsAtLine(location.source, location.line)),
|
||||
});
|
||||
|
||||
const enableBreakpointsOnLineItem = (
|
||||
location,
|
||||
blackboxedRangesForSelectedSource,
|
||||
isSelectedSourceOnIgnoreList,
|
||||
dispatch
|
||||
) => ({
|
||||
id: "node-menu-remove-breakpoints-on-line",
|
||||
label: L10N.getStr("breakpointMenuItem.enableAllAtLine.label"),
|
||||
accesskey: L10N.getStr("breakpointMenuItem.enableAllAtLine.accesskey"),
|
||||
disabled: isLineBlackboxed(
|
||||
blackboxedRangesForSelectedSource,
|
||||
location.line,
|
||||
isSelectedSourceOnIgnoreList
|
||||
),
|
||||
click: () =>
|
||||
dispatch(enableBreakpointsAtLine(location.source, location.line)),
|
||||
});
|
||||
|
||||
const disableBreakpointsOnLineItem = (location, dispatch) => ({
|
||||
id: "node-menu-remove-breakpoints-on-line",
|
||||
label: L10N.getStr("breakpointMenuItem.disableAllAtLine.label"),
|
||||
accesskey: L10N.getStr("breakpointMenuItem.disableAllAtLine.accesskey"),
|
||||
disabled: false,
|
||||
click: () =>
|
||||
dispatch(disableBreakpointsAtLine(location.source, location.line)),
|
||||
});
|
||||
@@ -0,0 +1,164 @@
|
||||
/* 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/>. */
|
||||
|
||||
"use strict";
|
||||
|
||||
// This test focuses on the UI interaction and doesn't assert that the breakpoints actually works
|
||||
|
||||
add_task(async function () {
|
||||
const dbg = await initDebugger("doc-scripts.html", "simple2.js");
|
||||
|
||||
await selectSource(dbg, "simple2.js");
|
||||
await waitForSelectedSource(dbg, "simple2.js");
|
||||
|
||||
info("Set condition `1`");
|
||||
await setConditionalBreakpoint(dbg, 5, "1");
|
||||
await waitForCondition(dbg, 1);
|
||||
|
||||
let bp = findBreakpoint(dbg, "simple2.js", 5);
|
||||
is(bp.options.condition, "1", "breakpoint is created with the condition");
|
||||
await assertConditionBreakpoint(dbg, 5);
|
||||
|
||||
info("Edit the conditional breakpoint set above");
|
||||
await setConditionalBreakpoint(dbg, 5, "2");
|
||||
await waitForCondition(dbg, 12);
|
||||
|
||||
bp = findBreakpoint(dbg, "simple2.js", 5);
|
||||
is(bp.options.condition, "12", "breakpoint is created with the condition");
|
||||
await assertConditionBreakpoint(dbg, 5);
|
||||
|
||||
info("Hit 'Enter' when the cursor is in the conditional statement");
|
||||
rightClickElement(dbg, "gutterElement", 5);
|
||||
await waitForContextMenu(dbg);
|
||||
selectContextMenuItem(dbg, `${selectors.editConditionItem}`);
|
||||
await waitForConditionalPanelFocus(dbg);
|
||||
pressKey(dbg, "Left");
|
||||
pressKey(dbg, "Enter");
|
||||
await waitForCondition(dbg, 12);
|
||||
|
||||
bp = findBreakpoint(dbg, "simple2.js", 5);
|
||||
is(bp.options.condition, "12", "Hit 'Enter' doesn't add a new line");
|
||||
|
||||
info("Hit 'Shift+Enter' when the cursor is in the conditional statement");
|
||||
rightClickElement(dbg, "gutterElement", 5);
|
||||
await waitForContextMenu(dbg);
|
||||
selectContextMenuItem(dbg, `${selectors.editConditionItem}`);
|
||||
await waitForConditionalPanelFocus(dbg);
|
||||
// The whole text is selected, hit Right key to get to the end of the input
|
||||
pressKey(dbg, "Right");
|
||||
// Move one char left to put the cursor between 1 and 2
|
||||
pressKey(dbg, "Left");
|
||||
// Insert a new line
|
||||
pressKey(dbg, "ShiftEnter");
|
||||
// And validate
|
||||
pressKey(dbg, "Enter");
|
||||
await waitForCondition(dbg, "1\n 2");
|
||||
|
||||
bp = findBreakpoint(dbg, "simple2.js", 5);
|
||||
is(bp.options.condition, "1\n 2", "Hit 'Shift+Enter' adds a new line");
|
||||
|
||||
info("The condition can be removed using the ConditionalPanel");
|
||||
dblClickElement(dbg, "conditionalBreakpointInSecPane");
|
||||
await waitForConditionalPanelFocus(dbg);
|
||||
pressKey(dbg, "Backspace");
|
||||
pressKey(dbg, "Enter");
|
||||
bp = findBreakpoint(dbg, "simple2.js", 5);
|
||||
is(bp.options.condition, null, "The condition was removed");
|
||||
|
||||
clickElement(dbg, "gutterElement", 5);
|
||||
await waitForDispatch(dbg.store, "REMOVE_BREAKPOINT");
|
||||
bp = findBreakpoint(dbg, "simple2.js", 5);
|
||||
is(bp, undefined, "breakpoint was removed");
|
||||
await assertNoBreakpoint(dbg, 5);
|
||||
|
||||
info("Adding a condition to a breakpoint");
|
||||
clickElement(dbg, "gutterElement", 5);
|
||||
await waitForDispatch(dbg.store, "SET_BREAKPOINT");
|
||||
await setConditionalBreakpoint(dbg, 5, "1");
|
||||
await waitForCondition(dbg, 1);
|
||||
|
||||
bp = findBreakpoint(dbg, "simple2.js", 5);
|
||||
is(bp.options.condition, "1", "breakpoint is created with the condition");
|
||||
await assertConditionBreakpoint(dbg, 5);
|
||||
|
||||
info("Double click the conditional breakpoint in secondary pane");
|
||||
dblClickElement(dbg, "conditionalBreakpointInSecPane");
|
||||
assertConditonalBreakpointPanelFocus(dbg, {});
|
||||
|
||||
info("Click the conditional breakpoint in secondary pane");
|
||||
await clickElement(dbg, "conditionalBreakpointInSecPane");
|
||||
const conditonalPanel = findElement(dbg, "conditionalPanel");
|
||||
is(conditonalPanel, null, "The conditional breakpoint panel is closed");
|
||||
|
||||
rightClickElement(dbg, "breakpointItem", 2);
|
||||
await waitForContextMenu(dbg);
|
||||
info('select "remove condition"');
|
||||
selectContextMenuItem(dbg, selectors.breakpointContextMenu.removeCondition);
|
||||
await waitForBreakpointWithoutCondition(dbg, "simple2.js", 5);
|
||||
bp = findBreakpoint(dbg, "simple2.js", 5);
|
||||
is(bp.options.condition, null, "breakpoint condition removed");
|
||||
|
||||
info('Add "log point"');
|
||||
await setLogPoint(dbg, 5, "44");
|
||||
await waitForLog(dbg, 44);
|
||||
await assertLogBreakpoint(dbg, 5);
|
||||
|
||||
bp = findBreakpoint(dbg, "simple2.js", 5);
|
||||
is(bp.options.logValue, "44", "breakpoint condition removed");
|
||||
|
||||
await altClickElement(dbg, "gutterElement", 6);
|
||||
bp = await waitForBreakpoint(dbg, "simple2.js", 6);
|
||||
is(bp.options.logValue, "displayName", "logPoint has default value");
|
||||
|
||||
info("Double click the logpoint in secondary pane");
|
||||
dblClickElement(dbg, "logPointInSecPane");
|
||||
assertConditonalBreakpointPanelFocus(dbg, { isLogPoint: true });
|
||||
|
||||
info("Click the logpoint in secondary pane");
|
||||
await clickElement(dbg, "logPointInSecPane");
|
||||
const logPointPanel = findElement(dbg, "logPointPanel");
|
||||
is(logPointPanel, null, "The logpoint panel is closed");
|
||||
await waitForSelectedLocation(dbg, 5, 3);
|
||||
|
||||
info("The log value can be removed using the ConditionalPanel");
|
||||
dblClickElement(dbg, "logPointInSecPane");
|
||||
await waitForConditionalPanelFocus(dbg);
|
||||
pressKey(dbg, "Backspace");
|
||||
pressKey(dbg, "Space");
|
||||
pressKey(dbg, "Enter");
|
||||
bp = findBreakpoint(dbg, "simple2.js", 5);
|
||||
is(bp.options.logValue, null, "The log value was removed");
|
||||
});
|
||||
|
||||
function waitForBreakpointWithoutCondition(dbg, url, line) {
|
||||
return waitForState(dbg, () => {
|
||||
const bp = findBreakpoint(dbg, url, line);
|
||||
return bp && !bp.options.condition;
|
||||
});
|
||||
}
|
||||
|
||||
async function setConditionalBreakpoint(dbg, index, condition) {
|
||||
// Make this work with either add or edit menu items
|
||||
const { addConditionItem, editConditionItem } = selectors;
|
||||
const selector = `${addConditionItem},${editConditionItem}`;
|
||||
rightClickElement(dbg, "gutterElement", index);
|
||||
await waitForContextMenu(dbg);
|
||||
selectContextMenuItem(dbg, selector);
|
||||
typeInPanel(dbg, condition);
|
||||
}
|
||||
|
||||
function assertConditonalBreakpointPanelFocus(dbg, { isLogPoint = false }) {
|
||||
const focusedElement = dbg.win.document.activeElement;
|
||||
const isPanelFocused =
|
||||
focusedElement.classList.contains("cm-content") &&
|
||||
focusedElement.closest(
|
||||
`.conditional-breakpoint-panel${isLogPoint ? ".log-point" : ""}`
|
||||
);
|
||||
ok(
|
||||
isPanelFocused,
|
||||
`The content element of ${
|
||||
isLogPoint ? "log point" : "conditional breakpoint"
|
||||
} panel is focused`
|
||||
);
|
||||
}
|
||||
File diff suppressed because it is too large.
Load diff
Reference in new issue
Block a user