Make the application panel support target switching
Categories
(DevTools :: Application Panel, enhancement)
Tracking
(Not tracked)
People
(Reporter: ochameau, Unassigned)
References
Details
Bug 1565263 landed the TargetList API which helps support switching to another target (as well as supporting the additional remote iframe target).
But we should followup in each tool in order to start using this new API.
The very first goal is to:
- stop memoizing the target/targetFront and may be also the target scoped front (inspector, console, thread, storage, ...). Instead we should use
toolbox.targetList.targetFront
in order to query for the current top level target front. - support target switching by using
TargetList.watchTargets
. In a first iteration we would only care about the top level target. In order to do so, we can check for theisTopLevel
argument being passed to the two callbacks register towatchTargets
:
this._toolbox.targetList.watchTargets([this._toolbox.targetList.TYPES.FRAME],
({ type, targetFront, isTopLevel }) => {
if (isTopLevel) {
// A new top level target is available
// This will be fired on toolbox opening, for the first one,
// And then, evertime we navigate to another process.
// For now, you would need `devtools.target-switching.enabled` to be set to true
// And navigate from any http website to about:robots, which loads into the parent process. Or enable Fission and navigate between two distinct top level domains.
}
},
({ type, targetFront, isTopLevel }) => {
if (isTopLevel) {
// A top level target has been destroyed
}
}
See bug 1565263 for how we migrated the console or bug 1578242 for the inspector.
Reporter | ||
Comment 1•5 years ago
|
||
It looks like it should be quite straightforward.
I see only two callsites which are impacted by the target-switching:
-
navigate
event listening
https://searchfox.org/mozilla-central/rev/62a130ba0ac80f75175e4b65536290b52391f116/devtools/client/application/initializer.js#59
We should do like the toolbox code. Use TargetList.watchTarget to listen for all the targets and for each of the top level target, listen for navigate:
https://searchfox.org/mozilla-central/rev/62a130ba0ac80f75175e4b65536290b52391f116/devtools/client/framework/toolbox.js#740-744
https://searchfox.org/mozilla-central/rev/62a130ba0ac80f75175e4b65536290b52391f116/devtools/client/framework/toolbox.js#617-626 -
fetchManifest
https://searchfox.org/mozilla-central/rev/62a130ba0ac80f75175e4b65536290b52391f116/devtools/client/application/src/modules/application-services.js#44-45
This uses a target and so should be reviewed. But nothing is to be changed as it uses Toolbox'starget
getter which is dynamic and will use the right target front. We may just ensure updating the application panel from initializer everytime a new target is notified.
Comment 2•5 years ago
|
||
(might be a duplicate of Bug 1600263)
Updated•5 years ago
|
Comment 3•5 years ago
|
||
Hi, I'm already working on this on 1600263 (thanks Julian for the heads up!)
Updated•5 years ago
|
Description
•