michael@0: /* Any copyright is dedicated to the Public Domain. michael@0: * http://creativecommons.org/publicdomain/zero/1.0/ */ michael@0: michael@0: // Test for the message timestamps option: check if the preference toggles the michael@0: // display of messages in the console output. See bug 722267. michael@0: michael@0: function test() michael@0: { michael@0: const PREF_MESSAGE_TIMESTAMP = "devtools.webconsole.timestampMessages"; michael@0: let hud; michael@0: michael@0: registerCleanupFunction(() => { michael@0: Services.prefs.clearUserPref(PREF_MESSAGE_TIMESTAMP); michael@0: }); michael@0: michael@0: addTab("data:text/html;charset=utf-8,Web Console test for bug 722267 - " + michael@0: "preference for toggling timestamps in messages"); michael@0: michael@0: browser.addEventListener("load", function tabLoad() { michael@0: browser.removeEventListener("load", tabLoad, true); michael@0: openConsole(null, consoleOpened); michael@0: }, true); michael@0: michael@0: function consoleOpened(aHud) michael@0: { michael@0: hud = aHud; michael@0: michael@0: info("console opened"); michael@0: let prefValue = Services.prefs.getBoolPref(PREF_MESSAGE_TIMESTAMP); michael@0: ok(!prefValue, "messages have no timestamp by default (pref check)"); michael@0: ok(hud.outputNode.classList.contains("hideTimestamps"), michael@0: "messages have no timestamp (class name check)"); michael@0: michael@0: let toolbox = gDevTools.getToolbox(hud.target); michael@0: toolbox.selectTool("options").then(onOptionsPanelSelected); michael@0: } michael@0: michael@0: function onOptionsPanelSelected(panel) michael@0: { michael@0: info("options panel opened"); michael@0: michael@0: gDevTools.once("pref-changed", onPrefChanged); michael@0: michael@0: let checkbox = panel.panelDoc.getElementById("webconsole-timestamp-messages"); michael@0: checkbox.click(); michael@0: } michael@0: michael@0: function onPrefChanged() michael@0: { michael@0: info("pref changed"); michael@0: let prefValue = Services.prefs.getBoolPref(PREF_MESSAGE_TIMESTAMP); michael@0: ok(prefValue, "messages have timestamps (pref check)"); michael@0: ok(!hud.outputNode.classList.contains("hideTimestamps"), michael@0: "messages have timestamps (class name check)"); michael@0: finishTest(); michael@0: } michael@0: }