michael@0: /* Any copyright is dedicated to the Public Domain. michael@0: http://creativecommons.org/publicdomain/zero/1.0/ */ michael@0: michael@0: /** michael@0: * Tests if a warning is shown in the inspector when debugger is paused. michael@0: */ michael@0: michael@0: const TAB_URL = EXAMPLE_URL + "doc_inline-script.html"; michael@0: michael@0: let gTab, gDebuggee, gPanel, gDebugger; michael@0: let gTarget, gToolbox; michael@0: michael@0: function test() { michael@0: initDebugger(TAB_URL).then(([aTab, aDebuggee, aPanel]) => { michael@0: gTab = aTab; michael@0: gDebuggee = aDebuggee; michael@0: gPanel = aPanel; michael@0: gDebugger = gPanel.panelWin; michael@0: gTarget = gPanel.target; michael@0: gToolbox = gPanel._toolbox; michael@0: michael@0: testPause(); michael@0: }); michael@0: } michael@0: michael@0: function testPause() { michael@0: gDebugger.gThreadClient.addOneTimeListener("paused", () => { michael@0: ok(gTarget.isThreadPaused, michael@0: "target.isThreadPaused has been updated to true."); michael@0: michael@0: gToolbox.once("inspector-selected", testNotificationIsUp1); michael@0: gToolbox.selectTool("inspector"); michael@0: }); michael@0: michael@0: EventUtils.sendMouseEvent({ type: "mousedown" }, michael@0: gDebugger.document.getElementById("resume"), michael@0: gDebugger); michael@0: } michael@0: michael@0: function testNotificationIsUp1() { michael@0: let notificationBox = gToolbox.getNotificationBox(); michael@0: let notification = notificationBox.getNotificationWithValue("inspector-script-paused"); michael@0: michael@0: ok(notification, michael@0: "Inspector notification is present (1)."); michael@0: michael@0: gToolbox.once("jsdebugger-selected", testNotificationIsHidden); michael@0: gToolbox.selectTool("jsdebugger"); michael@0: } michael@0: michael@0: function testNotificationIsHidden() { michael@0: let notificationBox = gToolbox.getNotificationBox(); michael@0: let notification = notificationBox.getNotificationWithValue("inspector-script-paused"); michael@0: michael@0: ok(!notification, michael@0: "Inspector notification is hidden (2)."); michael@0: michael@0: gToolbox.once("inspector-selected", testNotificationIsUp2); michael@0: gToolbox.selectTool("inspector"); michael@0: } michael@0: michael@0: function testNotificationIsUp2() { michael@0: let notificationBox = gToolbox.getNotificationBox(); michael@0: let notification = notificationBox.getNotificationWithValue("inspector-script-paused"); michael@0: michael@0: ok(notification, michael@0: "Inspector notification is present again (3)."); michael@0: michael@0: testResume(); michael@0: } michael@0: michael@0: function testResume() { michael@0: gDebugger.gThreadClient.addOneTimeListener("resumed", () => { michael@0: ok(!gTarget.isThreadPaused, michael@0: "target.isThreadPaused has been updated to false."); michael@0: michael@0: let notificationBox = gToolbox.getNotificationBox(); michael@0: let notification = notificationBox.getNotificationWithValue("inspector-script-paused"); michael@0: michael@0: ok(!notification, michael@0: "Inspector notification was removed once debugger resumed."); michael@0: michael@0: closeDebuggerAndFinish(gPanel); michael@0: }); michael@0: michael@0: EventUtils.sendMouseEvent({ type: "mousedown" }, michael@0: gDebugger.document.getElementById("resume"), michael@0: gDebugger); michael@0: } michael@0: michael@0: registerCleanupFunction(function() { michael@0: gTab = null; michael@0: gDebuggee = null; michael@0: gPanel = null; michael@0: gDebugger = null; michael@0: gTarget = null; michael@0: gToolbox = null; michael@0: });