michael@0: /* Any copyright is dedicated to the Public Domain. michael@0: http://creativecommons.org/publicdomain/zero/1.0/ */ michael@0: michael@0: /** michael@0: * Make sure that we disable the pretty print button for black boxed sources, michael@0: * and that clicking it doesn't do anything. michael@0: */ michael@0: michael@0: const TAB_URL = EXAMPLE_URL + "doc_pretty-print.html"; michael@0: michael@0: let gTab, gDebuggee, gPanel, gDebugger; michael@0: let gEditor, gSources; 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: gDebugger = gPanel.panelWin; michael@0: gEditor = gDebugger.DebuggerView.editor; michael@0: gSources = gDebugger.DebuggerView.Sources; michael@0: michael@0: waitForSourceShown(gPanel, "code_ugly.js") michael@0: .then(testSourceIsUgly) michael@0: .then(toggleBlackBoxing.bind(null, gPanel)) michael@0: .then(clickPrettyPrintButton) michael@0: .then(testSourceIsStillUgly) michael@0: .then(() => closeDebuggerAndFinish(gPanel)) michael@0: .then(null, aError => { michael@0: ok(false, "Got an error: " + DevToolsUtils.safeErrorString(aError)); michael@0: }); michael@0: }); michael@0: } michael@0: michael@0: function testSourceIsUgly() { michael@0: ok(!gEditor.getText().contains("\n "), michael@0: "The source shouldn't be pretty printed yet."); michael@0: } michael@0: michael@0: function clickPrettyPrintButton() { michael@0: gDebugger.document.getElementById("pretty-print").click(); michael@0: } michael@0: michael@0: function testSourceIsStillUgly() { michael@0: const { source } = gSources.selectedItem.attachment; michael@0: return gDebugger.DebuggerController.SourceScripts.getText(source).then(([, text]) => { michael@0: ok(!text.contains("\n ")); michael@0: }); michael@0: } michael@0: michael@0: registerCleanupFunction(function() { michael@0: gTab = null; michael@0: gDebuggee = null; michael@0: gPanel = null; michael@0: gDebugger = null; michael@0: gEditor = null; michael@0: gSources = null; michael@0: });