1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/browser/devtools/debugger/test/browser_dbg_pretty-print-10.js Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,58 @@ 1.4 +/* Any copyright is dedicated to the Public Domain. 1.5 + http://creativecommons.org/publicdomain/zero/1.0/ */ 1.6 + 1.7 +/** 1.8 + * Make sure that we disable the pretty print button for black boxed sources, 1.9 + * and that clicking it doesn't do anything. 1.10 + */ 1.11 + 1.12 +const TAB_URL = EXAMPLE_URL + "doc_pretty-print.html"; 1.13 + 1.14 +let gTab, gDebuggee, gPanel, gDebugger; 1.15 +let gEditor, gSources; 1.16 + 1.17 +function test() { 1.18 + initDebugger(TAB_URL).then(([aTab, aDebuggee, aPanel]) => { 1.19 + gTab = aTab; 1.20 + gDebuggee = aDebuggee; 1.21 + gPanel = aPanel; 1.22 + gDebugger = gPanel.panelWin; 1.23 + gEditor = gDebugger.DebuggerView.editor; 1.24 + gSources = gDebugger.DebuggerView.Sources; 1.25 + 1.26 + waitForSourceShown(gPanel, "code_ugly.js") 1.27 + .then(testSourceIsUgly) 1.28 + .then(toggleBlackBoxing.bind(null, gPanel)) 1.29 + .then(clickPrettyPrintButton) 1.30 + .then(testSourceIsStillUgly) 1.31 + .then(() => closeDebuggerAndFinish(gPanel)) 1.32 + .then(null, aError => { 1.33 + ok(false, "Got an error: " + DevToolsUtils.safeErrorString(aError)); 1.34 + }); 1.35 + }); 1.36 +} 1.37 + 1.38 +function testSourceIsUgly() { 1.39 + ok(!gEditor.getText().contains("\n "), 1.40 + "The source shouldn't be pretty printed yet."); 1.41 +} 1.42 + 1.43 +function clickPrettyPrintButton() { 1.44 + gDebugger.document.getElementById("pretty-print").click(); 1.45 +} 1.46 + 1.47 +function testSourceIsStillUgly() { 1.48 + const { source } = gSources.selectedItem.attachment; 1.49 + return gDebugger.DebuggerController.SourceScripts.getText(source).then(([, text]) => { 1.50 + ok(!text.contains("\n ")); 1.51 + }); 1.52 +} 1.53 + 1.54 +registerCleanupFunction(function() { 1.55 + gTab = null; 1.56 + gDebuggee = null; 1.57 + gPanel = null; 1.58 + gDebugger = null; 1.59 + gEditor = null; 1.60 + gSources = null; 1.61 +});