browser/devtools/webconsole/test/browser_repeated_messages_accuracy.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 /*
     3  * Any copyright is dedicated to the Public Domain.
     4  * http://creativecommons.org/publicdomain/zero/1.0/
     5  */
     7 // Test that makes sure messages are not considered repeated when coming from
     8 // different lines of code, or from different severities, etc.
     9 // See bugs 720180 and 800510.
    11 const TEST_URI = "http://example.com/browser/browser/devtools/webconsole/test/test-repeated-messages.html";
    13 function test() {
    14   const PREF = "devtools.webconsole.persistlog";
    15   Services.prefs.setBoolPref(PREF, true);
    16   registerCleanupFunction(() => Services.prefs.clearUserPref(PREF));
    18   addTab(TEST_URI);
    19   browser.addEventListener("load", function onLoad() {
    20     browser.removeEventListener("load", onLoad, true);
    21     openConsole(null, consoleOpened);
    22   }, true);
    23 }
    25 function consoleOpened(hud) {
    26   // Check that css warnings are not coalesced if they come from different lines.
    27   info("waiting for 2 css warnings");
    29   waitForMessages({
    30     webconsole: hud,
    31     messages: [{
    32       name: "two css warnings",
    33       category: CATEGORY_CSS,
    34       count: 2,
    35       repeats: 1,
    36     }],
    37   }).then(testCSSRepeats.bind(null, hud));
    38 }
    40 function testCSSRepeats(hud) {
    41   browser.addEventListener("load", function onLoad() {
    42     browser.removeEventListener("load", onLoad, true);
    44     info("wait for repeats after page reload");
    46     waitForMessages({
    47       webconsole: hud,
    48       messages: [{
    49         name: "two css warnings, repeated twice",
    50         category: CATEGORY_CSS,
    51         repeats: 2,
    52         count: 2,
    53       }],
    54     }).then(testCSSRepeatsAfterReload.bind(null, hud));
    55   }, true);
    56   content.location.reload();
    57 }
    59 function testCSSRepeatsAfterReload(hud) {
    60   hud.jsterm.clearOutput(true);
    61   content.wrappedJSObject.testConsole();
    63   info("wait for repeats with the console API");
    65   waitForMessages({
    66     webconsole: hud,
    67     messages: [
    68       {
    69         name: "console.log 'foo repeat' repeated twice",
    70         category: CATEGORY_WEBDEV,
    71         severity: SEVERITY_LOG,
    72         repeats: 2,
    73       },
    74       {
    75         name: "console.log 'foo repeat' repeated once",
    76         category: CATEGORY_WEBDEV,
    77         severity: SEVERITY_LOG,
    78         repeats: 1,
    79       },
    80       {
    81         name: "console.error 'foo repeat' repeated once",
    82         category: CATEGORY_WEBDEV,
    83         severity: SEVERITY_ERROR,
    84         repeats: 1,
    85       },
    86     ],
    87   }).then(testConsoleRepeats.bind(null, hud));
    88 }
    90 function testConsoleRepeats(hud) {
    91   hud.jsterm.clearOutput(true);
    92   hud.jsterm.execute("undefined");
    93   content.console.log("undefined");
    95   info("make sure console API messages are not coalesced with jsterm output");
    97   waitForMessages({
    98     webconsole: hud,
    99     messages: [
   100       {
   101         name: "'undefined' jsterm input message",
   102         text: "undefined",
   103         category: CATEGORY_INPUT,
   104       },
   105       {
   106         name: "'undefined' jsterm output message",
   107         text: "undefined",
   108         category: CATEGORY_OUTPUT,
   109       },
   110       {
   111         name: "'undefined' console.log message",
   112         text: "undefined",
   113         category: CATEGORY_WEBDEV,
   114         repeats: 1,
   115       },
   116     ],
   117   }).then(finishTest);
   118 }

mercurial