|
1 /* Any copyright is dedicated to the Public Domain. |
|
2 http://creativecommons.org/publicdomain/zero/1.0/ */ |
|
3 |
|
4 /** |
|
5 * Make sure that we have the correct line selected after pretty printing. |
|
6 */ |
|
7 |
|
8 const TAB_URL = EXAMPLE_URL + "doc_pretty-print.html"; |
|
9 |
|
10 let gTab, gDebuggee, gPanel, gDebugger; |
|
11 |
|
12 function test() { |
|
13 initDebugger(TAB_URL).then(([aTab, aDebuggee, aPanel]) => { |
|
14 gTab = aTab; |
|
15 gDebuggee = aDebuggee; |
|
16 gPanel = aPanel; |
|
17 gDebugger = gPanel.panelWin; |
|
18 |
|
19 waitForSourceShown(gPanel, "code_ugly.js") |
|
20 .then(runCodeAndPause) |
|
21 .then(() => { |
|
22 const sourceShown = waitForSourceShown(gPanel, "code_ugly.js"); |
|
23 const caretUpdated = waitForCaretUpdated(gPanel, 7); |
|
24 const finished = promise.all([sourceShown, caretUpdated]); |
|
25 clickPrettyPrintButton(); |
|
26 return finished; |
|
27 }) |
|
28 .then(resumeDebuggerThenCloseAndFinish.bind(null, gPanel)) |
|
29 .then(null, aError => { |
|
30 ok(false, "Got an error: " + DevToolsUtils.safeErrorString(aError)); |
|
31 }); |
|
32 }); |
|
33 } |
|
34 |
|
35 function runCodeAndPause() { |
|
36 const deferred = promise.defer(); |
|
37 once(gDebugger.gThreadClient, "paused").then(deferred.resolve); |
|
38 // Have to executeSoon so that we don't pause before this function returns. |
|
39 executeSoon(gDebuggee.foo); |
|
40 return deferred.promise; |
|
41 } |
|
42 |
|
43 function clickPrettyPrintButton() { |
|
44 gDebugger.document.getElementById("pretty-print").click(); |
|
45 } |
|
46 |
|
47 registerCleanupFunction(function() { |
|
48 gTab = null; |
|
49 gDebuggee = null; |
|
50 gPanel = null; |
|
51 gDebugger = null; |
|
52 }); |