|
1 /* Any copyright is dedicated to the Public Domain. |
|
2 http://creativecommons.org/publicdomain/zero/1.0/ */ |
|
3 |
|
4 /** |
|
5 * Tests that the debugger commands work as they should. |
|
6 */ |
|
7 |
|
8 const TEST_URI = EXAMPLE_URL + "doc_cmd-dbg.html"; |
|
9 |
|
10 function test() { |
|
11 return Task.spawn(function() { |
|
12 let options = yield helpers.openTab(TEST_URI); |
|
13 yield helpers.openToolbar(options); |
|
14 |
|
15 yield helpers.audit(options, [{ |
|
16 setup: "dbg open", |
|
17 exec: { output: "" } |
|
18 }]); |
|
19 |
|
20 let [gTab, gDebuggee, gPanel] = yield initDebugger(gBrowser.selectedTab); |
|
21 let gDebugger = gPanel.panelWin; |
|
22 let gThreadClient = gDebugger.gThreadClient; |
|
23 |
|
24 yield helpers.audit(options, [{ |
|
25 setup: "dbg list", |
|
26 exec: { output: /doc_cmd-dbg.html/ } |
|
27 }]); |
|
28 |
|
29 let button = gDebuggee.document.querySelector("input[type=button]"); |
|
30 let output = gDebuggee.document.querySelector("input[type=text]"); |
|
31 |
|
32 let cmd = function(aTyped, aState) { |
|
33 return promise.all([ |
|
34 waitForThreadEvents(gPanel, aState), |
|
35 helpers.audit(options, [{ setup: aTyped, exec: { output: "" } }]) |
|
36 ]); |
|
37 }; |
|
38 |
|
39 let click = function(aElement, aState) { |
|
40 return promise.all([ |
|
41 waitForThreadEvents(gPanel, aState), |
|
42 executeSoon(() => EventUtils.sendMouseEvent({ type: "click" }, aElement, gDebuggee)) |
|
43 ]); |
|
44 } |
|
45 |
|
46 yield cmd("dbg interrupt", "paused"); |
|
47 is(gThreadClient.state, "paused", "Debugger is paused."); |
|
48 |
|
49 yield cmd("dbg continue", "resumed"); |
|
50 isnot(gThreadClient.state, "paused", "Debugger has continued."); |
|
51 |
|
52 yield click(button, "paused"); |
|
53 is(gThreadClient.state, "paused", "Debugger is paused again."); |
|
54 |
|
55 yield cmd("dbg step in", "paused"); |
|
56 yield cmd("dbg step in", "paused"); |
|
57 yield cmd("dbg step in", "paused"); |
|
58 is(output.value, "step in", "Debugger stepped in."); |
|
59 |
|
60 yield cmd("dbg step over", "paused"); |
|
61 is(output.value, "step over", "Debugger stepped over."); |
|
62 |
|
63 yield cmd("dbg step out", "paused"); |
|
64 is(output.value, "step out", "Debugger stepped out."); |
|
65 |
|
66 yield cmd("dbg continue", "paused"); |
|
67 is(output.value, "dbg continue", "Debugger continued."); |
|
68 |
|
69 let closeDebugger = function() { |
|
70 let deferred = promise.defer(); |
|
71 |
|
72 helpers.audit(options, [{ |
|
73 setup: "dbg close", |
|
74 exec: { output: "" } |
|
75 }]) |
|
76 .then(() => { |
|
77 let toolbox = gDevTools.getToolbox(options.target); |
|
78 if (!toolbox) { |
|
79 ok(true, "Debugger is closed."); |
|
80 deferred.resolve(); |
|
81 } else { |
|
82 toolbox.on("destroyed", () => { |
|
83 ok(true, "Debugger just closed."); |
|
84 deferred.resolve(); |
|
85 }); |
|
86 } |
|
87 }); |
|
88 |
|
89 return deferred.promise; |
|
90 }; |
|
91 |
|
92 // We close the debugger twice to ensure 'dbg close' doesn't error when |
|
93 // toolbox is already closed. See bug 884638 for more info. |
|
94 yield closeDebugger(); |
|
95 yield closeDebugger(); |
|
96 yield helpers.closeToolbar(options); |
|
97 yield helpers.closeTab(options); |
|
98 |
|
99 }).then(finish, helpers.handleError); |
|
100 } |