mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
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
This commit is contained in:
parent
eebd285c04
commit
8287658570
@ -1,92 +0,0 @@
|
||||
/* vim:set ts=2 sw=2 sts=2 et: */
|
||||
/* Any copyright is dedicated to the Public Domain.
|
||||
http://creativecommons.org/publicdomain/zero/1.0/ */
|
||||
|
||||
// Bug 771452: make sure that setting a breakpoint in an inline script doesn't
|
||||
// add it twice.
|
||||
|
||||
const TAB_URL = EXAMPLE_URL + "browser_dbg_breakpoint-new-script.html";
|
||||
|
||||
var gPane = null;
|
||||
var gTab = null;
|
||||
var gDebugger = null;
|
||||
var gDebuggee = null;
|
||||
|
||||
function test()
|
||||
{
|
||||
debug_tab_pane(TAB_URL, function(aTab, aDebuggee, aPane) {
|
||||
gTab = aTab;
|
||||
gPane = aPane;
|
||||
gDebugger = gPane.panelWin;
|
||||
gDebuggee = aDebuggee;
|
||||
|
||||
testAddBreakpoint();
|
||||
});
|
||||
}
|
||||
|
||||
function testAddBreakpoint()
|
||||
{
|
||||
gDebugger.DebuggerController.activeThread.addOneTimeListener("framesadded", function() {
|
||||
Services.tm.currentThread.dispatch({ run: function() {
|
||||
|
||||
var frames = gDebugger.DebuggerView.StackFrames.widget._list;
|
||||
|
||||
is(gDebugger.DebuggerController.activeThread.state, "paused",
|
||||
"The debugger statement was reached.");
|
||||
|
||||
is(frames.querySelectorAll(".dbg-stackframe").length, 1,
|
||||
"Should have one frame.");
|
||||
|
||||
gPane.addBreakpoint({ url: TAB_URL, line: 9 }, function (aResponse, bpClient) {
|
||||
testResume();
|
||||
});
|
||||
}}, 0);
|
||||
});
|
||||
|
||||
gDebuggee.runDebuggerStatement();
|
||||
}
|
||||
|
||||
function testResume()
|
||||
{
|
||||
is(gDebugger.DebuggerController.activeThread.state, "paused",
|
||||
"The breakpoint wasn't hit yet.");
|
||||
|
||||
let thread = gDebugger.DebuggerController.activeThread;
|
||||
thread.addOneTimeListener("resumed", function() {
|
||||
thread.addOneTimeListener("paused", function() {
|
||||
executeSoon(testBreakpointHit);
|
||||
});
|
||||
|
||||
EventUtils.sendMouseEvent({ type: "click" },
|
||||
content.document.querySelector("button"));
|
||||
});
|
||||
|
||||
thread.resume();
|
||||
}
|
||||
|
||||
function testBreakpointHit()
|
||||
{
|
||||
is(gDebugger.DebuggerController.activeThread.state, "paused",
|
||||
"The breakpoint was hit.");
|
||||
|
||||
let thread = gDebugger.DebuggerController.activeThread;
|
||||
thread.addOneTimeListener("paused", function test(aEvent, aPacket) {
|
||||
thread.addOneTimeListener("resumed", function() {
|
||||
executeSoon(closeDebuggerAndFinish);
|
||||
});
|
||||
|
||||
is(aPacket.why.type, "debuggerStatement", "Execution has advanced to the next line.");
|
||||
isnot(aPacket.why.type, "breakpoint", "No ghost breakpoint was hit.");
|
||||
thread.resume();
|
||||
});
|
||||
|
||||
thread.resume();
|
||||
}
|
||||
|
||||
registerCleanupFunction(function() {
|
||||
removeTab(gTab);
|
||||
gPane = null;
|
||||
gTab = null;
|
||||
gDebugger = null;
|
||||
gDebuggee = null;
|
||||
});
|
@ -0,0 +1,97 @@
|
||||
/* 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);
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,322 @@
|
||||
/* Any copyright is dedicated to the Public Domain.
|
||||
http://creativecommons.org/publicdomain/zero/1.0/ */
|
||||
|
||||
/**
|
||||
* Test if the context menu associated with each breakpoint does what it should.
|
||||
*/
|
||||
|
||||
const TAB_URL = EXAMPLE_URL + "doc_script-switching-01.html";
|
||||
|
||||
function test() {
|
||||
let gTab, gDebuggee, gPanel, gDebugger;
|
||||
let gEditor, gSources, gBreakpoints;
|
||||
|
||||
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;
|
||||
|
||||
waitForSourceShown(gPanel, "-01.js")
|
||||
.then(performTestWhileNotPaused)
|
||||
.then(performTestWhilePaused)
|
||||
.then(() => resumeDebuggerThenCloseAndFinish(gPanel))
|
||||
.then(null, aError => {
|
||||
ok(false, "Got an error: " + aError.message + "\n" + aError.stack);
|
||||
});
|
||||
});
|
||||
|
||||
function addBreakpoints() {
|
||||
return promise.resolve(null)
|
||||
.then(() => gPanel.addBreakpoint({ url: gSources.values[0], line: 5 }))
|
||||
.then(() => gPanel.addBreakpoint({ url: gSources.values[1], line: 6 }))
|
||||
.then(() => gPanel.addBreakpoint({ url: gSources.values[1], line: 7 }))
|
||||
.then(() => gPanel.addBreakpoint({ url: gSources.values[1], line: 8 }))
|
||||
.then(() => gPanel.addBreakpoint({ url: gSources.values[1], line: 9 }))
|
||||
}
|
||||
|
||||
function performTestWhileNotPaused() {
|
||||
info("Performing test while not paused...");
|
||||
|
||||
return addBreakpoints()
|
||||
.then(initialChecks)
|
||||
.then(() => checkBreakpointToggleSelf(0))
|
||||
.then(() => checkBreakpointToggleOthers(0))
|
||||
.then(() => checkBreakpointToggleSelf(1))
|
||||
.then(() => checkBreakpointToggleOthers(1))
|
||||
.then(() => checkBreakpointToggleSelf(2))
|
||||
.then(() => checkBreakpointToggleOthers(2))
|
||||
.then(() => checkBreakpointToggleSelf(3))
|
||||
.then(() => checkBreakpointToggleOthers(3))
|
||||
.then(() => checkBreakpointToggleSelf(4))
|
||||
.then(() => checkBreakpointToggleOthers(4))
|
||||
.then(testDeleteAll);
|
||||
}
|
||||
|
||||
function performTestWhilePaused() {
|
||||
info("Performing test while paused...");
|
||||
|
||||
return addBreakpoints()
|
||||
.then(initialChecks)
|
||||
.then(pauseAndCheck)
|
||||
.then(() => checkBreakpointToggleSelf(0))
|
||||
.then(() => checkBreakpointToggleOthers(0))
|
||||
.then(() => checkBreakpointToggleSelf(1))
|
||||
.then(() => checkBreakpointToggleOthers(1))
|
||||
.then(() => checkBreakpointToggleSelf(2))
|
||||
.then(() => checkBreakpointToggleOthers(2))
|
||||
.then(() => checkBreakpointToggleSelf(3))
|
||||
.then(() => checkBreakpointToggleOthers(3))
|
||||
.then(() => checkBreakpointToggleSelf(4))
|
||||
.then(() => checkBreakpointToggleOthers(4))
|
||||
.then(testDeleteAll);
|
||||
}
|
||||
|
||||
function pauseAndCheck() {
|
||||
let finished = waitForSourceAndCaretAndScopes(gPanel, "-01.js", 5).then(() => {
|
||||
is(gSources.selectedLabel, "code_script-switching-01.js",
|
||||
"The currently selected source is incorrect (3).");
|
||||
is(gSources.selectedIndex, 0,
|
||||
"The currently selected source is incorrect (4).");
|
||||
ok(isCaretPos(gPanel, 5),
|
||||
"The editor location is correct after pausing.");
|
||||
});
|
||||
|
||||
is(gSources.selectedLabel, "code_script-switching-02.js",
|
||||
"The currently selected source is incorrect (1).");
|
||||
is(gSources.selectedIndex, 1,
|
||||
"The currently selected source is incorrect (2).");
|
||||
ok(isCaretPos(gPanel, 9),
|
||||
"The editor location is correct before pausing.");
|
||||
|
||||
ensureThreadClientState(gPanel, "resumed").then(() => {
|
||||
EventUtils.sendMouseEvent({ type: "click" },
|
||||
gDebuggee.document.querySelector("button"),
|
||||
gDebuggee);
|
||||
});
|
||||
|
||||
return finished;
|
||||
}
|
||||
|
||||
function initialChecks() {
|
||||
for (let source in gSources) {
|
||||
for (let breakpoint in source) {
|
||||
ok(gBreakpoints._getAdded(breakpoint.attachment),
|
||||
"All breakpoint items should have corresponding promises (1).");
|
||||
ok(!gBreakpoints._getRemoving(breakpoint.attachment),
|
||||
"All breakpoint items should have corresponding promises (2).");
|
||||
ok(breakpoint.attachment.actor,
|
||||
"All breakpoint items should have corresponding promises (3).");
|
||||
is(!!breakpoint.attachment.disabled, false,
|
||||
"All breakpoints should initially be enabled.");
|
||||
|
||||
let actor = breakpoint.attachment.actor;
|
||||
let prefix = "bp-cMenu-"; // "breakpoints context menu"
|
||||
let enableSelfId = prefix + "enableSelf-" + actor + "-menuitem";
|
||||
let disableSelfId = prefix + "disableSelf-" + actor + "-menuitem";
|
||||
|
||||
is(gDebugger.document.getElementById(enableSelfId).getAttribute("hidden"), "true",
|
||||
"The 'Enable breakpoint' context menu item should initially be hidden'.");
|
||||
ok(!gDebugger.document.getElementById(disableSelfId).hasAttribute("hidden"),
|
||||
"The 'Disable breakpoint' context menu item should initially not be hidden'.");
|
||||
is(breakpoint.attachment.view.checkbox.getAttribute("checked"), "true",
|
||||
"All breakpoints should initially have a checked checkbox.");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function checkBreakpointToggleSelf(aIndex) {
|
||||
let deferred = promise.defer();
|
||||
|
||||
EventUtils.sendMouseEvent({ type: "click" },
|
||||
gDebugger.document.querySelectorAll(".dbg-breakpoint")[aIndex],
|
||||
gDebugger);
|
||||
|
||||
let selectedBreakpoint = gSources._selectedBreakpointItem;
|
||||
|
||||
ok(gBreakpoints._getAdded(selectedBreakpoint.attachment),
|
||||
"There should be a breakpoint client available (1).");
|
||||
ok(!gBreakpoints._getRemoving(selectedBreakpoint.attachment),
|
||||
"There should be a breakpoint client available (2).");
|
||||
ok(selectedBreakpoint.attachment.actor,
|
||||
"There should be a breakpoint client available (3).");
|
||||
is(!!selectedBreakpoint.attachment.disabled, false,
|
||||
"The breakpoint should not be disabled yet (" + aIndex + ").");
|
||||
|
||||
gBreakpoints._getAdded(selectedBreakpoint.attachment).then(aBreakpointClient => {
|
||||
ok(aBreakpointClient,
|
||||
"There should be a breakpoint client available as a promise.");
|
||||
});
|
||||
|
||||
let actor = selectedBreakpoint.attachment.actor;
|
||||
let prefix = "bp-cMenu-"; // "breakpoints context menu"
|
||||
let enableSelfId = prefix + "enableSelf-" + actor + "-menuitem";
|
||||
let disableSelfId = prefix + "disableSelf-" + actor + "-menuitem";
|
||||
|
||||
is(gDebugger.document.getElementById(enableSelfId).getAttribute("hidden"), "true",
|
||||
"The 'Enable breakpoint' context menu item should be hidden'.");
|
||||
ok(!gDebugger.document.getElementById(disableSelfId).hasAttribute("hidden"),
|
||||
"The 'Disable breakpoint' context menu item should not be hidden'.");
|
||||
|
||||
ok(isCaretPos(gPanel, selectedBreakpoint.attachment.line),
|
||||
"The source editor caret position was incorrect (" + aIndex + ").");
|
||||
|
||||
waitForDebuggerEvents(gPanel, gDebugger.EVENTS.BREAKPOINT_REMOVED).then(() => {
|
||||
ok(!gBreakpoints._getAdded(selectedBreakpoint.attachment),
|
||||
"There should be no breakpoint client available (4).");
|
||||
|
||||
waitForDebuggerEvents(gPanel, gDebugger.EVENTS.BREAKPOINT_ADDED).then(() => {
|
||||
ok(gBreakpoints._getAdded(selectedBreakpoint.attachment),
|
||||
"There should be a breakpoint client available (5).");
|
||||
|
||||
deferred.resolve();
|
||||
});
|
||||
|
||||
// Test re-disabling this breakpoint.
|
||||
gSources._onEnableSelf(selectedBreakpoint.attachment.actor);
|
||||
is(selectedBreakpoint.attachment.disabled, false,
|
||||
"The current breakpoint should now be enabled.")
|
||||
|
||||
is(gDebugger.document.getElementById(enableSelfId).getAttribute("hidden"), "true",
|
||||
"The 'Enable breakpoint' context menu item should be hidden'.");
|
||||
ok(!gDebugger.document.getElementById(disableSelfId).hasAttribute("hidden"),
|
||||
"The 'Disable breakpoint' context menu item should not be hidden'.");
|
||||
ok(selectedBreakpoint.attachment.view.checkbox.hasAttribute("checked"),
|
||||
"The breakpoint should now be checked.");
|
||||
});
|
||||
|
||||
// Test disabling this breakpoint.
|
||||
gSources._onDisableSelf(selectedBreakpoint.attachment.actor);
|
||||
is(selectedBreakpoint.attachment.disabled, true,
|
||||
"The current breakpoint should now be disabled.")
|
||||
|
||||
ok(!gDebugger.document.getElementById(enableSelfId).hasAttribute("hidden"),
|
||||
"The 'Enable breakpoint' context menu item should not be hidden'.");
|
||||
is(gDebugger.document.getElementById(disableSelfId).getAttribute("hidden"), "true",
|
||||
"The 'Disable breakpoint' context menu item should be hidden'.");
|
||||
ok(!selectedBreakpoint.attachment.view.checkbox.hasAttribute("checked"),
|
||||
"The breakpoint should now be unchecked.");
|
||||
|
||||
return deferred.promise;
|
||||
}
|
||||
|
||||
function checkBreakpointToggleOthers(aIndex) {
|
||||
let deferred = promise.defer();
|
||||
|
||||
waitForDebuggerEvents(gPanel, gDebugger.EVENTS.BREAKPOINT_REMOVED, 4).then(() => {
|
||||
let selectedBreakpoint = gSources._selectedBreakpointItem;
|
||||
|
||||
ok(gBreakpoints._getAdded(selectedBreakpoint.attachment),
|
||||
"There should be a breakpoint client available (6).");
|
||||
ok(!gBreakpoints._getRemoving(selectedBreakpoint.attachment),
|
||||
"There should be a breakpoint client available (7).");
|
||||
ok(selectedBreakpoint.attachment.actor,
|
||||
"There should be a breakpoint client available (8).");
|
||||
is(!!selectedBreakpoint.attachment.disabled, false,
|
||||
"The targetted breakpoint should not have been disabled (" + aIndex + ").");
|
||||
|
||||
for (let source in gSources) {
|
||||
for (let otherBreakpoint in source) {
|
||||
if (otherBreakpoint != selectedBreakpoint) {
|
||||
ok(!gBreakpoints._getAdded(otherBreakpoint.attachment),
|
||||
"There should be no breakpoint client for a disabled breakpoint (9).");
|
||||
is(otherBreakpoint.attachment.disabled, true,
|
||||
"Non-targetted breakpoints should have been disabled (10).");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
waitForDebuggerEvents(gPanel, gDebugger.EVENTS.BREAKPOINT_ADDED, 4).then(() => {
|
||||
for (let source in gSources) {
|
||||
for (let someBreakpoint in source) {
|
||||
ok(gBreakpoints._getAdded(someBreakpoint.attachment),
|
||||
"There should be a breakpoint client for all enabled breakpoints (11).");
|
||||
is(someBreakpoint.attachment.disabled, false,
|
||||
"All breakpoints should now have been enabled (12).");
|
||||
}
|
||||
}
|
||||
|
||||
waitForDebuggerEvents(gPanel, gDebugger.EVENTS.BREAKPOINT_REMOVED, 5).then(() => {
|
||||
for (let source in gSources) {
|
||||
for (let someBreakpoint in source) {
|
||||
ok(!gBreakpoints._getAdded(someBreakpoint.attachment),
|
||||
"There should be no breakpoint client for a disabled breakpoint (13).");
|
||||
is(someBreakpoint.attachment.disabled, true,
|
||||
"All breakpoints should now have been disabled (14).");
|
||||
}
|
||||
}
|
||||
|
||||
waitForDebuggerEvents(gPanel, gDebugger.EVENTS.BREAKPOINT_ADDED, 5).then(() => {
|
||||
for (let source in gSources) {
|
||||
for (let someBreakpoint in source) {
|
||||
ok(gBreakpoints._getAdded(someBreakpoint.attachment),
|
||||
"There should be a breakpoint client for all enabled breakpoints (15).");
|
||||
is(someBreakpoint.attachment.disabled, false,
|
||||
"All breakpoints should now have been enabled (16).");
|
||||
}
|
||||
}
|
||||
|
||||
// Done.
|
||||
deferred.resolve();
|
||||
});
|
||||
|
||||
// Test re-enabling all breakpoints.
|
||||
enableAll();
|
||||
});
|
||||
|
||||
// Test disabling all breakpoints.
|
||||
disableAll();
|
||||
});
|
||||
|
||||
// Test re-enabling other breakpoints.
|
||||
enableOthers();
|
||||
});
|
||||
|
||||
// Test disabling other breakpoints.
|
||||
disableOthers();
|
||||
|
||||
return deferred.promise;
|
||||
}
|
||||
|
||||
function testDeleteAll() {
|
||||
let deferred = promise.defer();
|
||||
|
||||
waitForDebuggerEvents(gPanel, gDebugger.EVENTS.BREAKPOINT_REMOVED, 5).then(() => {
|
||||
ok(!gSources._selectedBreakpointItem,
|
||||
"There should be no breakpoint available after removing all breakpoints.");
|
||||
|
||||
for (let source in gSources) {
|
||||
for (let otherBreakpoint in source) {
|
||||
ok(false, "It's a trap!");
|
||||
}
|
||||
}
|
||||
|
||||
// Done.
|
||||
deferred.resolve()
|
||||
});
|
||||
|
||||
// Test deleting all breakpoints.
|
||||
deleteAll();
|
||||
|
||||
return deferred.promise;
|
||||
}
|
||||
|
||||
function disableOthers() {
|
||||
gSources._onDisableOthers(gSources._selectedBreakpointItem.attachment.actor);
|
||||
}
|
||||
function enableOthers() {
|
||||
gSources._onEnableOthers(gSources._selectedBreakpointItem.attachment.actor);
|
||||
}
|
||||
function disableAll() {
|
||||
gSources._onDisableAll();
|
||||
}
|
||||
function enableAll() {
|
||||
gSources._onEnableAll();
|
||||
}
|
||||
function deleteAll() {
|
||||
gSources._onDeleteAll();
|
||||
}
|
||||
}
|
331
browser/devtools/debugger/test/browser_dbg_breakpoints-editor.js
Normal file
331
browser/devtools/debugger/test/browser_dbg_breakpoints-editor.js
Normal file
@ -0,0 +1,331 @@
|
||||
/* Any copyright is dedicated to the Public Domain.
|
||||
http://creativecommons.org/publicdomain/zero/1.0/ */
|
||||
|
||||
/**
|
||||
* Bug 723069: Test the debugger breakpoint API and connection to the
|
||||
* source editor.
|
||||
*/
|
||||
|
||||
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(gDebugger.gThreadClient.state, "paused",
|
||||
"Should only be getting stack frames while paused.");
|
||||
is(gSources.itemCount, 2,
|
||||
"Found the expected number of sources.");
|
||||
is(gEditor.getText().indexOf("debugger"), 172,
|
||||
"The correct source was loaded initially.");
|
||||
is(gSources.selectedValue, gSources.values[1],
|
||||
"The correct source is selected.");
|
||||
|
||||
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.");
|
||||
|
||||
ok(!gBreakpoints._getAdded({ url: "foo", line: 3 }),
|
||||
"_getAdded('foo', 3) returns falsey.");
|
||||
ok(!gBreakpoints._getRemoving({ url: "bar", line: 3 }),
|
||||
"_getRemoving('bar', 3) returns falsey.");
|
||||
|
||||
is(gSources.values[1], gSources.selectedValue,
|
||||
"The second source should be currently selected.");
|
||||
|
||||
info("Add the first breakpoint.");
|
||||
let location = { url: gSources.selectedValue, line: 6 };
|
||||
gEditor.addEventListener(SourceEditor.EVENTS.BREAKPOINT_CHANGE, onEditorBreakpointAddFirst);
|
||||
gPanel.addBreakpoint(location).then(onBreakpointAddFirst);
|
||||
}
|
||||
|
||||
let breakpointsAdded = 0;
|
||||
let breakpointsRemoved = 0;
|
||||
let editorBreakpointChanges = 0;
|
||||
|
||||
function onEditorBreakpointAddFirst(aEvent) {
|
||||
gEditor.removeEventListener(SourceEditor.EVENTS.BREAKPOINT_CHANGE, onEditorBreakpointAddFirst);
|
||||
editorBreakpointChanges++;
|
||||
|
||||
ok(aEvent,
|
||||
"breakpoint1 added to the editor.");
|
||||
is(aEvent.added.length, 1,
|
||||
"One breakpoint added to the editor.");
|
||||
is(aEvent.removed.length, 0,
|
||||
"No breakpoint was removed from the editor.");
|
||||
is(aEvent.added[0].line, 5,
|
||||
"Editor breakpoint line is correct.");
|
||||
|
||||
is(gEditor.getBreakpoints().length, 1,
|
||||
"editor.getBreakpoints().length is correct.");
|
||||
}
|
||||
|
||||
function onBreakpointAddFirst(aBreakpointClient) {
|
||||
breakpointsAdded++;
|
||||
|
||||
ok(aBreakpointClient,
|
||||
"breakpoint1 added, client received.");
|
||||
is(aBreakpointClient.location.url, gSources.selectedValue,
|
||||
"breakpoint1 client url is correct.");
|
||||
is(aBreakpointClient.location.line, 6,
|
||||
"breakpoint1 client line is correct.");
|
||||
|
||||
ok(gBreakpoints._getAdded(aBreakpointClient.location),
|
||||
"breakpoint1 client found in the list of added breakpoints.");
|
||||
ok(!gBreakpoints._getRemoving(aBreakpointClient.location),
|
||||
"breakpoint1 client found in the list of removing breakpoints.");
|
||||
|
||||
is(gBreakpointsAdded.size, 1,
|
||||
"The list of added breakpoints holds only one breakpoint.");
|
||||
is(gBreakpointsRemoving.size, 0,
|
||||
"The list of removing breakpoints holds no breakpoint.");
|
||||
|
||||
gBreakpoints._getAdded(aBreakpointClient.location).then(aClient => {
|
||||
is(aClient, aBreakpointClient,
|
||||
"_getAdded() returns the correct breakpoint.");
|
||||
});
|
||||
|
||||
is(gSources.values[1], gSources.selectedValue,
|
||||
"The second source should be currently selected.");
|
||||
|
||||
info("Remove the first breakpoint.");
|
||||
gEditor.addEventListener(SourceEditor.EVENTS.BREAKPOINT_CHANGE, onEditorBreakpointRemoveFirst);
|
||||
gPanel.removeBreakpoint(aBreakpointClient.location).then(onBreakpointRemoveFirst);
|
||||
}
|
||||
|
||||
function onEditorBreakpointRemoveFirst(aEvent) {
|
||||
gEditor.removeEventListener(SourceEditor.EVENTS.BREAKPOINT_CHANGE, onEditorBreakpointRemoveFirst);
|
||||
editorBreakpointChanges++;
|
||||
|
||||
ok(aEvent,
|
||||
"breakpoint1 removed from the editor.");
|
||||
is(aEvent.added.length, 0,
|
||||
"No breakpoint was added to the editor.");
|
||||
is(aEvent.removed.length, 1,
|
||||
"One breakpoint was removed from the editor.");
|
||||
is(aEvent.removed[0].line, 5,
|
||||
"Editor breakpoint line is correct.");
|
||||
|
||||
is(gEditor.getBreakpoints().length, 0,
|
||||
"editor.getBreakpoints().length is correct.");
|
||||
}
|
||||
|
||||
function onBreakpointRemoveFirst(aLocation) {
|
||||
breakpointsRemoved++;
|
||||
|
||||
ok(aLocation,
|
||||
"breakpoint1 removed");
|
||||
is(aLocation.url, gSources.selectedValue,
|
||||
"breakpoint1 removal url is correct.");
|
||||
is(aLocation.line, 6,
|
||||
"breakpoint1 removal line is correct.");
|
||||
|
||||
testBreakpointAddBackground();
|
||||
}
|
||||
|
||||
function testBreakpointAddBackground() {
|
||||
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.");
|
||||
|
||||
ok(!gBreakpoints._getAdded({ url: gSources.selectedValue, line: 6 }),
|
||||
"_getAdded('gSources.selectedValue', 6) returns falsey.");
|
||||
ok(!gBreakpoints._getRemoving({ url: gSources.selectedValue, line: 6 }),
|
||||
"_getRemoving('gSources.selectedValue', 6) returns falsey.");
|
||||
|
||||
is(gSources.values[1], gSources.selectedValue,
|
||||
"The second source should be currently selected.");
|
||||
|
||||
info("Add a breakpoint to the first source, which is not selected.");
|
||||
let location = { url: gSources.values[0], line: 5 };
|
||||
let options = { noEditorUpdate: true };
|
||||
gEditor.addEventListener(SourceEditor.EVENTS.BREAKPOINT_CHANGE, onEditorBreakpointAddBackgroundTrap);
|
||||
gPanel.addBreakpoint(location, options).then(onBreakpointAddBackground);
|
||||
}
|
||||
|
||||
function onEditorBreakpointAddBackgroundTrap(aEvent) {
|
||||
// Trap listener: no breakpoint must be added to the editor when a
|
||||
// breakpoint is added to a source that is not currently selected.
|
||||
gEditor.removeEventListener(SourceEditor.EVENTS.BREAKPOINT_CHANGE, onEditorBreakpointAddBackgroundTrap);
|
||||
editorBreakpointChanges++;
|
||||
|
||||
ok(false, "breakpoint2 must not be added to the editor.");
|
||||
}
|
||||
|
||||
function onBreakpointAddBackground(aBreakpointClient, aResponseError) {
|
||||
breakpointsAdded++;
|
||||
|
||||
ok(aBreakpointClient,
|
||||
"breakpoint2 added, client received");
|
||||
is(aBreakpointClient.location.url, gSources.values[0],
|
||||
"breakpoint2 client url is correct.");
|
||||
is(aBreakpointClient.location.line, 5,
|
||||
"breakpoint2 client line is correct.");
|
||||
|
||||
ok(gBreakpoints._getAdded(aBreakpointClient.location),
|
||||
"breakpoint2 client found in the list of added breakpoints.");
|
||||
ok(!gBreakpoints._getRemoving(aBreakpointClient.location),
|
||||
"breakpoint2 client found in the list of removing breakpoints.");
|
||||
|
||||
is(gBreakpointsAdded.size, 1,
|
||||
"The list of added breakpoints holds only one breakpoint.");
|
||||
is(gBreakpointsRemoving.size, 0,
|
||||
"The list of removing breakpoints holds no breakpoint.");
|
||||
|
||||
gBreakpoints._getAdded(aBreakpointClient.location).then(aClient => {
|
||||
is(aClient, aBreakpointClient,
|
||||
"_getAdded() returns the correct breakpoint.");
|
||||
});
|
||||
|
||||
is(gSources.values[1], gSources.selectedValue,
|
||||
"The second source should be currently selected.");
|
||||
|
||||
// Remove the trap listener.
|
||||
gEditor.removeEventListener(SourceEditor.EVENTS.BREAKPOINT_CHANGE, onEditorBreakpointAddBackgroundTrap);
|
||||
|
||||
info("Switch to the first source, which is not yet selected");
|
||||
gEditor.addEventListener(SourceEditor.EVENTS.BREAKPOINT_CHANGE, onEditorBreakpointAddSwitch);
|
||||
gEditor.addEventListener(SourceEditor.EVENTS.TEXT_CHANGED, onEditorTextChanged);
|
||||
gSources.selectedIndex = 0;
|
||||
}
|
||||
|
||||
function onEditorBreakpointAddSwitch(aEvent) {
|
||||
gEditor.removeEventListener(SourceEditor.EVENTS.BREAKPOINT_CHANGE, onEditorBreakpointAddSwitch);
|
||||
editorBreakpointChanges++;
|
||||
|
||||
ok(aEvent,
|
||||
"breakpoint2 added to the editor.");
|
||||
is(aEvent.added.length, 1,
|
||||
"One breakpoint added to the editor.");
|
||||
is(aEvent.removed.length, 0,
|
||||
"No breakpoint was removed from the editor.");
|
||||
is(aEvent.added[0].line, 4,
|
||||
"Editor breakpoint line is correct.");
|
||||
|
||||
is(gEditor.getBreakpoints().length, 1,
|
||||
"editor.getBreakpoints().length is correct");
|
||||
}
|
||||
|
||||
function onEditorTextChanged() {
|
||||
// Wait for the actual text to be shown.
|
||||
if (gEditor.getText() != gDebugger.L10N.getStr("loadingText")) {
|
||||
onEditorTextReallyChanged();
|
||||
}
|
||||
}
|
||||
|
||||
function onEditorTextReallyChanged() {
|
||||
gEditor.removeEventListener(SourceEditor.EVENTS.TEXT_CHANGED, onEditorTextChanged);
|
||||
|
||||
is(gEditor.getText().indexOf("debugger"), -1,
|
||||
"The second source is no longer displayed.");
|
||||
is(gEditor.getText().indexOf("firstCall"), 118,
|
||||
"The first source is displayed.");
|
||||
|
||||
is(gSources.values[0], gSources.selectedValue,
|
||||
"The first source should be currently selected.");
|
||||
|
||||
let window = gEditor.editorElement.contentWindow;
|
||||
executeSoon(() => window.mozRequestAnimationFrame(onReadyForClick));
|
||||
}
|
||||
|
||||
function onReadyForClick() {
|
||||
info("Remove the second breakpoint using the mouse.");
|
||||
gEditor.addEventListener(SourceEditor.EVENTS.BREAKPOINT_CHANGE, onEditorBreakpointRemoveSecond);
|
||||
|
||||
let iframe = gEditor.editorElement;
|
||||
let testWin = iframe.ownerDocument.defaultView;
|
||||
|
||||
// Flush the layout for the iframe.
|
||||
info("rect " + iframe.contentDocument.documentElement.getBoundingClientRect());
|
||||
|
||||
let utils = testWin
|
||||
.QueryInterface(Ci.nsIInterfaceRequestor)
|
||||
.getInterface(Ci.nsIDOMWindowUtils);
|
||||
|
||||
let lineOffset = gEditor.getLineStart(4);
|
||||
let coords = gEditor.getLocationAtOffset(lineOffset);
|
||||
|
||||
let rect = iframe.getBoundingClientRect();
|
||||
let left = rect.left + 10;
|
||||
let top = rect.top + coords.y + 4;
|
||||
utils.sendMouseEventToWindow("mousedown", left, top, 0, 1, 0, false, 0, 0);
|
||||
utils.sendMouseEventToWindow("mouseup", left, top, 0, 1, 0, false, 0, 0);
|
||||
}
|
||||
|
||||
function onEditorBreakpointRemoveSecond(aEvent) {
|
||||
gEditor.removeEventListener(SourceEditor.EVENTS.BREAKPOINT_CHANGE, onEditorBreakpointRemoveSecond);
|
||||
editorBreakpointChanges++;
|
||||
|
||||
ok(aEvent,
|
||||
"breakpoint2 removed from the editor.");
|
||||
is(aEvent.added.length, 0,
|
||||
"No breakpoint was added to the editor.");
|
||||
is(aEvent.removed.length, 1,
|
||||
"One breakpoint was removed from the editor.");
|
||||
is(aEvent.removed[0].line, 4,
|
||||
"Editor breakpoint line is correct.");
|
||||
|
||||
is(gEditor.getBreakpoints().length, 0,
|
||||
"editor.getBreakpoints().length is correct.");
|
||||
|
||||
waitForDebuggerEvents(gPanel, gDebugger.EVENTS.AFTER_FRAMES_CLEARED).then(() => {
|
||||
finalCheck();
|
||||
closeDebuggerAndFinish(gPanel);
|
||||
});
|
||||
|
||||
gDebugger.gThreadClient.resume();
|
||||
}
|
||||
|
||||
function finalCheck() {
|
||||
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.");
|
||||
|
||||
ok(!gBreakpoints._getAdded({ url: gSources.values[0], line: 5 }),
|
||||
"_getAdded('gSources.values[0]', 5) returns falsey.");
|
||||
ok(!gBreakpoints._getRemoving({ url: gSources.values[0], line: 5 }),
|
||||
"_getRemoving('gSources.values[0]', 5) returns falsey.");
|
||||
|
||||
ok(!gBreakpoints._getAdded({ url: gSources.values[1], line: 6 }),
|
||||
"_getAdded('gSources.values[1]', 6) returns falsey.");
|
||||
ok(!gBreakpoints._getRemoving({ url: gSources.values[1], line: 6 }),
|
||||
"_getRemoving('gSources.values[1]', 6) returns falsey.");
|
||||
|
||||
ok(!gBreakpoints._getAdded({ url: "foo", line: 3 }),
|
||||
"_getAdded('foo', 3) returns falsey.");
|
||||
ok(!gBreakpoints._getRemoving({ url: "bar", line: 3 }),
|
||||
"_getRemoving('bar', 3) returns falsey.");
|
||||
|
||||
is(breakpointsAdded, 2,
|
||||
"Correct number of breakpoints have been added.");
|
||||
is(breakpointsRemoved, 1,
|
||||
"Correct number of breakpoints have been removed.");
|
||||
is(editorBreakpointChanges, 4,
|
||||
"Correct number of editor breakpoint changes.");
|
||||
}
|
||||
}
|
@ -0,0 +1,103 @@
|
||||
/* Any copyright is dedicated to the Public Domain.
|
||||
http://creativecommons.org/publicdomain/zero/1.0/ */
|
||||
|
||||
/**
|
||||
* Test if breakpoints are highlighted when they should.
|
||||
*/
|
||||
|
||||
const TAB_URL = EXAMPLE_URL + "doc_script-switching-01.html";
|
||||
|
||||
function test() {
|
||||
let gTab, gDebuggee, gPanel, gDebugger;
|
||||
let gEditor, gSources;
|
||||
|
||||
initDebugger(TAB_URL).then(([aTab, aDebuggee, aPanel]) => {
|
||||
gTab = aTab;
|
||||
gDebuggee = aDebuggee;
|
||||
gPanel = aPanel;
|
||||
gDebugger = gPanel.panelWin;
|
||||
gEditor = gDebugger.DebuggerView.editor;
|
||||
gSources = gDebugger.DebuggerView.Sources;
|
||||
|
||||
waitForSourceShown(gPanel, "-01.js")
|
||||
.then(addBreakpoints)
|
||||
.then(() => clickBreakpointAndCheck(0, 0, 5))
|
||||
.then(() => clickBreakpointAndCheck(1, 1, 6))
|
||||
.then(() => clickBreakpointAndCheck(2, 1, 7))
|
||||
.then(() => clickBreakpointAndCheck(3, 1, 8))
|
||||
.then(() => clickBreakpointAndCheck(4, 1, 9))
|
||||
.then(() => resumeDebuggerThenCloseAndFinish(gPanel))
|
||||
.then(null, aError => {
|
||||
ok(false, "Got an error: " + aError.message + "\n" + aError.stack);
|
||||
});
|
||||
});
|
||||
|
||||
function addBreakpoints() {
|
||||
return promise.resolve(null)
|
||||
.then(() => initialChecks(0, 1))
|
||||
.then(() => gPanel.addBreakpoint({ url: gSources.values[0], line: 5 }))
|
||||
.then(() => initialChecks(0, 5))
|
||||
.then(() => gPanel.addBreakpoint({ url: gSources.values[1], line: 6 }))
|
||||
.then(() => waitForSourceShown(gPanel, "-02.js"))
|
||||
.then(() => waitForCaretUpdated(gPanel, 6))
|
||||
.then(() => initialChecks(1, 6))
|
||||
.then(() => gPanel.addBreakpoint({ url: gSources.values[1], line: 7 }))
|
||||
.then(() => initialChecks(1, 7))
|
||||
.then(() => gPanel.addBreakpoint({ url: gSources.values[1], line: 8 }))
|
||||
.then(() => initialChecks(1, 8))
|
||||
.then(() => gPanel.addBreakpoint({ url: gSources.values[1], line: 9 }))
|
||||
.then(() => initialChecks(1, 9));
|
||||
}
|
||||
|
||||
function initialChecks(aSourceIndex, aCaretLine) {
|
||||
checkEditorContents(aSourceIndex);
|
||||
|
||||
is(gSources.selectedLabel, gSources.items[aSourceIndex].label,
|
||||
"The currently selected source label is incorrect (0).");
|
||||
is(gSources.selectedValue, gSources.items[aSourceIndex].value,
|
||||
"The currently selected source value is incorrect (0).");
|
||||
ok(isCaretPos(gPanel, aCaretLine),
|
||||
"The editor caret line and column were incorrect (0).");
|
||||
}
|
||||
|
||||
function clickBreakpointAndCheck(aBreakpointIndex, aSourceIndex, aCaretLine) {
|
||||
let finished = waitForCaretUpdated(gPanel, aCaretLine).then(() => {
|
||||
checkHighlight(gSources.values[aSourceIndex], aCaretLine);
|
||||
checkEditorContents(aSourceIndex);
|
||||
|
||||
is(gSources.selectedLabel, gSources.items[aSourceIndex].label,
|
||||
"The currently selected source label is incorrect (1).");
|
||||
is(gSources.selectedValue, gSources.items[aSourceIndex].value,
|
||||
"The currently selected source value is incorrect (1).");
|
||||
ok(isCaretPos(gPanel, aCaretLine),
|
||||
"The editor caret line and column were incorrect (1).");
|
||||
});
|
||||
|
||||
EventUtils.sendMouseEvent({ type: "click" },
|
||||
gDebugger.document.querySelectorAll(".dbg-breakpoint")[aBreakpointIndex],
|
||||
gDebugger);
|
||||
|
||||
return finished;
|
||||
}
|
||||
|
||||
function checkHighlight(aUrl, aLine) {
|
||||
is(gSources._selectedBreakpointItem, gSources.getBreakpoint({ url: aUrl, line: aLine }),
|
||||
"The currently selected breakpoint item is incorrect.");
|
||||
is(gSources._selectedBreakpointItem.attachment.url, aUrl,
|
||||
"The selected breakpoint item's source location attachment is incorrect.");
|
||||
is(gSources._selectedBreakpointItem.attachment.line, aLine,
|
||||
"The selected breakpoint item's source line number is incorrect.");
|
||||
ok(gSources._selectedBreakpointItem.target.classList.contains("selected"),
|
||||
"The selected breakpoint item's target should have a selected class.");
|
||||
}
|
||||
|
||||
function checkEditorContents(aSourceIndex) {
|
||||
if (aSourceIndex == 0) {
|
||||
is(gEditor.getText().indexOf("firstCall"), 118,
|
||||
"The first source is correctly displayed.");
|
||||
} else {
|
||||
is(gEditor.getText().indexOf("debugger"), 172,
|
||||
"The second source is correctly displayed.");
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,90 @@
|
||||
/* Any copyright is dedicated to the Public Domain.
|
||||
http://creativecommons.org/publicdomain/zero/1.0/ */
|
||||
|
||||
/**
|
||||
* Bug 771452: Make sure that setting a breakpoint in an inline source doesn't
|
||||
* add it twice.
|
||||
*/
|
||||
|
||||
const TAB_URL = EXAMPLE_URL + "doc_inline-script.html";
|
||||
|
||||
let gTab, gDebuggee, gPanel, gDebugger;
|
||||
|
||||
function test() {
|
||||
initDebugger(TAB_URL).then(([aTab, aDebuggee, aPanel]) => {
|
||||
gTab = aTab;
|
||||
gDebuggee = aDebuggee;
|
||||
gPanel = aPanel;
|
||||
gDebugger = gPanel.panelWin;
|
||||
|
||||
addBreakpoint();
|
||||
});
|
||||
}
|
||||
|
||||
function addBreakpoint() {
|
||||
waitForSourceAndCaretAndScopes(gPanel, ".html", 16).then(() => {
|
||||
is(gDebugger.gThreadClient.state, "paused",
|
||||
"The debugger statement was reached.");
|
||||
ok(isCaretPos(gPanel, 16),
|
||||
"The source editor caret position is incorrect (1).");
|
||||
|
||||
gPanel.addBreakpoint({ url: TAB_URL, line: 20 }).then(() => {
|
||||
testResume();
|
||||
});
|
||||
});
|
||||
|
||||
gDebuggee.runDebuggerStatement();
|
||||
}
|
||||
|
||||
function testResume() {
|
||||
is(gDebugger.gThreadClient.state, "paused",
|
||||
"The breakpoint wasn't hit yet.");
|
||||
|
||||
gDebugger.gThreadClient.resume(() => {
|
||||
gDebugger.gThreadClient.addOneTimeListener("paused", (aEvent, aPacket) => {
|
||||
waitForDebuggerEvents(gPanel, gDebugger.EVENTS.FETCHED_SCOPES).then(() => {
|
||||
is(aPacket.why.type, "breakpoint",
|
||||
"Execution has advanced to the next breakpoint.");
|
||||
isnot(aPacket.why.type, "debuggerStatement",
|
||||
"The breakpoint was hit before the debugger statement.");
|
||||
ok(isCaretPos(gPanel, 20),
|
||||
"The source editor caret position is incorrect (2).");
|
||||
|
||||
testBreakpointHit();
|
||||
});
|
||||
});
|
||||
|
||||
EventUtils.sendMouseEvent({ type: "click" },
|
||||
gDebuggee.document.querySelector("button"),
|
||||
gDebuggee);
|
||||
});
|
||||
}
|
||||
|
||||
function testBreakpointHit() {
|
||||
is(gDebugger.gThreadClient.state, "paused",
|
||||
"The breakpoint was hit.");
|
||||
|
||||
gDebugger.gThreadClient.addOneTimeListener("paused", (aEvent, aPacket) => {
|
||||
waitForDebuggerEvents(gPanel, gDebugger.EVENTS.FETCHED_SCOPES).then(() => {
|
||||
is(aPacket.why.type, "debuggerStatement",
|
||||
"Execution has advanced to the next line.");
|
||||
isnot(aPacket.why.type, "breakpoint",
|
||||
"No ghost breakpoint was hit.");
|
||||
ok(isCaretPos(gPanel, 20),
|
||||
"The source editor caret position is incorrect (3).");
|
||||
|
||||
resumeDebuggerThenCloseAndFinish(gPanel);
|
||||
});
|
||||
});
|
||||
|
||||
EventUtils.sendMouseEvent({ type: "mousedown" },
|
||||
gDebugger.document.getElementById("resume"),
|
||||
gDebugger);
|
||||
}
|
||||
|
||||
registerCleanupFunction(function() {
|
||||
gTab = null;
|
||||
gDebuggee = null;
|
||||
gPanel = null;
|
||||
gDebugger = null;
|
||||
});
|
255
browser/devtools/debugger/test/browser_dbg_breakpoints-pane.js
Normal file
255
browser/devtools/debugger/test/browser_dbg_breakpoints-pane.js
Normal file
@ -0,0 +1,255 @@
|
||||
/* Any copyright is dedicated to the Public Domain.
|
||||
http://creativecommons.org/publicdomain/zero/1.0/ */
|
||||
|
||||
/**
|
||||
* Bug 723071: Test adding a pane to display the list of breakpoints across
|
||||
* all sources in the debuggee.
|
||||
*/
|
||||
|
||||
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();
|
||||
});
|
||||
|
||||
let breakpointsAdded = 0;
|
||||
let breakpointsDisabled = 0;
|
||||
let breakpointsRemoved = 0;
|
||||
|
||||
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.");
|
||||
is(gEditor.getText().indexOf("debugger"), 172,
|
||||
"The correct source was loaded initially.");
|
||||
is(gSources.selectedValue, gSources.values[1],
|
||||
"The correct source is selected.");
|
||||
|
||||
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.");
|
||||
|
||||
ok(!gBreakpoints._getAdded({ url: "foo", line: 3 }),
|
||||
"_getAdded('foo', 3) returns falsey.");
|
||||
ok(!gBreakpoints._getRemoving({ url: "bar", line: 3 }),
|
||||
"_getRemoving('bar', 3) returns falsey.");
|
||||
|
||||
let breakpointsParent = gSources.widget._parent;
|
||||
let breakpointsList = gSources.widget._list;
|
||||
|
||||
is(breakpointsParent.childNodes.length, 1, // one sources list
|
||||
"Found junk in the breakpoints container.");
|
||||
is(breakpointsList.childNodes.length, 1, // one sources group
|
||||
"Found junk in the breakpoints container.");
|
||||
is(breakpointsList.querySelectorAll(".dbg-breakpoint").length, 0,
|
||||
"No breakpoints should be visible at this point.");
|
||||
|
||||
addBreakpoints(true).then(() => {
|
||||
is(breakpointsAdded, 3,
|
||||
"Should have added 3 breakpoints so far.");
|
||||
is(breakpointsDisabled, 0,
|
||||
"Shouldn't have disabled anything so far.");
|
||||
is(breakpointsRemoved, 0,
|
||||
"Shouldn't have removed anything so far.");
|
||||
|
||||
is(breakpointsParent.childNodes.length, 1, // one sources list
|
||||
"Found junk in the breakpoints container.");
|
||||
is(breakpointsList.childNodes.length, 1, // one sources group
|
||||
"Found junk in the breakpoints container.");
|
||||
is(breakpointsList.querySelectorAll(".dbg-breakpoint").length, 3,
|
||||
"3 breakpoints should be visible at this point.");
|
||||
|
||||
disableBreakpoints().then(() => {
|
||||
is(breakpointsAdded, 3,
|
||||
"Should still have 3 breakpoints added so far.");
|
||||
is(breakpointsDisabled, 3,
|
||||
"Should have 3 disabled breakpoints.");
|
||||
is(breakpointsRemoved, 0,
|
||||
"Shouldn't have removed anything so far.");
|
||||
|
||||
is(breakpointsParent.childNodes.length, 1, // one sources list
|
||||
"Found junk in the breakpoints container.");
|
||||
is(breakpointsList.childNodes.length, 1, // one sources group
|
||||
"Found junk in the breakpoints container.");
|
||||
is(breakpointsList.querySelectorAll(".dbg-breakpoint").length, breakpointsAdded,
|
||||
"Should have the same number of breakpoints in the pane.");
|
||||
is(breakpointsList.querySelectorAll(".dbg-breakpoint").length, breakpointsDisabled,
|
||||
"Should have the same number of disabled breakpoints.");
|
||||
|
||||
addBreakpoints().then(() => {
|
||||
is(breakpointsAdded, 3,
|
||||
"Should still have only 3 breakpoints added so far.");
|
||||
is(breakpointsDisabled, 3,
|
||||
"Should still have 3 disabled breakpoints.");
|
||||
is(breakpointsRemoved, 0,
|
||||
"Shouldn't have removed anything so far.");
|
||||
|
||||
is(breakpointsParent.childNodes.length, 1, // one sources list
|
||||
"Found junk in the breakpoints container.");
|
||||
is(breakpointsList.childNodes.length, 1, // one sources group
|
||||
"Found junk in the breakpoints container.");
|
||||
is(breakpointsList.querySelectorAll(".dbg-breakpoint").length, breakpointsAdded,
|
||||
"Since half of the breakpoints already existed, but disabled, " +
|
||||
"only half of the added breakpoints are actually in the pane.");
|
||||
|
||||
removeBreakpoints().then(() => {
|
||||
is(breakpointsRemoved, 3,
|
||||
"Should have 3 removed breakpoints.");
|
||||
|
||||
is(breakpointsParent.childNodes.length, 1, // one sources list
|
||||
"Found junk in the breakpoints container.");
|
||||
is(breakpointsList.childNodes.length, 1, // one sources group
|
||||
"Found junk in the breakpoints container.");
|
||||
is(breakpointsList.querySelectorAll(".dbg-breakpoint").length, 0,
|
||||
"No breakpoints should be visible at this point.");
|
||||
|
||||
waitForDebuggerEvents(gPanel, gDebugger.EVENTS.AFTER_FRAMES_CLEARED).then(() => {
|
||||
finalCheck();
|
||||
closeDebuggerAndFinish(gPanel);
|
||||
});
|
||||
|
||||
gDebugger.gThreadClient.resume();
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
function addBreakpoints(aIncrementFlag) {
|
||||
let deferred = promise.defer();
|
||||
|
||||
gPanel.addBreakpoint({ url: gSources.selectedValue, line: 6 }).then(aClient => {
|
||||
onBreakpointAdd(aClient, {
|
||||
increment: aIncrementFlag,
|
||||
line: 6,
|
||||
text: "eval(\"debugger;\");"
|
||||
});
|
||||
|
||||
gPanel.addBreakpoint({ url: gSources.selectedValue, line: 7 }).then(aClient => {
|
||||
onBreakpointAdd(aClient, {
|
||||
increment: aIncrementFlag,
|
||||
line: 7,
|
||||
text: "function foo() {}"
|
||||
});
|
||||
|
||||
gPanel.addBreakpoint({ url: gSources.selectedValue, line: 9 }).then(aClient => {
|
||||
onBreakpointAdd(aClient, {
|
||||
increment: aIncrementFlag,
|
||||
line: 9,
|
||||
text: "foo();"
|
||||
});
|
||||
|
||||
deferred.resolve();
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
return deferred.promise;
|
||||
}
|
||||
|
||||
function disableBreakpoints() {
|
||||
let deferred = promise.defer();
|
||||
|
||||
let nodes = breakpointsList.querySelectorAll(".dbg-breakpoint");
|
||||
info("Nodes to disable: " + breakpointsAdded.length);
|
||||
|
||||
is(nodes.length, breakpointsAdded,
|
||||
"The number of nodes to disable is incorrect.");
|
||||
|
||||
for (let node of nodes) {
|
||||
info("Disabling breakpoint: " + node.id);
|
||||
|
||||
let sourceItem = gSources.getItemForElement(node);
|
||||
let breakpointItem = gSources.getItemForElement.call(sourceItem, node);
|
||||
info("Found data: " + breakpointItem.attachment.toSource());
|
||||
|
||||
gSources.disableBreakpoint(breakpointItem.attachment).then(() => {
|
||||
if (++breakpointsDisabled == breakpointsAdded) {
|
||||
deferred.resolve();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
return deferred.promise;
|
||||
}
|
||||
|
||||
function removeBreakpoints() {
|
||||
let deferred = promise.defer();
|
||||
|
||||
let nodes = breakpointsList.querySelectorAll(".dbg-breakpoint");
|
||||
info("Nodes to remove: " + breakpointsAdded.length);
|
||||
|
||||
is(nodes.length, breakpointsAdded,
|
||||
"The number of nodes to remove is incorrect.");
|
||||
|
||||
for (let node of nodes) {
|
||||
info("Removing breakpoint: " + node.id);
|
||||
|
||||
let sourceItem = gSources.getItemForElement(node);
|
||||
let breakpointItem = gSources.getItemForElement.call(sourceItem, node);
|
||||
info("Found data: " + breakpointItem.attachment.toSource());
|
||||
|
||||
gPanel.removeBreakpoint(breakpointItem.attachment).then(() => {
|
||||
if (++breakpointsRemoved == breakpointsAdded) {
|
||||
deferred.resolve();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
return deferred.promise;
|
||||
}
|
||||
|
||||
function onBreakpointAdd(aBreakpointClient, aTestData) {
|
||||
if (aTestData.increment) {
|
||||
breakpointsAdded++;
|
||||
}
|
||||
|
||||
is(breakpointsList.querySelectorAll(".dbg-breakpoint").length, breakpointsAdded,
|
||||
aTestData.increment
|
||||
? "Should have added a breakpoint in the pane."
|
||||
: "Should have the same number of breakpoints in the pane.");
|
||||
|
||||
let id = "breakpoint-" + aBreakpointClient.actor;
|
||||
let node = gDebugger.document.getElementById(id);
|
||||
let line = node.getElementsByClassName("dbg-breakpoint-line")[0];
|
||||
let text = node.getElementsByClassName("dbg-breakpoint-text")[0];
|
||||
let check = node.querySelector("checkbox");
|
||||
|
||||
is(node.id, id,
|
||||
"Breakpoint element " + id + " found successfully.");
|
||||
is(line.getAttribute("value"), aTestData.line,
|
||||
"The expected information wasn't found in the breakpoint element.");
|
||||
is(text.getAttribute("value"), aTestData.text,
|
||||
"The expected line text wasn't found in the breakpoint element.");
|
||||
is(check.getAttribute("checked"), "true",
|
||||
"The breakpoint enable checkbox is checked as expected.");
|
||||
}
|
||||
}
|
||||
|
||||
function finalCheck() {
|
||||
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.");
|
||||
}
|
||||
}
|
@ -1,308 +0,0 @@
|
||||
/* Any copyright is dedicated to the Public Domain.
|
||||
http://creativecommons.org/publicdomain/zero/1.0/ */
|
||||
|
||||
/**
|
||||
* Bug 723069: test the debugger breakpoint API and connection to the source
|
||||
* editor.
|
||||
*/
|
||||
|
||||
const TAB_URL = EXAMPLE_URL + "browser_dbg_script-switching.html";
|
||||
|
||||
let gPane = null;
|
||||
let gTab = null;
|
||||
let gDebuggee = null;
|
||||
let gDebugger = null;
|
||||
let gEditor = null;
|
||||
let gSources = null;
|
||||
let gBreakpoints = null;
|
||||
|
||||
function test()
|
||||
{
|
||||
let scriptShown = false;
|
||||
let framesAdded = false;
|
||||
let resumed = false;
|
||||
let testStarted = false;
|
||||
|
||||
debug_tab_pane(TAB_URL, function(aTab, aDebuggee, aPane) {
|
||||
gTab = aTab;
|
||||
gDebuggee = aDebuggee;
|
||||
gPane = aPane;
|
||||
gDebugger = gPane.panelWin;
|
||||
resumed = true;
|
||||
|
||||
gDebugger.addEventListener("Debugger:SourceShown", onSourceShown);
|
||||
|
||||
gDebugger.DebuggerController.activeThread.addOneTimeListener("framesadded", function() {
|
||||
framesAdded = true;
|
||||
executeSoon(startTest);
|
||||
});
|
||||
|
||||
executeSoon(function() {
|
||||
gDebuggee.firstCall();
|
||||
});
|
||||
});
|
||||
|
||||
function onSourceShown(aEvent)
|
||||
{
|
||||
scriptShown = aEvent.detail.url.indexOf("-02.js") != -1;
|
||||
executeSoon(startTest);
|
||||
}
|
||||
|
||||
function startTest()
|
||||
{
|
||||
if (scriptShown && framesAdded && !testStarted) {
|
||||
gDebugger.removeEventListener("Debugger:SourceShown", onSourceShown);
|
||||
testStarted = true;
|
||||
Services.tm.currentThread.dispatch({ run: performTest }, 0);
|
||||
}
|
||||
}
|
||||
|
||||
function performTest()
|
||||
{
|
||||
gSources = gDebugger.DebuggerView.Sources;
|
||||
gEditor = gDebugger.editor;
|
||||
gBreakpoints = gPane.getAllBreakpoints();
|
||||
|
||||
is(gDebugger.DebuggerController.activeThread.state, "paused",
|
||||
"Should only be getting stack frames while paused.");
|
||||
|
||||
is(gSources.itemCount, 2,
|
||||
"Found the expected number of scripts.");
|
||||
|
||||
isnot(gEditor.getText().indexOf("debugger"), -1,
|
||||
"The correct script was loaded initially.");
|
||||
|
||||
isnot(gSources.selectedValue, gSources.values[0],
|
||||
"The correct script is selected");
|
||||
|
||||
is(Object.keys(gBreakpoints), 0, "no breakpoints");
|
||||
ok(!gPane.getBreakpoint("foo", 3), "getBreakpoint('foo', 3) returns falsey");
|
||||
is(gEditor.getBreakpoints().length, 0, "no breakpoints in the editor");
|
||||
|
||||
gEditor.addEventListener(SourceEditor.EVENTS.BREAKPOINT_CHANGE, onEditorBreakpointAddFirst);
|
||||
executeSoon(function() {
|
||||
gPane.addBreakpoint({url: gSources.selectedValue, line: 6}, onBreakpointAddFirst);
|
||||
});
|
||||
}
|
||||
|
||||
let breakpointsAdded = 0;
|
||||
let breakpointsRemoved = 0;
|
||||
let editorBreakpointChanges = 0;
|
||||
|
||||
function onEditorBreakpointAddFirst(aEvent)
|
||||
{
|
||||
gEditor.removeEventListener(SourceEditor.EVENTS.BREAKPOINT_CHANGE, onEditorBreakpointAddFirst);
|
||||
editorBreakpointChanges++;
|
||||
|
||||
ok(aEvent, "breakpoint1 added to the editor");
|
||||
is(aEvent.added.length, 1, "one breakpoint added to the editor");
|
||||
is(aEvent.removed.length, 0, "no breakpoint was removed from the editor");
|
||||
is(aEvent.added[0].line, 5, "editor breakpoint line is correct");
|
||||
|
||||
is(gEditor.getBreakpoints().length, 1,
|
||||
"editor.getBreakpoints().length is correct");
|
||||
}
|
||||
|
||||
function onBreakpointAddFirst(aBreakpointClient, aResponseError)
|
||||
{
|
||||
breakpointsAdded++;
|
||||
|
||||
ok(aBreakpointClient, "breakpoint1 added, client received");
|
||||
ok(!aResponseError, "breakpoint1 added without errors");
|
||||
is(aBreakpointClient.location.url, gSources.selectedValue,
|
||||
"breakpoint1 client url is correct");
|
||||
is(aBreakpointClient.location.line, 6,
|
||||
"breakpoint1 client line is correct");
|
||||
|
||||
executeSoon(function() {
|
||||
ok(aBreakpointClient.actor in gBreakpoints,
|
||||
"breakpoint1 client found in the list of debugger breakpoints");
|
||||
is(Object.keys(gBreakpoints).length, 1,
|
||||
"the list of debugger breakpoints holds only one breakpoint");
|
||||
is(gPane.getBreakpoint(gSources.selectedValue, 6), aBreakpointClient,
|
||||
"getBreakpoint returns the correct breakpoint");
|
||||
|
||||
info("remove the first breakpoint");
|
||||
gEditor.addEventListener(SourceEditor.EVENTS.BREAKPOINT_CHANGE, onEditorBreakpointRemoveFirst);
|
||||
gPane.removeBreakpoint(aBreakpointClient, onBreakpointRemoveFirst);
|
||||
});
|
||||
}
|
||||
|
||||
function onBreakpointRemoveFirst(aLocation)
|
||||
{
|
||||
breakpointsRemoved++;
|
||||
|
||||
ok(aLocation, "breakpoint1 removed");
|
||||
is(aLocation.url, gSources.selectedValue, "breakpoint1 remove: url is correct");
|
||||
is(aLocation.line, 6, "breakpoint1 remove: line is correct");
|
||||
|
||||
executeSoon(testBreakpointAddBackground);
|
||||
}
|
||||
|
||||
function onEditorBreakpointRemoveFirst(aEvent)
|
||||
{
|
||||
gEditor.removeEventListener(SourceEditor.EVENTS.BREAKPOINT_CHANGE, onEditorBreakpointRemoveFirst);
|
||||
editorBreakpointChanges++;
|
||||
|
||||
ok(aEvent, "breakpoint1 removed from the editor");
|
||||
is(aEvent.added.length, 0, "no breakpoint was added to the editor");
|
||||
is(aEvent.removed.length, 1, "one breakpoint was removed from the editor");
|
||||
is(aEvent.removed[0].line, 5, "editor breakpoint line is correct");
|
||||
|
||||
is(gEditor.getBreakpoints().length, 0,
|
||||
"editor.getBreakpoints().length is correct");
|
||||
}
|
||||
|
||||
function testBreakpointAddBackground()
|
||||
{
|
||||
info("add a breakpoint to the second script which is not selected");
|
||||
|
||||
is(Object.keys(gBreakpoints).length, 0,
|
||||
"no breakpoints in the debugger");
|
||||
ok(!gPane.getBreakpoint(gSources.selectedValue, 6),
|
||||
"getBreakpoint(selectedScript, 6) returns no breakpoint");
|
||||
isnot(gSources.values[0], gSources.selectedValue,
|
||||
"first script location is not the currently selected script");
|
||||
|
||||
gEditor.addEventListener(SourceEditor.EVENTS.BREAKPOINT_CHANGE, onEditorBreakpointAddBackgroundTrap);
|
||||
gPane.addBreakpoint({url: gSources.values[0], line: 5}, onBreakpointAddBackground);
|
||||
}
|
||||
|
||||
function onEditorBreakpointAddBackgroundTrap(aEvent)
|
||||
{
|
||||
// Trap listener: no breakpoint must be added to the editor when a
|
||||
// breakpoint is added to a script that is not currently selected.
|
||||
gEditor.removeEventListener(SourceEditor.EVENTS.BREAKPOINT_CHANGE, onEditorBreakpointAddBackgroundTrap);
|
||||
editorBreakpointChanges++;
|
||||
ok(false, "breakpoint2 must not be added to the editor");
|
||||
}
|
||||
|
||||
function onBreakpointAddBackground(aBreakpointClient, aResponseError)
|
||||
{
|
||||
breakpointsAdded++;
|
||||
|
||||
ok(aBreakpointClient, "breakpoint2 added, client received");
|
||||
ok(!aResponseError, "breakpoint2 added without errors");
|
||||
is(aBreakpointClient.location.url, gSources.values[0],
|
||||
"breakpoint2 client url is correct");
|
||||
is(aBreakpointClient.location.line, 5,
|
||||
"breakpoint2 client line is correct");
|
||||
|
||||
executeSoon(function() {
|
||||
ok(aBreakpointClient.actor in gBreakpoints,
|
||||
"breakpoint2 client found in the list of debugger breakpoints");
|
||||
|
||||
is(Object.keys(gBreakpoints).length, 1,
|
||||
"one breakpoint in the debugger");
|
||||
is(gPane.getBreakpoint(gSources.values[0], 5), aBreakpointClient,
|
||||
"getBreakpoint(locations[0], 5) returns the correct breakpoint");
|
||||
|
||||
// remove the trap listener
|
||||
gEditor.removeEventListener(SourceEditor.EVENTS.BREAKPOINT_CHANGE, onEditorBreakpointAddBackgroundTrap);
|
||||
|
||||
info("switch to the second script");
|
||||
gEditor.addEventListener(SourceEditor.EVENTS.BREAKPOINT_CHANGE, onEditorBreakpointAddSwitch);
|
||||
gEditor.addEventListener(SourceEditor.EVENTS.TEXT_CHANGED, onEditorTextChanged);
|
||||
gSources.selectedIndex = 0;
|
||||
});
|
||||
}
|
||||
|
||||
function onEditorBreakpointAddSwitch(aEvent)
|
||||
{
|
||||
gEditor.removeEventListener(SourceEditor.EVENTS.BREAKPOINT_CHANGE, onEditorBreakpointAddSwitch);
|
||||
editorBreakpointChanges++;
|
||||
|
||||
ok(aEvent, "breakpoint2 added to the editor");
|
||||
is(aEvent.added.length, 1, "one breakpoint added to the editor");
|
||||
is(aEvent.removed.length, 0, "no breakpoint was removed from the editor");
|
||||
is(aEvent.added[0].line, 4, "editor breakpoint line is correct");
|
||||
|
||||
is(gEditor.getBreakpoints().length, 1,
|
||||
"editor.getBreakpoints().length is correct");
|
||||
}
|
||||
|
||||
function onEditorTextChanged()
|
||||
{
|
||||
// Wait for the actual text to be shown.
|
||||
if (gDebugger.editor.getText() == gDebugger.L10N.getStr("loadingText")) {
|
||||
return;
|
||||
}
|
||||
// The requested source text has been shown, remove the event listener.
|
||||
gEditor.removeEventListener(SourceEditor.EVENTS.TEXT_CHANGED, onEditorTextChanged);
|
||||
|
||||
is(gEditor.getText().indexOf("debugger"), -1,
|
||||
"The second script is no longer displayed.");
|
||||
|
||||
isnot(gEditor.getText().indexOf("firstCall"), -1,
|
||||
"The first script is displayed.");
|
||||
|
||||
let window = gEditor.editorElement.contentWindow;
|
||||
executeSoon(() => window.mozRequestAnimationFrame(onReadyForClick));
|
||||
}
|
||||
|
||||
function onReadyForClick()
|
||||
{
|
||||
info("remove the second breakpoint using the mouse");
|
||||
gEditor.addEventListener(SourceEditor.EVENTS.BREAKPOINT_CHANGE, onEditorBreakpointRemoveSecond);
|
||||
|
||||
let iframe = gEditor.editorElement;
|
||||
let testWin = iframe.ownerDocument.defaultView;
|
||||
|
||||
// flush the layout for the iframe
|
||||
info("rect " + iframe.contentDocument.documentElement.getBoundingClientRect());
|
||||
|
||||
let utils = testWin.QueryInterface(Ci.nsIInterfaceRequestor)
|
||||
.getInterface(Ci.nsIDOMWindowUtils);
|
||||
|
||||
let lineOffset = gEditor.getLineStart(4);
|
||||
let coords = gEditor.getLocationAtOffset(lineOffset);
|
||||
|
||||
let rect = iframe.getBoundingClientRect();
|
||||
let left = rect.left + 10;
|
||||
let top = rect.top + coords.y + 4;
|
||||
utils.sendMouseEventToWindow("mousedown", left, top, 0, 1, 0, false, 0, 0);
|
||||
utils.sendMouseEventToWindow("mouseup", left, top, 0, 1, 0, false, 0, 0);
|
||||
}
|
||||
|
||||
function onEditorBreakpointRemoveSecond(aEvent)
|
||||
{
|
||||
gEditor.removeEventListener(SourceEditor.EVENTS.BREAKPOINT_CHANGE, onEditorBreakpointRemoveSecond);
|
||||
editorBreakpointChanges++;
|
||||
|
||||
ok(aEvent, "breakpoint2 removed from the editor");
|
||||
is(aEvent.added.length, 0, "no breakpoint was added to the editor");
|
||||
is(aEvent.removed.length, 1, "one breakpoint was removed from the editor");
|
||||
is(aEvent.removed[0].line, 4, "editor breakpoint line is correct");
|
||||
|
||||
is(gEditor.getBreakpoints().length, 0,
|
||||
"editor.getBreakpoints().length is correct");
|
||||
|
||||
executeSoon(function() {
|
||||
gDebugger.gClient.addOneTimeListener("resumed", function() {
|
||||
finalCheck();
|
||||
closeDebuggerAndFinish();
|
||||
});
|
||||
gDebugger.DebuggerController.activeThread.resume();
|
||||
});
|
||||
}
|
||||
|
||||
function finalCheck() {
|
||||
is(Object.keys(gBreakpoints).length, 0, "no breakpoint in the debugger");
|
||||
ok(!gPane.getBreakpoint(gSources.values[0], 5),
|
||||
"getBreakpoint(locations[0], 5) returns no breakpoint");
|
||||
}
|
||||
|
||||
registerCleanupFunction(function() {
|
||||
removeTab(gTab);
|
||||
is(breakpointsAdded, 2, "correct number of breakpoints have been added");
|
||||
is(breakpointsRemoved, 1, "correct number of breakpoints have been removed");
|
||||
is(editorBreakpointChanges, 4, "correct number of editor breakpoint changes");
|
||||
gPane = null;
|
||||
gTab = null;
|
||||
gDebuggee = null;
|
||||
gDebugger = null;
|
||||
gEditor = null;
|
||||
gSources = null;
|
||||
gBreakpoints = null;
|
||||
});
|
||||
}
|
@ -1,466 +0,0 @@
|
||||
/* Any copyright is dedicated to the Public Domain.
|
||||
http://creativecommons.org/publicdomain/zero/1.0/ */
|
||||
|
||||
/**
|
||||
* Test if the context menu associated with each breakpoint does what it should.
|
||||
*/
|
||||
|
||||
const TAB_URL = EXAMPLE_URL + "browser_dbg_script-switching.html";
|
||||
|
||||
let gPane = null;
|
||||
let gTab = null;
|
||||
let gDebuggee = null;
|
||||
let gDebugger = null;
|
||||
let gEditor = null;
|
||||
let gSources = null;
|
||||
|
||||
function test()
|
||||
{
|
||||
debug_tab_pane(TAB_URL, function(aTab, aDebuggee, aPane) {
|
||||
gTab = aTab;
|
||||
gDebuggee = aDebuggee;
|
||||
gPane = aPane;
|
||||
gDebugger = gPane.panelWin;
|
||||
gEditor = gDebugger.DebuggerView.editor;
|
||||
gSources = gDebugger.DebuggerView.Sources;
|
||||
gSources.preferredSource = EXAMPLE_URL + "test-script-switching-02.js";
|
||||
|
||||
gDebugger.addEventListener("Debugger:SourceShown", function _onEvent(aEvent) {
|
||||
let { url, loaded, text } = aEvent.detail;
|
||||
info("Shown source: " + url + ", loaded: " + loaded + ", text:\n" + text);
|
||||
info("Shown label: " + gSources.selectedLabel);
|
||||
info("All labels:" + gSources.labels);
|
||||
if (url.indexOf("-02") != -1) {
|
||||
gDebugger.removeEventListener(aEvent.type, _onEvent);
|
||||
performTestWhileNotPaused();
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
function addBreakpoints(callback) {
|
||||
gPane.addBreakpoint({url: gSources.orderedItems[0].value, line: 5}, function(cl, err) {
|
||||
gPane.addBreakpoint({url: gSources.orderedItems[1].value, line: 6}, function(cl, err) {
|
||||
gPane.addBreakpoint({url: gSources.orderedItems[1].value, line: 7}, function(cl, err) {
|
||||
gPane.addBreakpoint({url: gSources.orderedItems[1].value, line: 8}, function(cl, err) {
|
||||
gPane.addBreakpoint({url: gSources.orderedItems[1].value, line: 9}, function(cl, err) {
|
||||
callback();
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
function performTestWhileNotPaused()
|
||||
{
|
||||
info("Performing test while not paused...");
|
||||
|
||||
addBreakpoints(function() {
|
||||
initialChecks();
|
||||
|
||||
checkBreakpointToggleSelf(0, function() {
|
||||
checkBreakpointToggleOthers(0, function() {
|
||||
checkBreakpointToggleSelf(1, function() {
|
||||
checkBreakpointToggleOthers(1, function() {
|
||||
checkBreakpointToggleSelf(2, function() {
|
||||
checkBreakpointToggleOthers(2, function() {
|
||||
checkBreakpointToggleSelf(3, function() {
|
||||
checkBreakpointToggleOthers(3, function() {
|
||||
checkBreakpointToggleSelf(4, function() {
|
||||
checkBreakpointToggleOthers(4, function() {
|
||||
testDeleteAll(function() {
|
||||
performTestWhilePaused();
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
function performTestWhilePaused()
|
||||
{
|
||||
info("Performing test while paused...");
|
||||
|
||||
addBreakpoints(function() {
|
||||
initialChecks();
|
||||
|
||||
pauseAndCheck(function() {
|
||||
checkBreakpointToggleSelf(0, function() {
|
||||
checkBreakpointToggleOthers(0, function() {
|
||||
checkBreakpointToggleSelf(1, function() {
|
||||
checkBreakpointToggleOthers(1, function() {
|
||||
checkBreakpointToggleSelf(2, function() {
|
||||
checkBreakpointToggleOthers(2, function() {
|
||||
checkBreakpointToggleSelf(3, function() {
|
||||
checkBreakpointToggleOthers(3, function() {
|
||||
checkBreakpointToggleSelf(4, function() {
|
||||
checkBreakpointToggleOthers(4, function() {
|
||||
testDeleteAll(function() {
|
||||
closeDebuggerAndFinish();
|
||||
});
|
||||
}, true);
|
||||
});
|
||||
}, true);
|
||||
});
|
||||
}, true);
|
||||
});
|
||||
}, true);
|
||||
});
|
||||
}, true);
|
||||
});
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
function pauseAndCheck(callback) {
|
||||
gDebugger.gThreadClient.addOneTimeListener("resumed", function() {
|
||||
pauseAndCallback(function() {
|
||||
is(gSources.selectedLabel, "test-script-switching-01.js",
|
||||
"The currently selected source is incorrect (1).");
|
||||
is(gSources.selectedIndex, 1,
|
||||
"The currently selected source is incorrect (2).");
|
||||
|
||||
waitForCaretPos(4, function() {
|
||||
ok(true, "The editor location is correct after pausing.");
|
||||
callback();
|
||||
});
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
function pauseAndCallback(callback) {
|
||||
let scriptShown = false;
|
||||
let framesadded = false;
|
||||
let testContinued = false;
|
||||
|
||||
gDebugger.addEventListener("Debugger:SourceShown", function _onEvent(aEvent) {
|
||||
let url = aEvent.detail.url;
|
||||
if (url.indexOf("-01") != -1) {
|
||||
gDebugger.removeEventListener(aEvent.type, _onEvent);
|
||||
scriptShown = true;
|
||||
executeSoon(continueTest);
|
||||
}
|
||||
});
|
||||
|
||||
gDebugger.gThreadClient.addOneTimeListener("framesadded", function() {
|
||||
framesadded = true;
|
||||
executeSoon(continueTest);
|
||||
});
|
||||
|
||||
function continueTest() {
|
||||
if (scriptShown && framesadded && !testContinued) {
|
||||
testContinued = true;
|
||||
callback();
|
||||
}
|
||||
}
|
||||
|
||||
EventUtils.sendMouseEvent({ type: "click" },
|
||||
gDebuggee.document.querySelector("button"),
|
||||
gDebuggee.window);
|
||||
}
|
||||
|
||||
function initialChecks() {
|
||||
for (let source in gSources) {
|
||||
for (let breakpoint in source) {
|
||||
let { sourceLocation: url, lineNumber: line, actor } = breakpoint.attachment;
|
||||
|
||||
ok(gPane.getBreakpoint(url, line),
|
||||
"All breakpoint items should have corresponding clients (1).");
|
||||
ok(breakpoint.attachment.actor,
|
||||
"All breakpoint items should have corresponding clients (2).");
|
||||
is(!!breakpoint.attachment.disabled, false,
|
||||
"All breakpoints should initially be enabled.");
|
||||
|
||||
let prefix = "bp-cMenu-"; // "breakpoints context menu"
|
||||
let enableSelfId = prefix + "enableSelf-" + actor + "-menuitem";
|
||||
let disableSelfId = prefix + "disableSelf-" + actor + "-menuitem";
|
||||
|
||||
is(gDebugger.document.getElementById(enableSelfId).getAttribute("hidden"), "true",
|
||||
"The 'Enable breakpoint' context menu item should initially be hidden'.");
|
||||
ok(!gDebugger.document.getElementById(disableSelfId).hasAttribute("hidden"),
|
||||
"The 'Disable breakpoint' context menu item should initially not be hidden'.");
|
||||
is(breakpoint.attachment.view.checkbox.getAttribute("checked"), "true",
|
||||
"All breakpoints should initially have a checked checkbox.");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function checkBreakpointToggleSelf(index, callback) {
|
||||
EventUtils.sendMouseEvent({ type: "click" },
|
||||
gDebugger.document.querySelectorAll(".dbg-breakpoint")[index],
|
||||
gDebugger);
|
||||
|
||||
let selectedBreakpoint = gSources.selectedBreakpointItem;
|
||||
let { sourceLocation: url, lineNumber: line, actor } = selectedBreakpoint.attachment;
|
||||
|
||||
ok(gPane.getBreakpoint(url, line),
|
||||
"There should be a breakpoint client available (1).");
|
||||
ok(gSources.selectedBreakpointClient,
|
||||
"There should be a breakpoint client available (2).");
|
||||
is(!!selectedBreakpoint.attachment.disabled, false,
|
||||
"The breakpoint should not be disabled yet.");
|
||||
|
||||
let prefix = "bp-cMenu-"; // "breakpoints context menu"
|
||||
let enableSelfId = prefix + "enableSelf-" + actor + "-menuitem";
|
||||
let disableSelfId = prefix + "disableSelf-" + actor + "-menuitem";
|
||||
|
||||
is(gDebugger.document.getElementById(enableSelfId).getAttribute("hidden"), "true",
|
||||
"The 'Enable breakpoint' context menu item should be hidden'.");
|
||||
ok(!gDebugger.document.getElementById(disableSelfId).hasAttribute("hidden"),
|
||||
"The 'Disable breakpoint' context menu item should not be hidden'.");
|
||||
|
||||
waitForCaretPos(selectedBreakpoint.attachment.lineNumber - 1, function() {
|
||||
ok(true, "The editor location is correct (" + index + ").");
|
||||
|
||||
gDebugger.addEventListener("Debugger:BreakpointHidden", function _onEvent(aEvent) {
|
||||
gDebugger.removeEventListener(aEvent.type, _onEvent);
|
||||
|
||||
ok(!gPane.getBreakpoint(url, line),
|
||||
"There should be no breakpoint client available (2).");
|
||||
ok(!gSources.selectedBreakpointClient,
|
||||
"There should be no breakpoint client available (3).");
|
||||
|
||||
gDebugger.addEventListener("Debugger:BreakpointShown", function _onEvent(aEvent) {
|
||||
gDebugger.removeEventListener(aEvent.type, _onEvent);
|
||||
|
||||
ok(gPane.getBreakpoint(url, line),
|
||||
"There should be a breakpoint client available (4).");
|
||||
ok(gSources.selectedBreakpointClient,
|
||||
"There should be a breakpoint client available (5).");
|
||||
|
||||
callback();
|
||||
});
|
||||
|
||||
// Test re-disabling this breakpoint.
|
||||
executeSoon(function() {
|
||||
gSources._onEnableSelf(selectedBreakpoint.attachment.actor);
|
||||
is(selectedBreakpoint.attachment.disabled, false,
|
||||
"The current breakpoint should now be enabled.")
|
||||
|
||||
is(gDebugger.document.getElementById(enableSelfId).getAttribute("hidden"), "true",
|
||||
"The 'Enable breakpoint' context menu item should be hidden'.");
|
||||
ok(!gDebugger.document.getElementById(disableSelfId).hasAttribute("hidden"),
|
||||
"The 'Disable breakpoint' context menu item should not be hidden'.");
|
||||
ok(selectedBreakpoint.attachment.view.checkbox.hasAttribute("checked"),
|
||||
"The breakpoint should now be checked.");
|
||||
});
|
||||
});
|
||||
|
||||
// Test disabling this breakpoint.
|
||||
executeSoon(function() {
|
||||
gSources._onDisableSelf(selectedBreakpoint.attachment.actor);
|
||||
is(selectedBreakpoint.attachment.disabled, true,
|
||||
"The current breakpoint should now be disabled.")
|
||||
|
||||
ok(!gDebugger.document.getElementById(enableSelfId).hasAttribute("hidden"),
|
||||
"The 'Enable breakpoint' context menu item should not be hidden'.");
|
||||
is(gDebugger.document.getElementById(disableSelfId).getAttribute("hidden"), "true",
|
||||
"The 'Disable breakpoint' context menu item should be hidden'.");
|
||||
ok(!selectedBreakpoint.attachment.view.checkbox.hasAttribute("checked"),
|
||||
"The breakpoint should now be unchecked.");
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
function checkBreakpointToggleOthers(index, callback, whilePaused) {
|
||||
let count = 4
|
||||
gDebugger.addEventListener("Debugger:BreakpointHidden", function _onEvent(aEvent) {
|
||||
info(count + " breakpoints remain to be hidden...");
|
||||
if (!(--count)) {
|
||||
gDebugger.removeEventListener(aEvent.type, _onEvent);
|
||||
ok(true, "All breakpoints except one were hidden.");
|
||||
|
||||
let selectedBreakpoint = gSources.selectedBreakpointItem;
|
||||
let { sourceLocation: url, lineNumber: line, actor } = selectedBreakpoint.attachment;
|
||||
|
||||
ok(gPane.getBreakpoint(url, line),
|
||||
"There should be a breakpoint client available (6).");
|
||||
ok(gSources.selectedBreakpointClient,
|
||||
"There should be a breakpoint client available (7).");
|
||||
is(!!selectedBreakpoint.attachment.disabled, false,
|
||||
"The targetted breakpoint should not have been disabled.");
|
||||
|
||||
for (let source in gSources) {
|
||||
for (let otherBreakpoint in source) {
|
||||
if (otherBreakpoint != selectedBreakpoint) {
|
||||
ok(!gPane.getBreakpoint(
|
||||
otherBreakpoint.attachment.sourceLocation,
|
||||
otherBreakpoint.attachment.lineNumber),
|
||||
"There should be no breakpoint client for a disabled breakpoint (8).");
|
||||
is(otherBreakpoint.attachment.disabled, true,
|
||||
"Non-targetted breakpoints should have been disabled (9).");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
count = 4;
|
||||
gDebugger.addEventListener("Debugger:BreakpointShown", function _onEvent(aEvent) {
|
||||
info(count + " breakpoints remain to be reshown...");
|
||||
if (!(--count)) {
|
||||
gDebugger.removeEventListener(aEvent.type, _onEvent);
|
||||
ok(true, "All breakpoints are now reshown.");
|
||||
|
||||
for (let source in gSources) {
|
||||
for (let someBreakpoint in source) {
|
||||
ok(gPane.getBreakpoint(
|
||||
someBreakpoint.attachment.sourceLocation,
|
||||
someBreakpoint.attachment.lineNumber),
|
||||
"There should be a breakpoint client for all enabled breakpoints (10).");
|
||||
is(someBreakpoint.attachment.disabled, false,
|
||||
"All breakpoints should now have been enabled (11).");
|
||||
}
|
||||
}
|
||||
|
||||
count = 5;
|
||||
gDebugger.addEventListener("Debugger:BreakpointHidden", function _onEvent(aEvent) {
|
||||
info(count + " breakpoints remain to be rehidden...");
|
||||
if (!(--count)) {
|
||||
gDebugger.removeEventListener(aEvent.type, _onEvent);
|
||||
ok(true, "All breakpoints are now rehidden.");
|
||||
|
||||
for (let source in gSources) {
|
||||
for (let someBreakpoint in source) {
|
||||
ok(!gPane.getBreakpoint(
|
||||
someBreakpoint.attachment.sourceLocation,
|
||||
someBreakpoint.attachment.lineNumber),
|
||||
"There should be no breakpoint client for a disabled breakpoint (12).");
|
||||
is(someBreakpoint.attachment.disabled, true,
|
||||
"All breakpoints should now have been disabled (13).");
|
||||
}
|
||||
}
|
||||
|
||||
count = 5;
|
||||
gDebugger.addEventListener("Debugger:BreakpointShown", function _onEvent(aEvent) {
|
||||
info(count + " breakpoints remain to be reshown...");
|
||||
if (!(--count)) {
|
||||
gDebugger.removeEventListener(aEvent.type, _onEvent);
|
||||
ok(true, "All breakpoints are now rehidden.");
|
||||
|
||||
for (let source in gSources) {
|
||||
for (let someBreakpoint in source) {
|
||||
ok(gPane.getBreakpoint(
|
||||
someBreakpoint.attachment.sourceLocation,
|
||||
someBreakpoint.attachment.lineNumber),
|
||||
"There should be a breakpoint client for all enabled breakpoints (14).");
|
||||
is(someBreakpoint.attachment.disabled, false,
|
||||
"All breakpoints should now have been enabled (15).");
|
||||
}
|
||||
}
|
||||
|
||||
// Done.
|
||||
if (!whilePaused) {
|
||||
gDebugger.gThreadClient.addOneTimeListener("resumed", callback);
|
||||
} else {
|
||||
callback();
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
// Test re-enabling all breakpoints.
|
||||
enableAll();
|
||||
}
|
||||
});
|
||||
|
||||
// Test disabling all breakpoints.
|
||||
if (!whilePaused) {
|
||||
gDebugger.gThreadClient.addOneTimeListener("resumed", disableAll);
|
||||
} else {
|
||||
disableAll();
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
// Test re-enabling other breakpoints.
|
||||
enableOthers();
|
||||
}
|
||||
});
|
||||
|
||||
// Test disabling other breakpoints.
|
||||
if (!whilePaused) {
|
||||
gDebugger.gThreadClient.addOneTimeListener("resumed", disableOthers);
|
||||
} else {
|
||||
disableOthers();
|
||||
}
|
||||
}
|
||||
|
||||
function testDeleteAll(callback) {
|
||||
let count = 5
|
||||
gDebugger.addEventListener("Debugger:BreakpointHidden", function _onEvent(aEvent) {
|
||||
info(count + " breakpoints remain to be hidden...");
|
||||
if (!(--count)) {
|
||||
gDebugger.removeEventListener(aEvent.type, _onEvent);
|
||||
ok(true, "All breakpoints were hidden.");
|
||||
|
||||
ok(!gSources.selectedBreakpointItem,
|
||||
"There should be no breakpoint item available (16).");
|
||||
ok(!gSources.selectedBreakpointClient,
|
||||
"There should be no breakpoint client available (17).");
|
||||
|
||||
for (let source in gSources) {
|
||||
for (let otherBreakpoint in source) {
|
||||
ok(false, "It's a trap!");
|
||||
}
|
||||
}
|
||||
|
||||
// Done.
|
||||
callback();
|
||||
}
|
||||
});
|
||||
|
||||
// Test deleting all breakpoints.
|
||||
deleteAll();
|
||||
}
|
||||
|
||||
function disableOthers() {
|
||||
gSources._onDisableOthers(gSources.selectedBreakpointItem.attachment.actor);
|
||||
}
|
||||
function enableOthers() {
|
||||
gSources._onEnableOthers(gSources.selectedBreakpointItem.attachment.actor);
|
||||
}
|
||||
function disableAll() {
|
||||
gSources._onDisableAll(gSources.selectedBreakpointItem.attachment.actor);
|
||||
}
|
||||
function enableAll() {
|
||||
gSources._onEnableAll(gSources.selectedBreakpointItem.attachment.actor);
|
||||
}
|
||||
function deleteAll() {
|
||||
gSources._onDeleteAll(gSources.selectedBreakpointItem.attachment.actor);
|
||||
}
|
||||
|
||||
function waitForCaretPos(number, callback)
|
||||
{
|
||||
// Poll every few milliseconds until the source editor line is active.
|
||||
let count = 0;
|
||||
let intervalID = window.setInterval(function() {
|
||||
info("count: " + count + " ");
|
||||
if (++count > 50) {
|
||||
ok(false, "Timed out while polling for the line.");
|
||||
window.clearInterval(intervalID);
|
||||
return closeDebuggerAndFinish();
|
||||
}
|
||||
if (gEditor.getCaretPosition().line != number) {
|
||||
return;
|
||||
}
|
||||
// We got the source editor at the expected line, it's safe to callback.
|
||||
window.clearInterval(intervalID);
|
||||
callback();
|
||||
}, 100);
|
||||
}
|
||||
|
||||
registerCleanupFunction(function() {
|
||||
removeTab(gTab);
|
||||
gPane = null;
|
||||
gTab = null;
|
||||
gDebuggee = null;
|
||||
gDebugger = null;
|
||||
gEditor = null;
|
||||
gSources = null;
|
||||
});
|
||||
}
|
@ -1,224 +0,0 @@
|
||||
/* Any copyright is dedicated to the Public Domain.
|
||||
http://creativecommons.org/publicdomain/zero/1.0/ */
|
||||
|
||||
/**
|
||||
* Test if breakpoints are highlighted when they should.
|
||||
*/
|
||||
|
||||
const TAB_URL = EXAMPLE_URL + "browser_dbg_script-switching.html";
|
||||
|
||||
let gPane = null;
|
||||
let gTab = null;
|
||||
let gDebuggee = null;
|
||||
let gDebugger = null;
|
||||
let gEditor = null;
|
||||
let gSources = null;
|
||||
|
||||
function test()
|
||||
{
|
||||
debug_tab_pane(TAB_URL, function(aTab, aDebuggee, aPane) {
|
||||
gTab = aTab;
|
||||
gDebuggee = aDebuggee;
|
||||
gPane = aPane;
|
||||
gDebugger = gPane.panelWin;
|
||||
gEditor = gDebugger.DebuggerView.editor;
|
||||
gSources = gDebugger.DebuggerView.Sources;
|
||||
gSources.preferredSource = EXAMPLE_URL + "test-script-switching-02.js";
|
||||
|
||||
gDebugger.addEventListener("Debugger:SourceShown", function _onEvent(aEvent) {
|
||||
let { url, loaded, text } = aEvent.detail;
|
||||
info("Shown source: " + url + ", loaded: " + loaded + ", text:\n" + text);
|
||||
info("Shown label: " + gSources.selectedLabel);
|
||||
info("All labels:" + gSources.labels);
|
||||
if (url.indexOf("-02") != -1) {
|
||||
gDebugger.removeEventListener(aEvent.type, _onEvent);
|
||||
performTest();
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
function performTest()
|
||||
{
|
||||
initialChecks();
|
||||
gPane.addBreakpoint({url: gSources.orderedItems[0].value, line: 5}, function(cl, err) {
|
||||
initialChecks();
|
||||
gPane.addBreakpoint({url: gSources.orderedItems[1].value, line: 6}, function(cl, err) {
|
||||
initialChecks();
|
||||
gPane.addBreakpoint({url: gSources.orderedItems[1].value, line: 7}, function(cl, err) {
|
||||
initialChecks();
|
||||
gPane.addBreakpoint({url: gSources.orderedItems[1].value, line: 8}, function(cl, err) {
|
||||
initialChecks();
|
||||
gPane.addBreakpoint({url: gSources.orderedItems[1].value, line: 9}, function(cl, err) {
|
||||
initialChecks();
|
||||
testHighlight1();
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
function initialChecks() {
|
||||
is(gSources.selectedValue, gSources.orderedItems[1].value,
|
||||
"The currently selected source is incorrect (0).");
|
||||
is(gEditor.getCaretPosition().line, 0,
|
||||
"The editor caret line was incorrect (0).");
|
||||
is(gEditor.getCaretPosition().col, 0,
|
||||
"The editor caret column was incorrect (0).");
|
||||
}
|
||||
|
||||
function testHighlight1() {
|
||||
gSources.highlightBreakpoint(gSources.orderedItems[0].value, 5);
|
||||
checkHighlight(gSources.orderedItems[0].value, 5);
|
||||
|
||||
is(gSources.selectedValue, gSources.orderedItems[1].value,
|
||||
"The currently selected source is incorrect (1).");
|
||||
|
||||
is(gEditor.getCaretPosition().line, 0,
|
||||
"The editor caret line was incorrect (1).");
|
||||
is(gEditor.getCaretPosition().col, 0,
|
||||
"The editor caret column was incorrect (1).");
|
||||
|
||||
EventUtils.sendMouseEvent({ type: "click" },
|
||||
gDebugger.document.querySelectorAll(".dbg-breakpoint")[0],
|
||||
gDebugger);
|
||||
|
||||
waitForCaretPos(4, function() {
|
||||
ok(true, "The editor location is correct (1).");
|
||||
testHighlight2();
|
||||
});
|
||||
}
|
||||
|
||||
function testHighlight2() {
|
||||
gSources.highlightBreakpoint(gSources.orderedItems[1].value, 6);
|
||||
checkHighlight(gSources.orderedItems[1].value, 6);
|
||||
|
||||
is(gSources.selectedValue, gSources.orderedItems[0].value,
|
||||
"The currently selected source is incorrect (2).");
|
||||
|
||||
is(gEditor.getCaretPosition().line, 4,
|
||||
"The editor caret line was incorrect (2).");
|
||||
is(gEditor.getCaretPosition().col, 0,
|
||||
"The editor caret column was incorrect (2).");
|
||||
|
||||
EventUtils.sendMouseEvent({ type: "click" },
|
||||
gDebugger.document.querySelectorAll(".dbg-breakpoint")[1],
|
||||
gDebugger);
|
||||
|
||||
waitForCaretPos(5, function() {
|
||||
ok(true, "The editor location is correct (2).");
|
||||
testHighlight3();
|
||||
});
|
||||
}
|
||||
|
||||
function testHighlight3() {
|
||||
gSources.highlightBreakpoint(gSources.orderedItems[1].value, 7);
|
||||
checkHighlight(gSources.orderedItems[1].value, 7);
|
||||
|
||||
is(gSources.selectedValue, gSources.orderedItems[1].value,
|
||||
"The currently selected source is incorrect (3).");
|
||||
|
||||
is(gEditor.getCaretPosition().line, 5,
|
||||
"The editor caret line was incorrect (3).");
|
||||
is(gEditor.getCaretPosition().col, 0,
|
||||
"The editor caret column was incorrect (3).");
|
||||
|
||||
EventUtils.sendMouseEvent({ type: "click" },
|
||||
gDebugger.document.querySelectorAll(".dbg-breakpoint")[2],
|
||||
gDebugger);
|
||||
|
||||
waitForCaretPos(6, function() {
|
||||
ok(true, "The editor location is correct (3).");
|
||||
testHighlight4();
|
||||
});
|
||||
}
|
||||
|
||||
function testHighlight4() {
|
||||
gSources.highlightBreakpoint(gSources.orderedItems[1].value, 8);
|
||||
checkHighlight(gSources.orderedItems[1].value, 8);
|
||||
|
||||
is(gSources.selectedValue, gSources.orderedItems[1].value,
|
||||
"The currently selected source is incorrect (4).");
|
||||
|
||||
is(gEditor.getCaretPosition().line, 6,
|
||||
"The editor caret line was incorrect (4).");
|
||||
is(gEditor.getCaretPosition().col, 0,
|
||||
"The editor caret column was incorrect (4).");
|
||||
|
||||
EventUtils.sendMouseEvent({ type: "click" },
|
||||
gDebugger.document.querySelectorAll(".dbg-breakpoint")[3],
|
||||
gDebugger);
|
||||
|
||||
waitForCaretPos(7, function() {
|
||||
ok(true, "The editor location is correct (4).");
|
||||
testHighlight5();
|
||||
});
|
||||
}
|
||||
|
||||
function testHighlight5() {
|
||||
gSources.highlightBreakpoint(gSources.orderedItems[1].value, 9);
|
||||
checkHighlight(gSources.orderedItems[1].value, 9);
|
||||
|
||||
is(gSources.selectedValue, gSources.orderedItems[1].value,
|
||||
"The currently selected source is incorrect (5).");
|
||||
|
||||
is(gEditor.getCaretPosition().line, 7,
|
||||
"The editor caret line was incorrect (5).");
|
||||
is(gEditor.getCaretPosition().col, 0,
|
||||
"The editor caret column was incorrect (5).");
|
||||
|
||||
EventUtils.sendMouseEvent({ type: "click" },
|
||||
gDebugger.document.querySelectorAll(".dbg-breakpoint")[4],
|
||||
gDebugger);
|
||||
|
||||
waitForCaretPos(8, function() {
|
||||
ok(true, "The editor location is correct (5).");
|
||||
closeDebuggerAndFinish();
|
||||
});
|
||||
}
|
||||
|
||||
function checkHighlight(aUrl, aLine) {
|
||||
is(gSources.selectedBreakpointItem, gSources.getBreakpoint(aUrl, aLine),
|
||||
"The currently selected breakpoint item is incorrect.");
|
||||
is(gSources.selectedBreakpointClient, gPane.getBreakpoint(aUrl, aLine),
|
||||
"The currently selected breakpoint client is incorrect.");
|
||||
|
||||
is(gSources.selectedBreakpointItem.attachment.sourceLocation, aUrl,
|
||||
"The selected breakpoint item's source location attachment is incorrect.");
|
||||
is(gSources.selectedBreakpointItem.attachment.lineNumber, aLine,
|
||||
"The selected breakpoint item's source line number is incorrect.");
|
||||
|
||||
ok(gSources.selectedBreakpointItem.target.classList.contains("selected"),
|
||||
"The selected breakpoint item's target should have a selected class.");
|
||||
}
|
||||
|
||||
function waitForCaretPos(number, callback)
|
||||
{
|
||||
// Poll every few milliseconds until the source editor line is active.
|
||||
let count = 0;
|
||||
let intervalID = window.setInterval(function() {
|
||||
info("count: " + count + " ");
|
||||
if (++count > 50) {
|
||||
ok(false, "Timed out while polling for the line.");
|
||||
window.clearInterval(intervalID);
|
||||
return closeDebuggerAndFinish();
|
||||
}
|
||||
if (gEditor.getCaretPosition().line != number) {
|
||||
return;
|
||||
}
|
||||
// We got the source editor at the expected line, it's safe to callback.
|
||||
window.clearInterval(intervalID);
|
||||
callback();
|
||||
}, 100);
|
||||
}
|
||||
|
||||
registerCleanupFunction(function() {
|
||||
removeTab(gTab);
|
||||
gPane = null;
|
||||
gTab = null;
|
||||
gDebuggee = null;
|
||||
gDebugger = null;
|
||||
gEditor = null;
|
||||
gSources = null;
|
||||
});
|
||||
}
|
@ -1,301 +0,0 @@
|
||||
/* Any copyright is dedicated to the Public Domain.
|
||||
http://creativecommons.org/publicdomain/zero/1.0/ */
|
||||
|
||||
/**
|
||||
* Bug 723071: test adding a pane to display the list of breakpoints across
|
||||
* all scripts in the debuggee.
|
||||
*/
|
||||
|
||||
const TAB_URL = EXAMPLE_URL + "browser_dbg_script-switching.html";
|
||||
|
||||
let gPane = null;
|
||||
let gTab = null;
|
||||
let gDebuggee = null;
|
||||
let gDebugger = null;
|
||||
let gEditor = null;
|
||||
let gSources = null;
|
||||
let gBreakpoints = null;
|
||||
let gBreakpointsParent = null;
|
||||
let gBreakpointsList = null;
|
||||
|
||||
function test()
|
||||
{
|
||||
let scriptShown = false;
|
||||
let framesAdded = false;
|
||||
let resumed = false;
|
||||
let testStarted = false;
|
||||
|
||||
debug_tab_pane(TAB_URL, function(aTab, aDebuggee, aPane) {
|
||||
gTab = aTab;
|
||||
gDebuggee = aDebuggee;
|
||||
gPane = aPane;
|
||||
gDebugger = gPane.panelWin;
|
||||
resumed = true;
|
||||
|
||||
gDebugger.addEventListener("Debugger:SourceShown", onScriptShown);
|
||||
|
||||
gDebugger.DebuggerController.activeThread.addOneTimeListener("framesadded", function() {
|
||||
framesAdded = true;
|
||||
executeSoon(startTest);
|
||||
});
|
||||
|
||||
executeSoon(function() {
|
||||
gDebuggee.firstCall();
|
||||
});
|
||||
});
|
||||
|
||||
function onScriptShown(aEvent)
|
||||
{
|
||||
scriptShown = aEvent.detail.url.indexOf("-02.js") != -1;
|
||||
executeSoon(startTest);
|
||||
}
|
||||
|
||||
function startTest()
|
||||
{
|
||||
if (scriptShown && framesAdded && resumed && !testStarted) {
|
||||
gDebugger.removeEventListener("Debugger:SourceShown", onScriptShown);
|
||||
testStarted = true;
|
||||
Services.tm.currentThread.dispatch({ run: performTest }, 0);
|
||||
}
|
||||
}
|
||||
|
||||
let breakpointsAdded = 0;
|
||||
let breakpointsDisabled = 0;
|
||||
let breakpointsRemoved = 0;
|
||||
|
||||
function performTest()
|
||||
{
|
||||
gEditor = gDebugger.editor;
|
||||
gSources = gDebugger.DebuggerView.Sources;
|
||||
gBreakpoints = gPane.getAllBreakpoints();
|
||||
|
||||
is(gDebugger.DebuggerController.activeThread.state, "paused",
|
||||
"Should only be getting stack frames while paused.");
|
||||
|
||||
is(gSources.itemCount, 2,
|
||||
"Found the expected number of scripts.");
|
||||
|
||||
isnot(gEditor.getText().indexOf("debugger"), -1,
|
||||
"The correct script was loaded initially.");
|
||||
|
||||
isnot(gSources.selectedValue, gSources.values[0],
|
||||
"The correct script is selected");
|
||||
|
||||
is(Object.keys(gBreakpoints).length, 0, "no breakpoints");
|
||||
ok(!gPane.getBreakpoint("chocolate", 3), "getBreakpoint('chocolate', 3) returns falsey");
|
||||
is(gEditor.getBreakpoints().length, 0, "no breakpoints in the editor");
|
||||
|
||||
gBreakpointsParent = gSources.widget._parent;
|
||||
gBreakpointsList = gSources.widget._list;
|
||||
|
||||
is(gBreakpointsParent.childNodes.length, 1, // one sources list
|
||||
"Found junk in the breakpoints container.");
|
||||
is(gBreakpointsList.childNodes.length, 1, // one sources group
|
||||
"Found junk in the breakpoints container.");
|
||||
is(gBreakpointsList.querySelectorAll(".dbg-breakpoint").length, 0,
|
||||
"No breakpoints should be visible at this point.");
|
||||
|
||||
addBreakpoints(function() {
|
||||
is(breakpointsAdded, 3,
|
||||
"Should have added 3 breakpoints so far.");
|
||||
is(breakpointsDisabled, 0,
|
||||
"Shouldn't have disabled anything so far.");
|
||||
is(breakpointsRemoved, 0,
|
||||
"Shouldn't have removed anything so far.");
|
||||
|
||||
is(gBreakpointsParent.childNodes.length, 1, // one sources list
|
||||
"Found junk in the breakpoints container.");
|
||||
is(gBreakpointsList.childNodes.length, 1, // one sources group
|
||||
"Found junk in the breakpoints container.");
|
||||
is(gBreakpointsList.querySelectorAll(".dbg-breakpoint").length, 3,
|
||||
"3 breakpoints should be visible at this point.");
|
||||
|
||||
disableBreakpoints(function() {
|
||||
is(breakpointsAdded, 3,
|
||||
"Should still have 3 breakpoints added so far.");
|
||||
is(breakpointsDisabled, 3,
|
||||
"Should have 3 disabled breakpoints.");
|
||||
is(breakpointsRemoved, 0,
|
||||
"Shouldn't have removed anything so far.");
|
||||
|
||||
is(gBreakpointsParent.childNodes.length, 1, // one sources list
|
||||
"Found junk in the breakpoints container.");
|
||||
is(gBreakpointsList.childNodes.length, 1, // one sources group
|
||||
"Found junk in the breakpoints container.");
|
||||
is(gBreakpointsList.querySelectorAll(".dbg-breakpoint").length, breakpointsAdded,
|
||||
"Should have the same number of breakpoints in the pane.");
|
||||
is(gBreakpointsList.querySelectorAll(".dbg-breakpoint").length, breakpointsDisabled,
|
||||
"Should have the same number of disabled breakpoints.");
|
||||
|
||||
addBreakpoints(function() {
|
||||
is(breakpointsAdded, 3,
|
||||
"Should still have only 3 breakpoints added so far.");
|
||||
is(breakpointsDisabled, 3,
|
||||
"Should still have 3 disabled breakpoints.");
|
||||
is(breakpointsRemoved, 0,
|
||||
"Shouldn't have removed anything so far.");
|
||||
|
||||
is(gBreakpointsParent.childNodes.length, 1, // one sources list
|
||||
"Found junk in the breakpoints container.");
|
||||
is(gBreakpointsList.childNodes.length, 1, // one sources group
|
||||
"Found junk in the breakpoints container.");
|
||||
is(gBreakpointsList.querySelectorAll(".dbg-breakpoint").length, breakpointsAdded,
|
||||
"Since half of the breakpoints already existed, but disabled, " +
|
||||
"only half of the added breakpoints are actually in the pane.");
|
||||
|
||||
removeBreakpoints(function() {
|
||||
is(breakpointsRemoved, 3,
|
||||
"Should have 3 removed breakpoints.");
|
||||
|
||||
is(gBreakpointsParent.childNodes.length, 1, // one sources list
|
||||
"Found junk in the breakpoints container.");
|
||||
is(gBreakpointsList.childNodes.length, 1, // one sources group
|
||||
"Found junk in the breakpoints container.");
|
||||
is(gBreakpointsList.querySelectorAll(".dbg-breakpoint").length, 0,
|
||||
"No breakpoints should be visible at this point.");
|
||||
|
||||
executeSoon(function() {
|
||||
gDebugger.gClient.addOneTimeListener("resumed", function() {
|
||||
finalCheck();
|
||||
closeDebuggerAndFinish();
|
||||
});
|
||||
gDebugger.DebuggerController.activeThread.resume();
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
}, true);
|
||||
|
||||
function addBreakpoints(callback, increment)
|
||||
{
|
||||
let line;
|
||||
|
||||
executeSoon(function()
|
||||
{
|
||||
line = 6;
|
||||
gPane.addBreakpoint({url: gSources.selectedValue, line: line},
|
||||
function(cl, err) {
|
||||
onBreakpointAdd.call({ increment: increment, line: line }, cl, err);
|
||||
|
||||
line = 7;
|
||||
gPane.addBreakpoint({url: gSources.selectedValue, line: line},
|
||||
function(cl, err) {
|
||||
onBreakpointAdd.call({ increment: increment, line: line }, cl, err);
|
||||
|
||||
line = 9;
|
||||
gPane.addBreakpoint({url: gSources.selectedValue, line: line},
|
||||
function(cl, err) {
|
||||
onBreakpointAdd.call({ increment: increment, line: line }, cl, err);
|
||||
|
||||
executeSoon(function() {
|
||||
callback();
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
function disableBreakpoints(callback)
|
||||
{
|
||||
let nodes = Array.slice(gBreakpointsList.querySelectorAll(".dbg-breakpoint"));
|
||||
info("Nodes to disable: " + breakpointsAdded);
|
||||
|
||||
is(nodes.length, breakpointsAdded,
|
||||
"The number of nodes to disable is incorrect.");
|
||||
|
||||
Array.forEach(nodes, function(bkp) {
|
||||
info("Disabling breakpoint: " + bkp.id);
|
||||
|
||||
let sourceItem = gSources.getItemForElement(bkp);
|
||||
let breakpointItem = gSources.getItemForElement.call(sourceItem, bkp);
|
||||
let { sourceLocation: url, lineNumber: line } = breakpointItem.attachment;
|
||||
info("Found data: " + breakpointItem.attachment.toSource());
|
||||
|
||||
gSources.disableBreakpoint(url, line, { callback: function() {
|
||||
if (++breakpointsDisabled !== breakpointsAdded) {
|
||||
return;
|
||||
}
|
||||
executeSoon(function() {
|
||||
callback();
|
||||
});
|
||||
}});
|
||||
});
|
||||
}
|
||||
|
||||
function removeBreakpoints(callback)
|
||||
{
|
||||
let nodes = Array.slice(gBreakpointsList.querySelectorAll(".dbg-breakpoint"));
|
||||
info("Nodes to remove: " + breakpointsAdded);
|
||||
|
||||
is(nodes.length, breakpointsAdded,
|
||||
"The number of nodes to remove is incorrect.");
|
||||
|
||||
Array.forEach(nodes, function(bkp) {
|
||||
info("Removing breakpoint: " + bkp.id);
|
||||
|
||||
let sourceItem = gSources.getItemForElement(bkp);
|
||||
let breakpointItem = gSources.getItemForElement.call(sourceItem, bkp);
|
||||
let { sourceLocation: url, lineNumber: line } = breakpointItem.attachment;
|
||||
info("Found data: " + breakpointItem.attachment.toSource());
|
||||
|
||||
gPane.removeBreakpoint(gPane.getBreakpoint(url, line), function() {
|
||||
if (++breakpointsRemoved !== breakpointsAdded) {
|
||||
return;
|
||||
}
|
||||
executeSoon(function() {
|
||||
callback();
|
||||
});
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
function onBreakpointAdd(aBreakpointClient, aResponseError)
|
||||
{
|
||||
if (this.increment) {
|
||||
breakpointsAdded++;
|
||||
}
|
||||
|
||||
is(gBreakpointsList.querySelectorAll(".dbg-breakpoint").length, breakpointsAdded,
|
||||
this.increment ? "Should have added a breakpoint in the pane."
|
||||
: "Should have the same number of breakpoints in the pane.");
|
||||
|
||||
let id = "breakpoint-" + aBreakpointClient.actor;
|
||||
let bkp = gDebugger.document.getElementById(id);
|
||||
let line = bkp.getElementsByClassName("dbg-breakpoint-line")[0];
|
||||
let text = bkp.getElementsByClassName("dbg-breakpoint-text")[0];
|
||||
let check = bkp.querySelector("checkbox");
|
||||
|
||||
is(bkp.id, id,
|
||||
"Breakpoint element " + id + " found successfully.");
|
||||
is(line.getAttribute("value"), this.line,
|
||||
"The expected information wasn't found in the breakpoint element.");
|
||||
is(text.getAttribute("value"), gDebugger.DebuggerView.getEditorLineText(this.line - 1).trim(),
|
||||
"The expected line text wasn't found in the breakpoint element.");
|
||||
is(check.getAttribute("checked"), "true",
|
||||
"The breakpoint enable checkbox is checked as expected.");
|
||||
}
|
||||
}
|
||||
|
||||
function finalCheck() {
|
||||
is(Object.keys(gBreakpoints).length, 0, "no breakpoint in the debugger");
|
||||
ok(!gPane.getBreakpoint(gSources.values[0], 5),
|
||||
"getBreakpoint(locations[0], 5) returns no breakpoint");
|
||||
}
|
||||
|
||||
registerCleanupFunction(function() {
|
||||
is(breakpointsAdded, 3, "correct number of breakpoints have been added");
|
||||
is(breakpointsDisabled, 3, "correct number of breakpoints have been disabled");
|
||||
is(breakpointsRemoved, 3, "correct number of breakpoints have been removed");
|
||||
removeTab(gTab);
|
||||
gPane = null;
|
||||
gTab = null;
|
||||
gDebuggee = null;
|
||||
gDebugger = null;
|
||||
gEditor = null;
|
||||
gSources = null;
|
||||
gBreakpoints = null;
|
||||
gBreakpointsParent = null;
|
||||
gBreakpointsList = null;
|
||||
});
|
||||
}
|
@ -1,121 +0,0 @@
|
||||
/* 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 + "browser_dbg_script-switching.html";
|
||||
|
||||
let gPane = null;
|
||||
let gTab = null;
|
||||
let gDebuggee = null;
|
||||
let gDebugger = null;
|
||||
let gSources = null;
|
||||
let gEditor = null;
|
||||
let gBreakpoints = null;
|
||||
|
||||
function test() {
|
||||
let scriptShown = false;
|
||||
let framesAdded = false;
|
||||
let testStarted = false;
|
||||
let resumed = false;
|
||||
|
||||
debug_tab_pane(TAB_URL, function (aTab, aDebuggee, aPane) {
|
||||
gTab = aTab;
|
||||
gPane = aPane;
|
||||
gDebuggee = aDebuggee;
|
||||
gDebugger = gPane.panelWin;
|
||||
resumed = true;
|
||||
|
||||
gDebugger.addEventListener("Debugger:SourceShown", onSourceShown);
|
||||
|
||||
gDebugger.DebuggerController.activeThread.addOneTimeListener("framesadded", function () {
|
||||
framesAdded = true;
|
||||
executeSoon(startTest);
|
||||
});
|
||||
|
||||
executeSoon(function () {
|
||||
gDebuggee.firstCall();
|
||||
});
|
||||
});
|
||||
|
||||
function onSourceShown(aEvent) {
|
||||
scriptShown = aEvent.detail.url.indexOf("-02.js") != -1;
|
||||
executeSoon(startTest);
|
||||
}
|
||||
|
||||
function startTest() {
|
||||
if (scriptShown && framesAdded && resumed && !testStarted) {
|
||||
gDebugger.removeEventListener("Debugger:SourceShown", onSourceShown);
|
||||
testStarted = true;
|
||||
Services.tm.currentThread.dispatch({ run: performTest }, 0);
|
||||
}
|
||||
}
|
||||
|
||||
function performTest() {
|
||||
gSources = gDebugger.DebuggerView.Sources;
|
||||
gEditor = gDebugger.editor;
|
||||
gBreakpoints = gPane.getAllBreakpoints();
|
||||
is(Object.keys(gBreakpoints), 0, "There are no breakpoints");
|
||||
|
||||
gEditor.addEventListener(SourceEditor.EVENTS.BREAKPOINT_CHANGE,
|
||||
onEditorBreakpointAdd);
|
||||
|
||||
let location = { url: gSources.selectedValue, line: 4 };
|
||||
executeSoon(function () {
|
||||
gPane.addBreakpoint(location, onBreakpointAdd);
|
||||
});
|
||||
}
|
||||
|
||||
let onBpDebuggerAdd = false;
|
||||
let onBpEditorAdd = false;
|
||||
|
||||
function onBreakpointAdd(aBpClient) {
|
||||
is(aBpClient.location.url, gSources.selectedValue, "URL is the same");
|
||||
is(aBpClient.location.line, 6, "Line number is new");
|
||||
is(aBpClient.requestedLocation.line, 4, "Requested location is correct");
|
||||
|
||||
onBpDebuggerAdd = true;
|
||||
tryFinish();
|
||||
}
|
||||
|
||||
function onEditorBreakpointAdd(aEvent) {
|
||||
gEditor.removeEventListener(SourceEditor.EVENTS.BREAKPOINT_CHANGE,
|
||||
onEditorBreakpointAdd);
|
||||
|
||||
is(gEditor.getBreakpoints().length, 1,
|
||||
"There is only one breakpoint in the editor");
|
||||
|
||||
ok(!gPane.getBreakpoint(gSources.selectedValue, 4),
|
||||
"There are no breakpoints on an invalid line");
|
||||
|
||||
let br = gPane.getBreakpoint(gSources.selectedValue, 6);
|
||||
is(br.location.url, gSources.selectedValue, "URL is correct");
|
||||
is(br.location.line, 6, "Line number is correct");
|
||||
|
||||
onBpEditorAdd = true;
|
||||
tryFinish();
|
||||
}
|
||||
|
||||
function tryFinish() {
|
||||
info("onBpDebuggerAdd: " + onBpDebuggerAdd);
|
||||
info("onBpEditorAdd: " + onBpEditorAdd);
|
||||
|
||||
if (onBpDebuggerAdd && onBpEditorAdd) {
|
||||
closeDebuggerAndFinish();
|
||||
}
|
||||
}
|
||||
|
||||
registerCleanupFunction(function () {
|
||||
removeTab(gTab);
|
||||
gPane = null;
|
||||
gTab = null;
|
||||
gDebuggee = null;
|
||||
gDebugger = null;
|
||||
gSources = null;
|
||||
gEditor = null;
|
||||
gBreakpoints = null;
|
||||
});
|
||||
}
|
@ -1,393 +0,0 @@
|
||||
/* Any copyright is dedicated to the Public Domain.
|
||||
http://creativecommons.org/publicdomain/zero/1.0/ */
|
||||
|
||||
/**
|
||||
* Bug 740825: test the debugger conditional breakpoints.
|
||||
*/
|
||||
|
||||
const TAB_URL = EXAMPLE_URL + "browser_dbg_conditional-breakpoints.html";
|
||||
|
||||
let gPane = null;
|
||||
let gTab = null;
|
||||
let gDebuggee = null;
|
||||
let gDebugger = null;
|
||||
let gEditor = null;
|
||||
let gSources = null;
|
||||
let gBreakpoints = null;
|
||||
|
||||
requestLongerTimeout(2);
|
||||
|
||||
function test()
|
||||
{
|
||||
let scriptShown = false;
|
||||
let framesAdded = false;
|
||||
let resumed = false;
|
||||
let testStarted = false;
|
||||
|
||||
debug_tab_pane(TAB_URL, function(aTab, aDebuggee, aPane) {
|
||||
gTab = aTab;
|
||||
gDebuggee = aDebuggee;
|
||||
gPane = aPane;
|
||||
gDebugger = gPane.panelWin;
|
||||
|
||||
gDebugger.DebuggerView.toggleInstrumentsPane({ visible: true, animated: false });
|
||||
resumed = true;
|
||||
|
||||
gDebugger.addEventListener("Debugger:SourceShown", onScriptShown);
|
||||
|
||||
gDebugger.DebuggerController.activeThread.addOneTimeListener("framesadded", function() {
|
||||
framesAdded = true;
|
||||
executeSoon(startTest);
|
||||
});
|
||||
|
||||
executeSoon(function() {
|
||||
gDebuggee.ermahgerd(); // ermahgerd!!
|
||||
});
|
||||
});
|
||||
|
||||
function onScriptShown(aEvent)
|
||||
{
|
||||
scriptShown = aEvent.detail.url.indexOf("conditional-breakpoints") != -1;
|
||||
executeSoon(startTest);
|
||||
}
|
||||
|
||||
function startTest()
|
||||
{
|
||||
if (scriptShown && framesAdded && resumed && !testStarted) {
|
||||
gDebugger.removeEventListener("Debugger:SourceShown", onScriptShown);
|
||||
testStarted = true;
|
||||
Services.tm.currentThread.dispatch({ run: addBreakpoints }, 0);
|
||||
}
|
||||
}
|
||||
|
||||
function performTest()
|
||||
{
|
||||
gEditor = gDebugger.editor;
|
||||
gSources = gDebugger.DebuggerView.Sources;
|
||||
gBreakpoints = gPane.getAllBreakpoints();
|
||||
|
||||
is(gDebugger.DebuggerController.activeThread.state, "paused",
|
||||
"Should only be getting stack frames while paused.");
|
||||
|
||||
is(gSources.itemCount, 1,
|
||||
"Found the expected number of scripts.");
|
||||
|
||||
isnot(gEditor.getText().indexOf("ermahgerd"), -1,
|
||||
"The correct script was loaded initially.");
|
||||
|
||||
is(gSources.selectedValue, gSources.values[0],
|
||||
"The correct script is selected");
|
||||
|
||||
is(Object.keys(gBreakpoints).length, 13, "thirteen breakpoints");
|
||||
ok(!gPane.getBreakpoint("foo", 3), "getBreakpoint('foo', 3) returns falsey");
|
||||
is(gEditor.getBreakpoints().length, 13, "thirteen breakpoints in the editor");
|
||||
|
||||
executeSoon(test1);
|
||||
}
|
||||
|
||||
function test1(callback)
|
||||
{
|
||||
resumeAndTestBreakpoint(gSources.selectedValue, 14, test2);
|
||||
}
|
||||
|
||||
function test2(callback)
|
||||
{
|
||||
resumeAndTestBreakpoint(gSources.selectedValue, 15, test3);
|
||||
}
|
||||
|
||||
function test3(callback)
|
||||
{
|
||||
resumeAndTestBreakpoint(gSources.selectedValue, 16, test4);
|
||||
}
|
||||
|
||||
function test4(callback)
|
||||
{
|
||||
resumeAndTestBreakpoint(gSources.selectedValue, 17, test5);
|
||||
}
|
||||
|
||||
function test5(callback)
|
||||
{
|
||||
resumeAndTestBreakpoint(gSources.selectedValue, 18, test6);
|
||||
}
|
||||
|
||||
function test6(callback)
|
||||
{
|
||||
resumeAndTestBreakpoint(gSources.selectedValue, 19, test7);
|
||||
}
|
||||
|
||||
function test7(callback)
|
||||
{
|
||||
resumeAndTestBreakpoint(gSources.selectedValue, 21, test8);
|
||||
}
|
||||
|
||||
function test8(callback)
|
||||
{
|
||||
resumeAndTestBreakpoint(gSources.selectedValue, 22, test9);
|
||||
}
|
||||
|
||||
function test9(callback)
|
||||
{
|
||||
resumeAndTestBreakpoint(gSources.selectedValue, 23, test10);
|
||||
}
|
||||
|
||||
function test10(callback)
|
||||
{
|
||||
gDebugger.addEventListener("Debugger:AfterFramesCleared", function listener() {
|
||||
gDebugger.removeEventListener("Debugger:AfterFramesCleared", listener, true);
|
||||
|
||||
isnot(gSources.selectedItem, null,
|
||||
"There should be a selected script in the scripts pane.")
|
||||
is(gSources.selectedBreakpointItem, null,
|
||||
"There should be no selected breakpoint in the scripts pane.")
|
||||
is(gSources.selectedBreakpointClient, null,
|
||||
"There should be no selected client in the scripts pane.");
|
||||
is(gSources._conditionalPopupVisible, false,
|
||||
"The breakpoint conditional expression popup should not be shown.");
|
||||
|
||||
is(gDebugger.DebuggerView.StackFrames.widget._list.querySelectorAll(".dbg-stackframe").length, 0,
|
||||
"There should be no visible stackframes.");
|
||||
is(gDebugger.DebuggerView.Sources.widget._list.querySelectorAll(".dbg-breakpoint").length, 13,
|
||||
"There should be thirteen visible breakpoints.");
|
||||
|
||||
testReload();
|
||||
}, true);
|
||||
|
||||
gDebugger.DebuggerController.activeThread.resume();
|
||||
}
|
||||
|
||||
function resumeAndTestBreakpoint(url, line, callback)
|
||||
{
|
||||
resume(line, function() {
|
||||
waitForCaretPos(line - 1, function() {
|
||||
testBreakpoint(gSources.selectedBreakpointItem, gSources.selectedBreakpointClient, url, line, true);
|
||||
callback();
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
function testBreakpoint(aBreakpointItem, aBreakpointClient, url, line, editor)
|
||||
{
|
||||
is(aBreakpointItem.attachment.sourceLocation, gSources.selectedValue,
|
||||
"The breakpoint on line " + line + " wasn't added on the correct source.");
|
||||
is(aBreakpointItem.attachment.lineNumber, line,
|
||||
"The breakpoint on line " + line + " wasn't found.");
|
||||
is(!!aBreakpointItem.attachment.disabled, false,
|
||||
"The breakpoint on line " + line + " should be enabled.");
|
||||
is(!!aBreakpointItem.attachment.openPopupFlag, false,
|
||||
"The breakpoint on line " + line + " should not open a popup.");
|
||||
is(gSources._conditionalPopupVisible, false,
|
||||
"The breakpoint conditional expression popup should not be shown.");
|
||||
|
||||
is(aBreakpointClient.location.url, url,
|
||||
"The breakpoint's client url is correct");
|
||||
is(aBreakpointClient.location.line, line,
|
||||
"The breakpoint's client line is correct");
|
||||
isnot(aBreakpointClient.conditionalExpression, undefined,
|
||||
"The breakpoint on line " + line + " should have a conditional expression.");
|
||||
|
||||
if (editor) {
|
||||
is(gEditor.getCaretPosition().line + 1, line,
|
||||
"The editor caret position is not situated on the proper line.");
|
||||
is(gEditor.getCaretPosition().col, 0,
|
||||
"The editor caret position is not situated on the proper column.");
|
||||
}
|
||||
}
|
||||
|
||||
function addBreakpoints(callback)
|
||||
{
|
||||
let currentUrl = gDebugger.DebuggerView.Sources.selectedValue;
|
||||
|
||||
gPane.addBreakpoint({ url: currentUrl, line: 12 }, function() {
|
||||
gPane.addBreakpoint({ url: currentUrl, line: 13 }, function() {
|
||||
gPane.addBreakpoint({ url: currentUrl, line: 14 }, function() {
|
||||
gPane.addBreakpoint({ url: currentUrl, line: 15 }, function() {
|
||||
gPane.addBreakpoint({ url: currentUrl, line: 16 }, function() {
|
||||
gPane.addBreakpoint({ url: currentUrl, line: 17 }, function() {
|
||||
gPane.addBreakpoint({ url: currentUrl, line: 18 }, function() {
|
||||
gPane.addBreakpoint({ url: currentUrl, line: 19 }, function() {
|
||||
gPane.addBreakpoint({ url: currentUrl, line: 20 }, function() {
|
||||
gPane.addBreakpoint({ url: currentUrl, line: 21 }, function() {
|
||||
gPane.addBreakpoint({ url: currentUrl, line: 22 }, function() {
|
||||
gPane.addBreakpoint({ url: currentUrl, line: 23 }, function() {
|
||||
gPane.addBreakpoint({ url: currentUrl, line: 24 }, function() {
|
||||
performTest();
|
||||
}, {
|
||||
conditionalExpression: "b"
|
||||
});
|
||||
}, {
|
||||
conditionalExpression: "a !== null"
|
||||
});
|
||||
}, {
|
||||
conditionalExpression: "a !== undefined"
|
||||
});
|
||||
}, {
|
||||
conditionalExpression: "a"
|
||||
});
|
||||
}, {
|
||||
conditionalExpression: "(function() { return false; })()"
|
||||
});
|
||||
}, {
|
||||
conditionalExpression: "(function() {})"
|
||||
});
|
||||
}, {
|
||||
conditionalExpression: "({})"
|
||||
});
|
||||
}, {
|
||||
conditionalExpression: "/regexp/"
|
||||
});
|
||||
}, {
|
||||
conditionalExpression: "'nasu'"
|
||||
});
|
||||
}, {
|
||||
conditionalExpression: "true"
|
||||
});
|
||||
}, {
|
||||
conditionalExpression: "42"
|
||||
});
|
||||
}, {
|
||||
conditionalExpression: "null"
|
||||
});
|
||||
}, {
|
||||
conditionalExpression: "undefined"
|
||||
});
|
||||
}
|
||||
|
||||
function testReload()
|
||||
{
|
||||
info("Testing reload...");
|
||||
|
||||
function _get(url, line) {
|
||||
return [
|
||||
gDebugger.DebuggerView.Sources.getBreakpoint(url, line),
|
||||
gDebugger.DebuggerController.Breakpoints.getBreakpoint(url, line),
|
||||
url,
|
||||
line,
|
||||
];
|
||||
}
|
||||
|
||||
gDebugger.addEventListener("Debugger:SourceShown", function _onSourceShown() {
|
||||
gDebugger.removeEventListener("Debugger:SourceShown", _onSourceShown);
|
||||
|
||||
waitForBreakpoints(13, function() {
|
||||
testBreakpoint.apply(this, _get(gSources.selectedValue, 14));
|
||||
testBreakpoint.apply(this, _get(gSources.selectedValue, 15));
|
||||
testBreakpoint.apply(this, _get(gSources.selectedValue, 16));
|
||||
testBreakpoint.apply(this, _get(gSources.selectedValue, 17));
|
||||
testBreakpoint.apply(this, _get(gSources.selectedValue, 18));
|
||||
testBreakpoint.apply(this, _get(gSources.selectedValue, 19));
|
||||
testBreakpoint.apply(this, _get(gSources.selectedValue, 21));
|
||||
testBreakpoint.apply(this, _get(gSources.selectedValue, 22));
|
||||
testBreakpoint.apply(this, _get(gSources.selectedValue, 23));
|
||||
|
||||
isnot(gSources.selectedItem, null,
|
||||
"There should be a selected script in the scripts pane.")
|
||||
is(gSources.selectedBreakpointItem, null,
|
||||
"There should be no selected breakpoint in the scripts pane.")
|
||||
is(gSources.selectedBreakpointClient, null,
|
||||
"There should be no selected client in the scripts pane.");
|
||||
is(gSources._conditionalPopupVisible, false,
|
||||
"The breakpoint conditional expression popup should not be shown.");
|
||||
|
||||
closeDebuggerAndFinish();
|
||||
});
|
||||
});
|
||||
|
||||
finalCheck();
|
||||
gDebugger.DebuggerController.client.activeTab.reload();
|
||||
}
|
||||
|
||||
function finalCheck() {
|
||||
isnot(gEditor.getText().indexOf("ermahgerd"), -1,
|
||||
"The correct script is still loaded.");
|
||||
is(gSources.selectedValue, gSources.values[0],
|
||||
"The correct script is still selected");
|
||||
}
|
||||
|
||||
function resume(expected, callback) {
|
||||
gDebugger.DebuggerController.activeThread.addOneTimeListener("resumed", function() {
|
||||
waitForBreakpoint(expected, callback);
|
||||
});
|
||||
|
||||
EventUtils.sendMouseEvent({ type: "mousedown" },
|
||||
gDebugger.document.getElementById("resume"),
|
||||
gDebugger);
|
||||
}
|
||||
|
||||
let bogusClient = {
|
||||
location: {
|
||||
url: null,
|
||||
line: null
|
||||
}
|
||||
};
|
||||
|
||||
function waitForBreakpoint(expected, callback) {
|
||||
// Poll every few milliseconds until expected breakpoint is hit.
|
||||
let count = 0;
|
||||
let intervalID = window.setInterval(function() {
|
||||
info("count: " + count + " ");
|
||||
if (++count > 50) {
|
||||
ok(false, "Timed out while polling for the breakpoint.");
|
||||
window.clearInterval(intervalID);
|
||||
return closeDebuggerAndFinish();
|
||||
}
|
||||
if ((gSources.selectedBreakpointClient !== expected) &&
|
||||
(gSources.selectedBreakpointClient || bogusClient).location.line !== expected) {
|
||||
return;
|
||||
}
|
||||
// We arrived at the expected line, it's safe to callback.
|
||||
window.clearInterval(intervalID);
|
||||
callback();
|
||||
}, 100);
|
||||
}
|
||||
|
||||
function waitForBreakpoints(total, callback)
|
||||
{
|
||||
// Poll every few milliseconds until the breakpoints are retrieved.
|
||||
let count = 0;
|
||||
let intervalID = window.setInterval(function() {
|
||||
info("count: " + count + " ");
|
||||
if (++count > 50) {
|
||||
ok(false, "Timed out while polling for the breakpoints.");
|
||||
window.clearInterval(intervalID);
|
||||
return closeDebuggerAndFinish();
|
||||
}
|
||||
if (gSources.widget._list.querySelectorAll(".dbg-breakpoint").length != total) {
|
||||
return;
|
||||
}
|
||||
// We got all the breakpoints, it's safe to callback.
|
||||
window.clearInterval(intervalID);
|
||||
callback();
|
||||
}, 100);
|
||||
}
|
||||
|
||||
function waitForCaretPos(number, callback)
|
||||
{
|
||||
// Poll every few milliseconds until the source editor line is active.
|
||||
let count = 0;
|
||||
let intervalID = window.setInterval(function() {
|
||||
info("count: " + count + " ");
|
||||
if (++count > 50) {
|
||||
ok(false, "Timed out while polling for the line.");
|
||||
window.clearInterval(intervalID);
|
||||
return closeDebuggerAndFinish();
|
||||
}
|
||||
if (gEditor.getCaretPosition().line != number) {
|
||||
return;
|
||||
}
|
||||
// We got the source editor at the expected line, it's safe to callback.
|
||||
window.clearInterval(intervalID);
|
||||
callback();
|
||||
}, 100);
|
||||
}
|
||||
|
||||
registerCleanupFunction(function() {
|
||||
removeTab(gTab);
|
||||
gPane = null;
|
||||
gTab = null;
|
||||
gDebuggee = null;
|
||||
gDebugger = null;
|
||||
gEditor = null;
|
||||
gSources = null;
|
||||
gBreakpoints = null;
|
||||
});
|
||||
}
|
@ -1,583 +0,0 @@
|
||||
/* Any copyright is dedicated to the Public Domain.
|
||||
http://creativecommons.org/publicdomain/zero/1.0/ */
|
||||
|
||||
/**
|
||||
* Bug 740825: test the debugger conditional breakpoints.
|
||||
*/
|
||||
|
||||
const TAB_URL = EXAMPLE_URL + "browser_dbg_conditional-breakpoints.html";
|
||||
|
||||
let gPane = null;
|
||||
let gTab = null;
|
||||
let gDebuggee = null;
|
||||
let gDebugger = null;
|
||||
let gEditor = null;
|
||||
let gSources = null;
|
||||
let gBreakpoints = null;
|
||||
|
||||
requestLongerTimeout(2);
|
||||
|
||||
function test()
|
||||
{
|
||||
let scriptShown = false;
|
||||
let framesAdded = false;
|
||||
let resumed = false;
|
||||
let testStarted = false;
|
||||
|
||||
debug_tab_pane(TAB_URL, function(aTab, aDebuggee, aPane) {
|
||||
gTab = aTab;
|
||||
gDebuggee = aDebuggee;
|
||||
gPane = aPane;
|
||||
gDebugger = gPane.panelWin;
|
||||
|
||||
gDebugger.addEventListener("Debugger:SourceShown", onScriptShown);
|
||||
|
||||
gDebugger.DebuggerView.toggleInstrumentsPane({ visible: true, animated: false });
|
||||
resumed = true;
|
||||
|
||||
gDebugger.DebuggerController.activeThread.addOneTimeListener("framesadded", function() {
|
||||
framesAdded = true;
|
||||
executeSoon(startTest);
|
||||
});
|
||||
|
||||
executeSoon(function() {
|
||||
gDebuggee.ermahgerd(); // ermahgerd!!
|
||||
});
|
||||
});
|
||||
|
||||
function onScriptShown(aEvent)
|
||||
{
|
||||
scriptShown = aEvent.detail.url.indexOf("conditional-breakpoints") != -1;
|
||||
executeSoon(startTest);
|
||||
}
|
||||
|
||||
function startTest()
|
||||
{
|
||||
if (scriptShown && framesAdded && resumed && !testStarted) {
|
||||
gDebugger.removeEventListener("Debugger:SourceShown", onScriptShown);
|
||||
testStarted = true;
|
||||
Services.tm.currentThread.dispatch({ run: performTest }, 0);
|
||||
}
|
||||
}
|
||||
|
||||
function performTest()
|
||||
{
|
||||
gEditor = gDebugger.editor;
|
||||
gSources = gDebugger.DebuggerView.Sources;
|
||||
gBreakpoints = gPane.getAllBreakpoints();
|
||||
|
||||
is(gDebugger.DebuggerController.activeThread.state, "paused",
|
||||
"Should only be getting stack frames while paused.");
|
||||
|
||||
is(gSources.itemCount, 1,
|
||||
"Found the expected number of scripts.");
|
||||
|
||||
isnot(gEditor.getText().indexOf("ermahgerd"), -1,
|
||||
"The correct script was loaded initially.");
|
||||
|
||||
is(gSources.selectedValue, gSources.values[0],
|
||||
"The correct script is selected");
|
||||
|
||||
is(Object.keys(gBreakpoints), 0, "no breakpoints");
|
||||
ok(!gPane.getBreakpoint("foo", 3), "getBreakpoint('foo', 3) returns falsey");
|
||||
is(gEditor.getBreakpoints().length, 0, "no breakpoints in the editor");
|
||||
|
||||
executeSoon(addBreakpoint1);
|
||||
}
|
||||
|
||||
function addBreakpoint1()
|
||||
{
|
||||
gPane.addBreakpoint({ url: gSources.selectedValue, line: 12 });
|
||||
|
||||
waitForBreakpoint(12, function() {
|
||||
waitForCaretPos(10, function() {
|
||||
waitForPopup(false, function() {
|
||||
testBreakpoint(gSources.selectedBreakpointItem,
|
||||
gSources.selectedBreakpointClient,
|
||||
gSources.selectedValue, 12, false, false, false);
|
||||
|
||||
executeSoon(addBreakpoint2);
|
||||
});
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
function addBreakpoint2()
|
||||
{
|
||||
gSources._editorContextMenuLineNumber = 12;
|
||||
gSources._onCmdAddBreakpoint();
|
||||
|
||||
waitForBreakpoint(13, function() {
|
||||
waitForCaretPos(12, function() {
|
||||
waitForPopup(false, function() {
|
||||
testBreakpoint(gSources.selectedBreakpointItem,
|
||||
gSources.selectedBreakpointClient,
|
||||
gSources.selectedValue, 13, false, false, true);
|
||||
|
||||
executeSoon(modBreakpoint2);
|
||||
});
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
function modBreakpoint2()
|
||||
{
|
||||
gSources._editorContextMenuLineNumber = 12;
|
||||
gSources._onCmdAddConditionalBreakpoint();
|
||||
|
||||
waitForBreakpoint(13, function() {
|
||||
waitForCaretPos(12, function() {
|
||||
waitForPopup(true, function() {
|
||||
testBreakpoint(gSources.selectedBreakpointItem,
|
||||
gSources.selectedBreakpointClient,
|
||||
gSources.selectedValue, 13, true, true, true);
|
||||
|
||||
executeSoon(addBreakpoint3);
|
||||
});
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
function addBreakpoint3()
|
||||
{
|
||||
gSources._editorContextMenuLineNumber = 13;
|
||||
gSources._onCmdAddConditionalBreakpoint();
|
||||
|
||||
waitForBreakpoint(14, function() {
|
||||
waitForCaretPos(13, function() {
|
||||
waitForPopup(true, function() {
|
||||
testBreakpoint(gSources.selectedBreakpointItem,
|
||||
gSources.selectedBreakpointClient,
|
||||
gSources.selectedValue, 14, true, true, true);
|
||||
|
||||
executeSoon(modBreakpoint3);
|
||||
});
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
function modBreakpoint3()
|
||||
{
|
||||
write("bamboocha");
|
||||
EventUtils.sendKey("RETURN", gDebugger);
|
||||
|
||||
waitForBreakpoint(14, function() {
|
||||
waitForCaretPos(13, function() {
|
||||
waitForPopup(false, function() {
|
||||
is(gSources.selectedBreakpointClient.conditionalExpression, "bamboocha",
|
||||
"The bamboocha expression wasn't fonud on the conditional breakpoint");
|
||||
|
||||
executeSoon(setContextMenu);
|
||||
});
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
function setContextMenu()
|
||||
{
|
||||
let contextMenu = gDebugger.document.getElementById("sourceEditorContextMenu");
|
||||
info("Testing source editor popup...");
|
||||
|
||||
contextMenu.addEventListener("popupshown", function onPopupShown() {
|
||||
contextMenu.removeEventListener("popupshown", onPopupShown, false);
|
||||
info("Source editor popup shown...");
|
||||
|
||||
contextMenu.addEventListener("popuphidden", function onPopupHidden() {
|
||||
contextMenu.removeEventListener("popuphidden", onPopupHidden, false);
|
||||
info("Source editor popup hidden...");
|
||||
|
||||
is(gSources._editorContextMenuLineNumber, 14,
|
||||
"The context menu line number is incorrect after the popup was hidden.");
|
||||
executeSoon(addBreakpoint4);
|
||||
}, false);
|
||||
|
||||
is(gSources._editorContextMenuLineNumber, 14,
|
||||
"The context menu line number is incorrect after the popup was shown.");
|
||||
contextMenu.hidePopup();
|
||||
}, false);
|
||||
|
||||
is(gSources._editorContextMenuLineNumber, -1,
|
||||
"The context menu line number was incorrect before the popup was shown.");
|
||||
gSources._editorContextMenuLineNumber = 14;
|
||||
contextMenu.openPopup(gEditor.editorElement, "overlap", 0, 0, true, false);
|
||||
}
|
||||
|
||||
function addBreakpoint4()
|
||||
{
|
||||
gEditor.setCaretPosition(14);
|
||||
gSources._onCmdAddBreakpoint();
|
||||
|
||||
waitForBreakpoint(15, function() {
|
||||
waitForCaretPos(14, function() {
|
||||
waitForPopup(false, function() {
|
||||
testBreakpoint(gSources.selectedBreakpointItem,
|
||||
gSources.selectedBreakpointClient,
|
||||
gSources.selectedValue, 15, false, false, true);
|
||||
|
||||
executeSoon(delBreakpoint4);
|
||||
});
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
function delBreakpoint4()
|
||||
{
|
||||
gEditor.setCaretPosition(14);
|
||||
gSources._onCmdAddBreakpoint();
|
||||
|
||||
waitForBreakpoint(null, function() {
|
||||
waitForCaretPos(14, function() {
|
||||
waitForPopup(false, function() {
|
||||
is(gSources.selectedBreakpointItem, null,
|
||||
"There should be no selected breakpoint in the breakpoints pane.")
|
||||
is(gSources._conditionalPopupVisible, false,
|
||||
"The breakpoint conditional expression popup should not be shown.");
|
||||
|
||||
executeSoon(moveHighlight1);
|
||||
});
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
function moveHighlight1()
|
||||
{
|
||||
gEditor.setCaretPosition(13);
|
||||
|
||||
waitForBreakpoint(14, function() {
|
||||
waitForCaretPos(13, function() {
|
||||
waitForPopup(false, function() {
|
||||
testBreakpoint(gSources.selectedBreakpointItem,
|
||||
gSources.selectedBreakpointClient,
|
||||
gSources.selectedValue, 14, false, true, true);
|
||||
|
||||
executeSoon(testHighlights1);
|
||||
});
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
function testHighlights1()
|
||||
{
|
||||
isnot(gSources.selectedBreakpointItem, null,
|
||||
"There should be a selected breakpoint in the breakpoints pane.");
|
||||
is(gSources.selectedBreakpointItem.attachment.sourceLocation, gSources.selectedValue,
|
||||
"The selected breakpoint should have the correct location.");
|
||||
is(gSources.selectedBreakpointItem.attachment.lineNumber, 14,
|
||||
"The selected breakpoint should have the correct line number.");
|
||||
is(gSources._conditionalPopupVisible, false,
|
||||
"The breakpoint conditional expression popup should not be shown.");
|
||||
is(gEditor.getCaretPosition().line, 13,
|
||||
"The source editor caret position should be at line 13");
|
||||
is(gEditor.getCaretPosition().col, 0,
|
||||
"The source editor caret position should be at column 0");
|
||||
|
||||
gEditor.setCaretPosition(12);
|
||||
|
||||
waitForCaretPos(12, function() {
|
||||
waitForPopup(false, function() {
|
||||
isnot(gSources.selectedBreakpointItem, null,
|
||||
"There should be a selected breakpoint in the breakpoints pane.");
|
||||
is(gSources.selectedBreakpointItem.attachment.sourceLocation, gSources.selectedValue,
|
||||
"The selected breakpoint should have the correct location.");
|
||||
is(gSources.selectedBreakpointItem.attachment.lineNumber, 13,
|
||||
"The selected breakpoint should have the correct line number.");
|
||||
is(gSources._conditionalPopupVisible, false,
|
||||
"The breakpoint conditional expression popup should not be shown.");
|
||||
is(gEditor.getCaretPosition().line, 12,
|
||||
"The source editor caret position should be at line 12");
|
||||
is(gEditor.getCaretPosition().col, 0,
|
||||
"The source editor caret position should be at column 0");
|
||||
|
||||
gEditor.setCaretPosition(11);
|
||||
|
||||
waitForCaretPos(11, function() {
|
||||
waitForPopup(false, function() {
|
||||
isnot(gSources.selectedBreakpointItem, null,
|
||||
"There should be a selected breakpoint in the breakpoints pane.");
|
||||
is(gSources.selectedBreakpointItem.attachment.sourceLocation, gSources.selectedValue,
|
||||
"The selected breakpoint should have the correct location.");
|
||||
is(gSources.selectedBreakpointItem.attachment.lineNumber, 12,
|
||||
"The selected breakpoint should have the correct line number.");
|
||||
is(gSources._conditionalPopupVisible, false,
|
||||
"The breakpoint conditional expression popup should not be shown.");
|
||||
is(gEditor.getCaretPosition().line, 11,
|
||||
"The source editor caret position should be at line 11");
|
||||
is(gEditor.getCaretPosition().col, 0,
|
||||
"The source editor caret position should be at column 0");
|
||||
|
||||
gEditor.setCaretPosition(10);
|
||||
|
||||
waitForCaretPos(10, function() {
|
||||
waitForPopup(false, function() {
|
||||
is(gSources.selectedBreakpointItem, null,
|
||||
"There should not be a selected breakpoint in the breakpoints pane.");
|
||||
is(gSources._conditionalPopupVisible, false,
|
||||
"The breakpoint conditional expression popup should not be shown.");
|
||||
is(gEditor.getCaretPosition().line, 10,
|
||||
"The source editor caret position should be at line 10");
|
||||
is(gEditor.getCaretPosition().col, 0,
|
||||
"The source editor caret position should be at column 0");
|
||||
|
||||
gEditor.setCaretPosition(14);
|
||||
|
||||
waitForCaretPos(14, function() {
|
||||
waitForPopup(false, function() {
|
||||
is(gSources.selectedBreakpointItem, null,
|
||||
"There should not be a selected breakpoint in the breakpoints pane.");
|
||||
is(gSources._conditionalPopupVisible, false,
|
||||
"The breakpoint conditional expression popup should not be shown.");
|
||||
is(gEditor.getCaretPosition().line, 14,
|
||||
"The source editor caret position should be at line 14");
|
||||
is(gEditor.getCaretPosition().col, 0,
|
||||
"The source editor caret position should be at column 0");
|
||||
|
||||
executeSoon(testHighlights2);
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
function testHighlights2()
|
||||
{
|
||||
EventUtils.sendMouseEvent({ type: "click" },
|
||||
gSources.widget._list.querySelectorAll(".dbg-breakpoint")[2],
|
||||
gDebugger);
|
||||
|
||||
waitForCaretPos(13, function() {
|
||||
waitForPopup(true, function() {
|
||||
isnot(gSources.selectedBreakpointItem, null,
|
||||
"There should be a selected breakpoint in the breakpoints pane.");
|
||||
is(gSources.selectedBreakpointItem.attachment.sourceLocation, gSources.selectedValue,
|
||||
"The selected breakpoint should have the correct location.");
|
||||
is(gSources.selectedBreakpointItem.attachment.lineNumber, 14,
|
||||
"The selected breakpoint should have the correct line number.");
|
||||
is(gSources._conditionalPopupVisible, true,
|
||||
"The breakpoint conditional expression popup should be shown.");
|
||||
is(gEditor.getCaretPosition().line, 13,
|
||||
"The source editor caret position should be at line 13");
|
||||
is(gEditor.getCaretPosition().col, 0,
|
||||
"The source editor caret position should be at column 0");
|
||||
|
||||
EventUtils.sendMouseEvent({ type: "click" },
|
||||
gSources.widget._list.querySelectorAll(".dbg-breakpoint")[1],
|
||||
gDebugger);
|
||||
|
||||
waitForCaretPos(12, function() {
|
||||
waitForPopup(true, function() {
|
||||
isnot(gSources.selectedBreakpointItem, null,
|
||||
"There should be a selected breakpoint in the breakpoints pane.");
|
||||
is(gSources.selectedBreakpointItem.attachment.sourceLocation, gSources.selectedValue,
|
||||
"The selected breakpoint should have the correct location.");
|
||||
is(gSources.selectedBreakpointItem.attachment.lineNumber, 13,
|
||||
"The selected breakpoint should have the correct line number.");
|
||||
is(gSources._conditionalPopupVisible, true,
|
||||
"The breakpoint conditional expression popup should be shown.");
|
||||
is(gEditor.getCaretPosition().line, 12,
|
||||
"The source editor caret position should be at line 12");
|
||||
is(gEditor.getCaretPosition().col, 0,
|
||||
"The source editor caret position should be at column 0");
|
||||
|
||||
EventUtils.sendMouseEvent({ type: "click" },
|
||||
gSources.widget._list.querySelectorAll(".dbg-breakpoint")[0],
|
||||
gDebugger);
|
||||
|
||||
waitForCaretPos(11, function() {
|
||||
waitForPopup(false, function() {
|
||||
isnot(gSources.selectedBreakpointItem, null,
|
||||
"There should be a selected breakpoint in the breakpoints pane.");
|
||||
is(gSources.selectedBreakpointItem.attachment.sourceLocation, gSources.selectedValue,
|
||||
"The selected breakpoint should have the correct location.");
|
||||
is(gSources.selectedBreakpointItem.attachment.lineNumber, 12,
|
||||
"The selected breakpoint should have the correct line number.");
|
||||
is(gSources._conditionalPopupVisible, false,
|
||||
"The breakpoint conditional expression popup should be shown.");
|
||||
is(gEditor.getCaretPosition().line, 11,
|
||||
"The source editor caret position should be at line 11");
|
||||
is(gEditor.getCaretPosition().col, 0,
|
||||
"The source editor caret position should be at column 0");
|
||||
|
||||
executeSoon(delBreakpoint2);
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
function delBreakpoint2()
|
||||
{
|
||||
gSources._editorContextMenuLineNumber = 12;
|
||||
gSources._onCmdAddBreakpoint();
|
||||
|
||||
waitForBreakpoint(null, function() {
|
||||
waitForPopup(false, function() {
|
||||
is(gSources.selectedBreakpointItem, null,
|
||||
"There should be no selected breakpoint in the breakpoints pane.")
|
||||
is(gSources._conditionalPopupVisible, false,
|
||||
"The breakpoint conditional expression popup should not be shown.");
|
||||
|
||||
executeSoon(delBreakpoint3);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
function delBreakpoint3()
|
||||
{
|
||||
gSources._editorContextMenuLineNumber = 13;
|
||||
gSources._onCmdAddBreakpoint();
|
||||
|
||||
waitForBreakpoint(null, function() {
|
||||
waitForPopup(false, function() {
|
||||
is(gSources.selectedBreakpointItem, null,
|
||||
"There should be no selected breakpoint in the breakpoints pane.")
|
||||
is(gSources._conditionalPopupVisible, false,
|
||||
"The breakpoint conditional expression popup should not be shown.");
|
||||
|
||||
executeSoon(testBreakpoints);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
function testBreakpoints()
|
||||
{
|
||||
is(Object.keys(gBreakpoints).length, 1, "one breakpoint");
|
||||
ok(!gPane.getBreakpoint("foo", 3), "getBreakpoint('foo', 3) returns falsey");
|
||||
is(gEditor.getBreakpoints().length, 1, "one breakpoint in the editor");
|
||||
|
||||
closeDebuggerAndFinish();
|
||||
}
|
||||
|
||||
function testBreakpoint(aBreakpointItem, aBreakpointClient, url, line, popup, conditional, editor)
|
||||
{
|
||||
is(aBreakpointItem.attachment.sourceLocation, gSources.selectedValue,
|
||||
"The breakpoint on line " + line + " wasn't added on the correct source.");
|
||||
is(aBreakpointItem.attachment.lineNumber, line,
|
||||
"The breakpoint on line " + line + " wasn't found.");
|
||||
is(!aBreakpointItem.attachment.disabled, true,
|
||||
"The breakpoint on line " + line + " should be enabled.");
|
||||
is(gSources._conditionalPopupVisible, popup,
|
||||
"The breakpoint conditional expression popup should " + (popup ? "" : "not ") + "be shown.");
|
||||
|
||||
is(aBreakpointClient.location.url, url,
|
||||
"The breakpoint's client url is correct");
|
||||
is(aBreakpointClient.location.line, line,
|
||||
"The breakpoint's client line is correct");
|
||||
|
||||
if (conditional) {
|
||||
isnot(aBreakpointClient.conditionalExpression, undefined,
|
||||
"The breakpoint on line " + line + " should have a conditional expression.");
|
||||
} else {
|
||||
is(aBreakpointClient.conditionalExpression, undefined,
|
||||
"The breakpoint on line " + line + " should not have a conditional expression.");
|
||||
}
|
||||
|
||||
if (editor) {
|
||||
is(gEditor.getCaretPosition().line + 1, line,
|
||||
"The editor caret position is not situated on the proper line.");
|
||||
is(gEditor.getCaretPosition().col, 0,
|
||||
"The editor caret position is not situated on the proper column.");
|
||||
}
|
||||
}
|
||||
|
||||
let bogusClient = {
|
||||
location: {
|
||||
url: null,
|
||||
line: null
|
||||
}
|
||||
};
|
||||
|
||||
function waitForBreakpoint(expected, callback) {
|
||||
// Poll every few milliseconds until expected breakpoint is hit.
|
||||
let count = 0;
|
||||
let intervalID = window.setInterval(function() {
|
||||
info("count: " + count + " ");
|
||||
if (++count > 50) {
|
||||
ok(false, "Timed out while polling for the breakpoint.");
|
||||
window.clearInterval(intervalID);
|
||||
return closeDebuggerAndFinish();
|
||||
}
|
||||
if ((gSources.selectedBreakpointClient !== expected) &&
|
||||
(gSources.selectedBreakpointClient || bogusClient).location.line !== expected) {
|
||||
return;
|
||||
}
|
||||
// We arrived at the expected line, it's safe to callback.
|
||||
window.clearInterval(intervalID);
|
||||
callback();
|
||||
}, 100);
|
||||
}
|
||||
|
||||
function waitForCaretPos(number, callback)
|
||||
{
|
||||
// Poll every few milliseconds until the source editor line is active.
|
||||
let count = 0;
|
||||
let intervalID = window.setInterval(function() {
|
||||
info("count: " + count + " ");
|
||||
if (++count > 50) {
|
||||
ok(false, "Timed out while polling for the line.");
|
||||
window.clearInterval(intervalID);
|
||||
return closeDebuggerAndFinish();
|
||||
}
|
||||
if (gEditor.getCaretPosition().line != number) {
|
||||
return;
|
||||
}
|
||||
// We got the source editor at the expected line, it's safe to callback.
|
||||
window.clearInterval(intervalID);
|
||||
callback();
|
||||
}, 100);
|
||||
}
|
||||
|
||||
function waitForPopup(state, callback)
|
||||
{
|
||||
// Poll every few milliseconds until the expression popup is shown.
|
||||
let count = 0;
|
||||
let intervalID = window.setInterval(function() {
|
||||
info("count: " + count + " ");
|
||||
if (++count > 50) {
|
||||
ok(false, "Timed out while polling for the popup.");
|
||||
window.clearInterval(intervalID);
|
||||
return closeDebuggerAndFinish();
|
||||
}
|
||||
if (gSources._conditionalPopupVisible != state) {
|
||||
return;
|
||||
}
|
||||
// We got the expression popup at the expected state, it's safe to callback.
|
||||
window.clearInterval(intervalID);
|
||||
callback();
|
||||
}, 100);
|
||||
}
|
||||
|
||||
function clear() {
|
||||
gSources._cbTextbox.focus();
|
||||
gSources._cbTextbox.value = "";
|
||||
}
|
||||
|
||||
function write(text) {
|
||||
clear();
|
||||
append(text);
|
||||
}
|
||||
|
||||
function append(text) {
|
||||
gSources._cbTextbox.focus();
|
||||
|
||||
for (let i = 0; i < text.length; i++) {
|
||||
EventUtils.sendChar(text[i], gDebugger);
|
||||
}
|
||||
}
|
||||
|
||||
registerCleanupFunction(function() {
|
||||
removeTab(gTab);
|
||||
gPane = null;
|
||||
gTab = null;
|
||||
gDebuggee = null;
|
||||
gDebugger = null;
|
||||
gEditor = null;
|
||||
gSources = null;
|
||||
gBreakpoints = null;
|
||||
});
|
||||
}
|
@ -0,0 +1,218 @@
|
||||
/* Any copyright is dedicated to the Public Domain.
|
||||
http://creativecommons.org/publicdomain/zero/1.0/ */
|
||||
|
||||
/**
|
||||
* Bug 740825: Test the debugger conditional breakpoints.
|
||||
*/
|
||||
|
||||
const TAB_URL = EXAMPLE_URL + "doc_conditional-breakpoints.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, ".html", 17)
|
||||
.then(() => addBreakpoints())
|
||||
.then(() => initialChecks())
|
||||
.then(() => resumeAndTestBreakpoint(20))
|
||||
.then(() => resumeAndTestBreakpoint(21))
|
||||
.then(() => resumeAndTestBreakpoint(22))
|
||||
.then(() => resumeAndTestBreakpoint(23))
|
||||
.then(() => resumeAndTestBreakpoint(24))
|
||||
.then(() => resumeAndTestBreakpoint(25))
|
||||
.then(() => resumeAndTestBreakpoint(27))
|
||||
.then(() => resumeAndTestBreakpoint(28))
|
||||
.then(() => resumeAndTestBreakpoint(29))
|
||||
.then(() => resumeAndTestNoBreakpoint())
|
||||
.then(() => reloadActiveTab(gPanel, gDebugger.EVENTS.BREAKPOINT_SHOWN, 13))
|
||||
.then(() => ensureThreadClientState(gPanel, "resumed"))
|
||||
.then(() => testAfterReload())
|
||||
.then(() => closeDebuggerAndFinish(gPanel))
|
||||
.then(null, aError => {
|
||||
ok(false, "Got an error: " + aError.message + "\n" + aError.stack);
|
||||
});
|
||||
|
||||
gDebuggee.ermahgerd();
|
||||
});
|
||||
|
||||
function addBreakpoints() {
|
||||
return promise.resolve(null)
|
||||
.then(() => gPanel.addBreakpoint({ url: gSources.selectedValue, line: 18 }))
|
||||
.then(aClient => aClient.conditionalExpression = "undefined")
|
||||
.then(() => gPanel.addBreakpoint({ url: gSources.selectedValue, line: 19 }))
|
||||
.then(aClient => aClient.conditionalExpression = "null")
|
||||
.then(() => gPanel.addBreakpoint({ url: gSources.selectedValue, line: 20 }))
|
||||
.then(aClient => aClient.conditionalExpression = "42")
|
||||
.then(() => gPanel.addBreakpoint({ url: gSources.selectedValue, line: 21 }))
|
||||
.then(aClient => aClient.conditionalExpression = "true")
|
||||
.then(() => gPanel.addBreakpoint({ url: gSources.selectedValue, line: 22 }))
|
||||
.then(aClient => aClient.conditionalExpression = "'nasu'")
|
||||
.then(() => gPanel.addBreakpoint({ url: gSources.selectedValue, line: 23 }))
|
||||
.then(aClient => aClient.conditionalExpression = "/regexp/")
|
||||
.then(() => gPanel.addBreakpoint({ url: gSources.selectedValue, line: 24 }))
|
||||
.then(aClient => aClient.conditionalExpression = "({})")
|
||||
.then(() => gPanel.addBreakpoint({ url: gSources.selectedValue, line: 25 }))
|
||||
.then(aClient => aClient.conditionalExpression = "(function() {})")
|
||||
.then(() => gPanel.addBreakpoint({ url: gSources.selectedValue, line: 26 }))
|
||||
.then(aClient => aClient.conditionalExpression = "(function() { return false; })()")
|
||||
.then(() => gPanel.addBreakpoint({ url: gSources.selectedValue, line: 27 }))
|
||||
.then(aClient => aClient.conditionalExpression = "a")
|
||||
.then(() => gPanel.addBreakpoint({ url: gSources.selectedValue, line: 28 }))
|
||||
.then(aClient => aClient.conditionalExpression = "a !== undefined")
|
||||
.then(() => gPanel.addBreakpoint({ url: gSources.selectedValue, line: 29 }))
|
||||
.then(aClient => aClient.conditionalExpression = "a !== null")
|
||||
.then(() => gPanel.addBreakpoint({ url: gSources.selectedValue, line: 30 }))
|
||||
.then(aClient => aClient.conditionalExpression = "b")
|
||||
}
|
||||
|
||||
function initialChecks() {
|
||||
is(gDebugger.gThreadClient.state, "paused",
|
||||
"Should only be getting stack frames while paused.");
|
||||
is(gSources.itemCount, 1,
|
||||
"Found the expected number of sources.");
|
||||
is(gEditor.getText().indexOf("ermahgerd"), 253,
|
||||
"The correct source was loaded initially.");
|
||||
is(gSources.selectedValue, gSources.values[0],
|
||||
"The correct source is selected.");
|
||||
|
||||
is(gBreakpointsAdded.size, 13,
|
||||
"13 breakpoints currently added.");
|
||||
is(gBreakpointsRemoving.size, 0,
|
||||
"No breakpoints currently being removed.");
|
||||
is(gEditor.getBreakpoints().length, 13,
|
||||
"13 breakpoints currently shown in the editor.");
|
||||
|
||||
ok(!gBreakpoints._getAdded({ url: "foo", line: 3 }),
|
||||
"_getAdded('foo', 3) returns falsey.");
|
||||
ok(!gBreakpoints._getRemoving({ url: "bar", line: 3 }),
|
||||
"_getRemoving('bar', 3) returns falsey.");
|
||||
}
|
||||
|
||||
function resumeAndTestBreakpoint(aLine) {
|
||||
let finished = waitForCaretUpdated(gPanel, aLine).then(() => testBreakpoint(aLine));
|
||||
|
||||
EventUtils.sendMouseEvent({ type: "mousedown" },
|
||||
gDebugger.document.getElementById("resume"),
|
||||
gDebugger);
|
||||
|
||||
return finished;
|
||||
}
|
||||
|
||||
function resumeAndTestNoBreakpoint() {
|
||||
let finished = waitForDebuggerEvents(gPanel, gDebugger.EVENTS.AFTER_FRAMES_CLEARED).then(() => {
|
||||
is(gSources.itemCount, 1,
|
||||
"Found the expected number of sources.");
|
||||
is(gEditor.getText().indexOf("ermahgerd"), 253,
|
||||
"The correct source was loaded initially.");
|
||||
is(gSources.selectedValue, gSources.values[0],
|
||||
"The correct source is selected.");
|
||||
|
||||
ok(gSources.selectedItem,
|
||||
"There should be a selected source in the sources pane.")
|
||||
ok(!gSources._selectedBreakpointItem,
|
||||
"There should be no selected breakpoint in the sources pane.")
|
||||
is(gSources._conditionalPopupVisible, false,
|
||||
"The breakpoint conditional expression popup should not be shown.");
|
||||
|
||||
is(gDebugger.document.querySelectorAll(".dbg-stackframe").length, 0,
|
||||
"There should be no visible stackframes.");
|
||||
is(gDebugger.document.querySelectorAll(".dbg-breakpoint").length, 13,
|
||||
"There should be thirteen visible breakpoints.");
|
||||
});
|
||||
|
||||
gDebugger.gThreadClient.resume();
|
||||
|
||||
return finished;
|
||||
}
|
||||
|
||||
function testBreakpoint(aLine, aHighlightBreakpoint) {
|
||||
// Highlight the breakpoint only if required.
|
||||
if (aHighlightBreakpoint) {
|
||||
let finished = waitForCaretUpdated(gPanel, aLine).then(() => testBreakpoint(aLine));
|
||||
gSources.highlightBreakpoint({ url: gSources.selectedValue, line: aLine });
|
||||
return finished;
|
||||
}
|
||||
|
||||
let selectedUrl = gSources.selectedValue;
|
||||
let selectedBreakpoint = gSources._selectedBreakpointItem;
|
||||
|
||||
ok(selectedUrl,
|
||||
"There should be a selected item in the sources pane.");
|
||||
ok(selectedBreakpoint,
|
||||
"There should be a selected brekapoint in the sources pane.");
|
||||
|
||||
is(selectedBreakpoint.attachment.url, selectedUrl,
|
||||
"The breakpoint on line " + aLine + " wasn't added on the correct source.");
|
||||
is(selectedBreakpoint.attachment.line, aLine,
|
||||
"The breakpoint on line " + aLine + " wasn't found.");
|
||||
is(!!selectedBreakpoint.attachment.disabled, false,
|
||||
"The breakpoint on line " + aLine + " should be enabled.");
|
||||
is(!!selectedBreakpoint.attachment.openPopup, false,
|
||||
"The breakpoint on line " + aLine + " should not have opened a popup.");
|
||||
is(gSources._conditionalPopupVisible, false,
|
||||
"The breakpoint conditional expression popup should not have been shown.");
|
||||
|
||||
return gBreakpoints._getAdded(selectedBreakpoint.attachment).then(aBreakpointClient => {
|
||||
is(aBreakpointClient.location.url, selectedUrl,
|
||||
"The breakpoint's client url is correct");
|
||||
is(aBreakpointClient.location.line, aLine,
|
||||
"The breakpoint's client line is correct");
|
||||
isnot(aBreakpointClient.conditionalExpression, undefined,
|
||||
"The breakpoint on line " + aLine + " should have a conditional expression.");
|
||||
|
||||
ok(isCaretPos(gPanel, aLine),
|
||||
"The editor caret position is not properly set.");
|
||||
});
|
||||
}
|
||||
|
||||
function testAfterReload() {
|
||||
let selectedUrl = gSources.selectedValue;
|
||||
let selectedBreakpoint = gSources._selectedBreakpointItem;
|
||||
|
||||
ok(selectedUrl,
|
||||
"There should be a selected item in the sources pane after reload.");
|
||||
ok(!selectedBreakpoint,
|
||||
"There should be no selected brekapoint in the sources pane after reload.");
|
||||
|
||||
return promise.resolve(null)
|
||||
.then(() => testBreakpoint(18, true))
|
||||
.then(() => testBreakpoint(19, true))
|
||||
.then(() => testBreakpoint(20, true))
|
||||
.then(() => testBreakpoint(21, true))
|
||||
.then(() => testBreakpoint(22, true))
|
||||
.then(() => testBreakpoint(23, true))
|
||||
.then(() => testBreakpoint(24, true))
|
||||
.then(() => testBreakpoint(25, true))
|
||||
.then(() => testBreakpoint(26, true))
|
||||
.then(() => testBreakpoint(27, true))
|
||||
.then(() => testBreakpoint(28, true))
|
||||
.then(() => testBreakpoint(29, true))
|
||||
.then(() => testBreakpoint(30, true))
|
||||
.then(() => {
|
||||
is(gSources.itemCount, 1,
|
||||
"Found the expected number of sources.");
|
||||
is(gEditor.getText().indexOf("ermahgerd"), 253,
|
||||
"The correct source was loaded again.");
|
||||
is(gSources.selectedValue, gSources.values[0],
|
||||
"The correct source is selected.");
|
||||
|
||||
ok(gSources.selectedItem,
|
||||
"There should be a selected source in the sources pane.")
|
||||
ok(gSources._selectedBreakpointItem,
|
||||
"There should be a selected breakpoint in the sources pane.")
|
||||
is(gSources._conditionalPopupVisible, false,
|
||||
"The breakpoint conditional expression popup should not be shown.");
|
||||
});
|
||||
}
|
||||
}
|
@ -0,0 +1,196 @@
|
||||
/* Any copyright is dedicated to the Public Domain.
|
||||
http://creativecommons.org/publicdomain/zero/1.0/ */
|
||||
|
||||
/**
|
||||
* Bug 740825: Test the debugger conditional breakpoints.
|
||||
*/
|
||||
|
||||
const TAB_URL = EXAMPLE_URL + "doc_conditional-breakpoints.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, ".html", 17)
|
||||
.then(() => initialChecks())
|
||||
.then(() => addBreakpoint1())
|
||||
.then(() => testBreakpoint(18, false, false, undefined))
|
||||
.then(() => addBreakpoint2())
|
||||
.then(() => testBreakpoint(19, false, false, undefined))
|
||||
.then(() => modBreakpoint2())
|
||||
.then(() => testBreakpoint(19, false, true, undefined))
|
||||
.then(() => addBreakpoint3())
|
||||
.then(() => testBreakpoint(20, true, false, undefined))
|
||||
.then(() => modBreakpoint3())
|
||||
.then(() => testBreakpoint(20, true, false, "bamboocha"))
|
||||
.then(() => addBreakpoint4())
|
||||
.then(() => testBreakpoint(21, false, false, undefined))
|
||||
.then(() => delBreakpoint4())
|
||||
.then(() => setCaretPosition(18))
|
||||
.then(() => testBreakpoint(18, false, false, undefined))
|
||||
.then(() => setCaretPosition(19))
|
||||
.then(() => testBreakpoint(19, false, false, undefined))
|
||||
.then(() => setCaretPosition(20))
|
||||
.then(() => testBreakpoint(20, true, false, "bamboocha"))
|
||||
.then(() => setCaretPosition(17))
|
||||
.then(() => testNoBreakpoint(17))
|
||||
.then(() => setCaretPosition(21))
|
||||
.then(() => testNoBreakpoint(21))
|
||||
.then(() => clickOnBreakpoint(0))
|
||||
.then(() => testBreakpoint(18, false, false, undefined))
|
||||
.then(() => clickOnBreakpoint(1))
|
||||
.then(() => testBreakpoint(19, false, false, undefined))
|
||||
.then(() => clickOnBreakpoint(2))
|
||||
.then(() => testBreakpoint(20, true, true, "bamboocha"))
|
||||
.then(() => resumeDebuggerThenCloseAndFinish(gPanel))
|
||||
.then(null, aError => {
|
||||
ok(false, "Got an error: " + aError.message + "\n" + aError.stack);
|
||||
});
|
||||
|
||||
gDebuggee.ermahgerd();
|
||||
});
|
||||
|
||||
function initialChecks() {
|
||||
is(gDebugger.gThreadClient.state, "paused",
|
||||
"Should only be getting stack frames while paused.");
|
||||
is(gSources.itemCount, 1,
|
||||
"Found the expected number of sources.");
|
||||
is(gEditor.getText().indexOf("ermahgerd"), 253,
|
||||
"The correct source was loaded initially.");
|
||||
is(gSources.selectedValue, gSources.values[0],
|
||||
"The correct source is selected.");
|
||||
|
||||
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.");
|
||||
|
||||
ok(!gBreakpoints._getAdded({ url: "foo", line: 3 }),
|
||||
"_getAdded('foo', 3) returns falsey.");
|
||||
ok(!gBreakpoints._getRemoving({ url: "bar", line: 3 }),
|
||||
"_getRemoving('bar', 3) returns falsey.");
|
||||
}
|
||||
|
||||
function addBreakpoint1() {
|
||||
let finished = waitForDebuggerEvents(gPanel, gDebugger.EVENTS.BREAKPOINT_ADDED);
|
||||
gPanel.addBreakpoint({ url: gSources.selectedValue, line: 18 });
|
||||
return finished;
|
||||
}
|
||||
|
||||
function addBreakpoint2() {
|
||||
let finished = waitForDebuggerEvents(gPanel, gDebugger.EVENTS.BREAKPOINT_ADDED);
|
||||
setContextPosition(19);
|
||||
gSources._onCmdAddBreakpoint();
|
||||
return finished;
|
||||
}
|
||||
|
||||
function modBreakpoint2() {
|
||||
let finished = waitForDebuggerEvents(gPanel, gDebugger.EVENTS.CONDITIONAL_BREAKPOINT_POPUP_SHOWING);
|
||||
setContextPosition(19);
|
||||
gSources._onCmdAddConditionalBreakpoint();
|
||||
return finished;
|
||||
}
|
||||
|
||||
function addBreakpoint3() {
|
||||
let finished = waitForDebuggerEvents(gPanel, gDebugger.EVENTS.BREAKPOINT_ADDED);
|
||||
setContextPosition(20);
|
||||
gSources._onCmdAddConditionalBreakpoint();
|
||||
return finished;
|
||||
}
|
||||
|
||||
function modBreakpoint3() {
|
||||
let finished = waitForDebuggerEvents(gPanel, gDebugger.EVENTS.CONDITIONAL_BREAKPOINT_POPUP_HIDING);
|
||||
typeText(gSources._cbTextbox, "bamboocha");
|
||||
EventUtils.sendKey("RETURN", gDebugger);
|
||||
return finished;
|
||||
}
|
||||
|
||||
function addBreakpoint4() {
|
||||
let finished = waitForDebuggerEvents(gPanel, gDebugger.EVENTS.BREAKPOINT_ADDED);
|
||||
setContextPosition(21);
|
||||
gSources._onCmdAddBreakpoint();
|
||||
return finished;
|
||||
}
|
||||
|
||||
function delBreakpoint4() {
|
||||
let finished = waitForDebuggerEvents(gPanel, gDebugger.EVENTS.BREAKPOINT_REMOVED);
|
||||
setContextPosition(21);
|
||||
gSources._onCmdAddBreakpoint();
|
||||
return finished;
|
||||
}
|
||||
|
||||
function testBreakpoint(aLine, aOpenPopupFlag, aPopupVisible, aConditionalExpression) {
|
||||
let selectedUrl = gSources.selectedValue;
|
||||
let selectedBreakpoint = gSources._selectedBreakpointItem;
|
||||
|
||||
ok(selectedUrl,
|
||||
"There should be a selected item in the sources pane.");
|
||||
ok(selectedBreakpoint,
|
||||
"There should be a selected brekapoint in the sources pane.");
|
||||
|
||||
is(selectedBreakpoint.attachment.url, selectedUrl,
|
||||
"The breakpoint on line " + aLine + " wasn't added on the correct source.");
|
||||
is(selectedBreakpoint.attachment.line, aLine,
|
||||
"The breakpoint on line " + aLine + " wasn't found.");
|
||||
is(!!selectedBreakpoint.attachment.disabled, false,
|
||||
"The breakpoint on line " + aLine + " should be enabled.");
|
||||
is(!!selectedBreakpoint.attachment.openPopup, aOpenPopupFlag,
|
||||
"The breakpoint on line " + aLine + " should have a correct popup state (1).");
|
||||
is(gSources._conditionalPopupVisible, aPopupVisible,
|
||||
"The breakpoint on line " + aLine + " should have a correct popup state (2).");
|
||||
|
||||
return gBreakpoints._getAdded(selectedBreakpoint.attachment).then(aBreakpointClient => {
|
||||
is(aBreakpointClient.location.url, selectedUrl,
|
||||
"The breakpoint's client url is correct");
|
||||
is(aBreakpointClient.location.line, aLine,
|
||||
"The breakpoint's client line is correct");
|
||||
is(aBreakpointClient.conditionalExpression, aConditionalExpression,
|
||||
"The breakpoint on line " + aLine + " should have a correct conditional expression.");
|
||||
is("conditionalExpression" in aBreakpointClient, !!aConditionalExpression,
|
||||
"The breakpoint on line " + aLine + " should have a correct conditional state.");
|
||||
|
||||
ok(isCaretPos(gPanel, aLine),
|
||||
"The editor caret position is not properly set.");
|
||||
});
|
||||
}
|
||||
|
||||
function testNoBreakpoint(aLine) {
|
||||
let selectedUrl = gSources.selectedValue;
|
||||
let selectedBreakpoint = gSources._selectedBreakpointItem;
|
||||
|
||||
ok(selectedUrl,
|
||||
"There should be a selected item in the sources pane for line " + aLine + ".");
|
||||
ok(!selectedBreakpoint,
|
||||
"There should be no selected brekapoint in the sources pane for line " + aLine + ".");
|
||||
|
||||
ok(isCaretPos(gPanel, aLine),
|
||||
"The editor caret position is not properly set.");
|
||||
}
|
||||
|
||||
function setCaretPosition(aLine) {
|
||||
gEditor.setCaretPosition(aLine - 1);
|
||||
}
|
||||
|
||||
function setContextPosition(aLine) {
|
||||
gSources._editorContextMenuLineNumber = aLine - 1;
|
||||
}
|
||||
|
||||
function clickOnBreakpoint(aIndex) {
|
||||
EventUtils.sendMouseEvent({ type: "click" },
|
||||
gDebugger.document.querySelectorAll(".dbg-breakpoint")[aIndex],
|
||||
gDebugger);
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user