browser/devtools/debugger/test/browser_dbg_pretty-print-02.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.

     1 /* Any copyright is dedicated to the Public Domain.
     2    http://creativecommons.org/publicdomain/zero/1.0/ */
     4 /**
     5  * Make sure that right clicking and selecting the pretty print context menu
     6  * item prettifies the source.
     7  */
     9 const TAB_URL = EXAMPLE_URL + "doc_pretty-print.html";
    11 let gTab, gDebuggee, gPanel, gDebugger;
    12 let gEditor, gContextMenu;
    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");
    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 }
    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 }
    45 function testSourceIsPretty() {
    46   ok(gEditor.getText().contains("\n  "),
    47      "The source should be pretty printed.")
    48 }
    50 registerCleanupFunction(function() {
    51   gTab = null;
    52   gDebuggee = null;
    53   gPanel = null;
    54   gDebugger = null;
    55   gEditor = null;
    56   gContextMenu = null;
    57 });

mercurial