browser/devtools/debugger/test/browser_dbg_pause-resume.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_pause-resume.js	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,78 @@
     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 + * Tests if pausing and resuming in the main loop works properly.
     1.9 + */
    1.10 +
    1.11 +const TAB_URL = EXAMPLE_URL + "doc_pause-exceptions.html";
    1.12 +
    1.13 +let gTab, gDebuggee, gPanel, gDebugger;
    1.14 +let gResumeButton, gResumeKey, gFrames;
    1.15 +
    1.16 +function test() {
    1.17 +  initDebugger(TAB_URL).then(([aTab, aDebuggee, aPanel]) => {
    1.18 +    gTab = aTab;
    1.19 +    gDebuggee = aDebuggee;
    1.20 +    gPanel = aPanel;
    1.21 +    gDebugger = gPanel.panelWin;
    1.22 +    gResumeButton = gDebugger.document.getElementById("resume");
    1.23 +    gResumeKey = gDebugger.document.getElementById("resumeKey");
    1.24 +    gFrames = gDebugger.DebuggerView.StackFrames;
    1.25 +
    1.26 +    testPause();
    1.27 +  });
    1.28 +}
    1.29 +
    1.30 +function testPause() {
    1.31 +  is(gDebugger.gThreadClient.paused, false,
    1.32 +    "Should be running after starting the test.");
    1.33 +
    1.34 +  is(gResumeButton.getAttribute("tooltiptext"),
    1.35 +     gDebugger.L10N.getFormatStr("pauseButtonTooltip",
    1.36 +      gDebugger.ShortcutUtils.prettifyShortcut(gResumeKey)),
    1.37 +    "Button tooltip should be 'pause' when running.");
    1.38 +
    1.39 +  gDebugger.gThreadClient.addOneTimeListener("paused", () => {
    1.40 +    is(gDebugger.gThreadClient.paused, true,
    1.41 +      "Should be paused after an interrupt request.");
    1.42 +
    1.43 +    is(gResumeButton.getAttribute("tooltiptext"),
    1.44 +       gDebugger.L10N.getFormatStr("resumeButtonTooltip",
    1.45 +        gDebugger.ShortcutUtils.prettifyShortcut(gResumeKey)),
    1.46 +      "Button tooltip should be 'resume' when paused.");
    1.47 +
    1.48 +    is(gFrames.itemCount, 0,
    1.49 +      "Should have no frames when paused in the main loop.");
    1.50 +
    1.51 +    testResume();
    1.52 +  });
    1.53 +
    1.54 +  EventUtils.sendMouseEvent({ type: "mousedown" }, gResumeButton, gDebugger);
    1.55 +}
    1.56 +
    1.57 +function testResume() {
    1.58 +  gDebugger.gThreadClient.addOneTimeListener("resumed", () => {
    1.59 +    is(gDebugger.gThreadClient.paused, false,
    1.60 +      "Should be paused after an interrupt request.");
    1.61 +
    1.62 +    is(gResumeButton.getAttribute("tooltiptext"),
    1.63 +       gDebugger.L10N.getFormatStr("pauseButtonTooltip",
    1.64 +        gDebugger.ShortcutUtils.prettifyShortcut(gResumeKey)),
    1.65 +      "Button tooltip should be pause when running.");
    1.66 +
    1.67 +    closeDebuggerAndFinish(gPanel);
    1.68 +  });
    1.69 +
    1.70 +  EventUtils.sendMouseEvent({ type: "mousedown" }, gResumeButton, gDebugger);
    1.71 +}
    1.72 +
    1.73 +registerCleanupFunction(function() {
    1.74 +  gTab = null;
    1.75 +  gDebuggee = null;
    1.76 +  gPanel = null;
    1.77 +  gDebugger = null;
    1.78 +  gResumeButton = null;
    1.79 +  gResumeKey = null;
    1.80 +  gFrames = null;
    1.81 +});

mercurial