Wed, 31 Dec 2014 06:09:35 +0100
Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.
1 /* -*- Mode: javascript; js-indent-level: 2; -*- */
2 /* Any copyright is dedicated to the Public Domain.
3 http://creativecommons.org/publicdomain/zero/1.0/ */
5 // Test basic pretty printing functionality. Would be an xpcshell test, except
6 // for bug 921252.
8 let gTab, gDebuggee, gPanel, gClient, gThreadClient, gSource;
10 const TAB_URL = EXAMPLE_URL + "doc_pretty-print-2.html";
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;
20 findSource();
21 });
22 }
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 }
34 function prettyPrintSource() {
35 gThreadClient.source(gSource).prettyPrint(4, testPrettyPrinted);
36 }
38 function testPrettyPrinted({ error, source }) {
39 ok(!error);
40 ok(source.contains("\n "));
41 disablePrettyPrint();
42 }
44 function disablePrettyPrint() {
45 gThreadClient.source(gSource).disablePrettyPrint(testUgly);
46 }
48 function testUgly({ error, source }) {
49 ok(!error);
50 ok(!source.contains("\n "));
51 closeDebuggerAndFinish(gPanel);
52 }
54 registerCleanupFunction(function() {
55 gTab = gDebuggee = gPanel = gClient = gThreadClient = gSource = null;
56 });