diff --git a/devtools/client/framework/devtools.js b/devtools/client/framework/devtools.js index fdb145dea348..df69146111db 100644 --- a/devtools/client/framework/devtools.js +++ b/devtools/client/framework/devtools.js @@ -318,14 +318,6 @@ DevTools.prototype = { theme.id == currTheme) { Services.prefs.setCharPref("devtools.theme", "light"); - let data = { - pref: "devtools.theme", - newValue: "light", - oldValue: currTheme - }; - - this.emit("pref-changed", data); - this.emit("theme-unregistered", theme); } diff --git a/devtools/client/framework/test/browser_toolbox_options.js b/devtools/client/framework/test/browser_toolbox_options.js index d86111d8952e..57430cefa080 100644 --- a/devtools/client/framework/test/browser_toolbox_options.js +++ b/devtools/client/framework/test/browser_toolbox_options.js @@ -12,6 +12,7 @@ var doc = null, toolbox = null, panelWin = null, modifiedPrefs = []; const {LocalizationHelper} = require("devtools/shared/l10n"); const L10N = new LocalizationHelper("devtools/client/locales/toolbox.properties"); +const {PrefObserver} = require("devtools/client/shared/prefs"); add_task(function* () { const URL = "data:text/html;charset=utf8,test for dynamically registering " + @@ -151,14 +152,13 @@ function* testSelect(select) { continue; } + let observer = new PrefObserver("devtools."); + let deferred = defer(); - gDevTools.once("pref-changed", (event, data) => { - if (data.pref == pref) { - ok(true, "Correct pref was changed"); - is(GetPref(pref), option.value, "Preference been switched for " + pref); - } else { - ok(false, "Pref " + pref + " was not changed correctly"); - } + let changeSeen = false; + observer.once(pref, () => { + changeSeen = true; + is(GetPref(pref), option.value, "Preference been switched for " + pref); deferred.resolve(); }); @@ -167,21 +167,22 @@ function* testSelect(select) { select.dispatchEvent(changeEvent); yield deferred.promise; + + ok(changeSeen, "Correct pref was changed"); + observer.destroy(); } } function* testMouseClick(node, prefValue) { let deferred = defer(); + let observer = new PrefObserver("devtools."); + let pref = node.getAttribute("data-pref"); - gDevTools.once("pref-changed", (event, data) => { - if (data.pref == pref) { - ok(true, "Correct pref was changed"); - is(data.oldValue, prefValue, "Previous value is correct for " + pref); - is(data.newValue, !prefValue, "New value is correct for " + pref); - } else { - ok(false, "Pref " + pref + " was not changed correctly"); - } + let changeSeen = false; + observer.once(pref, () => { + changeSeen = true; + is(GetPref(pref), !prefValue, "New value is correct for " + pref); deferred.resolve(); }); @@ -195,6 +196,9 @@ function* testMouseClick(node, prefValue) { }); yield deferred.promise; + + ok(changeSeen, "Correct pref was changed"); + observer.destroy(); } function* testToggleTools() { diff --git a/devtools/client/framework/toolbox-options.js b/devtools/client/framework/toolbox-options.js index f3c31d10471b..80d377854347 100644 --- a/devtools/client/framework/toolbox-options.js +++ b/devtools/client/framework/toolbox-options.js @@ -275,7 +275,7 @@ OptionsPanel.prototype = { inputRadio.setAttribute("value", theme.id); inputRadio.setAttribute("name", "devtools-theme-item"); inputRadio.addEventListener("change", function (e) { - setPrefAndEmit(themeBox.getAttribute("data-pref"), + SetPref(themeBox.getAttribute("data-pref"), e.target.value); }); @@ -305,7 +305,7 @@ OptionsPanel.prototype = { } prefCheckbox.addEventListener("change", function (e) { let checkbox = e.target; - setPrefAndEmit(checkbox.getAttribute("data-pref"), checkbox.checked); + SetPref(checkbox.getAttribute("data-pref"), checkbox.checked); }); } // Themes radio inputs are handled in setupThemeList @@ -320,7 +320,7 @@ OptionsPanel.prototype = { } radioInput.addEventListener("change", function (e) { - setPrefAndEmit(radioGroup.getAttribute("data-pref"), + SetPref(radioGroup.getAttribute("data-pref"), e.target.value); }); } @@ -340,7 +340,7 @@ OptionsPanel.prototype = { prefSelect.addEventListener("change", function (e) { let select = e.target; - setPrefAndEmit(select.getAttribute("data-pref"), + SetPref(select.getAttribute("data-pref"), select.options[select.selectedIndex].value); }); } @@ -422,17 +422,3 @@ OptionsPanel.prototype = { return this.destroyPromise; } }; - -/* Set a pref and emit the pref-changed event if needed. */ -function setPrefAndEmit(prefName, newValue) { - let data = { - pref: prefName, - newValue: newValue - }; - data.oldValue = GetPref(data.pref); - SetPref(data.pref, data.newValue); - - if (data.newValue != data.oldValue) { - gDevTools.emit("pref-changed", data); - } -} diff --git a/devtools/client/framework/toolbox.js b/devtools/client/framework/toolbox.js index efbae90bf5b6..b4a0c05ce200 100644 --- a/devtools/client/framework/toolbox.js +++ b/devtools/client/framework/toolbox.js @@ -113,7 +113,9 @@ function Toolbox(target, selectedTool, hostType, contentWindow, frameId) { this.highlighterUtils = getHighlighterUtils(this); this._highlighterReady = this._highlighterReady.bind(this); this._highlighterHidden = this._highlighterHidden.bind(this); - this._prefChanged = this._prefChanged.bind(this); + this._applyCacheSettings = this._applyCacheSettings.bind(this); + this._applyServiceWorkersTestingSettings = + this._applyServiceWorkersTestingSettings.bind(this); this._saveSplitConsoleHeight = this._saveSplitConsoleHeight.bind(this); this._onFocus = this._onFocus.bind(this); this._onBrowserMessage = this._onBrowserMessage.bind(this); @@ -367,7 +369,10 @@ Toolbox.prototype = { this.closeButton = this.doc.getElementById("toolbox-close"); this.closeButton.addEventListener("click", this.destroy, true); - gDevTools.on("pref-changed", this._prefChanged); + Services.prefs.addObserver("devtools.cache.disabled", this._applyCacheSettings, + false); + Services.prefs.addObserver("devtools.serviceWorkers.testing.enabled", + this._applyServiceWorkersTestingSettings, false); let framesMenu = this.doc.getElementById("command-button-frames"); framesMenu.addEventListener("click", this.showFramesMenu, false); @@ -485,29 +490,6 @@ Toolbox.prototype = { this._telemetry.log(HOST_HISTOGRAM, this._getTelemetryHostId()); }, - /** - * Because our panels are lazy loaded this is a good place to watch for - * "pref-changed" events. - * @param {String} event - * The event type, "pref-changed". - * @param {Object} data - * { - * newValue: The new value - * oldValue: The old value - * pref: The name of the preference that has changed - * } - */ - _prefChanged: function (event, data) { - switch (data.pref) { - case "devtools.cache.disabled": - this._applyCacheSettings(); - break; - case "devtools.serviceWorkers.testing.enabled": - this._applyServiceWorkersTestingSettings(); - break; - } - }, - _buildOptions: function () { let selectOptions = (name, event) => { // Flip back to the last used panel if we are already @@ -2214,7 +2196,9 @@ Toolbox.prototype = { gDevTools.off("tool-registered", this._toolRegistered); gDevTools.off("tool-unregistered", this._toolUnregistered); - gDevTools.off("pref-changed", this._prefChanged); + Services.prefs.removeObserver("devtools.cache.disabled", this._applyCacheSettings); + Services.prefs.removeObserver("devtools.serviceWorkers.testing.enabled", + this._applyServiceWorkersTestingSettings); this._lastFocusedElement = null; if (this._sourceMapService) { diff --git a/devtools/client/inspector/computed/computed.js b/devtools/client/inspector/computed/computed.js index f89c99fdff34..12be8ed03b30 100644 --- a/devtools/client/inspector/computed/computed.js +++ b/devtools/client/inspector/computed/computed.js @@ -198,14 +198,13 @@ function CssComputedView(inspector, document, pageStyle) { // No results text. this.noResults = this.styleDocument.getElementById("computedview-no-results"); - // Refresh panel when color unit changed. + // Refresh panel when color unit changed or pref for showing + // original sources changes. this._handlePrefChange = this._handlePrefChange.bind(this); - gDevTools.on("pref-changed", this._handlePrefChange); - - // Refresh panel when pref for showing original sources changes this._onSourcePrefChanged = this._onSourcePrefChanged.bind(this); this._prefObserver = new PrefObserver("devtools."); this._prefObserver.on(PREF_ORIG_SOURCES, this._onSourcePrefChanged); + this._prefObserver.on("devtools.defaultColorUnit", this._handlePrefChange); // The element that we're inspecting, and the document that it comes from. this._viewedElement = null; @@ -262,8 +261,7 @@ CssComputedView.prototype = { }, _handlePrefChange: function (event, data) { - if (this._computed && (data.pref === "devtools.defaultColorUnit" || - data.pref === PREF_ORIG_SOURCES)) { + if (this._computed) { this.refreshPanel(); } }, @@ -600,6 +598,7 @@ CssComputedView.prototype = { }, _onSourcePrefChanged: function () { + this._handlePrefChange(); for (let propView of this.propertyViews) { propView.updateSourceLinks(); } @@ -734,9 +733,8 @@ CssComputedView.prototype = { this._viewedElement = null; this._outputParser = null; - gDevTools.off("pref-changed", this._handlePrefChange); - this._prefObserver.off(PREF_ORIG_SOURCES, this._onSourcePrefChanged); + this._prefObserver.off("devtools.defaultColorUnit", this._handlePrefChange); this._prefObserver.destroy(); // Cancel tree construction diff --git a/devtools/client/performance/performance-controller.js b/devtools/client/performance/performance-controller.js index e47a0c4010d5..7d2295fa5419 100644 --- a/devtools/client/performance/performance-controller.js +++ b/devtools/client/performance/performance-controller.js @@ -16,7 +16,7 @@ var { loader, require } = BrowserLoaderModule.BrowserLoader({ var { Task } = require("devtools/shared/task"); /* exported Heritage, ViewHelpers, WidgetMethods, setNamedTimeout, clearNamedTimeout */ var { Heritage, ViewHelpers, WidgetMethods, setNamedTimeout, clearNamedTimeout } = require("devtools/client/shared/widgets/view-helpers"); -var { gDevTools } = require("devtools/client/framework/devtools"); +var { PrefObserver } = require("devtools/client/shared/prefs"); // Events emitted by various objects in the panel. var EVENTS = require("devtools/client/performance/events"); @@ -143,7 +143,8 @@ var PerformanceController = { RecordingsView.on(EVENTS.UI_RECORDING_SELECTED, this._onRecordingSelectFromView); DetailsView.on(EVENTS.UI_DETAILS_VIEW_SELECTED, this._pipe); - gDevTools.on("pref-changed", this._onThemeChanged); + this._prefObserver = new PrefObserver("devtools."); + this._prefObserver.on("devtools.theme", this._onThemeChanged); }), /** @@ -163,7 +164,8 @@ var PerformanceController = { RecordingsView.off(EVENTS.UI_RECORDING_SELECTED, this._onRecordingSelectFromView); DetailsView.off(EVENTS.UI_DETAILS_VIEW_SELECTED, this._pipe); - gDevTools.off("pref-changed", this._onThemeChanged); + this._prefObserver.off("devtools.theme", this._onThemeChanged); + this._prefObserver.destroy(); }, /** @@ -402,14 +404,9 @@ var PerformanceController = { /* * Called when the developer tools theme changes. */ - _onThemeChanged: function (_, data) { - // Right now, gDevTools only emits `pref-changed` for the theme, - // but this could change in the future. - if (data.pref !== "devtools.theme") { - return; - } - - this.emit(EVENTS.THEME_CHANGED, data.newValue); + _onThemeChanged: function () { + let newValue = Services.prefs.getCharPref("devtools.theme"); + this.emit(EVENTS.THEME_CHANGED, newValue); }, /** diff --git a/devtools/client/shared/autocomplete-popup.js b/devtools/client/shared/autocomplete-popup.js index 1d24c948ef00..6b44ea528ebe 100644 --- a/devtools/client/shared/autocomplete-popup.js +++ b/devtools/client/shared/autocomplete-popup.js @@ -7,9 +7,9 @@ const HTML_NS = "http://www.w3.org/1999/xhtml"; const Services = require("Services"); -const {gDevTools} = require("devtools/client/framework/devtools"); const {HTMLTooltip} = require("devtools/client/shared/widgets/tooltip/HTMLTooltip"); const EventEmitter = require("devtools/shared/event-emitter"); +const {PrefObserver} = require("devtools/client/shared/prefs"); let itemIdCounter = 0; /** @@ -47,7 +47,9 @@ function AutocompletePopup(toolboxDoc, options = {}) { this.autoThemeEnabled = true; // Setup theme change listener. this._handleThemeChange = this._handleThemeChange.bind(this); - gDevTools.on("pref-changed", this._handleThemeChange); + this._prefObserver = new PrefObserver("devtools."); + this._prefObserver.on("devtools.theme", this._handleThemeChange); + this._currentTheme = theme; } // Create HTMLTooltip instance @@ -194,7 +196,8 @@ AutocompletePopup.prototype = { this._list.removeEventListener("click", this.onClick, false); if (this.autoThemeEnabled) { - gDevTools.off("pref-changed", this._handleThemeChange); + this._prefObserver.off("devtools.theme", this._handleThemeChange); + this._prefObserver.destroy(); } this._list.remove(); @@ -562,25 +565,17 @@ AutocompletePopup.prototype = { /** * Manages theme switching for the popup based on the devtools.theme pref. - * - * @private - * - * @param {String} event - * The name of the event. In this case, "pref-changed". - * @param {Object} data - * An object passed by the emitter of the event. In this case, the - * object consists of three properties: - * - pref {String} The name of the preference that was modified. - * - newValue {Object} The new value of the preference. - * - oldValue {Object} The old value of the preference. */ - _handleThemeChange: function (event, data) { - if (data.pref === "devtools.theme") { - this._tooltip.panel.classList.toggle(data.oldValue + "-theme", false); - this._tooltip.panel.classList.toggle(data.newValue + "-theme", true); - this._list.classList.toggle(data.oldValue + "-theme", false); - this._list.classList.toggle(data.newValue + "-theme", true); - } + _handleThemeChange: function () { + const oldValue = this._currentTheme; + const newValue = Services.prefs.getCharPref("devtools.theme"); + + this._tooltip.panel.classList.toggle(oldValue + "-theme", false); + this._tooltip.panel.classList.toggle(newValue + "-theme", true); + this._list.classList.toggle(oldValue + "-theme", false); + this._list.classList.toggle(newValue + "-theme", true); + + this._currentTheme = newValue; }, /** diff --git a/devtools/client/shared/test/browser_theme.js b/devtools/client/shared/test/browser_theme.js index 174e5aeec93f..c76503487e29 100644 --- a/devtools/client/shared/test/browser_theme.js +++ b/devtools/client/shared/test/browser_theme.js @@ -7,6 +7,7 @@ // Tests that theme utilities work const {getColor, getTheme, setTheme} = require("devtools/client/shared/theme"); +const {PrefObserver} = require("devtools/client/shared/prefs"); add_task(function* () { testGetTheme(); @@ -31,13 +32,14 @@ function testGetTheme() { function testSetTheme() { let originalTheme = getTheme(); - gDevTools.once("pref-changed", (_, { pref, oldValue, newValue }) => { + + let prefObserver = new PrefObserver("devtools."); + prefObserver.once("devtools.theme", pref => { is(pref, "devtools.theme", - "The 'pref-changed' event triggered by setTheme has correct pref."); - is(oldValue, originalTheme, - "The 'pref-changed' event triggered by setTheme has correct oldValue."); + "A preference event triggered by setTheme has correct pref."); + let newValue = Services.prefs.getCharPref("devtools.theme"); is(newValue, "dark", - "The 'pref-changed' event triggered by setTheme has correct newValue."); + "A preference event triggered by setTheme comes after the value is set."); }); setTheme("dark"); is(Services.prefs.getCharPref("devtools.theme"), "dark", @@ -52,6 +54,8 @@ function testSetTheme() { is(Services.prefs.getCharPref("devtools.theme"), "unknown", "setTheme() correctly sets an unknown theme."); Services.prefs.setCharPref("devtools.theme", originalTheme); + + prefObserver.destroy(); } function testGetColor() { diff --git a/devtools/client/shared/theme.js b/devtools/client/shared/theme.js index 6ba956f64be3..8fe9fceef782 100644 --- a/devtools/client/shared/theme.js +++ b/devtools/client/shared/theme.js @@ -10,7 +10,6 @@ */ const Services = require("Services"); -const { gDevTools } = require("devtools/client/framework/devtools"); const variableFileContents = require("raw!devtools/client/themes/variables.css"); @@ -67,18 +66,9 @@ const getColor = exports.getColor = (type, theme) => { }; /** - * Mimics selecting the theme selector in the toolbox; - * sets the preference and emits an event on gDevTools to trigger - * the themeing. + * Set the theme preference. */ const setTheme = exports.setTheme = (newTheme) => { - let oldTheme = getTheme(); - Services.prefs.setCharPref("devtools.theme", newTheme); - gDevTools.emit("pref-changed", { - pref: "devtools.theme", - newValue: newTheme, - oldValue: oldTheme - }); }; /* eslint-enable */ diff --git a/devtools/client/webaudioeditor/controller.js b/devtools/client/webaudioeditor/controller.js index 248a2a6f3524..efefc9c1598f 100644 --- a/devtools/client/webaudioeditor/controller.js +++ b/devtools/client/webaudioeditor/controller.js @@ -2,6 +2,8 @@ * License, v. 2.0. If a copy of the MPL was not distributed with this file, * You can obtain one at http://mozilla.org/MPL/2.0/. */ +const {PrefObserver} = require("devtools/client/shared/prefs"); + /** * A collection of `AudioNodeModel`s used throughout the editor * to keep track of audio nodes within the audio context. @@ -58,7 +60,9 @@ var WebAudioEditorController = { // Hook into theme change so we can change // the graph's marker styling, since we can't do this // with CSS - gDevTools.on("pref-changed", this._onThemeChange); + + this._prefObserver = new PrefObserver(""); + this._prefObserver.on("devtools.theme", this._onThemeChange); // Store the AudioNode definitions from the WebAudioFront, if the method exists. // If not, get the JSON directly. Using the actor method is preferable so the client @@ -90,7 +94,8 @@ var WebAudioEditorController = { gFront.off("disconnect-node", this._onDisconnectNode); gFront.off("change-param", this._onChangeParam); gFront.off("destroy-node", this._onDestroyNode); - gDevTools.off("pref-changed", this._onThemeChange); + this._prefObserver.off("devtools.theme", this._onThemeChange); + this._prefObserver.destroy(); }, /** @@ -129,8 +134,9 @@ var WebAudioEditorController = { * so that the graph can update marker styling, as that * cannot currently be done with CSS. */ - _onThemeChange: function (event, data) { - window.emit(EVENTS.THEME_CHANGE, data.newValue); + _onThemeChange: function () { + let newValue = Services.prefs.getCharPref("devtools.theme"); + window.emit(EVENTS.THEME_CHANGE, newValue); }, /** diff --git a/devtools/client/webconsole/new-console-output/test/mochitest/browser_webconsole_timestamps.js b/devtools/client/webconsole/new-console-output/test/mochitest/browser_webconsole_timestamps.js index 7de7dbe0009c..9866db3e6d7f 100644 --- a/devtools/client/webconsole/new-console-output/test/mochitest/browser_webconsole_timestamps.js +++ b/devtools/client/webconsole/new-console-output/test/mochitest/browser_webconsole_timestamps.js @@ -8,6 +8,8 @@ "use strict"; +const {PrefObserver} = require("devtools/client/shared/prefs"); + const TEST_URI = "data:text/html;charset=utf-8,Web Console test for " + "bug 1307871 - preference for toggling timestamps in messages"; const PREF_MESSAGE_TIMESTAMP = "devtools.webconsole.timestampMessages"; @@ -19,9 +21,11 @@ add_task(function* () { testPrefDefaults(outputEl); + let observer = new PrefObserver(""); let toolbox = gDevTools.getToolbox(hud.target); let optionsPanel = yield toolbox.selectTool("options"); - yield togglePref(optionsPanel); + yield togglePref(optionsPanel, observer); + observer.destroy(); yield testChangedPref(outputEl); @@ -35,13 +39,11 @@ function testPrefDefaults(outputEl) { "Messages should have no timestamp (class name check)"); } -function* togglePref(panel) { +function* togglePref(panel, observer) { info("Options panel opened"); info("Changing pref"); - let prefChanged = new Promise(resolve => { - gDevTools.once("pref-changed", resolve); - }); + let prefChanged = observer.once(PREF_MESSAGE_TIMESTAMP, () => {}); let checkbox = panel.panelDoc.getElementById("webconsole-timestamp-messages"); checkbox.click(); diff --git a/devtools/client/webconsole/test/browser_webconsole_expandable_timestamps.js b/devtools/client/webconsole/test/browser_webconsole_expandable_timestamps.js index 192387e8adea..35ce7d9dd3cd 100644 --- a/devtools/client/webconsole/test/browser_webconsole_expandable_timestamps.js +++ b/devtools/client/webconsole/test/browser_webconsole_expandable_timestamps.js @@ -8,6 +8,8 @@ "use strict"; +const {PrefObserver} = require("devtools/client/shared/prefs"); + const TEST_URI = "data:text/html;charset=utf-8,Web Console test for " + "bug 722267 - preference for toggling timestamps in messages"; const PREF_MESSAGE_TIMESTAMP = "devtools.webconsole.timestampMessages"; @@ -19,8 +21,10 @@ add_task(function* () { hud = yield openConsole(); let panel = yield consoleOpened(); - yield onOptionsPanelSelected(panel); + let observer = new PrefObserver(""); + yield onOptionsPanelSelected(panel, observer); onPrefChanged(); + observer.destroy(); Services.prefs.clearUserPref(PREF_MESSAGE_TIMESTAMP); hud = null; @@ -37,10 +41,10 @@ function consoleOpened() { return toolbox.selectTool("options"); } -function onOptionsPanelSelected(panel) { +function onOptionsPanelSelected(panel, observer) { info("options panel opened"); - let prefChanged = gDevTools.once("pref-changed", onPrefChanged); + let prefChanged = observer.once(PREF_MESSAGE_TIMESTAMP, () => {}); let checkbox = panel.panelDoc.getElementById("webconsole-timestamp-messages"); checkbox.click(); diff --git a/devtools/client/webconsole/webconsole.js b/devtools/client/webconsole/webconsole.js index 236b5f25e9db..214ac4620db6 100644 --- a/devtools/client/webconsole/webconsole.js +++ b/devtools/client/webconsole/webconsole.js @@ -17,6 +17,7 @@ Cu.import("resource://devtools/client/shared/browser-loader.js", BrowserLoaderMo const promise = require("promise"); const Services = require("Services"); const Telemetry = require("devtools/client/shared/telemetry"); +const {PrefObserver} = require("devtools/client/shared/prefs"); loader.lazyServiceGetter(this, "clipboardHelper", "@mozilla.org/widget/clipboardhelper;1", @@ -636,11 +637,9 @@ WebConsoleFrame.prototype = { }); // Toggle the timestamp on preference change - gDevTools.on("pref-changed", this._onToolboxPrefChanged); - this._onToolboxPrefChanged("pref-changed", { - pref: PREF_MESSAGE_TIMESTAMP, - newValue: Services.prefs.getBoolPref(PREF_MESSAGE_TIMESTAMP), - }); + this._prefObserver = new PrefObserver(""); + this._prefObserver.on(PREF_MESSAGE_TIMESTAMP, this._onToolboxPrefChanged); + this._onToolboxPrefChanged(); this._initShortcuts(); @@ -2691,25 +2690,16 @@ WebConsoleFrame.prototype = { }, /** - * Handler for the pref-changed event coming from the toolbox. - * Currently this function only handles the timestamps preferences. - * - * @private - * @param object event - * This parameter is a string that holds the event name - * pref-changed in this case. - * @param object data - * This is the pref-changed data object. - */ - _onToolboxPrefChanged: function (event, data) { - if (data.pref == PREF_MESSAGE_TIMESTAMP) { - if (this.NEW_CONSOLE_OUTPUT_ENABLED) { - this.newConsoleOutput.dispatchTimestampsToggle(data.newValue); - } else if (data.newValue) { - this.outputNode.classList.remove("hideTimestamps"); - } else { - this.outputNode.classList.add("hideTimestamps"); - } + * Called when the message timestamp pref changes. + */ + _onToolboxPrefChanged: function () { + let newValue = Services.prefs.getBoolPref(PREF_MESSAGE_TIMESTAMP); + if (this.NEW_CONSOLE_OUTPUT_ENABLED) { + this.newConsoleOutput.dispatchTimestampsToggle(newValue); + } else if (newValue) { + this.outputNode.classList.remove("hideTimestamps"); + } else { + this.outputNode.classList.add("hideTimestamps"); } }, @@ -2818,7 +2808,8 @@ WebConsoleFrame.prototype = { toolbox.off("webconsole-selected", this._onPanelSelected); } - gDevTools.off("pref-changed", this._onToolboxPrefChanged); + this._prefObserver.off(PREF_MESSAGE_TIMESTAMP, this._onToolboxPrefChanged); + this._prefObserver.destroy(); this.window.removeEventListener("resize", this.resize, true); this._repeatNodes = {};