fune/devtools/shared/commands
2024-04-11 08:43:17 +00:00
..
inspected-window Bug 1865689 - Fixup browser.toml - move prefs to DEFAULT. CLOSED TREE 2023-12-13 14:50:25 +00:00
inspector Bug 1713093 - [devtools] Fix intermittent with browser_inspector_command_findNodeFrontFromSelectors. r=devtools-reviewers,nchevobbe 2024-03-20 12:30:15 +00:00
network Bug 1853244 - convert .ini manifests to .toml: batch 6 {caps,devtools,dom}/**/browser.ini r=jmaher,media-playback-reviewers,devtools-reviewers,profiler-reviewers,alwu,nchevobbe,canaltinova 2023-09-22 20:42:14 +00:00
object Bug 1883305 - [devtools] Remove 123 backward compatibility code. r=ochameau,devtools-reviewers. 2024-03-04 14:20:53 +00:00
resource Bug 1767770 - [devtools] On content page load image requests are loaded r=devtools-reviewers,nchevobbe 2024-04-11 08:43:17 +00:00
root-resource
script Bug 1881359 - Part 2: Use DebuggerObject.prototype.isSameNativeWithJitInfo in eager evaluation to support methods with GenericMethod native function. r=nchevobbe,devtools-reviewers 2024-03-01 12:37:39 +00:00
target Bug 1866814 - [devtools] Merge all DevTools JS Actors into a single DOM Process JS Actor. r=devtools-reviewers,nchevobbe 2024-04-02 08:54:51 +00:00
target-configuration Bug 1858148 - Remove Cu.importGlobalProperties from sjs files as it is no longer needed. r=mossop,webdriver-reviewers,necko-reviewers,search-reviewers,devtools-reviewers,anti-tracking-reviewers,sessionstore-reviewers,pbz,dao,daleharvey,valentin 2023-11-04 09:29:27 +00:00
thread-configuration Backed out 2 changesets (bug 1887872) for causing dt failures on browser_dbg-old-breakpoint.js CLOSED TREE 2024-03-27 21:22:10 +02:00
tracer Bug 1880535 - Enable ESLint rule no-unused-private-class-members. r=Gijs,webdriver-reviewers,webcompat-reviewers,extension-reviewers,application-update-reviewers,devtools-reviewers,translations-reviewers,bytesized,twisniewski,jhirsch,robwu,whimboo 2024-02-20 22:09:21 +00:00
commands-factory.js
create-command.sh Bug 1875045 - [devtools] Add a script helper to easily create a new command. r=devtools-reviewers,nchevobbe 2024-01-29 13:59:51 +00:00
index.js Bug 1875045 - [devtools] Release Object actors by bulk. r=devtools-reviewers,devtools-backward-compat-reviewers,nchevobbe 2024-01-29 13:59:51 +00:00
moz.build Bug 1875045 - [devtools] Release Object actors by bulk. r=devtools-reviewers,devtools-backward-compat-reviewers,nchevobbe 2024-01-29 13:59:51 +00:00
README.md Bug 1875045 - [devtools] Add a script helper to easily create a new command. r=devtools-reviewers,nchevobbe 2024-01-29 13:59:51 +00:00

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:
    • 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.

If you want to create a new command, you can use a bash script to help your bootstrap all basic required files:

$ ./create-command.sh command-file-name CommandName

Where the first argument will be the name used for folder and files, using lower case and dash as separator. And the second argument will be the class name in code, using camlcase.