browser_dbg-breakpoints-cond-shortcut.js (4866B)
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 // Test opening conditional panel using keyboard shortcut. 6 // Should access the closest breakpoint to a passed in cursorPosition. 7 8 "use strict"; 9 10 add_task(async function () { 11 const dbg = await initDebugger("doc-scripts.html", "long.js"); 12 13 await selectSource(dbg, "long.js"); 14 await waitForSelectedSource(dbg, "long.js"); 15 // Wait a bit for CM6 to complete any updates so the conditional panel 16 // does not lose focus after the it has been opened 17 await waitForDocumentLoadComplete(dbg); 18 info( 19 "toggle conditional panel with shortcut: no breakpoints, default cursorPosition" 20 ); 21 pressKey(dbg, "toggleCondPanel"); 22 await waitForConditionalPanelFocus(dbg); 23 24 ok( 25 !!(await getConditionalPanelAtLine(dbg, 1)), 26 "conditional panel panel is open on line 1" 27 ); 28 is( 29 dbg.selectors.getConditionalPanelLocation().line, 30 1, 31 "conditional panel location is line 1" 32 ); 33 info("close conditional panel"); 34 pressKey(dbg, "Escape"); 35 36 info( 37 "toggle conditional panel with shortcut: cursor on line 32, no breakpoints" 38 ); 39 await selectSource(dbg, "long.js", 32, 2); 40 pressKey(dbg, "toggleCondPanel"); 41 42 await waitForConditionalPanelFocus(dbg); 43 ok( 44 !!(await getConditionalPanelAtLine(dbg, 32)), 45 "conditional panel is open on line 32" 46 ); 47 is( 48 dbg.selectors.getConditionalPanelLocation().line, 49 32, 50 "conditional panel location is line 32" 51 ); 52 info("close conditional panel"); 53 pressKey(dbg, "Escape"); 54 55 info("add active column breakpoint on line 32 and set cursorPosition"); 56 await selectSource(dbg, "long.js", 32, 2); 57 await enableFirstColumnBreakpoint(dbg); 58 info( 59 "toggle conditional panel with shortcut and add condition to first breakpoint" 60 ); 61 await setConditionalBreakpointWithKeyboardShortcut(dbg, "1"); 62 await waitForCondition(dbg, 1); 63 const firstBreakpoint = findColumnBreakpoint(dbg, "long.js", 32, 2); 64 is( 65 firstBreakpoint.options.condition, 66 "1", 67 "first breakpoint created with condition using shortcut" 68 ); 69 70 info("set cursor at second breakpoint position and activate breakpoint"); 71 await selectSource(dbg, "long.js", 32, 26); 72 await enableSecondColumnBreakpoint(dbg); 73 info( 74 "toggle conditional panel with shortcut and add condition to second breakpoint" 75 ); 76 await setConditionalBreakpointWithKeyboardShortcut(dbg, "2"); 77 await waitForCondition(dbg, 2); 78 const secondBreakpoint = findColumnBreakpoint(dbg, "long.js", 32, 26); 79 is( 80 secondBreakpoint.options.condition, 81 "2", 82 "second breakpoint created with condition using shortcut" 83 ); 84 85 info( 86 "set cursor position near first breakpoint, toggle conditional panel and edit breakpoint" 87 ); 88 await selectSource(dbg, "long.js", 32, 8); 89 info("toggle conditional panel and edit condition using shortcut"); 90 await setConditionalBreakpointWithKeyboardShortcut(dbg, "2"); 91 ok( 92 !!waitForCondition(dbg, "12"), 93 "breakpoint closest to cursor position has been edited" 94 ); 95 96 info("close conditional panel"); 97 pressKey(dbg, "Escape"); 98 99 info( 100 "set cursor position near second breakpoint, toggle conditional panel and edit breakpoint" 101 ); 102 await selectSource(dbg, "long.js", 32, 22); 103 info("toggle conditional panel and edit condition using shortcut"); 104 await setConditionalBreakpointWithKeyboardShortcut(dbg, "3"); 105 ok( 106 !!waitForCondition(dbg, "13"), 107 "breakpoint closest to cursor position has been edited" 108 ); 109 110 info("close conditional panel"); 111 pressKey(dbg, "Escape"); 112 113 info("toggle log panel with shortcut: cursor on line 33"); 114 115 await selectSource(dbg, "long.js", 34, 2); 116 await setLogBreakpointWithKeyboardShortcut(dbg, "3"); 117 ok( 118 !!waitForLog(dbg, "3"), 119 "breakpoint closest to cursor position has been edited" 120 ); 121 122 info("close conditional panel"); 123 pressKey(dbg, "Escape"); 124 }); 125 126 // from browser_dbg-breakpoints-columns.js 127 async function enableFirstColumnBreakpoint(dbg) { 128 await addBreakpoint(dbg, "long.js", 32); 129 const bpMarkers = await waitForAllElements(dbg, "columnBreakpoints"); 130 131 Assert.strictEqual(bpMarkers.length, 2, "2 column breakpoints"); 132 assertClass(bpMarkers[0], "active"); 133 assertClass(bpMarkers[1], "active", false); 134 } 135 136 async function enableSecondColumnBreakpoint(dbg) { 137 let bpMarkers = await waitForAllElements(dbg, "columnBreakpoints"); 138 139 bpMarkers[1].click(); 140 await waitForBreakpointCount(dbg, 2); 141 142 bpMarkers = findAllElements(dbg, "columnBreakpoints"); 143 assertClass(bpMarkers[1], "active"); 144 await waitForAllElements(dbg, "breakpointItems", 2); 145 } 146 147 function setLogBreakpointWithKeyboardShortcut(dbg, condition) { 148 pressKey(dbg, "toggleLogPanel"); 149 return typeInPanel(dbg, condition, true); 150 }