browser/devtools/webconsole/test/browser_webconsole_bug_642108_pruneTest.js

Wed, 31 Dec 2014 06:09:35 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 06:09:35 +0100
changeset 0
6474c204b198
permissions
-rw-r--r--

Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.

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

mercurial