browser_webconsole_optimized_out_vars.js (1594B)
1 /* Any copyright is dedicated to the Public Domain. 2 * http://creativecommons.org/publicdomain/zero/1.0/ */ 3 4 // Check that inspecting an optimized out variable works when execution is 5 // paused. 6 7 "use strict"; 8 9 const TEST_URI = 10 "http://example.com/browser/devtools/client/webconsole/" + 11 "test/browser/" + 12 "test-closure-optimized-out.html"; 13 14 add_task(async function () { 15 const breakpointLine = 18; 16 const hud = await openNewTabAndConsole(TEST_URI); 17 await openDebugger(); 18 19 const toolbox = hud.toolbox; 20 const dbg = createDebuggerContext(toolbox); 21 22 await selectSource(dbg, "test-closure-optimized-out.html"); 23 await addBreakpoint(dbg, "test-closure-optimized-out.html", breakpointLine); 24 25 // Cause the debuggee to pause 26 await pauseDebugger(dbg); 27 28 await toolbox.selectTool("webconsole"); 29 30 // This is the meat of the test: evaluate the optimized out variable. 31 info("Waiting for optimized out message"); 32 await executeAndWaitForResultMessage(hud, "upvar", "optimized out"); 33 ok(true, "Optimized out message logged"); 34 35 info("Open the debugger"); 36 await openDebugger(); 37 38 info("Resume"); 39 await resume(dbg); 40 41 info("Remove the breakpoint"); 42 const source = findSource(dbg, "test-closure-optimized-out.html"); 43 await removeBreakpoint(dbg, source.id, breakpointLine); 44 }); 45 46 async function pauseDebugger(dbg) { 47 info("Waiting for debugger to pause"); 48 const onPaused = waitForPaused(dbg); 49 SpecialPowers.spawn(gBrowser.selectedBrowser, [], async function () { 50 const button = content.document.querySelector("button"); 51 button.click(); 52 }); 53 await onPaused; 54 }