fune/devtools/client/webconsole
Alexandre Poirot 573f380baf Bug 1789202 - [devtools] Expose ChromeUtils as a global to all DevTools modules. r=perftest-reviewers,nchevobbe,AlexandruIonescu
This will help transition to ES Modules as this symbol is exposed to them.

$ sed -ie "/require(.ChromeUtils.)/d" $(git grep -l 'require("ChromeUtils")' devtools/)
$ sed -ie "/loader.lazyRequireGetter(this, .ChromeUtils./d" $(git grep -l 'loader.lazyRequireGetter(this, "ChromeUtils"' devtools/)
+ the edition of builtin-modules.js + eslintrc.js + manual eslint fixes

Differential Revision: https://phabricator.services.mozilla.com/D156402
2022-09-09 07:22:51 +00:00
..
actions Bug 1786805 - [devtools] Disable instant evaluation for top-level await expressions. r=jdescottes. 2022-08-26 14:35:12 +00:00
components Bug 1789201 - [devtools] Expose Services as a global to all DevTools modules. r=perftest-reviewers,nchevobbe,julienw,AlexandruIonescu 2022-09-09 07:22:51 +00:00
enhancers Bug 1776145 - [devtools] Remove unnecessary WebConsoleUI additionalProxies. r=ochameau,devtools-backward-compat-reviewers,jdescottes. 2022-07-04 13:27:51 +00:00
middleware Bug 1330099 - Enable object-shorthand eslint rule. r=jdescottes 2022-08-03 14:57:05 +00:00
reducers Bug 1786197 - Turn on ESLint rule for prefer-boolean-length-check for devtools. r=jdescottes 2022-08-26 13:39:34 +00:00
selectors Bug 1775058 - [devtools] Functionality to disable webconsole messages r=nchevobbe 2022-07-04 17:18:50 +00:00
test Bug 1789202 - [devtools] Expose ChromeUtils as a global to all DevTools modules. r=perftest-reviewers,nchevobbe,AlexandruIonescu 2022-09-09 07:22:51 +00:00
utils Bug 1789201 - [devtools] Expose Services as a global to all DevTools modules. r=perftest-reviewers,nchevobbe,julienw,AlexandruIonescu 2022-09-09 07:22:51 +00:00
browser-console-manager.js Bug 1789201 - [devtools] Expose Services as a global to all DevTools modules. r=perftest-reviewers,nchevobbe,julienw,AlexandruIonescu 2022-09-09 07:22:51 +00:00
browser-console.js Bug 1789201 - [devtools] Expose Services as a global to all DevTools modules. r=perftest-reviewers,nchevobbe,julienw,AlexandruIonescu 2022-09-09 07:22:51 +00:00
constants.js Bug 1777253 - [devtools] Remove content messages from console when switching to parent process only mode. r=jdescottes. 2022-08-01 09:33:19 +00:00
index.html Bug 1776853 - [devtools] Show ChromeDebugToolbar in Browser Console. r=ochameau. 2022-08-01 09:33:18 +00:00
moz.build Bug 1776145 - [devtools] Remove WebConsoleConnectionProxy. r=ochameau. 2022-07-04 13:27:52 +00:00
panel.js Bug 1330099 - Enable object-shorthand eslint rule. r=jdescottes 2022-08-03 14:57:05 +00:00
README.md
service-container.js
store.js Bug 1776853 - [devtools] Show ChromeDebugToolbar in Browser Console. r=ochameau. 2022-08-01 09:33:18 +00:00
types.js
utils.js Bug 1789201 - [devtools] Expose Services as a global to all DevTools modules. r=perftest-reviewers,nchevobbe,julienw,AlexandruIonescu 2022-09-09 07:22:51 +00:00
webconsole-ui.js Bug 1789202 - [devtools] Expose ChromeUtils as a global to all DevTools modules. r=perftest-reviewers,nchevobbe,AlexandruIonescu 2022-09-09 07:22:51 +00:00
webconsole-wrapper.js Bug 1789201 - [devtools] Expose Services as a global to all DevTools modules. r=perftest-reviewers,nchevobbe,julienw,AlexandruIonescu 2022-09-09 07:22:51 +00:00
webconsole.js Bug 1789201 - [devtools] Expose Services as a global to all DevTools modules. r=perftest-reviewers,nchevobbe,julienw,AlexandruIonescu 2022-09-09 07:22:51 +00:00

WebConsole

The WebConsole (webconsole) shows you all the console API calls made by scripts and alerts you when javascript errors are thrown by a script. It can also display network logs, and you can evaluate expressions using the console input, a.k.a. JsTerm. You can read more about it to learn all the features and how to use the tool.

Run WebConsole

If you want to build the WebConsole inside of the DevTools toolbox (Firefox Devtools Panels), follow the simple Firefox build documentation. Start your compiled firefox and open the Firefox developer tool, you can then see the WebConsole tab.

Code Structure

Top level files are used to launch the WebConsole inside of the DevTools toolbox. The main files used to run the WebConsole are:

  • main.js called by devtools toolbox to launch the WebConsole panel.
  • index.html panel UI and launch scripts.

UI

The WebConsole UI is built using React components (in components/).

The React application is rendered from webconsole-wrapper.js. It contains 4 top components:

  • ConsoleOutput (in ConsoleOutput.js) is the component where messages are rendered.
  • FilterBar (in FilterBar.js) is the component for the filter bars (filter input and toggle buttons).
  • SideBar (in SideBar.js) is the component that render the sidebar where objects can be placed in.
  • JsTerm (in JsTerm.js) is the component that render the console input.

We prefer stateless component (defined by function) instead of stateful component (defined by class) unless the component has to maintain its internal state.

State

Besides the UI, the WebConsole manages the app state via [Redux]. The following locations define the app state:

  • src/constants.js constants used across the tool including action and event names.
  • src/actions/ for all actions that change the state.
  • src/reducers/ for all reducers that change the state.
  • src/selectors/ functions that return a formatted version of parts of the app state.

The redux state is a plain javascript object with the following properties:

{
  // State of the filter input and toggle buttons
  filters,
  // State of the input history
  history,
  // Console messages data and state (hidden, expanded, groups, …)
  messages,
  // State of notifications displayed on the output (e.g. self-XSS warning message)
  notifications,
  // Preferences (persist message, message limit, …)
  prefs,
  // Interface state (filter bar visible, sidebar visible, …)
  ui,
}

Tests

See test/README.md