browser/devtools/webconsole/test/browser_webconsole_bug_585237_line_limit.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 * Contributor(s):
michael@0 7 * Patrick Walton <pcwalton@mozilla.com>
michael@0 8 * Mihai Șucan <mihai.sucan@gmail.com>
michael@0 9 *
michael@0 10 * ***** END LICENSE BLOCK ***** */
michael@0 11
michael@0 12 // Tests that the Web Console limits the number of lines displayed according to
michael@0 13 // the user's preferences.
michael@0 14
michael@0 15 const TEST_URI = "data:text/html;charset=utf8,test for bug 585237";
michael@0 16 let hud, testDriver;
michael@0 17
michael@0 18 function test() {
michael@0 19 addTab(TEST_URI);
michael@0 20 browser.addEventListener("load", function onLoad() {
michael@0 21 browser.removeEventListener("load", onLoad, true);
michael@0 22 openConsole(null, function(aHud) {
michael@0 23 hud = aHud;
michael@0 24 testDriver = testGen();
michael@0 25 testNext();
michael@0 26 });
michael@0 27 }, true);
michael@0 28 }
michael@0 29
michael@0 30 function testNext() {
michael@0 31 testDriver.next();
michael@0 32 }
michael@0 33
michael@0 34 function testGen() {
michael@0 35 let console = content.console;
michael@0 36 outputNode = hud.outputNode;
michael@0 37
michael@0 38 hud.jsterm.clearOutput();
michael@0 39
michael@0 40 let prefBranch = Services.prefs.getBranch("devtools.hud.loglimit.");
michael@0 41 prefBranch.setIntPref("console", 20);
michael@0 42
michael@0 43 for (let i = 0; i < 30; i++) {
michael@0 44 console.log("foo #" + i); // must change message to prevent repeats
michael@0 45 }
michael@0 46
michael@0 47 waitForMessages({
michael@0 48 webconsole: hud,
michael@0 49 messages: [{
michael@0 50 text: "foo #29",
michael@0 51 category: CATEGORY_WEBDEV,
michael@0 52 severity: SEVERITY_LOG,
michael@0 53 }],
michael@0 54 }).then(testNext);
michael@0 55
michael@0 56 yield undefined;
michael@0 57
michael@0 58 is(countMessageNodes(), 20, "there are 20 message nodes in the output " +
michael@0 59 "when the log limit is set to 20");
michael@0 60
michael@0 61 console.log("bar bug585237");
michael@0 62
michael@0 63 waitForMessages({
michael@0 64 webconsole: hud,
michael@0 65 messages: [{
michael@0 66 text: "bar bug585237",
michael@0 67 category: CATEGORY_WEBDEV,
michael@0 68 severity: SEVERITY_LOG,
michael@0 69 }],
michael@0 70 }).then(testNext);
michael@0 71
michael@0 72 yield undefined;
michael@0 73
michael@0 74 is(countMessageNodes(), 20, "there are still 20 message nodes in the " +
michael@0 75 "output when adding one more");
michael@0 76
michael@0 77 prefBranch.setIntPref("console", 30);
michael@0 78 for (let i = 0; i < 20; i++) {
michael@0 79 console.log("boo #" + i); // must change message to prevent repeats
michael@0 80 }
michael@0 81
michael@0 82 waitForMessages({
michael@0 83 webconsole: hud,
michael@0 84 messages: [{
michael@0 85 text: "boo #19",
michael@0 86 category: CATEGORY_WEBDEV,
michael@0 87 severity: SEVERITY_LOG,
michael@0 88 }],
michael@0 89 }).then(testNext);
michael@0 90
michael@0 91 yield undefined;
michael@0 92
michael@0 93 is(countMessageNodes(), 30, "there are 30 message nodes in the output " +
michael@0 94 "when the log limit is set to 30");
michael@0 95
michael@0 96 prefBranch.clearUserPref("console");
michael@0 97 hud = testDriver = prefBranch = console = outputNode = null;
michael@0 98 finishTest();
michael@0 99
michael@0 100 yield undefined;
michael@0 101 }
michael@0 102
michael@0 103 function countMessageNodes() {
michael@0 104 return outputNode.querySelectorAll(".message").length;
michael@0 105 }
michael@0 106

mercurial