michael@0: /* -*- Mode: javascript; js-indent-level: 2; -*- */ michael@0: /* Any copyright is dedicated to the Public Domain. michael@0: http://creativecommons.org/publicdomain/zero/1.0/ */ michael@0: michael@0: // Test basic pretty printing functionality. Would be an xpcshell test, except michael@0: // for bug 921252. michael@0: michael@0: let gTab, gDebuggee, gPanel, gClient, gThreadClient, gSource; michael@0: michael@0: const TAB_URL = EXAMPLE_URL + "doc_pretty-print-2.html"; michael@0: michael@0: function test() { michael@0: initDebugger(TAB_URL).then(([aTab, aDebuggee, aPanel]) => { michael@0: gTab = aTab; michael@0: gDebuggee = aDebuggee; michael@0: gPanel = aPanel; michael@0: gClient = gPanel.panelWin.gClient; michael@0: gThreadClient = gPanel.panelWin.DebuggerController.activeThread; michael@0: michael@0: findSource(); michael@0: }); michael@0: } michael@0: michael@0: function findSource() { michael@0: gThreadClient.getSources(({ error, sources }) => { michael@0: ok(!error); michael@0: sources = sources.filter(s => s.url.contains('code_ugly-2.js')); michael@0: is(sources.length, 1); michael@0: gSource = sources[0]; michael@0: prettyPrintSource(); michael@0: }); michael@0: } michael@0: michael@0: function prettyPrintSource() { michael@0: gThreadClient.source(gSource).prettyPrint(4, testPrettyPrinted); michael@0: } michael@0: michael@0: function testPrettyPrinted({ error, source }) { michael@0: ok(!error); michael@0: ok(source.contains("\n ")); michael@0: disablePrettyPrint(); michael@0: } michael@0: michael@0: function disablePrettyPrint() { michael@0: gThreadClient.source(gSource).disablePrettyPrint(testUgly); michael@0: } michael@0: michael@0: function testUgly({ error, source }) { michael@0: ok(!error); michael@0: ok(!source.contains("\n ")); michael@0: closeDebuggerAndFinish(gPanel); michael@0: } michael@0: michael@0: registerCleanupFunction(function() { michael@0: gTab = gDebuggee = gPanel = gClient = gThreadClient = gSource = null; michael@0: });