1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/browser/devtools/debugger/test/browser_dbg_breakpoints-button-02.js Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,70 @@ 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 when there are 1.9 + * some breakpoints already disabled. 1.10 + */ 1.11 + 1.12 +const TAB_URL = EXAMPLE_URL + "doc_script-switching-01.html"; 1.13 + 1.14 +function test() { 1.15 + let gTab, gDebuggee, gPanel, gDebugger; 1.16 + let gSources, gBreakpoints; 1.17 + 1.18 + initDebugger(TAB_URL).then(([aTab, aDebuggee, aPanel]) => { 1.19 + gTab = aTab; 1.20 + gDebuggee = aDebuggee; 1.21 + gPanel = aPanel; 1.22 + gDebugger = gPanel.panelWin; 1.23 + gSources = gDebugger.DebuggerView.Sources; 1.24 + gBreakpoints = gDebugger.DebuggerController.Breakpoints; 1.25 + 1.26 + waitForSourceShown(gPanel, "-01.js") 1.27 + .then(addBreakpoints) 1.28 + .then(disableSomeBreakpoints) 1.29 + .then(testToggleBreakpoints) 1.30 + .then(testEnableBreakpoints) 1.31 + .then(() => ensureThreadClientState(gPanel, "resumed")) 1.32 + .then(() => closeDebuggerAndFinish(gPanel)) 1.33 + .then(null, aError => { 1.34 + ok(false, "Got an error: " + aError.message + "\n" + aError.stack); 1.35 + }); 1.36 + }); 1.37 + 1.38 + function addBreakpoints() { 1.39 + return promise.resolve(null) 1.40 + .then(() => gPanel.addBreakpoint({ url: gSources.values[0], line: 5 })) 1.41 + .then(() => gPanel.addBreakpoint({ url: gSources.values[1], line: 6 })) 1.42 + .then(() => gPanel.addBreakpoint({ url: gSources.values[1], line: 7 })) 1.43 + .then(() => ensureThreadClientState(gPanel, "resumed")); 1.44 + } 1.45 + 1.46 + function disableSomeBreakpoints() { 1.47 + return promise.all([ 1.48 + gSources.disableBreakpoint({ url: gSources.values[0], line: 5 }), 1.49 + gSources.disableBreakpoint({ url: gSources.values[1], line: 6 }) 1.50 + ]); 1.51 + } 1.52 + 1.53 + function testToggleBreakpoints() { 1.54 + let finished = waitForDebuggerEvents(gPanel, gDebugger.EVENTS.BREAKPOINT_REMOVED, 1); 1.55 + gSources.toggleBreakpoints(); 1.56 + return finished.then(() => checkBreakpointsDisabled(true)); 1.57 + } 1.58 + 1.59 + function testEnableBreakpoints() { 1.60 + let finished = waitForDebuggerEvents(gPanel, gDebugger.EVENTS.BREAKPOINT_ADDED, 3); 1.61 + gSources.toggleBreakpoints(); 1.62 + return finished.then(() => checkBreakpointsDisabled(false)); 1.63 + } 1.64 + 1.65 + function checkBreakpointsDisabled(aState, aTotal = 3) { 1.66 + let breakpoints = gSources.getAllBreakpoints(); 1.67 + 1.68 + is(breakpoints.length, aTotal, 1.69 + "Breakpoints should still be set."); 1.70 + is(breakpoints.filter(e => e.attachment.disabled == aState).length, aTotal, 1.71 + "Breakpoints should be " + (aState ? "disabled" : "enabled") + "."); 1.72 + } 1.73 +}