Closed Bug 1510690 Opened Last year Closed 4 months ago

Console should restore the focus from the actor rather than from the UI

Categories

(DevTools :: Console, enhancement, P3)

enhancement

Tracking

(firefox70 fixed)

RESOLVED FIXED
Firefox 70
Tracking Status
firefox70 --- fixed

People

(Reporter: jdescottes, Assigned: ochameau)

References

Details

Attachments

(1 file)

Follow up to Bug 1507125

The console client code is calling the browsing context target actor on destroy to restore the focus on the content page:

  await this.target.activeTab.focus();
  
(https://searchfox.org/mozilla-central/rev/0859e6b10fb901875c80de8f8fc33cbb77b2505e/devtools/client/webconsole/webconsole.js#323)

However this code will fail if the connection has already been shutdown. Ideally this should be handled by the actor itself when it is destroyed. 

However for now the only relevant actor that is destroyed when closing the toolbox after opening only the console is the corresponding BrowsingContextTargetActor. The console actor itself is not destroyed. This behavior could be part of the destroy of the BrowsingContextTargetActor. To be consistent with what we do today this should only be done if the webconsole UI was started. But it seems that most panels are actually stealing the focus from the content page, and the webconsole is the only one which attempts to restore it on destroy. Meaning we can probably generalize this behavior a bit if we move the feature to the BrowsingContextTargetActor
(In reply to Julian Descottes [:jdescottes][:julian] from comment #0)
> However for now the only relevant actor that is destroyed when closing the
> toolbox after opening only the console is the corresponding
> BrowsingContextTargetActor. The console actor itself is not destroyed.

Actually, the console is destroyed as it is a target scoped actor.
It's destroy method should be called.
Target scoped actors are destroyed when calling detach of the BrowsingContextTargetActor. (We call detach when closing the toolbox in remote debugging while keeping the client alive. In local debugging we instantiate a new client everytime we debug a new tab.)
And the BrowsingContextTargetActor is detached when it is being destroyed (and all actors are destroyed when the client disconnects. When you pull the cable for usb debugging, or close the client)

> This
> behavior could be part of the destroy of the BrowsingContextTargetActor. To
> be consistent with what we do today this should only be done if the
> webconsole UI was started. But it seems that most panels are actually
> stealing the focus from the content page, and the webconsole is the only one
> which attempts to restore it on destroy. Meaning we can probably generalize
> this behavior a bit if we move the feature to the BrowsingContextTargetActor

Having said that, if it makes sense to make this feature cross-tools, yes, you could move that up to BrowsingContextTargetActor!
Ah ok, I assumed the webconsole actor was using protocol JS and I simply monitored which protocol JS actors were destroyed and since it wasn't one of them I assumed we kept it alive.

No RDP request should be done when the toolbox closes as there no guarantee that
the request will complete. Instead, such cleanup should be done by the actors.

Assignee: nobody → poirot.alex
Pushed by apoirot@mozilla.com:
https://hg.mozilla.org/integration/autoland/rev/27ac681ded07
Do focus the content window from the actor when the toolbox closes. r=nchevobbe
Status: NEW → RESOLVED
Closed: 4 months ago
Resolution: --- → FIXED
Target Milestone: --- → Firefox 70
Blocks: 1570692
You need to log in before you can comment on or make changes to this bug.