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.

michael@0 1 /*
michael@0 2 * Any copyright is dedicated to the Public Domain.
michael@0 3 * http://creativecommons.org/publicdomain/zero/1.0/
michael@0 4 */
michael@0 5
michael@0 6 // Check that clear output on page reload works - bug 705921.
michael@0 7
michael@0 8 function test()
michael@0 9 {
michael@0 10 const PREF = "devtools.webconsole.persistlog";
michael@0 11 const TEST_URI = "http://example.com/browser/browser/devtools/webconsole/test/test-console.html";
michael@0 12 let hud = null;
michael@0 13
michael@0 14 Services.prefs.setBoolPref(PREF, false);
michael@0 15 registerCleanupFunction(() => Services.prefs.clearUserPref(PREF));
michael@0 16
michael@0 17 addTab(TEST_URI);
michael@0 18
michael@0 19 browser.addEventListener("load", function onLoad() {
michael@0 20 browser.removeEventListener("load", onLoad, true);
michael@0 21 openConsole(null, consoleOpened);
michael@0 22 }, true);
michael@0 23
michael@0 24 function consoleOpened(aHud)
michael@0 25 {
michael@0 26 hud = aHud;
michael@0 27 ok(hud, "Web Console opened");
michael@0 28
michael@0 29 hud.jsterm.clearOutput();
michael@0 30 content.console.log("foobarz1");
michael@0 31 waitForMessages({
michael@0 32 webconsole: hud,
michael@0 33 messages: [{
michael@0 34 text: "foobarz1",
michael@0 35 category: CATEGORY_WEBDEV,
michael@0 36 severity: SEVERITY_LOG,
michael@0 37 }],
michael@0 38 }).then(onConsoleMessage);
michael@0 39 }
michael@0 40
michael@0 41 function onConsoleMessage()
michael@0 42 {
michael@0 43 browser.addEventListener("load", onReload, true);
michael@0 44 content.location.reload();
michael@0 45 }
michael@0 46
michael@0 47 function onReload()
michael@0 48 {
michael@0 49 browser.removeEventListener("load", onReload, true);
michael@0 50
michael@0 51 content.console.log("foobarz2");
michael@0 52
michael@0 53 waitForMessages({
michael@0 54 webconsole: hud,
michael@0 55 messages: [{
michael@0 56 text: "test-console.html",
michael@0 57 category: CATEGORY_NETWORK,
michael@0 58 },
michael@0 59 {
michael@0 60 text: "foobarz2",
michael@0 61 category: CATEGORY_WEBDEV,
michael@0 62 severity: SEVERITY_LOG,
michael@0 63 }],
michael@0 64 }).then(onConsoleMessageAfterReload);
michael@0 65 }
michael@0 66
michael@0 67 function onConsoleMessageAfterReload()
michael@0 68 {
michael@0 69 is(hud.outputNode.textContent.indexOf("foobarz1"), -1,
michael@0 70 "foobarz1 has been removed from output");
michael@0 71 finishTest();
michael@0 72 }
michael@0 73 }

mercurial