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

Wed, 31 Dec 2014 06:09:35 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 06:09:35 +0100
changeset 0
6474c204b198
permissions
-rw-r--r--

Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.

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

mercurial