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 right clicking and selecting the pretty print context menu michael@0: * item prettifies the source. 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, gContextMenu; 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: gContextMenu = gDebugger.document.getElementById("sourceEditorContextMenu"); michael@0: michael@0: waitForSourceShown(gPanel, "code_ugly.js") michael@0: .then(() => { michael@0: const finished = waitForSourceShown(gPanel, "code_ugly.js"); michael@0: selectContextMenuItem(); michael@0: return finished; michael@0: }) michael@0: .then(testSourceIsPretty) michael@0: .then(closeDebuggerAndFinish.bind(null, 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 selectContextMenuItem() { michael@0: once(gContextMenu, "popupshown").then(() => { michael@0: const menuItem = gDebugger.document.getElementById("se-dbg-cMenu-prettyPrint"); michael@0: menuItem.click(); michael@0: }); michael@0: gContextMenu.openPopup(gEditor.container, "overlap", 0, 0, true, false); michael@0: } michael@0: michael@0: function testSourceIsPretty() { michael@0: ok(gEditor.getText().contains("\n "), michael@0: "The source should be pretty printed.") 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: gContextMenu = null; michael@0: });