browser/devtools/debugger/test/browser_dbg_pause-warning.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 a warning is shown in the inspector when debugger is paused.
     6  */
     8 const TAB_URL = EXAMPLE_URL + "doc_inline-script.html";
    10 let gTab, gDebuggee, gPanel, gDebugger;
    11 let gTarget, gToolbox;
    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     gTarget = gPanel.target;
    20     gToolbox = gPanel._toolbox;
    22     testPause();
    23   });
    24 }
    26 function testPause() {
    27   gDebugger.gThreadClient.addOneTimeListener("paused", () => {
    28     ok(gTarget.isThreadPaused,
    29       "target.isThreadPaused has been updated to true.");
    31     gToolbox.once("inspector-selected", testNotificationIsUp1);
    32     gToolbox.selectTool("inspector");
    33   });
    35   EventUtils.sendMouseEvent({ type: "mousedown" },
    36     gDebugger.document.getElementById("resume"),
    37     gDebugger);
    38 }
    40 function testNotificationIsUp1() {
    41   let notificationBox = gToolbox.getNotificationBox();
    42   let notification = notificationBox.getNotificationWithValue("inspector-script-paused");
    44   ok(notification,
    45     "Inspector notification is present (1).");
    47   gToolbox.once("jsdebugger-selected", testNotificationIsHidden);
    48   gToolbox.selectTool("jsdebugger");
    49 }
    51 function testNotificationIsHidden() {
    52   let notificationBox = gToolbox.getNotificationBox();
    53   let notification = notificationBox.getNotificationWithValue("inspector-script-paused");
    55   ok(!notification,
    56     "Inspector notification is hidden (2).");
    58   gToolbox.once("inspector-selected", testNotificationIsUp2);
    59   gToolbox.selectTool("inspector");
    60 }
    62 function testNotificationIsUp2() {
    63   let notificationBox = gToolbox.getNotificationBox();
    64   let notification = notificationBox.getNotificationWithValue("inspector-script-paused");
    66   ok(notification,
    67     "Inspector notification is present again (3).");
    69   testResume();
    70 }
    72 function testResume() {
    73   gDebugger.gThreadClient.addOneTimeListener("resumed", () => {
    74     ok(!gTarget.isThreadPaused,
    75       "target.isThreadPaused has been updated to false.");
    77     let notificationBox = gToolbox.getNotificationBox();
    78     let notification = notificationBox.getNotificationWithValue("inspector-script-paused");
    80     ok(!notification,
    81       "Inspector notification was removed once debugger resumed.");
    83     closeDebuggerAndFinish(gPanel);
    84   });
    86   EventUtils.sendMouseEvent({ type: "mousedown" },
    87     gDebugger.document.getElementById("resume"),
    88     gDebugger);
    89 }
    91 registerCleanupFunction(function() {
    92   gTab = null;
    93   gDebuggee = null;
    94   gPanel = null;
    95   gDebugger = null;
    96   gTarget = null;
    97   gToolbox = null;
    98 });

mercurial