browser/devtools/webconsole/test/browser_console_nsiconsolemessage.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 /*
     2  * Any copyright is dedicated to the Public Domain.
     3  * http://creativecommons.org/publicdomain/zero/1.0/
     4  */
     6 // Check that nsIConsoleMessages are displayed in the Browser Console.
     7 // See bug 859756.
     9 const TEST_URI = "data:text/html;charset=utf8,<title>bug859756</title>\n" +
    10                  "<p>hello world\n<p>nsIConsoleMessages ftw!";
    12 function test()
    13 {
    14   const FILTER_PREF = "devtools.browserconsole.filter.jslog";
    15   Services.prefs.setBoolPref(FILTER_PREF, true);
    17   registerCleanupFunction(() => {
    18     Services.prefs.clearUserPref(FILTER_PREF);
    19   });
    21   Task.spawn(function*() {
    22     const {tab} = yield loadTab(TEST_URI);
    24     // Test for cached nsIConsoleMessages.
    25     Services.console.logStringMessage("test1 for bug859756");
    27     info("open web console");
    28     let hud = yield openConsole(tab);
    30     ok(hud, "web console opened");
    31     Services.console.logStringMessage("do-not-show-me");
    32     content.console.log("foobarz");
    34     yield waitForMessages({
    35       webconsole: hud,
    36       messages: [{
    37         text: "foobarz",
    38         category: CATEGORY_WEBDEV,
    39         severity: SEVERITY_LOG,
    40       }],
    41     });
    43     let text = hud.outputNode.textContent;
    44     is(text.indexOf("do-not-show-me"), -1,
    45        "nsIConsoleMessages are not displayed");
    46     is(text.indexOf("test1 for bug859756"), -1,
    47        "nsIConsoleMessages are not displayed (confirmed)");
    49     yield closeConsole(tab);
    51     info("web console closed");
    52     hud = yield HUDService.toggleBrowserConsole();
    53     ok(hud, "browser console opened");
    55     Services.console.logStringMessage("test2 for bug859756");
    57     let results = yield waitForMessages({
    58       webconsole: hud,
    59       messages: [{
    60         text: "test1 for bug859756",
    61         category: CATEGORY_JS,
    62       }, {
    63         text: "test2 for bug859756",
    64         category: CATEGORY_JS,
    65       }, {
    66         text: "do-not-show-me",
    67         category: CATEGORY_JS,
    68       }],
    69     });
    71     let msg = [...results[2].matched][0];
    72     ok(msg, "message element for do-not-show-me (nsIConsoleMessage)");
    73     isnot(msg.textContent.indexOf("do-not-show"), -1, "element content is correct");
    74     ok(!msg.classList.contains("filtered-by-type"), "element is not filtered");
    76     hud.setFilterState("jslog", false);
    78     ok(msg.classList.contains("filtered-by-type"), "element is filtered");
    79   }).then(finishTest);
    80 }

mercurial