gecko-dev/devtools/shared/commands
Alexandre Poirot 329c56536c Bug 1439509 - [devtools] Clear network events when their related WindowGlobal is destroyed. r=bomsy,devtools-backward-compat-reviewers,jdescottes
The main challenge here is to still support persist-logs feature of the netmonitor.
When this feature is enabled we have to keep around all the Network Events as before this patch.

Fission refactoring and the migration to server side NETWORK_EVENT watchers made
this fix significantly easier as we can now more easily reach out the parent process
code which is keeping things allocated.

Differential Revision: https://phabricator.services.mozilla.com/D124318
2021-09-07 17:51:52 +00:00
..
inspected-window Bug 1722749 - [devtools] Fix browser_ext_devtools_inspectedWindow_targetSwitch.js with server targets. r=rpl 2021-07-29 07:41:49 +00:00
inspector Bug 1716703 - [devtools] Rename TestActor to HighlighterTestActor. r=jdescottes. 2021-06-17 10:03:03 +00:00
resource Bug 1439509 - [devtools] Clear network events when their related WindowGlobal is destroyed. r=bomsy,devtools-backward-compat-reviewers,jdescottes 2021-09-07 17:51:52 +00:00
script Bug 1719160 - [devtools] Fix checkValue commands test helper. r=jdescottes. 2021-07-06 05:03:47 +00:00
target Bug 1728092 - [devtools] Use shared browserReload helper in most tests using browser.reload r=bomsy 2021-09-02 11:38:55 +00:00
target-configuration Bug 1727323 - [devtools] Enable bfcache in parent in tests that have been fixed thanks to server targets. r=bomsy 2021-08-25 17:16:27 +00:00
thread-configuration Bug 1725999 - [devtools] Remove backward compatibility code for ThreadConfigurationOptions r=bomsy 2021-08-23 07:59:07 +00:00
README.md
commands-factory.js Bug 1723133 - [devtools] Rename browser_target_list_* tests into browser_target_command_* . r=jdescottes. 2021-07-30 14:41:27 +00:00
index.js Bug 1727177 - [devtools] Fix devtools.netmonitor.saveRequestAndResponseBodies preference with new fission codepath. r=bomsy,devtools-backward-compat-reviewers 2021-09-01 08:30:22 +00:00
moz.build Bug 1712739 - [devtools] Add a `script` command with an `execute` method. r=jdescottes. 2021-06-02 13:15:06 +00:00

README.md

Commands

Commands are singletons, which can be easily used by any frontend code. They are meant to be exposed widely to the frontend so that any code can easily call any of their methods.

Commands classes expose static methods, which:

  • route to the right Front/Actor's method
  • handle backward compatibility
  • map to many target's actor if needed

These classes are instantiated once per descriptor and may have inner state, emit events, fire callbacks,...

A transient backward compat need, required by Fission refactorings will be to have some code checking a trait, and either:

  • call a single method on a parent process actor (like BreakpointListActor.setBreakpoint)
  • otherwise, call a method on each target's scoped actor (like ThreadActor.setBreakpoint, that, for each available target)

Without such layer, we would have to put such code here and there in the frontend code. This will be harder to remove later, once we get rid of old pre-fission-refactoring codepaths.

This layer already exists in some panels, but we are using slightly different names and practices:

  • Debugger uses "client" (devtools/client/debugger/src/client/) and "commands" (devtools/client/debugger/src/client/firefox/commands.js) Debugger's commands already bundle the code to dispatch an action to many target's actor. They also contain some backward compat code. Today, we pass around a client object via thunkArgs, which is mapped to commands.js, instead we could pass a debugger command object.
  • Network Monitor uses "connector" (devtools/client/netmonitor/src/connector) Connectors also bundles backward compat and dispatch to many target's actor. Today, we pass the connector to all middlewares from configureStore, we could instead pass the netmonitor command object.
  • Web Console has:
    • WebConsoleConnectionProxy, but this is probably going to disappear and doesn't do much.
    • WebConsoleUI, which does dispatch to many target's actor, via getAllProxies (see clearMessagesCache)
    • See devtools/client/webconsole/actions/input.js:handleHelperResult(), where we have to put some code, which is a duplicate of Netmonitor Connector, and could be shared via a netmonitor command class.
  • Inspector is probably the panel doing the most dispatch to many target's actor. Codes using getAllInspectorFronts could all be migrated to an inspector command class: https://searchfox.org/mozilla-central/search?q=symbol:%23getAllInspectorFronts&redirect=false and simplify a bit the frontend. It is also one panel, which still register listener to each target's inspector/walker fronts. Because inspector isn't using resources. But this work, registering listeners for each target might be done by such layer and translate the many actor's event into a unified one.

Last, but not least, this layer may allow us to slowly get rid of protocol.js. Command classes aren't Fronts, nor are they particularly connected to protocol.js. If we make it so that all the Frontend code using Fronts uses Commands instead, we might more easily get away from protocol.js.