|
1 /* Any copyright is dedicated to the Public Domain. |
|
2 * http://creativecommons.org/publicdomain/zero/1.0/ */ |
|
3 |
|
4 // Test for the message timestamps option: check if the preference toggles the |
|
5 // display of messages in the console output. See bug 722267. |
|
6 |
|
7 function test() |
|
8 { |
|
9 const PREF_MESSAGE_TIMESTAMP = "devtools.webconsole.timestampMessages"; |
|
10 let hud; |
|
11 |
|
12 registerCleanupFunction(() => { |
|
13 Services.prefs.clearUserPref(PREF_MESSAGE_TIMESTAMP); |
|
14 }); |
|
15 |
|
16 addTab("data:text/html;charset=utf-8,Web Console test for bug 722267 - " + |
|
17 "preference for toggling timestamps in messages"); |
|
18 |
|
19 browser.addEventListener("load", function tabLoad() { |
|
20 browser.removeEventListener("load", tabLoad, true); |
|
21 openConsole(null, consoleOpened); |
|
22 }, true); |
|
23 |
|
24 function consoleOpened(aHud) |
|
25 { |
|
26 hud = aHud; |
|
27 |
|
28 info("console opened"); |
|
29 let prefValue = Services.prefs.getBoolPref(PREF_MESSAGE_TIMESTAMP); |
|
30 ok(!prefValue, "messages have no timestamp by default (pref check)"); |
|
31 ok(hud.outputNode.classList.contains("hideTimestamps"), |
|
32 "messages have no timestamp (class name check)"); |
|
33 |
|
34 let toolbox = gDevTools.getToolbox(hud.target); |
|
35 toolbox.selectTool("options").then(onOptionsPanelSelected); |
|
36 } |
|
37 |
|
38 function onOptionsPanelSelected(panel) |
|
39 { |
|
40 info("options panel opened"); |
|
41 |
|
42 gDevTools.once("pref-changed", onPrefChanged); |
|
43 |
|
44 let checkbox = panel.panelDoc.getElementById("webconsole-timestamp-messages"); |
|
45 checkbox.click(); |
|
46 } |
|
47 |
|
48 function onPrefChanged() |
|
49 { |
|
50 info("pref changed"); |
|
51 let prefValue = Services.prefs.getBoolPref(PREF_MESSAGE_TIMESTAMP); |
|
52 ok(prefValue, "messages have timestamps (pref check)"); |
|
53 ok(!hud.outputNode.classList.contains("hideTimestamps"), |
|
54 "messages have timestamps (class name check)"); |
|
55 finishTest(); |
|
56 } |
|
57 } |