Bug 1335037 - add options to toggle new frontend for console/debugger;r=jryans
Add options (available in Nightly/Local builds only) to switch between the old
and new frontends for console and debugger.
MozReview-Commit-ID: 413xt7h9aoP
--- a/devtools/client/framework/toolbox-options.js
+++ b/devtools/client/framework/toolbox-options.js
@@ -9,16 +9,18 @@
const Services = require("Services");
const defer = require("devtools/shared/defer");
const {Task} = require("devtools/shared/task");
const {gDevTools} = require("devtools/client/framework/devtools");
const {LocalizationHelper} = require("devtools/shared/l10n");
const L10N = new LocalizationHelper("devtools/client/locales/toolbox.properties");
+loader.lazyRequireGetter(this, "system", "devtools/shared/system");
+
exports.OptionsPanel = OptionsPanel;
function GetPref(name) {
let type = Services.prefs.getPrefType(name);
switch (type) {
case Services.prefs.PREF_STRING:
return Services.prefs.getCharPref(name);
case Services.prefs.PREF_INT:
@@ -86,16 +88,17 @@ OptionsPanel.prototype = {
// For local debugging we need to make the target remote.
if (!this.target.isRemote) {
yield this.target.makeRemote();
}
this.setupToolsList();
this.setupToolbarButtonsList();
this.setupThemeList();
+ this.setupNightlyOptions();
yield this.populatePreferences();
this.isReady = true;
this.emit("ready");
return this;
}),
_addListeners: function () {
Services.prefs.addObserver("devtools.cache.disabled", this._prefChanged, false);
@@ -297,16 +300,65 @@ OptionsPanel.prototype = {
let themes = gDevTools.getThemeDefinitionArray();
for (let theme of themes) {
themeBox.appendChild(createThemeOption(theme));
}
this.updateCurrentTheme();
},
+ /**
+ * Add common preferences enabled only on Nightly.
+ */
+ setupNightlyOptions: function () {
+ let isNightly = system.constants.NIGHTLY_BUILD;
+ if (!isNightly) {
+ return;
+ }
+
+ // Labels for these new buttons are nightly only and mostly intended for working on
+ // devtools. They should not be localized.
+ let prefDefinitions = [{
+ pref: "devtools.webconsole.new-frontend-enabled",
+ label: "Enable new console frontend",
+ id: "devtools-new-webconsole",
+ parentId: "webconsole-options"
+ }, {
+ pref: "devtools.debugger.new-debugger-frontend",
+ label: "Enable new debugger frontend",
+ id: "devtools-new-debugger",
+ parentId: "debugger-options"
+ }];
+
+ let createPreferenceOption = ({pref, label, id}) => {
+ let inputLabel = this.panelDoc.createElement("label");
+ let checkbox = this.panelDoc.createElement("input");
+ checkbox.setAttribute("type", "checkbox");
+ if (GetPref(pref)) {
+ checkbox.setAttribute("checked", "checked");
+ }
+ checkbox.setAttribute("id", id);
+ checkbox.addEventListener("change", e => {
+ SetPref(pref, e.target.checked);
+ });
+
+ let inputSpanLabel = this.panelDoc.createElement("span");
+ inputSpanLabel.textContent = label;
+ inputLabel.appendChild(checkbox);
+ inputLabel.appendChild(inputSpanLabel);
+
+ return inputLabel;
+ };
+
+ for (let prefDefinition of prefDefinitions) {
+ let parent = this.panelDoc.getElementById(prefDefinition.parentId);
+ parent.appendChild(createPreferenceOption(prefDefinition));
+ }
+ },
+
populatePreferences: function () {
let prefCheckboxes = this.panelDoc.querySelectorAll(
"input[type=checkbox][data-pref]");
for (let prefCheckbox of prefCheckboxes) {
if (GetPref(prefCheckbox.getAttribute("data-pref"))) {
prefCheckbox.setAttribute("checked", true);
}
prefCheckbox.addEventListener("change", function (e) {