1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
|
/* vim:set ts=2 sw=2 sts=2 et: */
/*
* Any copyright is dedicated to the Public Domain.
* http://creativecommons.org/publicdomain/zero/1.0/
*/
// Tests that console.group/groupEnd works as intended.
const GROUP_INDENT = 12;
let testDriver, hud;
function test() {
addTab("data:text/html;charset=utf-8,Web Console test for bug 664131: Expand console " +
"object with group methods");
browser.addEventListener("load", function onLoad(aEvent) {
browser.removeEventListener(aEvent.type, onLoad, true);
openConsole(null, function(aHud) {
hud = aHud;
testDriver = testGen();
testNext();
});
}, true);
}
function testNext() {
testDriver.next();
}
function testGen() {
outputNode = hud.outputNode;
hud.jsterm.clearOutput();
content.console.group("bug664131a");
waitForSuccess({
name: "console.group displayed",
validatorFn: function()
{
return outputNode.textContent.indexOf("bug664131a") > -1;
},
successFn: testNext,
failureFn: finishTest,
});
yield;
let msg = outputNode.querySelectorAll(".webconsole-msg-icon-container");
is(msg.length, 1, "one message node displayed");
is(msg[0].style.marginLeft, GROUP_INDENT + "px", "correct group indent found");
content.console.log("bug664131a-inside");
waitForSuccess({
name: "console.log message displayed",
validatorFn: function()
{
return outputNode.textContent.indexOf("bug664131a-inside") > -1;
},
successFn: testNext,
failureFn: finishTest,
});
yield;
msg = outputNode.querySelectorAll(".webconsole-msg-icon-container");
is(msg.length, 2, "two message nodes displayed");
is(msg[1].style.marginLeft, GROUP_INDENT + "px", "correct group indent found");
content.console.groupEnd("bug664131a");
content.console.log("bug664131-outside");
waitForSuccess({
name: "console.log message displayed after groupEnd()",
validatorFn: function()
{
return outputNode.textContent.indexOf("bug664131-outside") > -1;
},
successFn: testNext,
failureFn: finishTest,
});
yield;
msg = outputNode.querySelectorAll(".webconsole-msg-icon-container");
is(msg.length, 3, "three message nodes displayed");
is(msg[2].style.marginLeft, "0px", "correct group indent found");
content.console.groupCollapsed("bug664131b");
waitForSuccess({
name: "console.groupCollapsed displayed",
validatorFn: function()
{
return outputNode.textContent.indexOf("bug664131b") > -1;
},
successFn: testNext,
failureFn: finishTest,
});
yield;
msg = outputNode.querySelectorAll(".webconsole-msg-icon-container");
is(msg.length, 4, "four message nodes displayed");
is(msg[3].style.marginLeft, GROUP_INDENT + "px", "correct group indent found");
// Test that clearing the console removes the indentation.
hud.jsterm.clearOutput();
content.console.log("bug664131-cleared");
waitForSuccess({
name: "console.log displayed after clearOutput",
validatorFn: function()
{
return outputNode.textContent.indexOf("bug664131-cleared") > -1;
},
successFn: testNext,
failureFn: finishTest,
});
yield;
msg = outputNode.querySelectorAll(".webconsole-msg-icon-container");
is(msg.length, 1, "one message node displayed");
is(msg[0].style.marginLeft, "0px", "correct group indent found");
testDriver = hud = null;
finishTest();
yield;
}
|