browser/devtools/debugger/test/browser_dbg_pretty-print-11.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-11.js	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,60 @@
     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 pretty printing is maintained across refreshes.
     1.9 + */
    1.10 +
    1.11 +const TAB_URL = EXAMPLE_URL + "doc_pretty-print.html";
    1.12 +
    1.13 +let gTab, gDebuggee, gPanel, gDebugger;
    1.14 +let gEditor, gSources;
    1.15 +
    1.16 +function test() {
    1.17 +  initDebugger(TAB_URL).then(([aTab, aDebuggee, aPanel]) => {
    1.18 +    gTab = aTab;
    1.19 +    gDebuggee = aDebuggee;
    1.20 +    gPanel = aPanel;
    1.21 +    gDebugger = gPanel.panelWin;
    1.22 +    gEditor = gDebugger.DebuggerView.editor;
    1.23 +    gSources = gDebugger.DebuggerView.Sources;
    1.24 +
    1.25 +    waitForSourceShown(gPanel, "code_ugly.js")
    1.26 +      .then(testSourceIsUgly)
    1.27 +      .then(() => {
    1.28 +        const finished = waitForSourceShown(gPanel, "code_ugly.js");
    1.29 +        clickPrettyPrintButton();
    1.30 +        return finished;
    1.31 +      })
    1.32 +      .then(testSourceIsPretty)
    1.33 +      .then(reloadActiveTab.bind(null, gPanel, gDebugger.EVENTS.SOURCE_SHOWN))
    1.34 +      .then(testSourceIsPretty)
    1.35 +      .then(() => resumeDebuggerThenCloseAndFinish(gPanel))
    1.36 +      .then(null, aError => {
    1.37 +        ok(false, "Got an error: " + DevToolsUtils.safeErrorString(aError));
    1.38 +      });
    1.39 +  });
    1.40 +}
    1.41 +
    1.42 +function testSourceIsUgly() {
    1.43 +  ok(!gEditor.getText().contains("\n  "),
    1.44 +     "The source shouldn't be pretty printed yet.");
    1.45 +}
    1.46 +
    1.47 +function clickPrettyPrintButton() {
    1.48 +  gDebugger.document.getElementById("pretty-print").click();
    1.49 +}
    1.50 +
    1.51 +function testSourceIsPretty() {
    1.52 +  ok(gEditor.getText().contains("\n  "),
    1.53 +     "The source should be pretty printed.")
    1.54 +}
    1.55 +
    1.56 +registerCleanupFunction(function() {
    1.57 +  gTab = null;
    1.58 +  gDebuggee = null;
    1.59 +  gPanel = null;
    1.60 +  gDebugger = null;
    1.61 +  gEditor = null;
    1.62 +  gSources = null;
    1.63 +});

mercurial