|
1 /* Any copyright is dedicated to the Public Domain. |
|
2 http://creativecommons.org/publicdomain/zero/1.0/ */ |
|
3 |
|
4 /** |
|
5 * Make sure that prettifying HTML sources doesn't do anything. |
|
6 */ |
|
7 |
|
8 const TAB_URL = EXAMPLE_URL + "doc_included-script.html"; |
|
9 |
|
10 let gTab, gDebuggee, gPanel, gDebugger; |
|
11 let gEditor, gSources, gControllerSources; |
|
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 gControllerSources = gDebugger.DebuggerController.SourceScripts; |
|
22 |
|
23 Task.spawn(function() { |
|
24 yield waitForSourceShown(gPanel, TAB_URL); |
|
25 |
|
26 // From this point onward, the source editor's text should never change. |
|
27 gEditor.once("change", () => { |
|
28 ok(false, "The source editor text shouldn't have changed."); |
|
29 }); |
|
30 |
|
31 is(gSources.selectedValue, TAB_URL, |
|
32 "The correct source is currently selected."); |
|
33 ok(gEditor.getText().contains("myFunction"), |
|
34 "The source shouldn't be pretty printed yet."); |
|
35 |
|
36 clickPrettyPrintButton(); |
|
37 |
|
38 let { source } = gSources.selectedItem.attachment; |
|
39 try { |
|
40 yield gControllerSources.togglePrettyPrint(source); |
|
41 ok(false, "The promise for a prettified source should be rejected!"); |
|
42 } catch ([source, error]) { |
|
43 is(error, "Can't prettify non-javascript files.", |
|
44 "The promise was correctly rejected with a meaningful message."); |
|
45 } |
|
46 |
|
47 let [source, text] = yield gControllerSources.getText(source); |
|
48 is(gSources.selectedValue, TAB_URL, |
|
49 "The correct source is still selected."); |
|
50 ok(gEditor.getText().contains("myFunction"), |
|
51 "The displayed source hasn't changed."); |
|
52 ok(text.contains("myFunction"), |
|
53 "The cached source text wasn't altered in any way."); |
|
54 |
|
55 yield closeDebuggerAndFinish(gPanel); |
|
56 }); |
|
57 }); |
|
58 } |
|
59 |
|
60 function clickPrettyPrintButton() { |
|
61 gDebugger.document.getElementById("pretty-print").click(); |
|
62 } |
|
63 |
|
64 function prepareDebugger(aPanel) { |
|
65 aPanel._view.Sources.preferredSource = TAB_URL; |
|
66 } |
|
67 |
|
68 registerCleanupFunction(function() { |
|
69 gTab = null; |
|
70 gDebuggee = null; |
|
71 gPanel = null; |
|
72 gDebugger = null; |
|
73 gEditor = null; |
|
74 gSources = null; |
|
75 gControllerSources = null; |
|
76 }); |