browser_webconsole_eval_in_debugger_stackframe2.js (2331B)
1 /* Any copyright is dedicated to the Public Domain. 2 * http://creativecommons.org/publicdomain/zero/1.0/ */ 3 4 // Test to make sure that web console commands can fire while paused at a 5 // breakpoint that was triggered from a JS call. Relies on asynchronous js 6 // evaluation over the protocol - see Bug 1088861. 7 8 "use strict"; 9 10 const TEST_URI = 11 "http://example.com/browser/devtools/client/webconsole/" + 12 "test/browser/test-eval-in-stackframe.html"; 13 14 add_task(async function () { 15 // TODO: Remove this pref change when middleware for terminating requests 16 // when closing a panel is implemented 17 await pushPref("devtools.debugger.features.inline-preview", false); 18 19 info("open the console"); 20 const hud = await openNewTabAndConsole(TEST_URI); 21 22 info("open the debugger"); 23 await openDebugger(); 24 25 const toolbox = hud.toolbox; 26 const dbg = createDebuggerContext(toolbox); 27 28 // firstCall calls secondCall, which has a debugger statement, so we'll be paused. 29 const onFirstCallMessageReceived = waitForMessageByType( 30 hud, 31 "undefined", 32 ".result" 33 ); 34 35 const unresolvedSymbol = Symbol(); 36 let firstCallEvaluationResult = unresolvedSymbol; 37 onFirstCallMessageReceived.then(message => { 38 firstCallEvaluationResult = message; 39 }); 40 execute(hud, "firstCall()"); 41 42 info("Waiting for a frame to be added"); 43 await waitForPaused(dbg, null, { shouldWaitForInlinePreviews: false }); 44 45 info("frames added, select the console again"); 46 await openConsole(); 47 48 info("Executing basic command while paused"); 49 await executeAndWaitForResultMessage(hud, "1 + 2", "3"); 50 ok(true, "`1 + 2` was evaluated whith debugger paused"); 51 52 info("Executing command using scoped variables while paused"); 53 await executeAndWaitForResultMessage( 54 hud, 55 "foo + foo2", 56 `"globalFooBug783499foo2SecondCall"` 57 ); 58 ok(true, "`foo + foo2` was evaluated as expected with debugger paused"); 59 60 info( 61 "Checking the first command, which is the last to resolve since it paused" 62 ); 63 Assert.strictEqual( 64 firstCallEvaluationResult, 65 unresolvedSymbol, 66 "firstCall was not evaluated yet" 67 ); 68 69 info("Resuming the thread"); 70 dbg.actions.resume(); 71 72 await onFirstCallMessageReceived; 73 Assert.notStrictEqual( 74 firstCallEvaluationResult, 75 unresolvedSymbol, 76 "firstCall() returned correct value" 77 ); 78 });