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