Bug 1620248 - [devtools] Ensure destroying ContentProcess target when the target is destroyed before process shutdown. r=nchevobbe,jdescottes

For now, we were emitting the "tabDetached" event on message-manager-close (=process shutdown),
or when the DevToolsServerConnection closes (=client closes the connection).
But not when the target is being destroyed by the frontend when calling ResourceWatcher.unwatchTargets,
which is calling process-helper's destroyTargets.
This was introducing test failure (browser_target_list_watchTargets.js) with never resolving RDP requests.

Differential Revision: https://phabricator.services.mozilla.com/D91559
This commit is contained in:
Alexandre Poirot 2020-10-22 10:02:31 +00:00
Родитель 49c488db1c
Коммит e1aa84044b
2 изменённых файлов: 11 добавлений и 0 удалений

Просмотреть файл

@ -595,6 +595,12 @@ function TargetMixin(parentClass) {
_addListeners() {
this.client.on("closed", this.destroy);
// `tabDetached` is sent by all target targets types: frame, process and workers.
// This is sent when the target is destroyed:
// * the target context destroys itself (the tab closes for ex, or the worker shuts down)
// in this case, it may be the connector that send this event in the name of the target actor
// * the target actor is destroyed, but the target context stays up and running (for ex, when we call Watcher.unwatchTargets)
// * the DevToolsServerConnection closes (client closes the connection)
this.on("tabDetached", this.destroy);
}

Просмотреть файл

@ -198,6 +198,11 @@ const ContentProcessTargetActor = ActorClassWithSpec(contentProcessTargetSpec, {
if (this.isDestroyed()) {
return;
}
// Notify the client that this target is being destroyed.
// So that we can destroy the target front and all its children.
this.emit("tabDetached");
Actor.prototype.destroy.call(this);
// Tell the live lists we aren't watching any more.