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.

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

mercurial