browser/devtools/debugger/test/browser_dbg_pretty-print-on-paused.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-on-paused.js	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,67 @@
     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 + * Test that pretty printing when the debugger is paused does not switch away
     1.9 + * from the selected source.
    1.10 + */
    1.11 +
    1.12 +const TAB_URL = EXAMPLE_URL + "doc_pretty-print-on-paused.html";
    1.13 +
    1.14 +let gTab, gDebuggee, gPanel, gDebugger, gThreadClient, gSources;
    1.15 +
    1.16 +const SECOND_SOURCE_VALUE = EXAMPLE_URL + "code_ugly-2.js";
    1.17 +
    1.18 +function test(){
    1.19 +  initDebugger(TAB_URL).then(([aTab, aDebuggee, aPanel]) => {
    1.20 +    gTab = aTab;
    1.21 +    gDebuggee = aDebuggee;
    1.22 +    gPanel = aPanel;
    1.23 +    gDebugger = gPanel.panelWin;
    1.24 +    gThreadClient = gDebugger.gThreadClient;
    1.25 +    gSources = gDebugger.DebuggerView.Sources;
    1.26 +
    1.27 +    Task.spawn(function* () {
    1.28 +      try {
    1.29 +        yield ensureSourceIs(gPanel, "code_script-switching-02.js", true);
    1.30 +
    1.31 +        yield doInterrupt(gPanel);
    1.32 +        yield rdpInvoke(gThreadClient, gThreadClient.setBreakpoint, {
    1.33 +          url: gSources.selectedValue,
    1.34 +          line: 6
    1.35 +        });
    1.36 +        yield doResume(gPanel);
    1.37 +
    1.38 +        const bpHit = waitForCaretAndScopes(gPanel, 6);
    1.39 +        // Get the debuggee call off this tick so that we aren't accidentally
    1.40 +        // blocking the yielding of bpHit which causes a deadlock.
    1.41 +        executeSoon(() => gDebuggee.secondCall());
    1.42 +        yield bpHit;
    1.43 +
    1.44 +        info("Switch to the second source.");
    1.45 +        const sourceShown = waitForSourceShown(gPanel, SECOND_SOURCE_VALUE);
    1.46 +        gSources.selectedValue = SECOND_SOURCE_VALUE;
    1.47 +        yield sourceShown;
    1.48 +
    1.49 +        info("Pretty print the source.");
    1.50 +        const prettyPrinted = waitForSourceShown(gPanel, SECOND_SOURCE_VALUE);
    1.51 +        gDebugger.document.getElementById("pretty-print").click();
    1.52 +        yield prettyPrinted;
    1.53 +
    1.54 +        yield resumeDebuggerThenCloseAndFinish(gPanel);
    1.55 +      } catch (e) {
    1.56 +        DevToolsUtils.reportException("browser_dbg_pretty-print-on-paused.js", e);
    1.57 +        ok(false, "Got an error: " + DevToolsUtils.safeErrorString(e));
    1.58 +      }
    1.59 +    });
    1.60 +  });
    1.61 +}
    1.62 +
    1.63 +registerCleanupFunction(function() {
    1.64 +  gTab = null;
    1.65 +  gDebuggee = null;
    1.66 +  gPanel = null;
    1.67 +  gDebugger = null;
    1.68 +  gThreadClient = null;
    1.69 +  gSources = null;
    1.70 +});

mercurial