1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/browser/devtools/debugger/test/browser_dbg_pretty-print-07.js Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,56 @@ 1.4 +/* -*- Mode: javascript; js-indent-level: 2; -*- */ 1.5 +/* Any copyright is dedicated to the Public Domain. 1.6 + http://creativecommons.org/publicdomain/zero/1.0/ */ 1.7 + 1.8 +// Test basic pretty printing functionality. Would be an xpcshell test, except 1.9 +// for bug 921252. 1.10 + 1.11 +let gTab, gDebuggee, gPanel, gClient, gThreadClient, gSource; 1.12 + 1.13 +const TAB_URL = EXAMPLE_URL + "doc_pretty-print-2.html"; 1.14 + 1.15 +function test() { 1.16 + initDebugger(TAB_URL).then(([aTab, aDebuggee, aPanel]) => { 1.17 + gTab = aTab; 1.18 + gDebuggee = aDebuggee; 1.19 + gPanel = aPanel; 1.20 + gClient = gPanel.panelWin.gClient; 1.21 + gThreadClient = gPanel.panelWin.DebuggerController.activeThread; 1.22 + 1.23 + findSource(); 1.24 + }); 1.25 +} 1.26 + 1.27 +function findSource() { 1.28 + gThreadClient.getSources(({ error, sources }) => { 1.29 + ok(!error); 1.30 + sources = sources.filter(s => s.url.contains('code_ugly-2.js')); 1.31 + is(sources.length, 1); 1.32 + gSource = sources[0]; 1.33 + prettyPrintSource(); 1.34 + }); 1.35 +} 1.36 + 1.37 +function prettyPrintSource() { 1.38 + gThreadClient.source(gSource).prettyPrint(4, testPrettyPrinted); 1.39 +} 1.40 + 1.41 +function testPrettyPrinted({ error, source }) { 1.42 + ok(!error); 1.43 + ok(source.contains("\n ")); 1.44 + disablePrettyPrint(); 1.45 +} 1.46 + 1.47 +function disablePrettyPrint() { 1.48 + gThreadClient.source(gSource).disablePrettyPrint(testUgly); 1.49 +} 1.50 + 1.51 +function testUgly({ error, source }) { 1.52 + ok(!error); 1.53 + ok(!source.contains("\n ")); 1.54 + closeDebuggerAndFinish(gPanel); 1.55 +} 1.56 + 1.57 +registerCleanupFunction(function() { 1.58 + gTab = gDebuggee = gPanel = gClient = gThreadClient = gSource = null; 1.59 +});