|
1 /* vim:set ts=2 sw=2 sts=2 et: */ |
|
2 /* Any copyright is dedicated to the Public Domain. |
|
3 * http://creativecommons.org/publicdomain/zero/1.0/ */ |
|
4 |
|
5 // Test that console.count() counts as expected. See bug 922208. |
|
6 |
|
7 const TEST_URI = "http://example.com/browser/browser/devtools/webconsole/test/test-console-count.html"; |
|
8 |
|
9 function test() { |
|
10 Task.spawn(runner).then(finishTest); |
|
11 |
|
12 function* runner() { |
|
13 const {tab} = yield loadTab(TEST_URI); |
|
14 const hud = yield openConsole(tab); |
|
15 |
|
16 let button = content.document.querySelector("#local"); |
|
17 ok(button, "we have the local-tests button"); |
|
18 EventUtils.sendMouseEvent({ type: "click" }, button, content); |
|
19 let messages = []; |
|
20 [ |
|
21 "start", |
|
22 "<no label>: 2", |
|
23 "console.count() testcounter: 1", |
|
24 "console.count() testcounter: 2", |
|
25 "console.count() testcounter: 3", |
|
26 "console.count() testcounter: 4", |
|
27 "end" |
|
28 ].forEach(function (msg) { |
|
29 messages.push({ |
|
30 text: msg, |
|
31 category: CATEGORY_WEBDEV, |
|
32 severity: SEVERITY_LOG |
|
33 }); |
|
34 }); |
|
35 messages.push({ |
|
36 name: "Three local counts with no label and count=1", |
|
37 text: "<no label>: 1", |
|
38 category: CATEGORY_WEBDEV, |
|
39 severity: SEVERITY_LOG, |
|
40 count: 3 |
|
41 }); |
|
42 yield waitForMessages({ |
|
43 webconsole: hud, |
|
44 messages: messages |
|
45 }); |
|
46 |
|
47 hud.jsterm.clearOutput(); |
|
48 |
|
49 button = content.document.querySelector("#external"); |
|
50 ok(button, "we have the external-tests button"); |
|
51 EventUtils.sendMouseEvent({ type: "click" }, button, content); |
|
52 messages = []; |
|
53 [ |
|
54 "start", |
|
55 "console.count() testcounter: 5", |
|
56 "console.count() testcounter: 6", |
|
57 "end" |
|
58 ].forEach(function (msg) { |
|
59 messages.push({ |
|
60 text: msg, |
|
61 category: CATEGORY_WEBDEV, |
|
62 severity: SEVERITY_LOG |
|
63 }); |
|
64 }); |
|
65 messages.push({ |
|
66 name: "Two external counts with no label and count=1", |
|
67 text: "<no label>: 1", |
|
68 category: CATEGORY_WEBDEV, |
|
69 severity: SEVERITY_LOG, |
|
70 count: 2 |
|
71 }); |
|
72 yield waitForMessages({ |
|
73 webconsole: hud, |
|
74 messages: messages |
|
75 }); |
|
76 } |
|
77 } |