Wed, 31 Dec 2014 06:09:35 +0100
Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.
1 /* Any copyright is dedicated to the Public Domain.
2 http://creativecommons.org/publicdomain/zero/1.0/ */
4 /**
5 * Test if the breakpoints toggle button works as advertised when there are
6 * some breakpoints already disabled.
7 */
9 const TAB_URL = EXAMPLE_URL + "doc_script-switching-01.html";
11 function test() {
12 let gTab, gDebuggee, gPanel, gDebugger;
13 let gSources, gBreakpoints;
15 initDebugger(TAB_URL).then(([aTab, aDebuggee, aPanel]) => {
16 gTab = aTab;
17 gDebuggee = aDebuggee;
18 gPanel = aPanel;
19 gDebugger = gPanel.panelWin;
20 gSources = gDebugger.DebuggerView.Sources;
21 gBreakpoints = gDebugger.DebuggerController.Breakpoints;
23 waitForSourceShown(gPanel, "-01.js")
24 .then(addBreakpoints)
25 .then(disableSomeBreakpoints)
26 .then(testToggleBreakpoints)
27 .then(testEnableBreakpoints)
28 .then(() => ensureThreadClientState(gPanel, "resumed"))
29 .then(() => closeDebuggerAndFinish(gPanel))
30 .then(null, aError => {
31 ok(false, "Got an error: " + aError.message + "\n" + aError.stack);
32 });
33 });
35 function addBreakpoints() {
36 return promise.resolve(null)
37 .then(() => gPanel.addBreakpoint({ url: gSources.values[0], line: 5 }))
38 .then(() => gPanel.addBreakpoint({ url: gSources.values[1], line: 6 }))
39 .then(() => gPanel.addBreakpoint({ url: gSources.values[1], line: 7 }))
40 .then(() => ensureThreadClientState(gPanel, "resumed"));
41 }
43 function disableSomeBreakpoints() {
44 return promise.all([
45 gSources.disableBreakpoint({ url: gSources.values[0], line: 5 }),
46 gSources.disableBreakpoint({ url: gSources.values[1], line: 6 })
47 ]);
48 }
50 function testToggleBreakpoints() {
51 let finished = waitForDebuggerEvents(gPanel, gDebugger.EVENTS.BREAKPOINT_REMOVED, 1);
52 gSources.toggleBreakpoints();
53 return finished.then(() => checkBreakpointsDisabled(true));
54 }
56 function testEnableBreakpoints() {
57 let finished = waitForDebuggerEvents(gPanel, gDebugger.EVENTS.BREAKPOINT_ADDED, 3);
58 gSources.toggleBreakpoints();
59 return finished.then(() => checkBreakpointsDisabled(false));
60 }
62 function checkBreakpointsDisabled(aState, aTotal = 3) {
63 let breakpoints = gSources.getAllBreakpoints();
65 is(breakpoints.length, aTotal,
66 "Breakpoints should still be set.");
67 is(breakpoints.filter(e => e.attachment.disabled == aState).length, aTotal,
68 "Breakpoints should be " + (aState ? "disabled" : "enabled") + ".");
69 }
70 }