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