Bug 1315391 - Clean up actor destruction after changing to `destroy`. r=ochameau

The `destroy` method in some actors would throw errors or was incomplete,
leading to various issues closing the toolbox after the previous patch.

This cleans up all such cases noticed through manual testing of the toolbox.

MozReview-Commit-ID: 6EZYFwjSri

--HG--
extra : rebase_source : b9db68be857285de4269f7354f6ecbf703c82e29
This commit is contained in:
J. Ryan Stinnett 2016-11-11 18:24:41 -06:00
Родитель a8aec05d11
Коммит b2575a1b27
4 изменённых файлов: 37 добавлений и 26 удалений

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

@ -19,9 +19,8 @@ const { cssColors } = require("devtools/shared/css/color-db");
exports.CssPropertiesActor = ActorClassWithSpec(cssPropertiesSpec, {
typeName: "cssProperties",
initialize(conn, parent) {
initialize(conn) {
Actor.prototype.initialize.call(this, conn);
this.parent = parent;
},
destroy() {

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

@ -18,13 +18,13 @@ loader.lazyRequireGetter(this, "events", "sdk/event/core");
var PromisesActor = protocol.ActorClassWithSpec(promisesSpec, {
/**
* @param conn DebuggerServerConnection.
* @param parent TabActor|RootActor
* @param parentActor TabActor|RootActor
*/
initialize: function (conn, parent) {
initialize: function (conn, parentActor) {
protocol.Actor.prototype.initialize.call(this, conn);
this.conn = conn;
this.parent = parent;
this.parentActor = parentActor;
this.state = "detached";
this._dbg = null;
this._gripDepth = 0;
@ -38,16 +38,16 @@ var PromisesActor = protocol.ActorClassWithSpec(promisesSpec, {
},
destroy: function () {
protocol.Actor.prototype.destroy.call(this, this.conn);
if (this.state === "attached") {
this.detach();
}
protocol.Actor.prototype.destroy.call(this, this.conn);
},
get dbg() {
if (!this._dbg) {
this._dbg = this.parent.makeDebugger();
this._dbg = this.parentActor.makeDebugger();
}
return this._dbg;
},
@ -65,14 +65,14 @@ var PromisesActor = protocol.ActorClassWithSpec(promisesSpec, {
this._promisesSettled = [];
this.dbg.findScripts().forEach(s => {
this.parent.sources.createSourceActors(s.source);
this.parentActor.sources.createSourceActors(s.source);
});
this.dbg.onNewScript = s => {
this.parent.sources.createSourceActors(s.source);
this.parentActor.sources.createSourceActors(s.source);
};
events.on(this.parent, "window-ready", this._onWindowReady);
events.on(this.parentActor, "window-ready", this._onWindowReady);
this.state = "attached";
}, "attaching to the PromisesActor"),
@ -92,7 +92,7 @@ var PromisesActor = protocol.ActorClassWithSpec(promisesSpec, {
this._navigationLifetimePool = null;
}
events.off(this.parent, "window-ready", this._onWindowReady);
events.off(this.parentActor, "window-ready", this._onWindowReady);
this.state = "detached";
}),
@ -122,7 +122,7 @@ var PromisesActor = protocol.ActorClassWithSpec(promisesSpec, {
decrementGripDepth: () => this._gripDepth--,
createValueGrip: v =>
createValueGrip(v, this._navigationLifetimePool, this.objectGrip),
sources: () => this.parent.sources,
sources: () => this.parentActor.sources,
createEnvironmentActor: () => DevToolsUtils.reportException(
"PromisesActor", Error("createEnvironmentActor not yet implemented")),
getGlobalDebugObject: () => DevToolsUtils.reportException(

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

@ -161,6 +161,9 @@ StorageActors.defaults = function (typeName, observationTopic) {
events.off(this.storageActor, "window-destroyed", this.onWindowDestroyed);
this.hostVsStores.clear();
protocol.Actor.prototype.destroy.call(this);
this.storageActor = null;
},
@ -415,7 +418,11 @@ StorageActors.createActor({
events.off(this.storageActor, "window-ready", this.onWindowReady);
events.off(this.storageActor, "window-destroyed", this.onWindowDestroyed);
this._pendingResponse = this.storageActor = null;
this._pendingResponse = null;
protocol.Actor.prototype.destroy.call(this);
this.storageActor = null;
},
/**
@ -1444,6 +1451,10 @@ StorageActors.createActor({
events.off(this.storageActor, "window-ready", this.onWindowReady);
events.off(this.storageActor, "window-destroyed", this.onWindowDestroyed);
protocol.Actor.prototype.destroy.call(this);
this.storageActor = null;
},
/**
@ -2233,9 +2244,8 @@ let StorageActor = protocol.ActorClassWithSpec(specs.storageSpec, {
},
initialize(conn, tabActor) {
protocol.Actor.prototype.initialize.call(this, null);
protocol.Actor.prototype.initialize.call(this, conn);
this.conn = conn;
this.parentActor = tabActor;
this.childActorPool = new Map();
@ -2271,10 +2281,8 @@ let StorageActor = protocol.ActorClassWithSpec(specs.storageSpec, {
Services.obs.removeObserver(this, "inner-window-destroyed", false);
this.destroyed = true;
if (this.parentActor.browser) {
this.parentActor.browser.removeEventListener(
"pageshow", this.onPageChange, true);
this.parentActor.browser.removeEventListener(
"pagehide", this.onPageChange, true);
this.parentActor.browser.removeEventListener("pageshow", this.onPageChange, true);
this.parentActor.browser.removeEventListener("pagehide", this.onPageChange, true);
}
// Destroy the registered store types
for (let actor of this.childActorPool.values()) {
@ -2282,9 +2290,15 @@ let StorageActor = protocol.ActorClassWithSpec(specs.storageSpec, {
}
this.childActorPool.clear();
this.childWindowPool.clear();
this.childWindowPool = this.childActorPool = this.__poolMap = this.conn =
this.parentActor = this.boundUpdate = this.registeredPool =
this._pendingResponse = null;
this.childActorPool = null;
this.childWindowPool = null;
this.parentActor = null;
this.boundUpdate = null;
this.registeredPool = null;
this._pendingResponse = null;
protocol.Actor.prototype.destroy.call(this);
},
/**

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

@ -28,9 +28,7 @@ var WebGLPrimitiveCounter = exports.WebGLPrimitiveCounter = Class({
this.tabActor = tabActor;
},
destroy: function () {
this.stopRecording();
},
destroy: function () {},
/**
* Starts monitoring primitive draws, storing the primitives count per tick.