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.

     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 ***** */
     8 // Tests that the Web Console limits the number of lines displayed according to
     9 // the user's preferences.
    11 const TEST_URI = "data:text/html;charset=utf-8,<p>test for bug 642108.";
    12 const LOG_LIMIT = 20;
    14 function test() {
    15   let hud;
    17   Task.spawn(runner).then(finishTest);
    19   function* runner() {
    20     let {tab} = yield loadTab(TEST_URI);
    22     Services.prefs.setIntPref("devtools.hud.loglimit.cssparser", LOG_LIMIT);
    23     Services.prefs.setBoolPref("devtools.webconsole.filter.cssparser", true);
    25     registerCleanupFunction(function() {
    26       Services.prefs.clearUserPref("devtools.hud.loglimit.cssparser");
    27       Services.prefs.clearUserPref("devtools.webconsole.filter.cssparser");
    28     });
    30     hud = yield openConsole(tab);
    32     for (let i = 0; i < 5; i++) {
    33       logCSSMessage("css log x");
    34     }
    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     });
    46     for (let i = 0; i < LOG_LIMIT + 5; i++) {
    47       logCSSMessage("css log " + i);
    48     }
    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     });
    64     is(hud.ui.outputNode.querySelectorAll(".message").length, LOG_LIMIT,
    65        "number of messages");
    67     is(Object.keys(hud.ui._repeatNodes).length, LOG_LIMIT,
    68        "repeated nodes pruned from repeatNodes");
    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   }
    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