From 751b6be5a3241861e63e3e95acbf36ca88293e85 Mon Sep 17 00:00:00 2001 From: Jason Laster Date: Tue, 17 Sep 2019 19:37:00 +0000 Subject: [PATCH] Bug 1578772 - Enable/disable replay from Devtools settings. r=bhackett Differential Revision: https://phabricator.services.mozilla.com/D46162 --HG-- extra : moz-landing-system : lando --- devtools/client/definitions.js | 10 ++-------- .../test/browser_toolbox_options_disable_buttons.js | 4 ++-- devtools/client/framework/toolbox-options.js | 8 +++++++- devtools/client/framework/toolbox.js | 7 ++++++- 4 files changed, 17 insertions(+), 12 deletions(-) diff --git a/devtools/client/definitions.js b/devtools/client/definitions.js index e0ecb02511e6..0df0ced3374f 100644 --- a/devtools/client/definitions.js +++ b/devtools/client/definitions.js @@ -556,20 +556,14 @@ exports.ToolboxButtons = [ { id: "command-button-replay", description: l10n("toolbox.buttons.replay"), - isTargetSupported: target => - Services.prefs.getBoolPref("devtools.recordreplay.mvp.enabled") && - !target.canRewind && - target.isLocalTab, + isTargetSupported: target => !target.canRewind && target.isLocalTab, onClick: () => reloadAndRecordTab(), isChecked: () => false, }, { id: "command-button-stop-replay", description: l10n("toolbox.buttons.stopReplay"), - isTargetSupported: target => - Services.prefs.getBoolPref("devtools.recordreplay.mvp.enabled") && - target.canRewind && - target.isLocalTab, + isTargetSupported: target => target.canRewind && target.isLocalTab, onClick: () => reloadAndStopRecordingTab(), isChecked: () => true, }, diff --git a/devtools/client/framework/test/browser_toolbox_options_disable_buttons.js b/devtools/client/framework/test/browser_toolbox_options_disable_buttons.js index 7fa04267d92c..ded172686f7d 100644 --- a/devtools/client/framework/test/browser_toolbox_options_disable_buttons.js +++ b/devtools/client/framework/test/browser_toolbox_options_disable_buttons.js @@ -130,9 +130,9 @@ function testToggleToolboxButtons() { const toolbarButtonNodes = [...doc.querySelectorAll(".command-button")]; - // NOTE: the web-replay buttons are not checkboxes + // NOTE: the web-replay buttons only appear if the feature is enabled. is( - checkNodes.length + 2, + checkNodes.length + 1, toolbox.toolbarButtons.length, "All of the buttons are toggleable." ); diff --git a/devtools/client/framework/toolbox-options.js b/devtools/client/framework/toolbox-options.js index c2f31a378120..1154a0628b22 100644 --- a/devtools/client/framework/toolbox-options.js +++ b/devtools/client/framework/toolbox-options.js @@ -181,6 +181,7 @@ OptionsPanel.prototype = { const commandButton = toolbarButtons.filter( toggleableButton => toggleableButton.id === checkbox.id )[0]; + Services.prefs.setBoolPref( commandButton.visibilityswitch, checkbox.checked @@ -195,7 +196,12 @@ OptionsPanel.prototype = { const checkboxInput = this.panelDoc.createElement("input"); checkboxInput.setAttribute("type", "checkbox"); checkboxInput.setAttribute("id", button.id); - if (Services.prefs.getBoolPref(button.visibilityswitch, true)) { + const defaultValue = + button.id !== "command-button-replay" + ? true + : Services.prefs.getBoolPref("devtools.recordreplay.mvp.enabled"); + + if (Services.prefs.getBoolPref(button.visibilityswitch, defaultValue)) { checkboxInput.setAttribute("checked", true); } checkboxInput.addEventListener( diff --git a/devtools/client/framework/toolbox.js b/devtools/client/framework/toolbox.js index e9bc72c7b629..0c98ed951efa 100644 --- a/devtools/client/framework/toolbox.js +++ b/devtools/client/framework/toolbox.js @@ -2014,7 +2014,12 @@ Toolbox.prototype = { _commandIsVisible: function(button) { const { isTargetSupported, isCurrentlyVisible, visibilityswitch } = button; - if (!Services.prefs.getBoolPref(visibilityswitch, true)) { + const defaultValue = + button.id !== "command-button-replay" + ? true + : Services.prefs.getBoolPref("devtools.recordreplay.mvp.enabled"); + + if (!Services.prefs.getBoolPref(visibilityswitch, defaultValue)) { return false; }