michael@0: /* Any copyright is dedicated to the Public Domain. michael@0: http://creativecommons.org/publicdomain/zero/1.0/ */ michael@0: michael@0: /** michael@0: * Test that pretty printing when the debugger is paused does not switch away michael@0: * from the selected source. michael@0: */ michael@0: michael@0: const TAB_URL = EXAMPLE_URL + "doc_pretty-print-on-paused.html"; michael@0: michael@0: let gTab, gDebuggee, gPanel, gDebugger, gThreadClient, gSources; michael@0: michael@0: const SECOND_SOURCE_VALUE = EXAMPLE_URL + "code_ugly-2.js"; michael@0: michael@0: function test(){ michael@0: initDebugger(TAB_URL).then(([aTab, aDebuggee, aPanel]) => { michael@0: gTab = aTab; michael@0: gDebuggee = aDebuggee; michael@0: gPanel = aPanel; michael@0: gDebugger = gPanel.panelWin; michael@0: gThreadClient = gDebugger.gThreadClient; michael@0: gSources = gDebugger.DebuggerView.Sources; michael@0: michael@0: Task.spawn(function* () { michael@0: try { michael@0: yield ensureSourceIs(gPanel, "code_script-switching-02.js", true); michael@0: michael@0: yield doInterrupt(gPanel); michael@0: yield rdpInvoke(gThreadClient, gThreadClient.setBreakpoint, { michael@0: url: gSources.selectedValue, michael@0: line: 6 michael@0: }); michael@0: yield doResume(gPanel); michael@0: michael@0: const bpHit = waitForCaretAndScopes(gPanel, 6); michael@0: // Get the debuggee call off this tick so that we aren't accidentally michael@0: // blocking the yielding of bpHit which causes a deadlock. michael@0: executeSoon(() => gDebuggee.secondCall()); michael@0: yield bpHit; michael@0: michael@0: info("Switch to the second source."); michael@0: const sourceShown = waitForSourceShown(gPanel, SECOND_SOURCE_VALUE); michael@0: gSources.selectedValue = SECOND_SOURCE_VALUE; michael@0: yield sourceShown; michael@0: michael@0: info("Pretty print the source."); michael@0: const prettyPrinted = waitForSourceShown(gPanel, SECOND_SOURCE_VALUE); michael@0: gDebugger.document.getElementById("pretty-print").click(); michael@0: yield prettyPrinted; michael@0: michael@0: yield resumeDebuggerThenCloseAndFinish(gPanel); michael@0: } catch (e) { michael@0: DevToolsUtils.reportException("browser_dbg_pretty-print-on-paused.js", e); michael@0: ok(false, "Got an error: " + DevToolsUtils.safeErrorString(e)); michael@0: } michael@0: }); michael@0: }); michael@0: } michael@0: michael@0: registerCleanupFunction(function() { michael@0: gTab = null; michael@0: gDebuggee = null; michael@0: gPanel = null; michael@0: gDebugger = null; michael@0: gThreadClient = null; michael@0: gSources = null; michael@0: });