1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/browser/devtools/webconsole/test/browser_console_clear_on_reload.js Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,73 @@ 1.4 +/* 1.5 + * Any copyright is dedicated to the Public Domain. 1.6 + * http://creativecommons.org/publicdomain/zero/1.0/ 1.7 + */ 1.8 + 1.9 +// Check that clear output on page reload works - bug 705921. 1.10 + 1.11 +function test() 1.12 +{ 1.13 + const PREF = "devtools.webconsole.persistlog"; 1.14 + const TEST_URI = "http://example.com/browser/browser/devtools/webconsole/test/test-console.html"; 1.15 + let hud = null; 1.16 + 1.17 + Services.prefs.setBoolPref(PREF, false); 1.18 + registerCleanupFunction(() => Services.prefs.clearUserPref(PREF)); 1.19 + 1.20 + addTab(TEST_URI); 1.21 + 1.22 + browser.addEventListener("load", function onLoad() { 1.23 + browser.removeEventListener("load", onLoad, true); 1.24 + openConsole(null, consoleOpened); 1.25 + }, true); 1.26 + 1.27 + function consoleOpened(aHud) 1.28 + { 1.29 + hud = aHud; 1.30 + ok(hud, "Web Console opened"); 1.31 + 1.32 + hud.jsterm.clearOutput(); 1.33 + content.console.log("foobarz1"); 1.34 + waitForMessages({ 1.35 + webconsole: hud, 1.36 + messages: [{ 1.37 + text: "foobarz1", 1.38 + category: CATEGORY_WEBDEV, 1.39 + severity: SEVERITY_LOG, 1.40 + }], 1.41 + }).then(onConsoleMessage); 1.42 + } 1.43 + 1.44 + function onConsoleMessage() 1.45 + { 1.46 + browser.addEventListener("load", onReload, true); 1.47 + content.location.reload(); 1.48 + } 1.49 + 1.50 + function onReload() 1.51 + { 1.52 + browser.removeEventListener("load", onReload, true); 1.53 + 1.54 + content.console.log("foobarz2"); 1.55 + 1.56 + waitForMessages({ 1.57 + webconsole: hud, 1.58 + messages: [{ 1.59 + text: "test-console.html", 1.60 + category: CATEGORY_NETWORK, 1.61 + }, 1.62 + { 1.63 + text: "foobarz2", 1.64 + category: CATEGORY_WEBDEV, 1.65 + severity: SEVERITY_LOG, 1.66 + }], 1.67 + }).then(onConsoleMessageAfterReload); 1.68 + } 1.69 + 1.70 + function onConsoleMessageAfterReload() 1.71 + { 1.72 + is(hud.outputNode.textContent.indexOf("foobarz1"), -1, 1.73 + "foobarz1 has been removed from output"); 1.74 + finishTest(); 1.75 + } 1.76 +}