browser_webconsole_expandable_timestamps.js 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. /* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */
  2. /* Any copyright is dedicated to the Public Domain.
  3. * http://creativecommons.org/publicdomain/zero/1.0/ */
  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. "use strict";
  7. const TEST_URI = "data:text/html;charset=utf-8,Web Console test for " +
  8. "bug 722267 - preference for toggling timestamps in messages";
  9. const PREF_MESSAGE_TIMESTAMP = "devtools.webconsole.timestampMessages";
  10. var hud;
  11. add_task(function* () {
  12. yield loadTab(TEST_URI);
  13. hud = yield openConsole();
  14. let panel = yield consoleOpened();
  15. yield onOptionsPanelSelected(panel);
  16. onPrefChanged();
  17. Services.prefs.clearUserPref(PREF_MESSAGE_TIMESTAMP);
  18. hud = null;
  19. });
  20. function consoleOpened() {
  21. info("console opened");
  22. let prefValue = Services.prefs.getBoolPref(PREF_MESSAGE_TIMESTAMP);
  23. ok(!prefValue, "messages have no timestamp by default (pref check)");
  24. ok(hud.outputNode.classList.contains("hideTimestamps"),
  25. "messages have no timestamp (class name check)");
  26. let toolbox = gDevTools.getToolbox(hud.target);
  27. return toolbox.selectTool("options");
  28. }
  29. function onOptionsPanelSelected(panel) {
  30. info("options panel opened");
  31. let prefChanged = gDevTools.once("pref-changed", onPrefChanged);
  32. let checkbox = panel.panelDoc.getElementById("webconsole-timestamp-messages");
  33. checkbox.click();
  34. return prefChanged;
  35. }
  36. function onPrefChanged() {
  37. info("pref changed");
  38. let prefValue = Services.prefs.getBoolPref(PREF_MESSAGE_TIMESTAMP);
  39. ok(prefValue, "messages have timestamps (pref check)");
  40. ok(!hud.outputNode.classList.contains("hideTimestamps"),
  41. "messages have timestamps (class name check)");
  42. }