browser/devtools/webconsole/test/browser_console_clear_on_reload.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 clear output on page reload works - bug 705921.
     8 function test()
     9 {
    10   const PREF = "devtools.webconsole.persistlog";
    11   const TEST_URI = "http://example.com/browser/browser/devtools/webconsole/test/test-console.html";
    12   let hud = null;
    14   Services.prefs.setBoolPref(PREF, false);
    15   registerCleanupFunction(() => Services.prefs.clearUserPref(PREF));
    17   addTab(TEST_URI);
    19   browser.addEventListener("load", function onLoad() {
    20     browser.removeEventListener("load", onLoad, true);
    21     openConsole(null, consoleOpened);
    22   }, true);
    24   function consoleOpened(aHud)
    25   {
    26     hud = aHud;
    27     ok(hud, "Web Console opened");
    29     hud.jsterm.clearOutput();
    30     content.console.log("foobarz1");
    31     waitForMessages({
    32       webconsole: hud,
    33       messages: [{
    34         text: "foobarz1",
    35         category: CATEGORY_WEBDEV,
    36         severity: SEVERITY_LOG,
    37       }],
    38     }).then(onConsoleMessage);
    39   }
    41   function onConsoleMessage()
    42   {
    43     browser.addEventListener("load", onReload, true);
    44     content.location.reload();
    45   }
    47   function onReload()
    48   {
    49     browser.removeEventListener("load", onReload, true);
    51     content.console.log("foobarz2");
    53     waitForMessages({
    54       webconsole: hud,
    55       messages: [{
    56         text: "test-console.html",
    57         category: CATEGORY_NETWORK,
    58       },
    59       {
    60         text: "foobarz2",
    61         category: CATEGORY_WEBDEV,
    62         severity: SEVERITY_LOG,
    63       }],
    64     }).then(onConsoleMessageAfterReload);
    65   }
    67   function onConsoleMessageAfterReload()
    68   {
    69     is(hud.outputNode.textContent.indexOf("foobarz1"), -1,
    70        "foobarz1 has been removed from output");
    71     finishTest();
    72   }
    73 }

mercurial