|
1 /* Any copyright is dedicated to the Public Domain. |
|
2 http://creativecommons.org/publicdomain/zero/1.0/ */ |
|
3 |
|
4 /** |
|
5 * Test that pretty printing when the debugger is paused does not switch away |
|
6 * from the selected source. |
|
7 */ |
|
8 |
|
9 const TAB_URL = EXAMPLE_URL + "doc_pretty-print-on-paused.html"; |
|
10 |
|
11 let gTab, gDebuggee, gPanel, gDebugger, gThreadClient, gSources; |
|
12 |
|
13 const SECOND_SOURCE_VALUE = EXAMPLE_URL + "code_ugly-2.js"; |
|
14 |
|
15 function test(){ |
|
16 initDebugger(TAB_URL).then(([aTab, aDebuggee, aPanel]) => { |
|
17 gTab = aTab; |
|
18 gDebuggee = aDebuggee; |
|
19 gPanel = aPanel; |
|
20 gDebugger = gPanel.panelWin; |
|
21 gThreadClient = gDebugger.gThreadClient; |
|
22 gSources = gDebugger.DebuggerView.Sources; |
|
23 |
|
24 Task.spawn(function* () { |
|
25 try { |
|
26 yield ensureSourceIs(gPanel, "code_script-switching-02.js", true); |
|
27 |
|
28 yield doInterrupt(gPanel); |
|
29 yield rdpInvoke(gThreadClient, gThreadClient.setBreakpoint, { |
|
30 url: gSources.selectedValue, |
|
31 line: 6 |
|
32 }); |
|
33 yield doResume(gPanel); |
|
34 |
|
35 const bpHit = waitForCaretAndScopes(gPanel, 6); |
|
36 // Get the debuggee call off this tick so that we aren't accidentally |
|
37 // blocking the yielding of bpHit which causes a deadlock. |
|
38 executeSoon(() => gDebuggee.secondCall()); |
|
39 yield bpHit; |
|
40 |
|
41 info("Switch to the second source."); |
|
42 const sourceShown = waitForSourceShown(gPanel, SECOND_SOURCE_VALUE); |
|
43 gSources.selectedValue = SECOND_SOURCE_VALUE; |
|
44 yield sourceShown; |
|
45 |
|
46 info("Pretty print the source."); |
|
47 const prettyPrinted = waitForSourceShown(gPanel, SECOND_SOURCE_VALUE); |
|
48 gDebugger.document.getElementById("pretty-print").click(); |
|
49 yield prettyPrinted; |
|
50 |
|
51 yield resumeDebuggerThenCloseAndFinish(gPanel); |
|
52 } catch (e) { |
|
53 DevToolsUtils.reportException("browser_dbg_pretty-print-on-paused.js", e); |
|
54 ok(false, "Got an error: " + DevToolsUtils.safeErrorString(e)); |
|
55 } |
|
56 }); |
|
57 }); |
|
58 } |
|
59 |
|
60 registerCleanupFunction(function() { |
|
61 gTab = null; |
|
62 gDebuggee = null; |
|
63 gPanel = null; |
|
64 gDebugger = null; |
|
65 gThreadClient = null; |
|
66 gSources = null; |
|
67 }); |