browser/devtools/debugger/test/browser_dbg_pretty-print-03.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-03.js	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,52 @@
     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 have the correct line selected after pretty printing.
     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 +
    1.15 +function test() {
    1.16 +  initDebugger(TAB_URL).then(([aTab, aDebuggee, aPanel]) => {
    1.17 +    gTab = aTab;
    1.18 +    gDebuggee = aDebuggee;
    1.19 +    gPanel = aPanel;
    1.20 +    gDebugger = gPanel.panelWin;
    1.21 +
    1.22 +    waitForSourceShown(gPanel, "code_ugly.js")
    1.23 +      .then(runCodeAndPause)
    1.24 +      .then(() => {
    1.25 +        const sourceShown = waitForSourceShown(gPanel, "code_ugly.js");
    1.26 +        const caretUpdated = waitForCaretUpdated(gPanel, 7);
    1.27 +        const finished = promise.all([sourceShown, caretUpdated]);
    1.28 +        clickPrettyPrintButton();
    1.29 +        return finished;
    1.30 +      })
    1.31 +      .then(resumeDebuggerThenCloseAndFinish.bind(null, gPanel))
    1.32 +      .then(null, aError => {
    1.33 +        ok(false, "Got an error: " + DevToolsUtils.safeErrorString(aError));
    1.34 +      });
    1.35 +  });
    1.36 +}
    1.37 +
    1.38 +function runCodeAndPause() {
    1.39 +  const deferred = promise.defer();
    1.40 +  once(gDebugger.gThreadClient, "paused").then(deferred.resolve);
    1.41 +  // Have to executeSoon so that we don't pause before this function returns.
    1.42 +  executeSoon(gDebuggee.foo);
    1.43 +  return deferred.promise;
    1.44 +}
    1.45 +
    1.46 +function clickPrettyPrintButton() {
    1.47 +  gDebugger.document.getElementById("pretty-print").click();
    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 +});

mercurial