1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/browser/devtools/debugger/test/browser_dbg_breakpoints-disabled-reload.js Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,115 @@ 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 that disabled breakpoints survive target navigation. 1.9 + */ 1.10 + 1.11 +const TAB_URL = EXAMPLE_URL + "doc_script-switching-01.html"; 1.12 + 1.13 +function test() { 1.14 + initDebugger(TAB_URL).then(([aTab, aDebuggee, aPanel]) => { 1.15 + let gDebugger = aPanel.panelWin; 1.16 + let gEvents = gDebugger.EVENTS; 1.17 + let gEditor = gDebugger.DebuggerView.editor; 1.18 + let gSources = gDebugger.DebuggerView.Sources; 1.19 + let gBreakpoints = gDebugger.DebuggerController.Breakpoints; 1.20 + let gBreakpointLocation = { url: EXAMPLE_URL + "code_script-switching-01.js", line: 5 }; 1.21 + 1.22 + Task.spawn(function() { 1.23 + yield waitForSourceShown(aPanel, "-01.js"); 1.24 + yield aPanel.addBreakpoint(gBreakpointLocation); 1.25 + 1.26 + yield ensureThreadClientState(aPanel, "resumed"); 1.27 + yield testWhenBreakpointEnabledAndFirstSourceShown(); 1.28 + 1.29 + yield reloadActiveTab(aPanel, gEvents.SOURCE_SHOWN); 1.30 + yield testWhenBreakpointEnabledAndSecondSourceShown(); 1.31 + 1.32 + yield gSources.disableBreakpoint(gBreakpointLocation); 1.33 + yield reloadActiveTab(aPanel, gEvents.SOURCE_SHOWN); 1.34 + yield testWhenBreakpointDisabledAndSecondSourceShown(); 1.35 + 1.36 + yield gSources.enableBreakpoint(gBreakpointLocation); 1.37 + yield reloadActiveTab(aPanel, gEvents.SOURCE_SHOWN); 1.38 + yield testWhenBreakpointEnabledAndSecondSourceShown(); 1.39 + 1.40 + yield resumeDebuggerThenCloseAndFinish(aPanel); 1.41 + }); 1.42 + 1.43 + function verifyView({ disabled, visible }) { 1.44 + return Task.spawn(function() { 1.45 + // It takes a tick for the checkbox in the SideMenuWidget and the 1.46 + // gutter in the editor to get updated. 1.47 + yield waitForTick(); 1.48 + 1.49 + let breakpointItem = gSources.getBreakpoint(gBreakpointLocation); 1.50 + let visibleBreakpoints = gEditor.getBreakpoints(); 1.51 + is(!!breakpointItem.attachment.disabled, disabled, 1.52 + "The selected brekapoint state was correct."); 1.53 + is(breakpointItem.attachment.view.checkbox.hasAttribute("checked"), !disabled, 1.54 + "The selected brekapoint's checkbox state was correct."); 1.55 + 1.56 + // Source editor starts counting line and column numbers from 0. 1.57 + let breakpointLine = breakpointItem.attachment.line - 1; 1.58 + let matchedBreakpoints = visibleBreakpoints.filter(e => e.line == breakpointLine); 1.59 + is(!!matchedBreakpoints.length, visible, 1.60 + "The selected breakpoint's visibility in the editor was correct."); 1.61 + }); 1.62 + } 1.63 + 1.64 + // All the following executeSoon()'s are required to spin the event loop 1.65 + // before causing the debuggee to pause, to allow functions to yield first. 1.66 + 1.67 + function testWhenBreakpointEnabledAndFirstSourceShown() { 1.68 + return Task.spawn(function() { 1.69 + yield ensureSourceIs(aPanel, "-01.js"); 1.70 + yield verifyView({ disabled: false, visible: true }); 1.71 + 1.72 + executeSoon(() => aDebuggee.firstCall()); 1.73 + yield waitForDebuggerEvents(aPanel, gEvents.FETCHED_SCOPES); 1.74 + yield ensureSourceIs(aPanel, "-01.js"); 1.75 + yield ensureCaretAt(aPanel, 5); 1.76 + yield verifyView({ disabled: false, visible: true }); 1.77 + 1.78 + executeSoon(() => gDebugger.gThreadClient.resume()); 1.79 + yield waitForSourceAndCaretAndScopes(aPanel, "-02.js", 1); 1.80 + yield verifyView({ disabled: false, visible: false }); 1.81 + }); 1.82 + } 1.83 + 1.84 + function testWhenBreakpointEnabledAndSecondSourceShown() { 1.85 + return Task.spawn(function() { 1.86 + yield ensureSourceIs(aPanel, "-02.js", true); 1.87 + yield verifyView({ disabled: false, visible: false }); 1.88 + 1.89 + executeSoon(() => aDebuggee.firstCall()); 1.90 + yield waitForSourceAndCaretAndScopes(aPanel, "-01.js", 1); 1.91 + yield verifyView({ disabled: false, visible: true }); 1.92 + 1.93 + executeSoon(() => gDebugger.gThreadClient.resume()); 1.94 + yield waitForSourceAndCaretAndScopes(aPanel, "-02.js", 1); 1.95 + yield verifyView({ disabled: false, visible: false }); 1.96 + }); 1.97 + } 1.98 + 1.99 + function testWhenBreakpointDisabledAndSecondSourceShown() { 1.100 + return Task.spawn(function() { 1.101 + yield ensureSourceIs(aPanel, "-02.js", true); 1.102 + yield verifyView({ disabled: true, visible: false }); 1.103 + 1.104 + executeSoon(() => aDebuggee.firstCall()); 1.105 + yield waitForDebuggerEvents(aPanel, gEvents.FETCHED_SCOPES); 1.106 + yield ensureSourceIs(aPanel, "-02.js"); 1.107 + yield ensureCaretAt(aPanel, 1); 1.108 + yield verifyView({ disabled: true, visible: false }); 1.109 + 1.110 + executeSoon(() => gDebugger.gThreadClient.resume()); 1.111 + yield waitForDebuggerEvents(aPanel, gEvents.AFTER_FRAMES_CLEARED); 1.112 + yield ensureSourceIs(aPanel, "-02.js"); 1.113 + yield ensureCaretAt(aPanel, 1); 1.114 + yield verifyView({ disabled: true, visible: false }); 1.115 + }); 1.116 + } 1.117 + }); 1.118 +}