browser/devtools/webconsole/test/browser_webconsole_bug_642108_pruneTest.js

changeset 0
6474c204b198
equal deleted inserted replaced
-1:000000000000 0:5c4a098d6690
1 /* vim:set ts=2 sw=2 sts=2 et: */
2 /* ***** BEGIN LICENSE BLOCK *****
3 * Any copyright is dedicated to the Public Domain.
4 * http://creativecommons.org/publicdomain/zero/1.0/
5 *
6 * ***** END LICENSE BLOCK ***** */
7
8 // Tests that the Web Console limits the number of lines displayed according to
9 // the user's preferences.
10
11 const TEST_URI = "data:text/html;charset=utf-8,<p>test for bug 642108.";
12 const LOG_LIMIT = 20;
13
14 function test() {
15 let hud;
16
17 Task.spawn(runner).then(finishTest);
18
19 function* runner() {
20 let {tab} = yield loadTab(TEST_URI);
21
22 Services.prefs.setIntPref("devtools.hud.loglimit.cssparser", LOG_LIMIT);
23 Services.prefs.setBoolPref("devtools.webconsole.filter.cssparser", true);
24
25 registerCleanupFunction(function() {
26 Services.prefs.clearUserPref("devtools.hud.loglimit.cssparser");
27 Services.prefs.clearUserPref("devtools.webconsole.filter.cssparser");
28 });
29
30 hud = yield openConsole(tab);
31
32 for (let i = 0; i < 5; i++) {
33 logCSSMessage("css log x");
34 }
35
36 yield waitForMessages({
37 webconsole: hud,
38 messages: [{
39 text: "css log x",
40 category: CATEGORY_CSS,
41 severity: SEVERITY_WARNING,
42 repeats: 5,
43 }],
44 });
45
46 for (let i = 0; i < LOG_LIMIT + 5; i++) {
47 logCSSMessage("css log " + i);
48 }
49
50 let [result] = yield waitForMessages({
51 webconsole: hud,
52 messages: [{
53 text: "css log 5",
54 category: CATEGORY_CSS,
55 severity: SEVERITY_WARNING,
56 },
57 {
58 text: "css log 24", // LOG_LIMIT + 5
59 category: CATEGORY_CSS,
60 severity: SEVERITY_WARNING,
61 }],
62 });
63
64 is(hud.ui.outputNode.querySelectorAll(".message").length, LOG_LIMIT,
65 "number of messages");
66
67 is(Object.keys(hud.ui._repeatNodes).length, LOG_LIMIT,
68 "repeated nodes pruned from repeatNodes");
69
70 let msg = [...result.matched][0];
71 let repeats = msg.querySelector(".message-repeats");
72 is(repeats.getAttribute("value"), 1,
73 "repeated nodes pruned from repeatNodes (confirmed)");
74 }
75
76 function logCSSMessage(msg) {
77 let node = hud.ui.createMessageNode(CATEGORY_CSS, SEVERITY_WARNING, msg);
78 hud.ui.outputMessage(CATEGORY_CSS, node);
79 }
80 }

mercurial