gecko/browser/devtools/debugger/test/browser_dbg_breakpoints-actual-location.js
Victor Porof 0c99b6054c Bug 876277 - Cleanup debugger breakpoints tests, r=past
--HG--
rename : browser/devtools/debugger/test/browser_dbg_bug737803_editor_actual_location.js => browser/devtools/debugger/test/browser_dbg_breakpoints-actual-location.js
rename : browser/devtools/debugger/test/browser_dbg_bug723071_editor-breakpoints-contextmenu.js => browser/devtools/debugger/test/browser_dbg_breakpoints-contextmenu.js
rename : browser/devtools/debugger/test/browser_dbg_bug723069_editor-breakpoints.js => browser/devtools/debugger/test/browser_dbg_breakpoints-editor.js
rename : browser/devtools/debugger/test/browser_dbg_bug723071_editor-breakpoints-highlight.js => browser/devtools/debugger/test/browser_dbg_breakpoints-highlight.js
rename : browser/devtools/debugger/test/browser_dbg_breakpoint-new-script.js => browser/devtools/debugger/test/browser_dbg_breakpoints-new-script.js
rename : browser/devtools/debugger/test/browser_dbg_bug723071_editor-breakpoints-pane.js => browser/devtools/debugger/test/browser_dbg_breakpoints-pane.js
rename : browser/devtools/debugger/test/browser_dbg_bug740825_conditional-breakpoints-01.js => browser/devtools/debugger/test/browser_dbg_conditional-breakpoints-01.js
rename : browser/devtools/debugger/test/browser_dbg_bug740825_conditional-breakpoints-02.js => browser/devtools/debugger/test/browser_dbg_conditional-breakpoints-02.js
2013-09-13 16:23:17 +03:00

98 lines
3.4 KiB
JavaScript

/* Any copyright is dedicated to the Public Domain.
http://creativecommons.org/publicdomain/zero/1.0/ */
/**
* Bug 737803: Setting a breakpoint in a line without code should move
* the icon to the actual location.
*/
const TAB_URL = EXAMPLE_URL + "doc_script-switching-01.html";
function test() {
let gTab, gDebuggee, gPanel, gDebugger;
let gEditor, gSources, gBreakpoints, gBreakpointsAdded, gBreakpointsRemoving;
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;
gBreakpointsRemoving = gBreakpoints._removing;
waitForSourceAndCaretAndScopes(gPanel, "-02.js", 6).then(performTest);
gDebuggee.firstCall();
});
function performTest() {
is(gBreakpointsAdded.size, 0,
"No breakpoints currently added.");
is(gBreakpointsRemoving.size, 0,
"No breakpoints currently being removed.");
is(gEditor.getBreakpoints().length, 0,
"No breakpoints currently shown in the editor.");
gEditor.addEventListener(SourceEditor.EVENTS.BREAKPOINT_CHANGE, onEditorBreakpointAdd);
gPanel.addBreakpoint({ url: gSources.selectedValue, line: 4 }).then(onBreakpointAdd);
}
let onBpDebuggerAdd = false;
let onBpEditorAdd = false;
function onBreakpointAdd(aBreakpointClient) {
ok(aBreakpointClient,
"Breakpoint added, client received.");
is(aBreakpointClient.location.url, gSources.selectedValue,
"Breakpoint client url is the same.");
is(aBreakpointClient.location.line, 6,
"Breakpoint client line is new.");
is(aBreakpointClient.requestedLocation.url, gSources.selectedValue,
"Requested location url is correct");
is(aBreakpointClient.requestedLocation.line, 4,
"Requested location line is correct");
onBpDebuggerAdd = true;
maybeFinish();
}
function onEditorBreakpointAdd(aEvent) {
gEditor.removeEventListener(SourceEditor.EVENTS.BREAKPOINT_CHANGE, onEditorBreakpointAdd);
is(gEditor.getBreakpoints().length, 1,
"There is only one breakpoint in the editor");
ok(!gBreakpoints._getAdded({ url: gSources.selectedValue, line: 4 }),
"There isn't any breakpoint added on an invalid line.");
ok(!gBreakpoints._getRemoving({ url: gSources.selectedValue, line: 4 }),
"There isn't any breakpoint removed from an invalid line.");
ok(gBreakpoints._getAdded({ url: gSources.selectedValue, line: 6 }),
"There is a breakpoint added on the actual line.");
ok(!gBreakpoints._getRemoving({ url: gSources.selectedValue, line: 6 }),
"There isn't any breakpoint removed from the actual line.");
gBreakpoints._getAdded({ url: gSources.selectedValue, line: 6 }).then(aBreakpointClient => {
is(aBreakpointClient.location.url, gSources.selectedValue,
"Breakpoint client location url is correct.");
is(aBreakpointClient.location.line, 6,
"Breakpoint client location line is correct.");
onBpEditorAdd = true;
maybeFinish();
});
}
function maybeFinish() {
info("onBpDebuggerAdd: " + onBpDebuggerAdd);
info("onBpEditorAdd: " + onBpEditorAdd);
if (onBpDebuggerAdd && onBpEditorAdd) {
resumeDebuggerThenCloseAndFinish(gPanel);
}
}
}