browser_dbg-editor-gutter.js (4603B)
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 // Tests the breakpoint gutter and making sure breakpoint icons exist 6 // correctly 7 8 "use strict"; 9 10 // FIXME bug 1524374 removing breakpoints in this test can cause uncaught 11 // rejections and make bug 1512742 permafail. 12 PromiseTestUtils.allowMatchingRejectionsGlobally(/NS_ERROR_NOT_INITIALIZED/); 13 14 add_task(async function testGutterBreakpoints() { 15 const dbg = await initDebugger("doc-scripts.html", "simple1.js"); 16 const source = findSource(dbg, "simple1.js"); 17 18 await selectSource(dbg, source); 19 20 // Make sure that clicking the gutter creates a breakpoint icon. 21 await clickGutter(dbg, 4); 22 await waitForDispatch(dbg.store, "SET_BREAKPOINT"); 23 is(dbg.selectors.getBreakpointCount(), 1, "One breakpoint exists"); 24 await assertBreakpoint(dbg, 4); 25 26 // Make sure clicking at the same place removes the icon. 27 await clickGutter(dbg, 4); 28 await waitForDispatch(dbg.store, "REMOVE_BREAKPOINT"); 29 is(dbg.selectors.getBreakpointCount(), 0, "No breakpoints exist"); 30 await assertNoBreakpoint(dbg, 4); 31 }); 32 33 add_task(async function testGutterBreakpointsInIgnoredSource() { 34 await pushPref("devtools.debugger.map-scopes-enabled", true); 35 info( 36 "Ensure clicking on gutter to add breakpoint should not un-ignore source" 37 ); 38 const dbg = await initDebugger("doc-sourcemaps3.html"); 39 await waitForSources(dbg, "bundle.js", "sorted.js", "test.js"); 40 41 info("Ignore the source"); 42 await selectSource(dbg, findSource(dbg, "sorted.js")); 43 await clickElement(dbg, "blackbox"); 44 await waitForDispatch(dbg.store, "BLACKBOX_WHOLE_SOURCES"); 45 46 // invoke test 47 invokeInTab("test"); 48 49 // wait to make sure no pause has occured 50 await wait(1000); 51 assertNotPaused(dbg); 52 53 info("Ensure gutter breakpoint gets set with click"); 54 await clickGutter(dbg, 4); 55 await waitForDispatch(dbg.store, "SET_BREAKPOINT"); 56 57 info("Assert that the `Enable breakpoint` context menu item is disabled"); 58 const popup = await openContextMenuInDebugger(dbg, "gutterElement", 4); 59 await assertContextMenuItemDisabled( 60 dbg, 61 "#node-menu-enable-breakpoint", 62 true 63 ); 64 await closeContextMenu(dbg, popup); 65 66 is(dbg.selectors.getBreakpointCount(), 1, "One breakpoint exists"); 67 await assertBreakpoint(dbg, 4); 68 is( 69 findBreakpoint(dbg, "sorted.js", 4).disabled, 70 true, 71 "The breakpoint in the ignored source looks disabled" 72 ); 73 74 invokeInTab("test"); 75 76 await wait(1000); 77 assertNotPaused(dbg); 78 79 ok(true, "source is still blackboxed"); 80 }); 81 82 add_task(async function testGutterBreakpointsForSourceWithIgnoredLines() { 83 info( 84 "Asserts that adding a breakpoint to the gutter of an un-ignored line does not un-ignore other ranges in the source" 85 ); 86 const dbg = await initDebugger("doc-sourcemaps3.html"); 87 await waitForSources(dbg, "bundle.js", "sorted.js", "test.js"); 88 89 await selectSource(dbg, findSource(dbg, "sorted.js")); 90 91 info("Ignoring line 17 to 21 using the editor context menu"); 92 await selectEditorLinesAndOpenContextMenu(dbg, { 93 startLine: 17, 94 endLine: 21, 95 }); 96 await selectBlackBoxContextMenuItem(dbg, "blackbox-lines"); 97 98 info("Set breakpoint on an un-ignored line"); 99 await clickGutter(dbg, 4); 100 await waitForDispatch(dbg.store, "SET_BREAKPOINT"); 101 102 info("Assert that the `Disable breakpoint` context menu item is enabled"); 103 const popup = await openContextMenuInDebugger(dbg, "gutterElement", 4); 104 await assertContextMenuItemDisabled( 105 dbg, 106 "#node-menu-disable-breakpoint", 107 false 108 ); 109 await closeContextMenu(dbg, popup); 110 111 info("Assert that the lines 17 to 21 are still ignored"); 112 await assertIgnoredStyleInSourceLines(dbg, { 113 lines: [17, 21], 114 hasBlackboxedLinesClass: true, 115 }); 116 117 info( 118 "Asserts that adding a breakpoint to the gutter of an ignored line creates a disabled breakpoint" 119 ); 120 info("Set breakpoint on an ignored line"); 121 await clickGutter(dbg, 19); 122 await waitForDispatch(dbg.store, "SET_BREAKPOINT"); 123 124 info("Assert that the `Enable breakpoint` context menu item is disabled"); 125 const popup2 = await openContextMenuInDebugger(dbg, "gutterElement", 19); 126 await assertContextMenuItemDisabled( 127 dbg, 128 "#node-menu-enable-breakpoint", 129 true 130 ); 131 await closeContextMenu(dbg, popup2); 132 133 info("Assert that the breakpoint on the line 19 is visually disabled"); 134 is( 135 findBreakpoint(dbg, "sorted.js", 19).disabled, 136 true, 137 "The breakpoint on an ignored line is disabled" 138 ); 139 });