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

Wed, 31 Dec 2014 06:09:35 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 06:09:35 +0100
changeset 0
6474c204b198
permissions
-rw-r--r--

Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.

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

mercurial