Bug 1578772 - Enable/disable replay from Devtools settings. r=bhackett

Differential Revision: https://phabricator.services.mozilla.com/D46162

--HG--
extra : moz-landing-system : lando
This commit is contained in:
Jason Laster 2019-09-17 19:37:00 +00:00
Родитель c136338d72
Коммит 751b6be5a3
4 изменённых файлов: 17 добавлений и 12 удалений

Просмотреть файл

@ -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,
},

Просмотреть файл

@ -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."
);

Просмотреть файл

@ -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(

Просмотреть файл

@ -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;
}