browser/devtools/debugger/test/browser_dbg_breakpoints-button-01.js

branch
TOR_BUG_9701
changeset 15
b8a032363ba2
equal deleted inserted replaced
-1:000000000000 0:3b979a22976b
1 /* Any copyright is dedicated to the Public Domain.
2 http://creativecommons.org/publicdomain/zero/1.0/ */
3
4 /**
5 * Test if the breakpoints toggle button works as advertised.
6 */
7
8 const TAB_URL = EXAMPLE_URL + "doc_script-switching-01.html";
9
10 function test() {
11 let gTab, gDebuggee, gPanel, gDebugger;
12 let gSources, gBreakpoints;
13
14 initDebugger(TAB_URL).then(([aTab, aDebuggee, aPanel]) => {
15 gTab = aTab;
16 gDebuggee = aDebuggee;
17 gPanel = aPanel;
18 gDebugger = gPanel.panelWin;
19 gSources = gDebugger.DebuggerView.Sources;
20 gBreakpoints = gDebugger.DebuggerController.Breakpoints;
21
22 waitForSourceShown(gPanel, "-01.js")
23 .then(addBreakpoints)
24 .then(testDisableBreakpoints)
25 .then(testEnableBreakpoints)
26 .then(() => ensureThreadClientState(gPanel, "resumed"))
27 .then(() => closeDebuggerAndFinish(gPanel))
28 .then(null, aError => {
29 ok(false, "Got an error: " + aError.message + "\n" + aError.stack);
30 });
31 });
32
33 function addBreakpoints() {
34 return promise.resolve(null)
35 .then(() => gPanel.addBreakpoint({ url: gSources.values[0], line: 5 }))
36 .then(() => gPanel.addBreakpoint({ url: gSources.values[1], line: 6 }))
37 .then(() => gPanel.addBreakpoint({ url: gSources.values[1], line: 7 }))
38 .then(() => ensureThreadClientState(gPanel, "resumed"));
39 }
40
41 function testDisableBreakpoints() {
42 let finished = waitForDebuggerEvents(gPanel, gDebugger.EVENTS.BREAKPOINT_REMOVED, 3);
43 gSources.toggleBreakpoints();
44 return finished.then(() => checkBreakpointsDisabled(true));
45 }
46
47 function testEnableBreakpoints() {
48 let finished = waitForDebuggerEvents(gPanel, gDebugger.EVENTS.BREAKPOINT_ADDED, 3);
49 gSources.toggleBreakpoints();
50 return finished.then(() => checkBreakpointsDisabled(false));
51 }
52
53 function checkBreakpointsDisabled(aState, aTotal = 3) {
54 let breakpoints = gSources.getAllBreakpoints();
55
56 is(breakpoints.length, aTotal,
57 "Breakpoints should still be set.");
58 is(breakpoints.filter(e => e.attachment.disabled == aState).length, aTotal,
59 "Breakpoints should be " + (aState ? "disabled" : "enabled") + ".");
60 }
61 }

mercurial