browser_dbg-features-breakpoints.js (4141B)
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 /** 8 * Assert that breakpoints and stepping works in various conditions 9 */ 10 11 const testServer = createVersionizedHttpTestServer( 12 "../examples/sourcemaps-reload-uncompressed" 13 ); 14 const TEST_URL = testServer.urlFor("index.html"); 15 16 add_task( 17 async function testSteppingFromOriginalToGeneratedAndAnotherOriginal() { 18 const dbg = await initDebuggerWithAbsoluteURL( 19 TEST_URL, 20 "index.html", 21 "script.js", 22 "original.js" 23 ); 24 25 await selectSource(dbg, "original.js"); 26 await addBreakpoint(dbg, "original.js", 8); 27 assertBreakpointSnippet(dbg, 1, "await nonSourceMappedFunction();"); 28 29 info("Test pausing on an original source"); 30 invokeInTab("foo"); 31 await waitForPausedInOriginalFileAndToggleMapScopes(dbg, "original.js"); 32 33 await assertPausedAtSourceAndLine( 34 dbg, 35 findSource(dbg, "original.js").id, 36 8 37 ); 38 39 info("Then stepping into a generated source"); 40 await stepIn(dbg); 41 await assertPausedAtSourceAndLine(dbg, findSource(dbg, "script.js").id, 5); 42 43 info("Stepping another time within the same generated source"); 44 await stepIn(dbg); 45 await assertPausedAtSourceAndLine(dbg, findSource(dbg, "script.js").id, 7); 46 47 info("And finally stepping into another original source"); 48 await stepIn(dbg); 49 await assertPausedAtSourceAndLine( 50 dbg, 51 findSource(dbg, "removed-original.js").id, 52 4 53 ); 54 55 info("Walk up the stack backward, until we resume execution"); 56 await stepIn(dbg); 57 await assertPausedAtSourceAndLine( 58 dbg, 59 findSource(dbg, "removed-original.js").id, 60 5 61 ); 62 63 await stepIn(dbg); 64 await assertPausedAtSourceAndLine(dbg, findSource(dbg, "script.js").id, 8); 65 66 await stepIn(dbg); 67 await assertPausedAtSourceAndLine( 68 dbg, 69 findSource(dbg, "original.js").id, 70 9 71 ); 72 73 await stepIn(dbg); 74 await assertPausedAtSourceAndLine( 75 dbg, 76 findSource(dbg, "original.js").id, 77 10 78 ); 79 80 // We can't use the `stepIn` helper as this last step will resume 81 // and the helper is expecting to pause again 82 await dbg.actions.stepIn(); 83 await assertNotPaused(dbg); 84 } 85 ); 86 87 /** 88 * Tests that the source tree works with all the various types of sources 89 * coming from the integration test page. 90 * 91 * Also assert a few extra things on sources with query strings: 92 * - they can be pretty printed, 93 * - quick open matches them, 94 * - you can set breakpoint on them. 95 */ 96 add_task(async function testSourceTreeOnTheIntegrationTestPage() { 97 const dbg = await initDebuggerWithAbsoluteURL("about:blank"); 98 99 await navigateToAbsoluteURL( 100 dbg, 101 TEST_URL, 102 "index.html", 103 "script.js", 104 "log-worker.js" 105 ); 106 107 info("Select the source and add a breakpoint"); 108 await selectSource(dbg, "script.js"); 109 await addBreakpoint(dbg, "script.js", 7); 110 111 info("Trigger the breakpoint and wait for the debugger to pause"); 112 invokeInTab("nonSourceMappedFunction"); 113 await waitForPaused(dbg); 114 115 info("Resume and remove the breakpoint"); 116 await resume(dbg); 117 await removeBreakpoint(dbg, findSource(dbg, "script.js").id, 7); 118 119 info("Trigger the function again and check the debugger does not pause"); 120 invokeInTab("nonSourceMappedFunction"); 121 await wait(500); 122 assertNotPaused(dbg); 123 124 info("[worker] Select the source and add a breakpoint"); 125 await selectSource(dbg, "log-worker.js"); 126 await addBreakpoint(dbg, "log-worker.js", 2); 127 128 info("[worker] Trigger the breakpoint and wait for the debugger to pause"); 129 invokeInTab("invokeLogWorker"); 130 await waitForPaused(dbg); 131 132 info("[worker] Resume and remove the breakpoint"); 133 await resume(dbg); 134 await removeBreakpoint(dbg, findSource(dbg, "log-worker.js").id, 2); 135 136 info( 137 "[worker] Trigger the function again and check the debugger does not pause" 138 ); 139 invokeInTab("invokeLogWorker"); 140 await wait(500); 141 assertNotPaused(dbg); 142 143 dbg.toolbox.closeToolbox(); 144 });