browser_dbg-breaking-from-console.js (1338B)
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 `debugger` statements are hit before the debugger even 8 // initializes and it properly highlights the right location in the 9 // debugger. 10 11 add_task(async function () { 12 const url = `${EXAMPLE_URL}doc-script-switching.html`; 13 const toolbox = await openNewTabAndToolbox(url, "webconsole"); 14 15 // Type "debugger" into console 16 const wrapper = toolbox.getPanel("webconsole").hud.ui.wrapper; 17 const onSelected = toolbox.once("jsdebugger-selected"); 18 wrapper.dispatchEvaluateExpression("debugger"); 19 20 // Wait for the debugger to be selected and make sure it's paused 21 await onSelected; 22 is(toolbox.threadFront.state, "paused"); 23 24 // Create a dbg context 25 const dbg = createDebuggerContext(toolbox); 26 27 // Make sure the thread is paused in the right source and location 28 await waitForPaused(dbg); 29 const selectedSource = dbg.selectors.getSelectedSource(); 30 ok( 31 !selectedSource.url, 32 "The selected source is the console evaluation and doesn't have a URL" 33 ); 34 is(getEditorContent(dbg), "debugger"); 35 await assertPausedAtSourceAndLine(dbg, selectedSource.id, 1); 36 37 await resume(dbg); 38 });