Thu, 22 Jan 2015 13:21:57 +0100
Incorporate requested changes from Mozilla in review:
https://bugzilla.mozilla.org/show_bug.cgi?id=1123480#c6
michael@0 | 1 | /* Any copyright is dedicated to the Public Domain. |
michael@0 | 2 | http://creativecommons.org/publicdomain/zero/1.0/ */ |
michael@0 | 3 | |
michael@0 | 4 | /** |
michael@0 | 5 | * Tests if pausing and resuming in the main loop works properly. |
michael@0 | 6 | */ |
michael@0 | 7 | |
michael@0 | 8 | const TAB_URL = EXAMPLE_URL + "doc_pause-exceptions.html"; |
michael@0 | 9 | |
michael@0 | 10 | let gTab, gDebuggee, gPanel, gDebugger; |
michael@0 | 11 | let gResumeButton, gResumeKey, gFrames; |
michael@0 | 12 | |
michael@0 | 13 | function test() { |
michael@0 | 14 | initDebugger(TAB_URL).then(([aTab, aDebuggee, aPanel]) => { |
michael@0 | 15 | gTab = aTab; |
michael@0 | 16 | gDebuggee = aDebuggee; |
michael@0 | 17 | gPanel = aPanel; |
michael@0 | 18 | gDebugger = gPanel.panelWin; |
michael@0 | 19 | gResumeButton = gDebugger.document.getElementById("resume"); |
michael@0 | 20 | gResumeKey = gDebugger.document.getElementById("resumeKey"); |
michael@0 | 21 | gFrames = gDebugger.DebuggerView.StackFrames; |
michael@0 | 22 | |
michael@0 | 23 | testPause(); |
michael@0 | 24 | }); |
michael@0 | 25 | } |
michael@0 | 26 | |
michael@0 | 27 | function testPause() { |
michael@0 | 28 | is(gDebugger.gThreadClient.paused, false, |
michael@0 | 29 | "Should be running after starting the test."); |
michael@0 | 30 | |
michael@0 | 31 | is(gResumeButton.getAttribute("tooltiptext"), |
michael@0 | 32 | gDebugger.L10N.getFormatStr("pauseButtonTooltip", |
michael@0 | 33 | gDebugger.ShortcutUtils.prettifyShortcut(gResumeKey)), |
michael@0 | 34 | "Button tooltip should be 'pause' when running."); |
michael@0 | 35 | |
michael@0 | 36 | gDebugger.gThreadClient.addOneTimeListener("paused", () => { |
michael@0 | 37 | is(gDebugger.gThreadClient.paused, true, |
michael@0 | 38 | "Should be paused after an interrupt request."); |
michael@0 | 39 | |
michael@0 | 40 | is(gResumeButton.getAttribute("tooltiptext"), |
michael@0 | 41 | gDebugger.L10N.getFormatStr("resumeButtonTooltip", |
michael@0 | 42 | gDebugger.ShortcutUtils.prettifyShortcut(gResumeKey)), |
michael@0 | 43 | "Button tooltip should be 'resume' when paused."); |
michael@0 | 44 | |
michael@0 | 45 | is(gFrames.itemCount, 0, |
michael@0 | 46 | "Should have no frames when paused in the main loop."); |
michael@0 | 47 | |
michael@0 | 48 | testResume(); |
michael@0 | 49 | }); |
michael@0 | 50 | |
michael@0 | 51 | EventUtils.sendMouseEvent({ type: "mousedown" }, gResumeButton, gDebugger); |
michael@0 | 52 | } |
michael@0 | 53 | |
michael@0 | 54 | function testResume() { |
michael@0 | 55 | gDebugger.gThreadClient.addOneTimeListener("resumed", () => { |
michael@0 | 56 | is(gDebugger.gThreadClient.paused, false, |
michael@0 | 57 | "Should be paused after an interrupt request."); |
michael@0 | 58 | |
michael@0 | 59 | is(gResumeButton.getAttribute("tooltiptext"), |
michael@0 | 60 | gDebugger.L10N.getFormatStr("pauseButtonTooltip", |
michael@0 | 61 | gDebugger.ShortcutUtils.prettifyShortcut(gResumeKey)), |
michael@0 | 62 | "Button tooltip should be pause when running."); |
michael@0 | 63 | |
michael@0 | 64 | closeDebuggerAndFinish(gPanel); |
michael@0 | 65 | }); |
michael@0 | 66 | |
michael@0 | 67 | EventUtils.sendMouseEvent({ type: "mousedown" }, gResumeButton, gDebugger); |
michael@0 | 68 | } |
michael@0 | 69 | |
michael@0 | 70 | registerCleanupFunction(function() { |
michael@0 | 71 | gTab = null; |
michael@0 | 72 | gDebuggee = null; |
michael@0 | 73 | gPanel = null; |
michael@0 | 74 | gDebugger = null; |
michael@0 | 75 | gResumeButton = null; |
michael@0 | 76 | gResumeKey = null; |
michael@0 | 77 | gFrames = null; |
michael@0 | 78 | }); |