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
134
135
136
137
138
139
140
141
142
143
144
145
146
|
/* vim:set ts=2 sw=2 sts=2 et: */
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
// Tests that the basic console.log()-style APIs and filtering work.
const TEST_URI = "http://example.com/browser/browser/devtools/webconsole/test/test-console.html";
let testDriver = null;
let subtestDriver = null;
function test() {
addTab(TEST_URI);
browser.addEventListener("DOMContentLoaded", onLoad, false);
}
function onLoad() {
browser.removeEventListener("DOMContentLoaded", onLoad, false);
openConsole(null, function(aHud) {
hud = aHud;
hudId = hud.hudId;
outputNode = hud.outputNode;
testDriver = testGen();
testDriver.next();
});
}
function testGen() {
subtestGen("log");
yield;
subtestGen("info");
yield;
subtestGen("warn");
yield;
subtestGen("error");
yield;
subtestGen("debug"); // bug 616742
yield;
testDriver = subtestDriver = null;
finishTest();
yield;
}
function subtestGen(aMethod) {
subtestDriver = testConsoleLoggingAPI(aMethod);
subtestDriver.next();
}
function testConsoleLoggingAPI(aMethod) {
let console = content.wrappedJSObject.console;
hud.jsterm.clearOutput();
setStringFilter("foo");
console[aMethod]("foo-bar-baz");
console[aMethod]("bar-baz");
function nextTest() {
subtestDriver.next();
}
waitForSuccess({
name: "1 hidden " + aMethod + " node via string filtering",
validatorFn: function()
{
return outputNode.querySelectorAll(".hud-filtered-by-string").length == 1;
},
successFn: nextTest,
failureFn: nextTest,
});
yield;
hud.jsterm.clearOutput();
// now toggle the current method off - make sure no visible message
// TODO: move all filtering tests into a separate test file: see bug 608135
setStringFilter("");
hud.setFilterState(aMethod, false);
console[aMethod]("foo-bar-baz");
waitForSuccess({
name: "1 message hidden for " + aMethod + " (logging turned off)",
validatorFn: function()
{
return outputNode.querySelectorAll("description").length == 1;
},
successFn: nextTest,
failureFn: nextTest,
});
yield;
hud.jsterm.clearOutput();
hud.setFilterState(aMethod, true);
console[aMethod]("foo-bar-baz");
waitForSuccess({
name: "1 message shown for " + aMethod + " (logging turned on)",
validatorFn: function()
{
return outputNode.querySelectorAll("description").length == 1;
},
successFn: nextTest,
failureFn: nextTest,
});
yield;
hud.jsterm.clearOutput();
setStringFilter("");
// test for multiple arguments.
console[aMethod]("foo", "bar");
waitForSuccess({
name: "show both console arguments for " + aMethod,
validatorFn: function()
{
let node = outputNode.querySelector(".hud-msg-node");
return node && /"foo" "bar"/.test(node.textContent);
},
successFn: nextTest,
failureFn: nextTest,
});
yield;
testDriver.next();
yield;
}
function setStringFilter(aValue) {
hud.ui.filterBox.value = aValue;
hud.ui.adjustVisibilityOnSearchStringChange();
}
|