|
1 /* Any copyright is dedicated to the Public Domain. |
|
2 http://creativecommons.org/publicdomain/zero/1.0/ */ |
|
3 |
|
4 /** |
|
5 * Make sure that pretty printing is maintained across refreshes. |
|
6 */ |
|
7 |
|
8 const TAB_URL = EXAMPLE_URL + "doc_pretty-print.html"; |
|
9 |
|
10 let gTab, gDebuggee, gPanel, gDebugger; |
|
11 let gEditor, gSources; |
|
12 |
|
13 function test() { |
|
14 initDebugger(TAB_URL).then(([aTab, aDebuggee, aPanel]) => { |
|
15 gTab = aTab; |
|
16 gDebuggee = aDebuggee; |
|
17 gPanel = aPanel; |
|
18 gDebugger = gPanel.panelWin; |
|
19 gEditor = gDebugger.DebuggerView.editor; |
|
20 gSources = gDebugger.DebuggerView.Sources; |
|
21 |
|
22 waitForSourceShown(gPanel, "code_ugly.js") |
|
23 .then(testSourceIsUgly) |
|
24 .then(() => { |
|
25 const finished = waitForSourceShown(gPanel, "code_ugly.js"); |
|
26 clickPrettyPrintButton(); |
|
27 return finished; |
|
28 }) |
|
29 .then(testSourceIsPretty) |
|
30 .then(reloadActiveTab.bind(null, gPanel, gDebugger.EVENTS.SOURCE_SHOWN)) |
|
31 .then(testSourceIsPretty) |
|
32 .then(() => resumeDebuggerThenCloseAndFinish(gPanel)) |
|
33 .then(null, aError => { |
|
34 ok(false, "Got an error: " + DevToolsUtils.safeErrorString(aError)); |
|
35 }); |
|
36 }); |
|
37 } |
|
38 |
|
39 function testSourceIsUgly() { |
|
40 ok(!gEditor.getText().contains("\n "), |
|
41 "The source shouldn't be pretty printed yet."); |
|
42 } |
|
43 |
|
44 function clickPrettyPrintButton() { |
|
45 gDebugger.document.getElementById("pretty-print").click(); |
|
46 } |
|
47 |
|
48 function testSourceIsPretty() { |
|
49 ok(gEditor.getText().contains("\n "), |
|
50 "The source should be pretty printed.") |
|
51 } |
|
52 |
|
53 registerCleanupFunction(function() { |
|
54 gTab = null; |
|
55 gDebuggee = null; |
|
56 gPanel = null; |
|
57 gDebugger = null; |
|
58 gEditor = null; |
|
59 gSources = null; |
|
60 }); |