mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 986151 - Fix line number of breakpoints when added from context menu. r=past
This commit is contained in:
parent
8bb72418c9
commit
d0d975c8e8
@ -944,7 +944,9 @@ SourcesView.prototype = Heritage.extend(WidgetMethods, {
|
||||
*/
|
||||
_onCmdAddBreakpoint: function(e) {
|
||||
let url = DebuggerView.Sources.selectedValue;
|
||||
let line = DebuggerView.editor.getCursor().line + 1;
|
||||
let line = (e && e.sourceEvent.target.tagName == 'menuitem' ?
|
||||
DebuggerView.clickedLine + 1 :
|
||||
DebuggerView.editor.getCursor().line + 1);
|
||||
let location = { url: url, line: line };
|
||||
let breakpointItem = this.getBreakpoint(location);
|
||||
|
||||
@ -961,9 +963,11 @@ SourcesView.prototype = Heritage.extend(WidgetMethods, {
|
||||
/**
|
||||
* Called when the add conditional breakpoint key sequence was pressed.
|
||||
*/
|
||||
_onCmdAddConditionalBreakpoint: function() {
|
||||
_onCmdAddConditionalBreakpoint: function(e) {
|
||||
let url = DebuggerView.Sources.selectedValue;
|
||||
let line = DebuggerView.editor.getCursor().line + 1;
|
||||
let line = (e && e.sourceEvent.target.tagName == 'menuitem' ?
|
||||
DebuggerView.clickedLine + 1 :
|
||||
DebuggerView.editor.getCursor().line + 1);
|
||||
let location = { url: url, line: line };
|
||||
let breakpointItem = this.getBreakpoint(location);
|
||||
|
||||
|
@ -236,11 +236,18 @@ let DebuggerView = {
|
||||
this._onEditorLoad(aCallback);
|
||||
});
|
||||
|
||||
this.editor.on("gutterClick", (ev, line) => {
|
||||
if (this.editor.hasBreakpoint(line)) {
|
||||
this.editor.removeBreakpoint(line);
|
||||
} else {
|
||||
this.editor.addBreakpoint(line);
|
||||
this.editor.on("gutterClick", (ev, line, button) => {
|
||||
// A right-click shouldn't do anything but keep track of where
|
||||
// it was clicked.
|
||||
if(button == 2) {
|
||||
this.clickedLine = line;
|
||||
}
|
||||
else {
|
||||
if (this.editor.hasBreakpoint(line)) {
|
||||
this.editor.removeBreakpoint(line);
|
||||
} else {
|
||||
this.editor.addBreakpoint(line);
|
||||
}
|
||||
}
|
||||
});
|
||||
},
|
||||
|
@ -67,9 +67,9 @@
|
||||
<command id="variablesFocusCommand"
|
||||
oncommand="DebuggerView.Filtering._doVariablesFocus()"/>
|
||||
<command id="addBreakpointCommand"
|
||||
oncommand="DebuggerView.Sources._onCmdAddBreakpoint()"/>
|
||||
oncommand="DebuggerView.Sources._onCmdAddBreakpoint(event)"/>
|
||||
<command id="addConditionalBreakpointCommand"
|
||||
oncommand="DebuggerView.Sources._onCmdAddConditionalBreakpoint()"/>
|
||||
oncommand="DebuggerView.Sources._onCmdAddConditionalBreakpoint(event)"/>
|
||||
<command id="addWatchExpressionCommand"
|
||||
oncommand="DebuggerView.WatchExpressions._onCmdAddExpression()"/>
|
||||
<command id="removeAllWatchExpressionsCommand"
|
||||
|
@ -115,6 +115,7 @@ support-files =
|
||||
[browser_dbg_breakpoints-break-on-last-line-of-script-on-reload.js]
|
||||
[browser_dbg_breakpoints-button-01.js]
|
||||
[browser_dbg_breakpoints-button-02.js]
|
||||
[browser_dbg_breakpoints-contextmenu-add.js]
|
||||
[browser_dbg_breakpoints-contextmenu.js]
|
||||
[browser_dbg_breakpoints-disabled-reload.js]
|
||||
[browser_dbg_breakpoints-editor.js]
|
||||
|
@ -0,0 +1,96 @@
|
||||
/* Any copyright is dedicated to the Public Domain.
|
||||
http://creativecommons.org/publicdomain/zero/1.0/ */
|
||||
|
||||
/**
|
||||
* Test adding breakpoints from the source editor context menu
|
||||
*/
|
||||
|
||||
const TAB_URL = EXAMPLE_URL + "doc_script-switching-01.html";
|
||||
|
||||
function test() {
|
||||
let gTab, gDebuggee, gPanel, gDebugger;
|
||||
let gEditor, gSources, gContextMenu, gBreakpoints, gBreakpointsAdded;
|
||||
|
||||
initDebugger(TAB_URL).then(([aTab, aDebuggee, aPanel]) => {
|
||||
gTab = aTab;
|
||||
gDebuggee = aDebuggee;
|
||||
gPanel = aPanel;
|
||||
gDebugger = gPanel.panelWin;
|
||||
gEditor = gDebugger.DebuggerView.editor;
|
||||
gSources = gDebugger.DebuggerView.Sources;
|
||||
gBreakpoints = gDebugger.DebuggerController.Breakpoints;
|
||||
gBreakpointsAdded = gBreakpoints._added;
|
||||
gContextMenu = gDebugger.document.getElementById("sourceEditorContextMenu");
|
||||
|
||||
waitForSourceAndCaretAndScopes(gPanel, "-02.js", 1)
|
||||
.then(performTest)
|
||||
.then(() => resumeDebuggerThenCloseAndFinish(gPanel))
|
||||
.then(null, aError => {
|
||||
ok(false, "Got an error: " + aError.message + "\n" + aError.stack);
|
||||
});
|
||||
|
||||
gDebuggee.firstCall();
|
||||
});
|
||||
|
||||
function performTest() {
|
||||
is(gDebugger.gThreadClient.state, "paused",
|
||||
"Should only be getting stack frames while paused.");
|
||||
is(gSources.itemCount, 2,
|
||||
"Found the expected number of sources.");
|
||||
isnot(gEditor.getText().indexOf("debugger"), -1,
|
||||
"The correct source was loaded initially.");
|
||||
is(gSources.selectedValue, gSources.values[1],
|
||||
"The correct source is selected.");
|
||||
|
||||
ok(gContextMenu,
|
||||
"The source editor's context menupopup is available.");
|
||||
|
||||
gEditor.focus();
|
||||
gEditor.setSelection({ line: 1, ch: 0 }, { line: 1, ch: 10 });
|
||||
|
||||
return testAddBreakpoint().then(testAddConditionalBreakpoint);
|
||||
}
|
||||
|
||||
function testAddBreakpoint() {
|
||||
gContextMenu.openPopup(gEditor.container, "overlap", 0, 0, true, false);
|
||||
gEditor.emit("gutterClick", 6, 2);
|
||||
|
||||
return once(gContextMenu, "popupshown").then(() => {
|
||||
is(gBreakpointsAdded.size, 0, "no breakpoints added");
|
||||
|
||||
let cmd = gContextMenu.querySelector('menuitem[command=addBreakpointCommand]');
|
||||
let bpShown = waitForDebuggerEvents(gPanel, gDebugger.EVENTS.BREAKPOINT_SHOWN);
|
||||
EventUtils.synthesizeMouseAtCenter(cmd, {}, gDebugger);
|
||||
return bpShown;
|
||||
}).then(() => {
|
||||
is(gBreakpointsAdded.size, 1,
|
||||
"1 breakpoint correctly added");
|
||||
is(gEditor.getBreakpoints().length, 1,
|
||||
"1 breakpoint currently shown in the editor.");
|
||||
ok(gBreakpoints._getAdded({ url: gSources.values[1], line: 7 }),
|
||||
"Breakpoint on line 7 exists");
|
||||
});
|
||||
}
|
||||
|
||||
function testAddConditionalBreakpoint() {
|
||||
gContextMenu.openPopup(gEditor.container, "overlap", 0, 0, true, false);
|
||||
gEditor.emit("gutterClick", 7, 2);
|
||||
|
||||
return once(gContextMenu, "popupshown").then(() => {
|
||||
is(gBreakpointsAdded.size, 1,
|
||||
"1 breakpoint correctly added");
|
||||
|
||||
let cmd = gContextMenu.querySelector('menuitem[command=addConditionalBreakpointCommand]');
|
||||
let bpShown = waitForDebuggerEvents(gPanel, gDebugger.EVENTS.CONDITIONAL_BREAKPOINT_POPUP_SHOWING);
|
||||
EventUtils.synthesizeMouseAtCenter(cmd, {}, gDebugger);
|
||||
return bpShown;
|
||||
}).then(() => {
|
||||
is(gBreakpointsAdded.size, 2,
|
||||
"2 breakpoints correctly added");
|
||||
is(gEditor.getBreakpoints().length, 2,
|
||||
"2 breakpoints currently shown in the editor.");
|
||||
ok(gBreakpoints._getAdded({ url: gSources.values[1], line: 8 }),
|
||||
"Breakpoint on line 8 exists");
|
||||
});
|
||||
}
|
||||
}
|
@ -303,7 +303,7 @@ Editor.prototype = {
|
||||
return;
|
||||
}
|
||||
|
||||
this.emit("gutterClick", line);
|
||||
this.emit("gutterClick", line, ev.button);
|
||||
});
|
||||
|
||||
win.CodeMirror.defineExtension("l10n", (name) => {
|
||||
|
Loading…
Reference in New Issue
Block a user