gecko-dev/devtools/shared/commands
Nicolas Chevobbe 3d186a69eb Bug 1765370 - [devtools] Always update configuration in InspectedWindowCommand.reload. r=jdescottes.
This was already happening due to an erroneous typeof check.
Luckikly this is actually what we want (and what Chrome is doing FWIW).

Differential Revision: https://phabricator.services.mozilla.com/D144139
2022-04-20 07:15:58 +00:00
..
inspected-window Bug 1765370 - [devtools] Always update configuration in InspectedWindowCommand.reload. r=jdescottes. 2022-04-20 07:15:58 +00:00
inspector Bug 1739371 - [devtools] Fix browser_inspector_command_findNodeFrontFromSelectors.js intermittent. r=ochameau. 2021-11-08 14:25:49 +00:00
resource Bug 1764102 - [devtools] Ensure firing dom-complete when the page pauses or fails loading. r=nchevobbe 2022-04-19 16:13:13 +00:00
root-resource Bug 1748529 - Show extensions non-persistent background script status changes in about:debugging. r=jdescottes,mixedpuppy,fluent-reviewers,devtools-backward-compat-reviewers,flod,ochameau 2022-03-16 15:17:42 +00:00
script Bug 1571708 - [devtools] Inline WebConsoleUI.getWebconsoleFront into autocomplete code. r=jdescottes 2022-04-11 11:07:56 +00:00
target Bug 1763364 - [devtools] Call getTab with browserId instead of outerWindowID. r=ochameau,devtools-backward-compat-reviewers,bomsy. 2022-04-12 11:59:30 +00:00
target-configuration Bug 1759962 - Don't return the DPI override in devicePixelRatio to privileged code. r=nchevobbe,webdriver-reviewers 2022-03-23 17:03:04 +00:00
thread-configuration Bug 1756616 - [devtools] Avoid the toolbox to fail opening because of a destroying worker. r=jdescottes 2022-04-11 20:07:47 +00:00
commands-factory.js Bug 1763364 - [devtools] Call getTab with browserId instead of outerWindowID. r=ochameau,devtools-backward-compat-reviewers,bomsy. 2022-04-12 11:59:30 +00:00
index.js Bug 1757951 - [devtools] Implement "Root" Resources in order to be able to watch for context-less resources in the parent process. r=jdescottes,devtools-backward-compat-reviewers 2022-03-10 22:43:48 +00:00
moz.build Bug 1757951 - [devtools] Implement "Root" Resources in order to be able to watch for context-less resources in the parent process. r=jdescottes,devtools-backward-compat-reviewers 2022-03-10 22:43:48 +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.