browser_dbg-state-based-panels.js (5332B)
1 /* This Source Code Form is subject to the terms of the Mozilla Public 2 * License, v. 2.0. If a copy of the MPL was not distributed with this 3 * file, You can obtain one at <http://mozilla.org/MPL/2.0/>. */ 4 5 "use strict"; 6 7 // Tests that breakpoint panels open when their relevant breakpoint is hit 8 add_task(async function testBreakpointsPaneOpenOnPause() { 9 const dbg = await initDebugger("doc-sources.html", "simple1.js"); 10 11 clickElementWithSelector(dbg, ".breakpoints-pane h2"); 12 13 info("Confirm the breakpoints pane is closed"); 14 is(getPaneElements(dbg).length, 1); 15 16 await selectSource(dbg, "simple1.js"); 17 await addBreakpoint(dbg, "simple1.js", 4); 18 19 info("Trigger the breakpoint ane ensure we're paused"); 20 invokeInTab("main"); 21 await waitForPaused(dbg, "simple1.js"); 22 23 info("Confirm the breakpoints pane is open"); 24 is(getPaneElements(dbg).length, 2); 25 26 await resume(dbg); 27 28 info("Confirm the breakpoints pane is closed again"); 29 is(getPaneElements(dbg).length, 1); 30 }); 31 32 // Tests that the breakpoint pane remains closed on stepping 33 add_task(async function testBreakpointsPanePersistOnStepping() { 34 const dbg = await initDebugger("doc-scripts.html", "simple3.js"); 35 36 await selectSource(dbg, "simple3.js"); 37 await addBreakpoint(dbg, "simple3.js", 9); 38 await waitForBreakpoint(dbg, "simple3.js", 9); 39 40 invokeInTab("nestedA"); 41 await waitForPaused(dbg, "simple3.js"); 42 43 is(getPaneElements(dbg).length, 2, "Breakpoints pane is open"); 44 45 info("Close breakpoints pane"); 46 47 clickElementWithSelector(dbg, ".breakpoints-pane h2"); 48 49 is(getPaneElements(dbg).length, 1, "Breakpoint pane is closed"); 50 51 info("Step into nestedB"); 52 53 await stepIn(dbg); 54 55 const frameElements = findAllElements(dbg, "frames"); 56 assertFrameIsSelected(dbg, frameElements[0], "nestedB"); 57 58 is(getPaneElements(dbg).length, 1, "Breakpoints pane is still closed"); 59 }); 60 61 // Tests that the breakpoint pane remains closed on call-stack frame selection 62 add_task(async function testBreakpointsPanePersistOnFrameSelection() { 63 const dbg = await initDebugger("doc-scripts.html", "simple3.js"); 64 65 info("Close breakpoints pane"); 66 67 clickElementWithSelector(dbg, ".breakpoints-pane h2"); 68 69 is(getPaneElements(dbg).length, 1, "Breakpoint pane is closed"); 70 71 await selectSource(dbg, "simple3.js"); 72 await addBreakpoint(dbg, "simple3.js", 13); 73 await waitForBreakpoint(dbg, "simple3.js", 13); 74 75 invokeInTab("nestedA"); 76 await waitForPaused(dbg, "simple3.js"); 77 78 is(getPaneElements(dbg).length, 2, "Breakpoints pane is open"); 79 80 info("Close breakpoints pane"); 81 82 clickElementWithSelector(dbg, ".breakpoints-pane h2"); 83 84 is(getPaneElements(dbg).length, 1, "Breakpoint pane is closed"); 85 86 is(getFrameList(dbg).length, 2, "Call stack has two frames"); 87 88 info("Click on second call stack frame"); 89 90 await clickElement(dbg, "frame", 2); 91 92 const frameElements = findAllElements(dbg, "frames"); 93 assertFrameIsSelected(dbg, frameElements[1], "nestedA"); 94 95 is(getPaneElements(dbg).length, 1, "Breakpoint pane is still closed"); 96 }); 97 98 // Tests that the breakpoint pane persists when toggled during pause 99 add_task(async function testBreakpointsPanePersistOnPauseToggle() { 100 const dbg = await initDebugger("doc-scripts.html", "simple3.js"); 101 102 await selectSource(dbg, "simple3.js"); 103 await addBreakpoint(dbg, "simple3.js", 9); 104 await waitForBreakpoint(dbg, "simple3.js", 9); 105 106 info("Close breakpoint pane"); 107 108 clickElementWithSelector(dbg, ".breakpoints-pane h2"); 109 110 is(getPaneElements(dbg).length, 1, "Breakpoint pane is closed"); 111 112 info("Trigger breakpoint"); 113 114 invokeInTab("nestedA"); 115 await waitForPaused(dbg, "simple3.js"); 116 117 is(getPaneElements(dbg).length, 2, "Breakpoints pane is open"); 118 119 info("Close breakpoint pane and reopen it"); 120 121 clickElementWithSelector(dbg, ".breakpoints-pane h2"); 122 123 is(getPaneElements(dbg).length, 1, "Breakpoints pane is closed"); 124 125 clickElementWithSelector(dbg, ".breakpoints-pane h2"); 126 127 is(getPaneElements(dbg).length, 2, "Breakpoints pane is open"); 128 129 await resume(dbg); 130 131 // After resuming from the breakpoint, the debugger statement will be hit. 132 await waitForPaused(dbg, "simple3.js"); 133 await resume(dbg); 134 135 is(getPaneElements(dbg).length, 2, "Breakpoints pane is still open"); 136 }); 137 138 // Tests that the breakpoint pane remains closed when event breakpoints log is toggled 139 add_task(async function testBreakpointsPaneRemainsClosedWhenLogToggled() { 140 const dbg = await initDebugger("doc-scripts.html", "simple3.js"); 141 142 await selectSource(dbg, "simple3.js"); 143 await addBreakpoint(dbg, "simple3.js", 9); 144 await waitForBreakpoint(dbg, "simple3.js", 9); 145 146 info("Trigger breakpoint"); 147 148 invokeInTab("nestedA"); 149 await waitForPaused(dbg, "simple3.js"); 150 151 info("Close breakpoint pane"); 152 153 clickElementWithSelector(dbg, ".breakpoints-pane h2"); 154 155 is(getPaneElements(dbg).length, 1, "Breakpoint pane is closed"); 156 157 info("Check event listener breakpoints log box"); 158 const wait = waitForDispatch(dbg.store, "TOGGLE_EVENT_LISTENERS"); 159 await clickElement(dbg, "logEventsCheckbox"); 160 await wait; 161 162 is(getPaneElements(dbg).length, 1, "Breakpoint pane is still closed"); 163 }); 164 165 function getPaneElements(dbg) { 166 return findElementWithSelector(dbg, ".breakpoints-pane").childNodes; 167 } 168 169 function getFrameList(dbg) { 170 return dbg.win.document.querySelectorAll(".call-stack-pane .frame"); 171 }