browser/devtools/debugger/test/browser_dbg_pretty-print-10.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 we disable the pretty print button for black boxed sources,
     6  * and that clicking it doesn't do anything.
     7  */
     9 const TAB_URL = EXAMPLE_URL + "doc_pretty-print.html";
    11 let gTab, gDebuggee, gPanel, gDebugger;
    12 let gEditor, gSources;
    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     gSources = gDebugger.DebuggerView.Sources;
    23     waitForSourceShown(gPanel, "code_ugly.js")
    24       .then(testSourceIsUgly)
    25       .then(toggleBlackBoxing.bind(null, gPanel))
    26       .then(clickPrettyPrintButton)
    27       .then(testSourceIsStillUgly)
    28       .then(() => closeDebuggerAndFinish(gPanel))
    29       .then(null, aError => {
    30         ok(false, "Got an error: " + DevToolsUtils.safeErrorString(aError));
    31       });
    32   });
    33 }
    35 function testSourceIsUgly() {
    36   ok(!gEditor.getText().contains("\n    "),
    37      "The source shouldn't be pretty printed yet.");
    38 }
    40 function clickPrettyPrintButton() {
    41   gDebugger.document.getElementById("pretty-print").click();
    42 }
    44 function testSourceIsStillUgly() {
    45   const { source } = gSources.selectedItem.attachment;
    46   return gDebugger.DebuggerController.SourceScripts.getText(source).then(([, text]) => {
    47     ok(!text.contains("\n    "));
    48   });
    49 }
    51 registerCleanupFunction(function() {
    52   gTab = null;
    53   gDebuggee = null;
    54   gPanel = null;
    55   gDebugger = null;
    56   gEditor = null;
    57   gSources = null;
    58 });

mercurial