Bug 1562839 - Put editor mode behind a pref. r=Honza.
authorNicolas Chevobbe <nchevobbe@mozilla.com>
Wed, 03 Jul 2019 11:14:22 +0000
changeset 481093 5289c222f0d082ea10ef220b698ceeceb74ac2d1
parent 481092 bf2ad1e22a7189ab23532789888351b55afcf0be
child 481094 cab912119d7999d329e3cb06f15ad780547fa119
push id36234
push useropoprus@mozilla.com
push dateThu, 04 Jul 2019 03:31:17 +0000
treeherdermozilla-central@8ad5fbc5b935 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersHonza
bugs1562839
milestone69.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1562839 - Put editor mode behind a pref. r=Honza. Differential Revision: https://phabricator.services.mozilla.com/D36582
devtools/client/preferences/devtools-client.js
devtools/client/webconsole/components/App.js
devtools/client/webconsole/constants.js
devtools/client/webconsole/reducers/prefs.js
devtools/client/webconsole/store.js
devtools/client/webconsole/test/mocha-test-setup.js
devtools/client/webconsole/test/mochitest/browser_jsterm_editor.js
devtools/client/webconsole/test/mochitest/browser_jsterm_editor_enter.js
devtools/client/webconsole/test/mochitest/browser_jsterm_editor_execute.js
devtools/client/webconsole/test/mochitest/browser_jsterm_editor_gutter.js
devtools/client/webconsole/test/mochitest/browser_jsterm_editor_toggle_keyboard_shortcut.js
devtools/client/webconsole/test/mochitest/browser_jsterm_editor_toolbar.js
devtools/client/webconsole/webconsole-wrapper.js
--- a/devtools/client/preferences/devtools-client.js
+++ b/devtools/client/preferences/devtools-client.js
@@ -277,17 +277,24 @@ pref("devtools.webconsole.timestampMessa
 pref("devtools.webconsole.sidebarToggle", true);
 #else
 pref("devtools.webconsole.sidebarToggle", false);
 #endif
 
 // Enable CodeMirror in the JsTerm
 pref("devtools.webconsole.jsterm.codeMirror", true);
 
-// Enable editor mode in the console.
+// Enable editor mode in the console in Nightly builds.
+#if defined(NIGHTLY_BUILD)
+pref("devtools.webconsole.features.editor", true);
+#else
+pref("devtools.webconsole.features.editor", false);
+#endif
+
+// Saved editor mode state in the console.
 pref("devtools.webconsole.input.editor", false);
 
 // Disable the new performance recording panel by default
 pref("devtools.performance.new-panel-enabled", false);
 
 // Enable message grouping in the console, true by default
 pref("devtools.webconsole.groupWarningMessages", true);
 
--- a/devtools/client/webconsole/components/App.js
+++ b/devtools/client/webconsole/components/App.js
@@ -54,46 +54,51 @@ class App extends Component {
       currentReverseSearchEntry: PropTypes.string,
       reverseSearchInputVisible: PropTypes.bool,
       reverseSearchInitialValue: PropTypes.string,
       editorMode: PropTypes.bool,
       hideShowContentMessagesCheckbox: PropTypes.bool,
       sidebarVisible: PropTypes.bool.isRequired,
       filterBarDisplayMode:
         PropTypes.oneOf([...Object.values(FILTERBAR_DISPLAY_MODES)]).isRequired,
+      editorFeatureEnabled: PropTypes.bool.isRequired,
     };
   }
 
   constructor(props) {
     super(props);
 
     this.onClick = this.onClick.bind(this);
     this.onPaste = this.onPaste.bind(this);
     this.onKeyDown = this.onKeyDown.bind(this);
   }
 
   onKeyDown(event) {
     const {
       dispatch,
       webConsoleUI,
+      editorFeatureEnabled,
     } = this.props;
 
     if (
       (!isMacOS && event.key === "F9") ||
       (isMacOS && event.key === "r" && event.ctrlKey === true)
     ) {
       const initialValue = webConsoleUI.jsterm && webConsoleUI.jsterm.getSelectedText();
       dispatch(actions.reverseSearchInputToggle({initialValue}));
       event.stopPropagation();
     }
 
-    if (event.key.toLowerCase() === "b" && (
-      isMacOS && event.metaKey ||
-      !isMacOS && event.ctrlKey
-    )) {
+    if (
+      editorFeatureEnabled &&
+      event.key.toLowerCase() === "b" && (
+        isMacOS && event.metaKey ||
+        !isMacOS && event.ctrlKey
+      )
+    ) {
       event.stopPropagation();
       event.preventDefault();
       dispatch(actions.editorToggle());
     }
   }
 
   onClick(event) {
     const target = event.originalTarget || event.target;
--- a/devtools/client/webconsole/constants.js
+++ b/devtools/client/webconsole/constants.js
@@ -76,16 +76,17 @@ const prefs = {
       MESSAGE_TIMESTAMP: "devtools.webconsole.timestampMessages",
     },
     FEATURES: {
       // We use the same pref to enable the sidebar on webconsole and browser console.
       SIDEBAR_TOGGLE: "devtools.webconsole.sidebarToggle",
       JSTERM_CODE_MIRROR: "devtools.webconsole.jsterm.codeMirror",
       AUTOCOMPLETE: "devtools.webconsole.input.autocomplete",
       GROUP_WARNINGS: "devtools.webconsole.groupWarningMessages",
+      EDITOR: "devtools.webconsole.features.editor",
     },
   },
 };
 
 const FILTERS = {
   CSS: "css",
   DEBUG: "debug",
   ERROR: "error",
--- a/devtools/client/webconsole/reducers/prefs.js
+++ b/devtools/client/webconsole/reducers/prefs.js
@@ -10,16 +10,17 @@ const {
 } = require("devtools/client/webconsole/constants");
 
 const PrefState = (overrides) => Object.freeze(Object.assign({
   logLimit: 1000,
   sidebarToggle: false,
   jstermCodeMirror: false,
   groupWarnings: false,
   historyCount: 50,
+  editor: false,
 }, overrides));
 
 function prefs(state = PrefState(), action) {
   if (action.type === WARNING_GROUPS_TOGGLE) {
     return {
       ...state,
       groupWarnings: action.value,
     };
--- a/devtools/client/webconsole/store.js
+++ b/devtools/client/webconsole/store.js
@@ -46,26 +46,28 @@ function configureStore(webConsoleUI, op
   } = prefsService;
 
   const logLimit = options.logLimit
     || Math.max(getIntPref("devtools.hud.loglimit"), 1);
   const sidebarToggle = getBoolPref(PREFS.FEATURES.SIDEBAR_TOGGLE);
   const jstermCodeMirror = getBoolPref(PREFS.FEATURES.JSTERM_CODE_MIRROR);
   const autocomplete = getBoolPref(PREFS.FEATURES.AUTOCOMPLETE);
   const groupWarnings = getBoolPref(PREFS.FEATURES.GROUP_WARNINGS);
+  const editor = getBoolPref(PREFS.FEATURES.EDITOR);
   const historyCount = getIntPref(PREFS.UI.INPUT_HISTORY_COUNT);
 
   const initialState = {
     prefs: PrefState({
       logLimit,
       sidebarToggle,
       jstermCodeMirror,
       autocomplete,
       historyCount,
       groupWarnings,
+      editor,
     }),
     filters: FilterState({
       error: getBoolPref(PREFS.FILTER.ERROR),
       warn: getBoolPref(PREFS.FILTER.WARN),
       info: getBoolPref(PREFS.FILTER.INFO),
       debug: getBoolPref(PREFS.FILTER.DEBUG),
       log: getBoolPref(PREFS.FILTER.LOG),
       css: getBoolPref(PREFS.FILTER.CSS),
--- a/devtools/client/webconsole/test/mocha-test-setup.js
+++ b/devtools/client/webconsole/test/mocha-test-setup.js
@@ -23,16 +23,17 @@ pref("devtools.webconsole.inputHistoryCo
 pref("devtools.webconsole.persistlog", false);
 pref("devtools.webconsole.timestampMessages", false);
 pref("devtools.webconsole.sidebarToggle", true);
 pref("devtools.webconsole.jsterm.codeMirror", true);
 pref("devtools.webconsole.groupWarningMessages", false);
 pref("devtools.webconsole.input.editor", false);
 pref("devtools.webconsole.input.autocomplete", true);
 pref("devtools.browserconsole.contentMessages", true);
+pref("devtools.webconsole.features.editor", true);
 
 global.loader = {
   lazyServiceGetter: () => {},
   lazyGetter: (context, name, fn) => {
 
   },
   lazyRequireGetter: (context, name, path, destruct) => {
     if (path === "devtools/shared/async-storage") {
--- a/devtools/client/webconsole/test/mochitest/browser_jsterm_editor.js
+++ b/devtools/client/webconsole/test/mochitest/browser_jsterm_editor.js
@@ -3,16 +3,17 @@
 
 // Check that the editor is displayed as expected.
 
 "use strict";
 
 const TEST_URI = "data:text/html;charset=utf8,<p>Test editor";
 
 add_task(async function() {
+  await pushPref("devtools.webconsole.features.editor", true);
   // Run test with legacy JsTerm
   await pushPref("devtools.webconsole.jsterm.codeMirror", false);
   await performTests();
 
   // And then run it with the CodeMirror-powered one.
   await pushPref("devtools.webconsole.jsterm.codeMirror", true);
   await performTests();
 });
--- a/devtools/client/webconsole/test/mochitest/browser_jsterm_editor_enter.js
+++ b/devtools/client/webconsole/test/mochitest/browser_jsterm_editor_enter.js
@@ -5,16 +5,17 @@
 // and Enter does not when in editor mode.
 // See https://bugzilla.mozilla.org/show_bug.cgi?id=1519314
 
 "use strict";
 
 const TEST_URI = "data:text/html;charset=utf-8,Web Console test for bug 1519314";
 
 add_task(async function() {
+  await pushPref("devtools.webconsole.features.editor", true);
   await pushPref("devtools.webconsole.input.editor", true);
   // Run test with legacy JsTerm
   await pushPref("devtools.webconsole.jsterm.codeMirror", false);
   await performEditorEnabledTests();
   // And then run it with the CodeMirror-powered one.
   await pushPref("devtools.webconsole.jsterm.codeMirror", true);
   await performEditorEnabledTests();
 });
--- a/devtools/client/webconsole/test/mochitest/browser_jsterm_editor_execute.js
+++ b/devtools/client/webconsole/test/mochitest/browser_jsterm_editor_execute.js
@@ -5,16 +5,17 @@
 // is set to true.
 // See https://bugzilla.mozilla.org/show_bug.cgi?id=1519313
 
 "use strict";
 
 const TEST_URI = "data:text/html;charset=utf-8,Web Console test for bug 1519313";
 
 add_task(async function() {
+  await pushPref("devtools.webconsole.features.editor", true);
   await pushPref("devtools.webconsole.input.editor", true);
   // Run test with legacy JsTerm
   await pushPref("devtools.webconsole.jsterm.codeMirror", false);
   await performTests();
   // And then run it with the CodeMirror-powered one.
   await pushPref("devtools.webconsole.jsterm.codeMirror", true);
   await performTests();
 });
--- a/devtools/client/webconsole/test/mochitest/browser_jsterm_editor_gutter.js
+++ b/devtools/client/webconsole/test/mochitest/browser_jsterm_editor_gutter.js
@@ -5,16 +5,17 @@
 // 'devtools.webconsole.input.editor' is true.
 // See https://bugzilla.mozilla.org/show_bug.cgi?id=1519315
 
 "use strict";
 
 const TEST_URI = "data:text/html;charset=utf-8,Test JsTerm editor line gutters";
 
 add_task(async function() {
+  await pushPref("devtools.webconsole.features.editor", true);
   await pushPref("devtools.webconsole.input.editor", true);
 
   const hud = await openNewTabAndConsole(TEST_URI);
 
   info("Check that the line numbers gutter is rendered when in editor layout");
   ok(getLineNumbersGutterElement(hud),
     "line numbers gutter is rendered on the input when in editor mode.");
 
--- a/devtools/client/webconsole/test/mochitest/browser_jsterm_editor_toggle_keyboard_shortcut.js
+++ b/devtools/client/webconsole/test/mochitest/browser_jsterm_editor_toggle_keyboard_shortcut.js
@@ -5,16 +5,17 @@
 // See https://bugzilla.mozilla.org/show_bug.cgi?id=1519105
 
 "use strict";
 
 const TEST_URI = "data:text/html;charset=utf-8,Test editor mode toggle keyboard shortcut";
 const EDITOR_PREF = "devtools.webconsole.input.editor";
 
 add_task(async function() {
+  await pushPref("devtools.webconsole.features.editor", true);
   await pushPref("devtools.webconsole.input.editor", true);
   // Run test with legacy JsTerm
   info("Test legacy JsTerm");
   await pushPref("devtools.webconsole.jsterm.codeMirror", false);
   await performTest();
 
   // And then run it with the CodeMirror-powered one.
   info("Test codeMirror JsTerm");
--- a/devtools/client/webconsole/test/mochitest/browser_jsterm_editor_toolbar.js
+++ b/devtools/client/webconsole/test/mochitest/browser_jsterm_editor_toolbar.js
@@ -3,16 +3,17 @@
 
 // Check that the editor toolbar works as expected when in editor mode.
 
 "use strict";
 
 const TEST_URI = "data:text/html;charset=utf8,<p>Test editor toolbar";
 
 add_task(async function() {
+  await pushPref("devtools.webconsole.features.editor", true);
   // Run test with legacy JsTerm
   await pushPref("devtools.webconsole.jsterm.codeMirror", false);
   await performTests();
 
   // And then run it with the CodeMirror-powered one.
   await pushPref("devtools.webconsole.jsterm.codeMirror", true);
   await performTests();
 });
--- a/devtools/client/webconsole/webconsole-wrapper.js
+++ b/devtools/client/webconsole/webconsole-wrapper.js
@@ -353,16 +353,17 @@ class WebConsoleWrapper {
         telemetry: this.telemetry,
         services: serviceContainer,
       });
 
       const {prefs} = store.getState();
       const jstermCodeMirror = prefs.jstermCodeMirror
         && !Services.appinfo.accessibilityEnabled;
       const autocomplete = prefs.autocomplete;
+      const editorFeatureEnabled = prefs.editor;
 
       this.prefsObservers = new Map();
       this.prefsObservers.set(PREFS.UI.MESSAGE_TIMESTAMP, () => {
         const enabled = Services.prefs.getBoolPref(PREFS.UI.MESSAGE_TIMESTAMP);
         store.dispatch(actions.timestampsToggle(enabled));
       });
 
       this.prefsObservers.set(PREFS.FEATURES.GROUP_WARNINGS, () => {
@@ -376,16 +377,17 @@ class WebConsoleWrapper {
 
       const app = App({
         serviceContainer,
         webConsoleUI,
         onFirstMeaningfulPaint: resolve,
         closeSplitConsole: this.closeSplitConsole.bind(this),
         jstermCodeMirror,
         autocomplete,
+        editorFeatureEnabled,
         hideShowContentMessagesCheckbox: !webConsoleUI.isBrowserConsole,
       });
 
       // Render the root Application component.
       if (this.parentNode) {
         const provider = createElement(Provider, { store }, app);
         this.body = ReactDOM.render(provider, this.parentNode);
       } else {