1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/browser/devtools/debugger/test/browser_dbg_breakpoints-button-01.js Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,61 @@ 1.4 +/* Any copyright is dedicated to the Public Domain. 1.5 + http://creativecommons.org/publicdomain/zero/1.0/ */ 1.6 + 1.7 +/** 1.8 + * Test if the breakpoints toggle button works as advertised. 1.9 + */ 1.10 + 1.11 +const TAB_URL = EXAMPLE_URL + "doc_script-switching-01.html"; 1.12 + 1.13 +function test() { 1.14 + let gTab, gDebuggee, gPanel, gDebugger; 1.15 + let gSources, gBreakpoints; 1.16 + 1.17 + initDebugger(TAB_URL).then(([aTab, aDebuggee, aPanel]) => { 1.18 + gTab = aTab; 1.19 + gDebuggee = aDebuggee; 1.20 + gPanel = aPanel; 1.21 + gDebugger = gPanel.panelWin; 1.22 + gSources = gDebugger.DebuggerView.Sources; 1.23 + gBreakpoints = gDebugger.DebuggerController.Breakpoints; 1.24 + 1.25 + waitForSourceShown(gPanel, "-01.js") 1.26 + .then(addBreakpoints) 1.27 + .then(testDisableBreakpoints) 1.28 + .then(testEnableBreakpoints) 1.29 + .then(() => ensureThreadClientState(gPanel, "resumed")) 1.30 + .then(() => closeDebuggerAndFinish(gPanel)) 1.31 + .then(null, aError => { 1.32 + ok(false, "Got an error: " + aError.message + "\n" + aError.stack); 1.33 + }); 1.34 + }); 1.35 + 1.36 + function addBreakpoints() { 1.37 + return promise.resolve(null) 1.38 + .then(() => gPanel.addBreakpoint({ url: gSources.values[0], line: 5 })) 1.39 + .then(() => gPanel.addBreakpoint({ url: gSources.values[1], line: 6 })) 1.40 + .then(() => gPanel.addBreakpoint({ url: gSources.values[1], line: 7 })) 1.41 + .then(() => ensureThreadClientState(gPanel, "resumed")); 1.42 + } 1.43 + 1.44 + function testDisableBreakpoints() { 1.45 + let finished = waitForDebuggerEvents(gPanel, gDebugger.EVENTS.BREAKPOINT_REMOVED, 3); 1.46 + gSources.toggleBreakpoints(); 1.47 + return finished.then(() => checkBreakpointsDisabled(true)); 1.48 + } 1.49 + 1.50 + function testEnableBreakpoints() { 1.51 + let finished = waitForDebuggerEvents(gPanel, gDebugger.EVENTS.BREAKPOINT_ADDED, 3); 1.52 + gSources.toggleBreakpoints(); 1.53 + return finished.then(() => checkBreakpointsDisabled(false)); 1.54 + } 1.55 + 1.56 + function checkBreakpointsDisabled(aState, aTotal = 3) { 1.57 + let breakpoints = gSources.getAllBreakpoints(); 1.58 + 1.59 + is(breakpoints.length, aTotal, 1.60 + "Breakpoints should still be set."); 1.61 + is(breakpoints.filter(e => e.attachment.disabled == aState).length, aTotal, 1.62 + "Breakpoints should be " + (aState ? "disabled" : "enabled") + "."); 1.63 + } 1.64 +}