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

91 lines
2.5 KiB
JavaScript

/* 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;
});