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

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/browser/devtools/debugger/test/browser_dbg_pretty-print-02.js	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,57 @@
     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 right clicking and selecting the pretty print context menu
     1.9 + * item prettifies the source.
    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, gContextMenu;
    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 +    gContextMenu = gDebugger.document.getElementById("sourceEditorContextMenu");
    1.25 +
    1.26 +    waitForSourceShown(gPanel, "code_ugly.js")
    1.27 +      .then(() => {
    1.28 +        const finished = waitForSourceShown(gPanel, "code_ugly.js");
    1.29 +        selectContextMenuItem();
    1.30 +        return finished;
    1.31 +      })
    1.32 +      .then(testSourceIsPretty)
    1.33 +      .then(closeDebuggerAndFinish.bind(null, gPanel))
    1.34 +      .then(null, aError => {
    1.35 +        ok(false, "Got an error: " + DevToolsUtils.safeErrorString(aError));
    1.36 +      });
    1.37 +  });
    1.38 +}
    1.39 +
    1.40 +function selectContextMenuItem() {
    1.41 +  once(gContextMenu, "popupshown").then(() => {
    1.42 +    const menuItem = gDebugger.document.getElementById("se-dbg-cMenu-prettyPrint");
    1.43 +    menuItem.click();
    1.44 +  });
    1.45 +  gContextMenu.openPopup(gEditor.container, "overlap", 0, 0, true, false);
    1.46 +}
    1.47 +
    1.48 +function testSourceIsPretty() {
    1.49 +  ok(gEditor.getText().contains("\n  "),
    1.50 +     "The source should be pretty printed.")
    1.51 +}
    1.52 +
    1.53 +registerCleanupFunction(function() {
    1.54 +  gTab = null;
    1.55 +  gDebuggee = null;
    1.56 +  gPanel = null;
    1.57 +  gDebugger = null;
    1.58 +  gEditor = null;
    1.59 +  gContextMenu = null;
    1.60 +});

mercurial