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
|
/* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */
/* vim: set ft=javascript ts=2 et sw=2 tw=80: */
/* Any copyright is dedicated to the Public Domain.
* http://creativecommons.org/publicdomain/zero/1.0/ */
// Tests that the Web Console limits the number of lines displayed according to
// the user's preferences.
"use strict";
const TEST_URI = "data:text/html;charset=utf-8,<p>test for bug 642108.";
const LOG_LIMIT = 20;
function test() {
let hud;
Task.spawn(runner).then(finishTest);
function* runner() {
let {tab} = yield loadTab(TEST_URI);
Services.prefs.setIntPref("devtools.hud.loglimit.cssparser", LOG_LIMIT);
Services.prefs.setBoolPref("devtools.webconsole.filter.cssparser", true);
registerCleanupFunction(function () {
Services.prefs.clearUserPref("devtools.hud.loglimit.cssparser");
Services.prefs.clearUserPref("devtools.webconsole.filter.cssparser");
});
hud = yield openConsole(tab);
for (let i = 0; i < 5; i++) {
logCSSMessage("css log x");
}
yield waitForMessages({
webconsole: hud,
messages: [{
text: "css log x",
category: CATEGORY_CSS,
severity: SEVERITY_WARNING,
repeats: 5,
}],
});
for (let i = 0; i < LOG_LIMIT + 5; i++) {
logCSSMessage("css log " + i);
}
let [result] = yield waitForMessages({
webconsole: hud,
messages: [{
text: "css log 5",
category: CATEGORY_CSS,
severity: SEVERITY_WARNING,
},
{
// LOG_LIMIT + 5
text: "css log 24",
category: CATEGORY_CSS,
severity: SEVERITY_WARNING,
}],
});
is(hud.ui.outputNode.querySelectorAll(".message").length, LOG_LIMIT,
"number of messages");
is(Object.keys(hud.ui._repeatNodes).length, LOG_LIMIT,
"repeated nodes pruned from repeatNodes");
let msg = [...result.matched][0];
let repeats = msg.querySelector(".message-repeats");
is(repeats.getAttribute("value"), 1,
"repeated nodes pruned from repeatNodes (confirmed)");
}
function logCSSMessage(msg) {
let node = hud.ui.createMessageNode(CATEGORY_CSS, SEVERITY_WARNING, msg);
hud.ui.outputMessage(CATEGORY_CSS, node);
}
}
|