1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/browser/devtools/webconsole/test/browser_webconsole_bug_642108_pruneTest.js Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,80 @@ 1.4 +/* vim:set ts=2 sw=2 sts=2 et: */ 1.5 +/* ***** BEGIN LICENSE BLOCK ***** 1.6 + * Any copyright is dedicated to the Public Domain. 1.7 + * http://creativecommons.org/publicdomain/zero/1.0/ 1.8 + * 1.9 + * ***** END LICENSE BLOCK ***** */ 1.10 + 1.11 +// Tests that the Web Console limits the number of lines displayed according to 1.12 +// the user's preferences. 1.13 + 1.14 +const TEST_URI = "data:text/html;charset=utf-8,<p>test for bug 642108."; 1.15 +const LOG_LIMIT = 20; 1.16 + 1.17 +function test() { 1.18 + let hud; 1.19 + 1.20 + Task.spawn(runner).then(finishTest); 1.21 + 1.22 + function* runner() { 1.23 + let {tab} = yield loadTab(TEST_URI); 1.24 + 1.25 + Services.prefs.setIntPref("devtools.hud.loglimit.cssparser", LOG_LIMIT); 1.26 + Services.prefs.setBoolPref("devtools.webconsole.filter.cssparser", true); 1.27 + 1.28 + registerCleanupFunction(function() { 1.29 + Services.prefs.clearUserPref("devtools.hud.loglimit.cssparser"); 1.30 + Services.prefs.clearUserPref("devtools.webconsole.filter.cssparser"); 1.31 + }); 1.32 + 1.33 + hud = yield openConsole(tab); 1.34 + 1.35 + for (let i = 0; i < 5; i++) { 1.36 + logCSSMessage("css log x"); 1.37 + } 1.38 + 1.39 + yield waitForMessages({ 1.40 + webconsole: hud, 1.41 + messages: [{ 1.42 + text: "css log x", 1.43 + category: CATEGORY_CSS, 1.44 + severity: SEVERITY_WARNING, 1.45 + repeats: 5, 1.46 + }], 1.47 + }); 1.48 + 1.49 + for (let i = 0; i < LOG_LIMIT + 5; i++) { 1.50 + logCSSMessage("css log " + i); 1.51 + } 1.52 + 1.53 + let [result] = yield waitForMessages({ 1.54 + webconsole: hud, 1.55 + messages: [{ 1.56 + text: "css log 5", 1.57 + category: CATEGORY_CSS, 1.58 + severity: SEVERITY_WARNING, 1.59 + }, 1.60 + { 1.61 + text: "css log 24", // LOG_LIMIT + 5 1.62 + category: CATEGORY_CSS, 1.63 + severity: SEVERITY_WARNING, 1.64 + }], 1.65 + }); 1.66 + 1.67 + is(hud.ui.outputNode.querySelectorAll(".message").length, LOG_LIMIT, 1.68 + "number of messages"); 1.69 + 1.70 + is(Object.keys(hud.ui._repeatNodes).length, LOG_LIMIT, 1.71 + "repeated nodes pruned from repeatNodes"); 1.72 + 1.73 + let msg = [...result.matched][0]; 1.74 + let repeats = msg.querySelector(".message-repeats"); 1.75 + is(repeats.getAttribute("value"), 1, 1.76 + "repeated nodes pruned from repeatNodes (confirmed)"); 1.77 + } 1.78 + 1.79 + function logCSSMessage(msg) { 1.80 + let node = hud.ui.createMessageNode(CATEGORY_CSS, SEVERITY_WARNING, msg); 1.81 + hud.ui.outputMessage(CATEGORY_CSS, node); 1.82 + } 1.83 +}