browser/devtools/debugger/test/browser_dbg_pretty-print-12.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-12.js	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,54 @@
     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 we don't leave the pretty print button checked when we fail to
     1.9 + * pretty print a source (because it isn't a JS file, for example).
    1.10 + */
    1.11 +
    1.12 +const TAB_URL = EXAMPLE_URL + "doc_blackboxing.html";
    1.13 +
    1.14 +let gTab, gDebuggee, gPanel, gDebugger;
    1.15 +let gEditor, gSources;
    1.16 +
    1.17 +function test() {
    1.18 +  initDebugger(TAB_URL).then(([aTab, aDebuggee, aPanel]) => {
    1.19 +    gTab = aTab;
    1.20 +    gDebuggee = aDebuggee;
    1.21 +    gPanel = aPanel;
    1.22 +    gDebugger = gPanel.panelWin;
    1.23 +    gEditor = gDebugger.DebuggerView.editor;
    1.24 +    gSources = gDebugger.DebuggerView.Sources;
    1.25 +
    1.26 +    waitForSourceShown(gPanel, "")
    1.27 +      .then(() => {
    1.28 +        let shown = ensureSourceIs(gPanel, TAB_URL, true)
    1.29 +        gSources.selectedValue = TAB_URL;
    1.30 +        return shown;
    1.31 +      })
    1.32 +      .then(clickPrettyPrintButton)
    1.33 +      .then(testButtonIsntChecked)
    1.34 +      .then(() => closeDebuggerAndFinish(gPanel))
    1.35 +      .then(null, aError => {
    1.36 +        ok(false, "Got an error: " + DevToolsUtils.safeErrorString(aError));
    1.37 +      });
    1.38 +  });
    1.39 +}
    1.40 +
    1.41 +function clickPrettyPrintButton() {
    1.42 +  gDebugger.document.getElementById("pretty-print").click();
    1.43 +}
    1.44 +
    1.45 +function testButtonIsntChecked() {
    1.46 +  is(gDebugger.document.getElementById("pretty-print").checked, false,
    1.47 +     "The button shouldn't be checked after trying to pretty print a non-js file.");
    1.48 +}
    1.49 +
    1.50 +registerCleanupFunction(function() {
    1.51 +  gTab = null;
    1.52 +  gDebuggee = null;
    1.53 +  gPanel = null;
    1.54 +  gDebugger = null;
    1.55 +  gEditor = null;
    1.56 +  gSources = null;
    1.57 +});

mercurial