browser/devtools/debugger/test/browser_dbg_pause-warning.js

changeset 0
6474c204b198
equal deleted inserted replaced
-1:000000000000 0:cd7546b016ec
1 /* Any copyright is dedicated to the Public Domain.
2 http://creativecommons.org/publicdomain/zero/1.0/ */
3
4 /**
5 * Tests if a warning is shown in the inspector when debugger is paused.
6 */
7
8 const TAB_URL = EXAMPLE_URL + "doc_inline-script.html";
9
10 let gTab, gDebuggee, gPanel, gDebugger;
11 let gTarget, gToolbox;
12
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;
21
22 testPause();
23 });
24 }
25
26 function testPause() {
27 gDebugger.gThreadClient.addOneTimeListener("paused", () => {
28 ok(gTarget.isThreadPaused,
29 "target.isThreadPaused has been updated to true.");
30
31 gToolbox.once("inspector-selected", testNotificationIsUp1);
32 gToolbox.selectTool("inspector");
33 });
34
35 EventUtils.sendMouseEvent({ type: "mousedown" },
36 gDebugger.document.getElementById("resume"),
37 gDebugger);
38 }
39
40 function testNotificationIsUp1() {
41 let notificationBox = gToolbox.getNotificationBox();
42 let notification = notificationBox.getNotificationWithValue("inspector-script-paused");
43
44 ok(notification,
45 "Inspector notification is present (1).");
46
47 gToolbox.once("jsdebugger-selected", testNotificationIsHidden);
48 gToolbox.selectTool("jsdebugger");
49 }
50
51 function testNotificationIsHidden() {
52 let notificationBox = gToolbox.getNotificationBox();
53 let notification = notificationBox.getNotificationWithValue("inspector-script-paused");
54
55 ok(!notification,
56 "Inspector notification is hidden (2).");
57
58 gToolbox.once("inspector-selected", testNotificationIsUp2);
59 gToolbox.selectTool("inspector");
60 }
61
62 function testNotificationIsUp2() {
63 let notificationBox = gToolbox.getNotificationBox();
64 let notification = notificationBox.getNotificationWithValue("inspector-script-paused");
65
66 ok(notification,
67 "Inspector notification is present again (3).");
68
69 testResume();
70 }
71
72 function testResume() {
73 gDebugger.gThreadClient.addOneTimeListener("resumed", () => {
74 ok(!gTarget.isThreadPaused,
75 "target.isThreadPaused has been updated to false.");
76
77 let notificationBox = gToolbox.getNotificationBox();
78 let notification = notificationBox.getNotificationWithValue("inspector-script-paused");
79
80 ok(!notification,
81 "Inspector notification was removed once debugger resumed.");
82
83 closeDebuggerAndFinish(gPanel);
84 });
85
86 EventUtils.sendMouseEvent({ type: "mousedown" },
87 gDebugger.document.getElementById("resume"),
88 gDebugger);
89 }
90
91 registerCleanupFunction(function() {
92 gTab = null;
93 gDebuggee = null;
94 gPanel = null;
95 gDebugger = null;
96 gTarget = null;
97 gToolbox = null;
98 });

mercurial