2013-09-13 06:23:19 -07:00
|
|
|
/* Any copyright is dedicated to the Public Domain.
|
|
|
|
http://creativecommons.org/publicdomain/zero/1.0/ */
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Tests if pausing and resuming in the main loop works properly.
|
2012-02-09 23:46:10 -08:00
|
|
|
*/
|
|
|
|
|
2013-09-13 06:23:19 -07:00
|
|
|
const TAB_URL = EXAMPLE_URL + "doc_pause-exceptions.html";
|
|
|
|
|
|
|
|
let gTab, gDebuggee, gPanel, gDebugger;
|
|
|
|
let gResumeButton, gResumeKey, gFrames;
|
2012-02-09 23:46:10 -08:00
|
|
|
|
|
|
|
function test() {
|
2013-09-13 06:23:19 -07:00
|
|
|
initDebugger(TAB_URL).then(([aTab, aDebuggee, aPanel]) => {
|
2012-02-09 23:46:10 -08:00
|
|
|
gTab = aTab;
|
2013-09-13 06:23:19 -07:00
|
|
|
gDebuggee = aDebuggee;
|
|
|
|
gPanel = aPanel;
|
|
|
|
gDebugger = gPanel.panelWin;
|
|
|
|
gResumeButton = gDebugger.document.getElementById("resume");
|
|
|
|
gResumeKey = gDebugger.document.getElementById("resumeKey");
|
|
|
|
gFrames = gDebugger.DebuggerView.StackFrames;
|
2012-02-09 23:46:10 -08:00
|
|
|
|
|
|
|
testPause();
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
function testPause() {
|
2013-09-13 06:23:19 -07:00
|
|
|
is(gDebugger.gThreadClient.paused, false,
|
|
|
|
"Should be running after starting the test.");
|
2012-02-09 23:46:10 -08:00
|
|
|
|
2013-09-13 06:23:19 -07:00
|
|
|
is(gResumeButton.getAttribute("tooltiptext"),
|
|
|
|
gDebugger.L10N.getFormatStr("pauseButtonTooltip",
|
2013-10-20 13:50:37 -07:00
|
|
|
gDebugger.ShortcutUtils.prettifyShortcut(gResumeKey)),
|
2013-09-13 06:23:19 -07:00
|
|
|
"Button tooltip should be 'pause' when running.");
|
2012-02-09 23:46:10 -08:00
|
|
|
|
2013-09-13 06:23:19 -07:00
|
|
|
gDebugger.gThreadClient.addOneTimeListener("paused", () => {
|
|
|
|
is(gDebugger.gThreadClient.paused, true,
|
|
|
|
"Should be paused after an interrupt request.");
|
2012-02-09 23:46:10 -08:00
|
|
|
|
2013-09-13 06:23:19 -07:00
|
|
|
is(gResumeButton.getAttribute("tooltiptext"),
|
|
|
|
gDebugger.L10N.getFormatStr("resumeButtonTooltip",
|
2013-10-20 13:50:37 -07:00
|
|
|
gDebugger.ShortcutUtils.prettifyShortcut(gResumeKey)),
|
2013-09-13 06:23:19 -07:00
|
|
|
"Button tooltip should be 'resume' when paused.");
|
2012-02-09 23:46:10 -08:00
|
|
|
|
2013-09-13 06:23:19 -07:00
|
|
|
is(gFrames.itemCount, 0,
|
|
|
|
"Should have no frames when paused in the main loop.");
|
2012-02-09 23:46:10 -08:00
|
|
|
|
2013-09-13 06:23:19 -07:00
|
|
|
testResume();
|
2012-02-09 23:46:10 -08:00
|
|
|
});
|
|
|
|
|
2013-09-13 06:23:19 -07:00
|
|
|
EventUtils.sendMouseEvent({ type: "mousedown" }, gResumeButton, gDebugger);
|
2012-02-09 23:46:10 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
function testResume() {
|
2013-09-13 06:23:19 -07:00
|
|
|
gDebugger.gThreadClient.addOneTimeListener("resumed", () => {
|
|
|
|
is(gDebugger.gThreadClient.paused, false,
|
|
|
|
"Should be paused after an interrupt request.");
|
2012-02-09 23:46:10 -08:00
|
|
|
|
2013-09-13 06:23:19 -07:00
|
|
|
is(gResumeButton.getAttribute("tooltiptext"),
|
|
|
|
gDebugger.L10N.getFormatStr("pauseButtonTooltip",
|
2013-10-20 13:50:37 -07:00
|
|
|
gDebugger.ShortcutUtils.prettifyShortcut(gResumeKey)),
|
2013-09-13 06:23:19 -07:00
|
|
|
"Button tooltip should be pause when running.");
|
2012-02-09 23:46:10 -08:00
|
|
|
|
2013-09-13 06:23:19 -07:00
|
|
|
closeDebuggerAndFinish(gPanel);
|
2012-02-09 23:46:10 -08:00
|
|
|
});
|
|
|
|
|
2013-09-13 06:23:19 -07:00
|
|
|
EventUtils.sendMouseEvent({ type: "mousedown" }, gResumeButton, gDebugger);
|
2012-02-09 23:46:10 -08:00
|
|
|
}
|
2012-03-06 00:22:17 -08:00
|
|
|
|
|
|
|
registerCleanupFunction(function() {
|
|
|
|
gTab = null;
|
2013-09-13 06:23:19 -07:00
|
|
|
gDebuggee = null;
|
|
|
|
gPanel = null;
|
2012-09-12 03:39:51 -07:00
|
|
|
gDebugger = null;
|
2013-09-13 06:23:19 -07:00
|
|
|
gResumeButton = null;
|
|
|
|
gResumeKey = null;
|
|
|
|
gFrames = null;
|
2012-03-06 00:22:17 -08:00
|
|
|
});
|