browser/devtools/debugger/test/browser_dbg_pretty-print-05.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 prettifying HTML sources doesn't do anything.
     6  */
     8 const TAB_URL = EXAMPLE_URL + "doc_included-script.html";
    10 let gTab, gDebuggee, gPanel, gDebugger;
    11 let gEditor, gSources, gControllerSources;
    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;
    21     gControllerSources = gDebugger.DebuggerController.SourceScripts;
    23     Task.spawn(function() {
    24       yield waitForSourceShown(gPanel, TAB_URL);
    26       // From this point onward, the source editor's text should never change.
    27       gEditor.once("change", () => {
    28         ok(false, "The source editor text shouldn't have changed.");
    29       });
    31       is(gSources.selectedValue, TAB_URL,
    32         "The correct source is currently selected.");
    33       ok(gEditor.getText().contains("myFunction"),
    34         "The source shouldn't be pretty printed yet.");
    36       clickPrettyPrintButton();
    38       let { source } = gSources.selectedItem.attachment;
    39       try {
    40         yield gControllerSources.togglePrettyPrint(source);
    41         ok(false, "The promise for a prettified source should be rejected!");
    42       } catch ([source, error]) {
    43         is(error, "Can't prettify non-javascript files.",
    44           "The promise was correctly rejected with a meaningful message.");
    45       }
    47       let [source, text] = yield gControllerSources.getText(source);
    48       is(gSources.selectedValue, TAB_URL,
    49         "The correct source is still selected.");
    50       ok(gEditor.getText().contains("myFunction"),
    51         "The displayed source hasn't changed.");
    52       ok(text.contains("myFunction"),
    53         "The cached source text wasn't altered in any way.");
    55       yield closeDebuggerAndFinish(gPanel);
    56     });
    57   });
    58 }
    60 function clickPrettyPrintButton() {
    61   gDebugger.document.getElementById("pretty-print").click();
    62 }
    64 function prepareDebugger(aPanel) {
    65   aPanel._view.Sources.preferredSource = TAB_URL;
    66 }
    68 registerCleanupFunction(function() {
    69   gTab = null;
    70   gDebuggee = null;
    71   gPanel = null;
    72   gDebugger = null;
    73   gEditor = null;
    74   gSources = null;
    75   gControllerSources = null;
    76 });

mercurial