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

Thu, 22 Jan 2015 13:21:57 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Thu, 22 Jan 2015 13:21:57 +0100
branch
TOR_BUG_9701
changeset 15
b8a032363ba2
permissions
-rw-r--r--

Incorporate requested changes from Mozilla in review:
https://bugzilla.mozilla.org/show_bug.cgi?id=1123480#c6

     1 /* Any copyright is dedicated to the Public Domain.
     2    http://creativecommons.org/publicdomain/zero/1.0/ */
     4 /**
     5  * Make sure that pretty printing is maintained across refreshes.
     6  */
     8 const TAB_URL = EXAMPLE_URL + "doc_pretty-print.html";
    10 let gTab, gDebuggee, gPanel, gDebugger;
    11 let gEditor, gSources;
    13 function test() {
    14   initDebugger(TAB_URL).then(([aTab, aDebuggee, aPanel]) => {
    15     gTab = aTab;
    16     gDebuggee = aDebuggee;
    17     gPanel = aPanel;
    18     gDebugger = gPanel.panelWin;
    19     gEditor = gDebugger.DebuggerView.editor;
    20     gSources = gDebugger.DebuggerView.Sources;
    22     waitForSourceShown(gPanel, "code_ugly.js")
    23       .then(testSourceIsUgly)
    24       .then(() => {
    25         const finished = waitForSourceShown(gPanel, "code_ugly.js");
    26         clickPrettyPrintButton();
    27         return finished;
    28       })
    29       .then(testSourceIsPretty)
    30       .then(reloadActiveTab.bind(null, gPanel, gDebugger.EVENTS.SOURCE_SHOWN))
    31       .then(testSourceIsPretty)
    32       .then(() => resumeDebuggerThenCloseAndFinish(gPanel))
    33       .then(null, aError => {
    34         ok(false, "Got an error: " + DevToolsUtils.safeErrorString(aError));
    35       });
    36   });
    37 }
    39 function testSourceIsUgly() {
    40   ok(!gEditor.getText().contains("\n  "),
    41      "The source shouldn't be pretty printed yet.");
    42 }
    44 function clickPrettyPrintButton() {
    45   gDebugger.document.getElementById("pretty-print").click();
    46 }
    48 function testSourceIsPretty() {
    49   ok(gEditor.getText().contains("\n  "),
    50      "The source should be pretty printed.")
    51 }
    53 registerCleanupFunction(function() {
    54   gTab = null;
    55   gDebuggee = null;
    56   gPanel = null;
    57   gDebugger = null;
    58   gEditor = null;
    59   gSources = null;
    60 });

mercurial