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

changeset 0
6474c204b198
equal deleted inserted replaced
-1:000000000000 0:5b5fca0e1a0e
1 /* Any copyright is dedicated to the Public Domain.
2 http://creativecommons.org/publicdomain/zero/1.0/ */
3
4 /**
5 * Make sure that right clicking and selecting the pretty print context menu
6 * item prettifies the source.
7 */
8
9 const TAB_URL = EXAMPLE_URL + "doc_pretty-print.html";
10
11 let gTab, gDebuggee, gPanel, gDebugger;
12 let gEditor, gContextMenu;
13
14 function test() {
15 initDebugger(TAB_URL).then(([aTab, aDebuggee, aPanel]) => {
16 gTab = aTab;
17 gDebuggee = aDebuggee;
18 gPanel = aPanel;
19 gDebugger = gPanel.panelWin;
20 gEditor = gDebugger.DebuggerView.editor;
21 gContextMenu = gDebugger.document.getElementById("sourceEditorContextMenu");
22
23 waitForSourceShown(gPanel, "code_ugly.js")
24 .then(() => {
25 const finished = waitForSourceShown(gPanel, "code_ugly.js");
26 selectContextMenuItem();
27 return finished;
28 })
29 .then(testSourceIsPretty)
30 .then(closeDebuggerAndFinish.bind(null, gPanel))
31 .then(null, aError => {
32 ok(false, "Got an error: " + DevToolsUtils.safeErrorString(aError));
33 });
34 });
35 }
36
37 function selectContextMenuItem() {
38 once(gContextMenu, "popupshown").then(() => {
39 const menuItem = gDebugger.document.getElementById("se-dbg-cMenu-prettyPrint");
40 menuItem.click();
41 });
42 gContextMenu.openPopup(gEditor.container, "overlap", 0, 0, true, false);
43 }
44
45 function testSourceIsPretty() {
46 ok(gEditor.getText().contains("\n "),
47 "The source should be pretty printed.")
48 }
49
50 registerCleanupFunction(function() {
51 gTab = null;
52 gDebuggee = null;
53 gPanel = null;
54 gDebugger = null;
55 gEditor = null;
56 gContextMenu = null;
57 });

mercurial