browser/devtools/debugger/test/browser_dbg_pause-resume.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  * Tests if pausing and resuming in the main loop works properly.
     6  */
     8 const TAB_URL = EXAMPLE_URL + "doc_pause-exceptions.html";
    10 let gTab, gDebuggee, gPanel, gDebugger;
    11 let gResumeButton, gResumeKey, gFrames;
    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     gResumeButton = gDebugger.document.getElementById("resume");
    20     gResumeKey = gDebugger.document.getElementById("resumeKey");
    21     gFrames = gDebugger.DebuggerView.StackFrames;
    23     testPause();
    24   });
    25 }
    27 function testPause() {
    28   is(gDebugger.gThreadClient.paused, false,
    29     "Should be running after starting the test.");
    31   is(gResumeButton.getAttribute("tooltiptext"),
    32      gDebugger.L10N.getFormatStr("pauseButtonTooltip",
    33       gDebugger.ShortcutUtils.prettifyShortcut(gResumeKey)),
    34     "Button tooltip should be 'pause' when running.");
    36   gDebugger.gThreadClient.addOneTimeListener("paused", () => {
    37     is(gDebugger.gThreadClient.paused, true,
    38       "Should be paused after an interrupt request.");
    40     is(gResumeButton.getAttribute("tooltiptext"),
    41        gDebugger.L10N.getFormatStr("resumeButtonTooltip",
    42         gDebugger.ShortcutUtils.prettifyShortcut(gResumeKey)),
    43       "Button tooltip should be 'resume' when paused.");
    45     is(gFrames.itemCount, 0,
    46       "Should have no frames when paused in the main loop.");
    48     testResume();
    49   });
    51   EventUtils.sendMouseEvent({ type: "mousedown" }, gResumeButton, gDebugger);
    52 }
    54 function testResume() {
    55   gDebugger.gThreadClient.addOneTimeListener("resumed", () => {
    56     is(gDebugger.gThreadClient.paused, false,
    57       "Should be paused after an interrupt request.");
    59     is(gResumeButton.getAttribute("tooltiptext"),
    60        gDebugger.L10N.getFormatStr("pauseButtonTooltip",
    61         gDebugger.ShortcutUtils.prettifyShortcut(gResumeKey)),
    62       "Button tooltip should be pause when running.");
    64     closeDebuggerAndFinish(gPanel);
    65   });
    67   EventUtils.sendMouseEvent({ type: "mousedown" }, gResumeButton, gDebugger);
    68 }
    70 registerCleanupFunction(function() {
    71   gTab = null;
    72   gDebuggee = null;
    73   gPanel = null;
    74   gDebugger = null;
    75   gResumeButton = null;
    76   gResumeKey = null;
    77   gFrames = null;
    78 });

mercurial