Commit 7e6e3186 authored by Alexandre Poirot's avatar Alexandre Poirot
Browse files

Bug 1825509 - [devtools] Remember JS tracing log method across restart....

Bug 1825509 - [devtools] Remember JS tracing log method across restart. r=devtools-reviewers,nchevobbe

The log method being choosed in the context menu wasn't saved in a preference,
so that you have to pick STDOUT on each new firefox restart.

Differential Revision: https://phabricator.services.mozilla.com/D174096
parent 15624fe2
Loading
Loading
Loading
Loading
+9 −0
Original line number Diff line number Diff line
@@ -237,3 +237,12 @@ export function copyToClipboard(location) {
    }
  };
}

export function setJavascriptTracingLogMethod(value) {
  return ({ dispatch, getState }) => {
    dispatch({
      type: "SET_JAVASCRIPT_TRACING_LOG_METHOD",
      value,
    });
  };
}
+12 −13
Original line number Diff line number Diff line
@@ -17,6 +17,7 @@ import {
  getIsCurrentThreadPaused,
  getIsThreadCurrentlyTracing,
  getSupportsJavascriptTracing,
  getJavascriptTracingLogMethod,
} from "../../selectors";
import { formatKeyShortcut } from "../../utils/text";
import actions from "../../actions";
@@ -86,9 +87,7 @@ class CommandBar extends Component {
  constructor() {
    super();

    this.state = {
      logMethod: LOG_METHODS.CONSOLE,
    };
    this.state = {};
  }
  static get propTypes() {
    return {
@@ -111,6 +110,8 @@ class CommandBar extends Component {
      toggleSourceMapsEnabled: PropTypes.func.isRequired,
      topFrameSelected: PropTypes.bool.isRequired,
      toggleTracing: PropTypes.func.isRequired,
      logMethod: PropTypes.string.isRequired,
      setJavascriptTracingLogMethod: PropTypes.func.isRequired,
    };
  }

@@ -204,10 +205,10 @@ class CommandBar extends Component {
        title={
          this.props.isTracingEnabled
            ? L10N.getStr("stopTraceButtonTooltip")
            : L10N.getFormatStr("startTraceButtonTooltip", this.state.logMethod)
            : L10N.getFormatStr("startTraceButtonTooltip", this.props.logMethod)
        }
        onClick={event => {
          this.props.toggleTracing(this.state.logMethod);
          this.props.toggleTracing(this.props.logMethod);
        }}
        onContextMenu={event => {
          event.preventDefault();
@@ -222,21 +223,17 @@ class CommandBar extends Component {
            {
              id: "debugger-trace-menu-item-console",
              label: L10N.getStr("traceInWebConsole"),
              checked: this.state.logMethod == LOG_METHODS.CONSOLE,
              checked: this.props.logMethod == LOG_METHODS.CONSOLE,
              click: () => {
                this.setState({
                  logMethod: LOG_METHODS.CONSOLE,
                });
                this.props.setJavascriptTracingLogMethod(LOG_METHODS.CONSOLE);
              },
            },
            {
              id: "debugger-trace-menu-item-stdout",
              label: L10N.getStr("traceInStdout"),
              checked: this.state.logMethod == LOG_METHODS.STDOUT,
              checked: this.props.logMethod == LOG_METHODS.STDOUT,
              click: () => {
                this.setState({
                  logMethod: LOG_METHODS.STDOUT,
                });
                this.props.setJavascriptTracingLogMethod(LOG_METHODS.STDOUT);
              },
            },
          ];
@@ -390,10 +387,12 @@ const mapStateToProps = state => ({
  isPaused: getIsCurrentThreadPaused(state),
  isTracingEnabled: getIsThreadCurrentlyTracing(state, getCurrentThread(state)),
  supportsJavascriptTracing: getSupportsJavascriptTracing(state),
  logMethod: getJavascriptTracingLogMethod(state),
});

export default connect(mapStateToProps, {
  toggleTracing: actions.toggleTracing,
  setJavascriptTracingLogMethod: actions.setJavascriptTracingLogMethod,
  resume: actions.resume,
  stepIn: actions.stepIn,
  stepOut: actions.stepOut,
+6 −0
Original line number Diff line number Diff line
@@ -28,6 +28,7 @@ export const initialUIState = ({ supportsJavascriptTracing = false } = {}) => ({
  editorWrappingEnabled: prefs.editorWrapping,
  javascriptEnabled: true,
  supportsJavascriptTracing,
  javascriptTracingLogMethod: prefs.javascriptTracingLogMethod,
  mutableSearchOptions: prefs.searchOptions || {
    [searchKeys.FILE_SEARCH]: {
      regexMatch: false,
@@ -141,6 +142,11 @@ function update(state = initialUIState(), action) {
      return { ...state, activeSearch: null, highlightedLineRange: {} };
    }

    case "SET_JAVASCRIPT_TRACING_LOG_METHOD": {
      prefs.javascriptTracingLogMethod = action.value;
      return { ...state, javascriptTracingLogMethod: action.value };
    }

    case "SET_SEARCH_OPTIONS": {
      state.mutableSearchOptions[action.searchKey] = {
        ...state.mutableSearchOptions[action.searchKey],
+4 −0
Original line number Diff line number Diff line
@@ -58,6 +58,10 @@ export function getSupportsJavascriptTracing(state) {
  return state.ui.supportsJavascriptTracing;
}

export function getJavascriptTracingLogMethod(state) {
  return state.ui.javascriptTracingLogMethod;
}

export function getSearchOptions(state, searchKey) {
  return state.ui.mutableSearchOptions[searchKey];
}
+5 −0
Original line number Diff line number Diff line
@@ -44,6 +44,7 @@ if (isNode()) {
  pref("devtools.debugger.skip-pausing", false);
  pref("devtools.debugger.log-actions", true);
  pref("devtools.debugger.log-event-breakpoints", false);
  pref("devtools.debugger.javascript-tracing-log-method", "console");
  pref("devtools.debugger.features.workers", true);
  pref("devtools.debugger.features.async-stepping", false);
  pref("devtools.debugger.features.wasm", true);
@@ -112,6 +113,10 @@ export const prefs = new PrefsHelper("devtools", {
  logActions: ["Bool", "debugger.log-actions"],
  logEventBreakpoints: ["Bool", "debugger.log-event-breakpoints"],
  indentSize: ["Int", "editor.tabsize"],
  javascriptTracingLogMethod: [
    "String",
    "debugger.javascript-tracing-log-method",
  ],
});

// The pref may not be defined. Defaulting to null isn't viable (cursor never blinks).
Loading