browser/devtools/debugger/test/browser_dbg_pretty-print-07.js

changeset 0
6474c204b198
equal deleted inserted replaced
-1:000000000000 0:0cdf3eecb73a
1 /* -*- Mode: javascript; js-indent-level: 2; -*- */
2 /* Any copyright is dedicated to the Public Domain.
3 http://creativecommons.org/publicdomain/zero/1.0/ */
4
5 // Test basic pretty printing functionality. Would be an xpcshell test, except
6 // for bug 921252.
7
8 let gTab, gDebuggee, gPanel, gClient, gThreadClient, gSource;
9
10 const TAB_URL = EXAMPLE_URL + "doc_pretty-print-2.html";
11
12 function test() {
13 initDebugger(TAB_URL).then(([aTab, aDebuggee, aPanel]) => {
14 gTab = aTab;
15 gDebuggee = aDebuggee;
16 gPanel = aPanel;
17 gClient = gPanel.panelWin.gClient;
18 gThreadClient = gPanel.panelWin.DebuggerController.activeThread;
19
20 findSource();
21 });
22 }
23
24 function findSource() {
25 gThreadClient.getSources(({ error, sources }) => {
26 ok(!error);
27 sources = sources.filter(s => s.url.contains('code_ugly-2.js'));
28 is(sources.length, 1);
29 gSource = sources[0];
30 prettyPrintSource();
31 });
32 }
33
34 function prettyPrintSource() {
35 gThreadClient.source(gSource).prettyPrint(4, testPrettyPrinted);
36 }
37
38 function testPrettyPrinted({ error, source }) {
39 ok(!error);
40 ok(source.contains("\n "));
41 disablePrettyPrint();
42 }
43
44 function disablePrettyPrint() {
45 gThreadClient.source(gSource).disablePrettyPrint(testUgly);
46 }
47
48 function testUgly({ error, source }) {
49 ok(!error);
50 ok(!source.contains("\n "));
51 closeDebuggerAndFinish(gPanel);
52 }
53
54 registerCleanupFunction(function() {
55 gTab = gDebuggee = gPanel = gClient = gThreadClient = gSource = null;
56 });

mercurial