1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/browser/devtools/webconsole/test/browser_webconsole_expandable_timestamps.js Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,57 @@ 1.4 +/* Any copyright is dedicated to the Public Domain. 1.5 + * http://creativecommons.org/publicdomain/zero/1.0/ */ 1.6 + 1.7 +// Test for the message timestamps option: check if the preference toggles the 1.8 +// display of messages in the console output. See bug 722267. 1.9 + 1.10 +function test() 1.11 +{ 1.12 + const PREF_MESSAGE_TIMESTAMP = "devtools.webconsole.timestampMessages"; 1.13 + let hud; 1.14 + 1.15 + registerCleanupFunction(() => { 1.16 + Services.prefs.clearUserPref(PREF_MESSAGE_TIMESTAMP); 1.17 + }); 1.18 + 1.19 + addTab("data:text/html;charset=utf-8,Web Console test for bug 722267 - " + 1.20 + "preference for toggling timestamps in messages"); 1.21 + 1.22 + browser.addEventListener("load", function tabLoad() { 1.23 + browser.removeEventListener("load", tabLoad, true); 1.24 + openConsole(null, consoleOpened); 1.25 + }, true); 1.26 + 1.27 + function consoleOpened(aHud) 1.28 + { 1.29 + hud = aHud; 1.30 + 1.31 + info("console opened"); 1.32 + let prefValue = Services.prefs.getBoolPref(PREF_MESSAGE_TIMESTAMP); 1.33 + ok(!prefValue, "messages have no timestamp by default (pref check)"); 1.34 + ok(hud.outputNode.classList.contains("hideTimestamps"), 1.35 + "messages have no timestamp (class name check)"); 1.36 + 1.37 + let toolbox = gDevTools.getToolbox(hud.target); 1.38 + toolbox.selectTool("options").then(onOptionsPanelSelected); 1.39 + } 1.40 + 1.41 + function onOptionsPanelSelected(panel) 1.42 + { 1.43 + info("options panel opened"); 1.44 + 1.45 + gDevTools.once("pref-changed", onPrefChanged); 1.46 + 1.47 + let checkbox = panel.panelDoc.getElementById("webconsole-timestamp-messages"); 1.48 + checkbox.click(); 1.49 + } 1.50 + 1.51 + function onPrefChanged() 1.52 + { 1.53 + info("pref changed"); 1.54 + let prefValue = Services.prefs.getBoolPref(PREF_MESSAGE_TIMESTAMP); 1.55 + ok(prefValue, "messages have timestamps (pref check)"); 1.56 + ok(!hud.outputNode.classList.contains("hideTimestamps"), 1.57 + "messages have timestamps (class name check)"); 1.58 + finishTest(); 1.59 + } 1.60 +}