|
1 /* Any copyright is dedicated to the Public Domain. |
|
2 * http://creativecommons.org/publicdomain/zero/1.0/ */ |
|
3 |
|
4 // Test various GCLI commands |
|
5 |
|
6 const TEST_URI = "data:text/html;charset=utf-8,gcli-commands"; |
|
7 |
|
8 function test() { |
|
9 return Task.spawn(spawnTest).then(finish, helpers.handleError); |
|
10 } |
|
11 |
|
12 function spawnTest() { |
|
13 let options = yield helpers.openTab(TEST_URI); |
|
14 yield helpers.openToolbar(options); |
|
15 |
|
16 let subjectPromise = helpers.observeOnce("web-console-created"); |
|
17 |
|
18 helpers.audit(options, [ |
|
19 { |
|
20 setup: "console open", |
|
21 exec: { } |
|
22 } |
|
23 ]); |
|
24 |
|
25 let subject = yield subjectPromise; |
|
26 |
|
27 subject.QueryInterface(Ci.nsISupportsString); |
|
28 let hud = HUDService.getHudReferenceById(subject.data); |
|
29 ok(hud, "console open"); |
|
30 |
|
31 let jstermExecute = helpers.promiseify(hud.jsterm.execute, hud.jsterm); |
|
32 let msg = yield jstermExecute("pprint(window)"); |
|
33 |
|
34 ok(msg, "output for pprint(window)"); |
|
35 |
|
36 let oncePromise = hud.jsterm.once("messages-cleared"); |
|
37 |
|
38 helpers.audit(options, [ |
|
39 { |
|
40 setup: "console clear", |
|
41 exec: { output: "" } |
|
42 } |
|
43 ]); |
|
44 |
|
45 yield oncePromise; |
|
46 |
|
47 let labels = hud.outputNode.querySelectorAll(".message"); |
|
48 is(labels.length, 0, "no output in console"); |
|
49 |
|
50 yield helpers.audit(options, [ |
|
51 { |
|
52 setup: "console close", |
|
53 exec: { output: true } |
|
54 } |
|
55 ]); |
|
56 |
|
57 ok(!HUDService.getHudReferenceById(hud.hudId), "console closed"); |
|
58 |
|
59 yield helpers.closeToolbar(options); |
|
60 yield helpers.closeTab(options); |
|
61 } |