зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1697109 - [devtools] Always destroy worker and webextension descriptors when descriptor-destroyed is sent. r=jdescottes,devtools-backward-compat-reviewers
Differential Revision: https://phabricator.services.mozilla.com/D107466
This commit is contained in:
Родитель
568e0d1fe9
Коммит
195337eea7
|
@ -107,9 +107,8 @@ class WorkerDescriptorFront extends DescriptorMixin(
|
|||
}
|
||||
|
||||
async detach() {
|
||||
let response;
|
||||
try {
|
||||
response = await super.detach();
|
||||
await super.detach();
|
||||
|
||||
if (this.registration) {
|
||||
// Bug 1644772 - Sometimes, the Browser Toolbox fails opening with a connection timeout
|
||||
|
@ -120,8 +119,6 @@ class WorkerDescriptorFront extends DescriptorMixin(
|
|||
} catch (e) {
|
||||
this.logDetachError(e, "worker");
|
||||
}
|
||||
|
||||
return response;
|
||||
}
|
||||
|
||||
async _getRegistrationIfActive() {
|
||||
|
|
|
@ -59,11 +59,8 @@ const WebExtensionDescriptorActor = protocol.ActorClassWithSpec(
|
|||
this.addonId = addon.id;
|
||||
this._childFormPromise = null;
|
||||
|
||||
// Called when the debug browser element has been destroyed
|
||||
this._extensionFrameDisconnect = this._extensionFrameDisconnect.bind(
|
||||
this
|
||||
);
|
||||
this._onChildExit = this._onChildExit.bind(this);
|
||||
this.destroy = this.destroy.bind(this);
|
||||
AddonManager.addAddonListener(this);
|
||||
},
|
||||
|
||||
|
@ -121,7 +118,7 @@ const WebExtensionDescriptorActor = protocol.ActorClassWithSpec(
|
|||
this._form = await connectToFrame(
|
||||
this.conn,
|
||||
this._browser,
|
||||
this._extensionFrameDisconnect,
|
||||
this.destroy,
|
||||
{ addonId: this.addonId }
|
||||
);
|
||||
|
||||
|
@ -192,7 +189,36 @@ const WebExtensionDescriptorActor = protocol.ActorClassWithSpec(
|
|||
);
|
||||
},
|
||||
|
||||
_extensionFrameDisconnect() {
|
||||
/**
|
||||
* Handle the child actor exit.
|
||||
*/
|
||||
_onChildExit(msg) {
|
||||
if (msg.json.actor !== this._childActorID) {
|
||||
return;
|
||||
}
|
||||
|
||||
this.destroy();
|
||||
},
|
||||
|
||||
// AddonManagerListener callbacks.
|
||||
onInstalled(addon) {
|
||||
if (addon.id != this.addonId) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Update the AddonManager's addon object on reload/update.
|
||||
this.addon = addon;
|
||||
},
|
||||
|
||||
onUninstalled(addon) {
|
||||
if (addon != this.addon) {
|
||||
return;
|
||||
}
|
||||
|
||||
this.destroy();
|
||||
},
|
||||
|
||||
destroy() {
|
||||
AddonManager.removeAddonListener(this);
|
||||
|
||||
this.addon = null;
|
||||
|
@ -213,39 +239,7 @@ const WebExtensionDescriptorActor = protocol.ActorClassWithSpec(
|
|||
this._childActorID = null;
|
||||
|
||||
this.emit("descriptor-destroyed");
|
||||
},
|
||||
|
||||
/**
|
||||
* Handle the child actor exit.
|
||||
*/
|
||||
_onChildExit(msg) {
|
||||
if (msg.json.actor !== this._childActorID) {
|
||||
return;
|
||||
}
|
||||
|
||||
this._extensionFrameDisconnect();
|
||||
},
|
||||
|
||||
// AddonManagerListener callbacks.
|
||||
onInstalled(addon) {
|
||||
if (addon.id != this.addonId) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Update the AddonManager's addon object on reload/update.
|
||||
this.addon = addon;
|
||||
},
|
||||
|
||||
onUninstalled(addon) {
|
||||
if (addon != this.addon) {
|
||||
return;
|
||||
}
|
||||
|
||||
this._extensionFrameDisconnect();
|
||||
},
|
||||
|
||||
destroy() {
|
||||
this._extensionFrameDisconnect();
|
||||
protocol.Actor.prototype.destroy.call(this);
|
||||
},
|
||||
}
|
||||
|
|
|
@ -10,6 +10,10 @@
|
|||
* See devtools/docs/backend/actor-hierarchy.md for more details.
|
||||
*/
|
||||
|
||||
// protocol.js uses objects as exceptions in order to define
|
||||
// error packets.
|
||||
/* eslint-disable no-throw-literal */
|
||||
|
||||
const { Ci } = require("chrome");
|
||||
const ChromeUtils = require("ChromeUtils");
|
||||
const { DevToolsServer } = require("devtools/server/devtools-server");
|
||||
|
@ -107,14 +111,10 @@ const WorkerDescriptorActor = protocol.ActorClassWithSpec(
|
|||
|
||||
detach() {
|
||||
if (!this._attached) {
|
||||
return { error: "wrongState" };
|
||||
throw { error: "wrongState" };
|
||||
}
|
||||
|
||||
this._detach();
|
||||
|
||||
this.emit("descriptor-destroyed");
|
||||
|
||||
return { type: "detached" };
|
||||
this.destroy();
|
||||
},
|
||||
|
||||
destroy() {
|
||||
|
@ -174,11 +174,7 @@ const WorkerDescriptorActor = protocol.ActorClassWithSpec(
|
|||
},
|
||||
|
||||
_onWorkerClose() {
|
||||
if (this._attached) {
|
||||
this._detach();
|
||||
}
|
||||
|
||||
this.emit("descriptor-destroyed");
|
||||
this.destroy();
|
||||
},
|
||||
|
||||
_onWorkerError(filename, lineno, message) {
|
||||
|
|
|
@ -15,7 +15,7 @@ const workerDescriptorSpec = generateActorSpec({
|
|||
},
|
||||
detach: {
|
||||
request: {},
|
||||
response: RetVal("json"),
|
||||
response: {},
|
||||
},
|
||||
getTarget: {
|
||||
request: {},
|
||||
|
|
Загрузка…
Ссылка в новой задаче