diff --git a/devtools/shared/protocol.js b/devtools/shared/protocol.js index 46158e4076e6..c1092cc5806a 100644 --- a/devtools/shared/protocol.js +++ b/devtools/shared/protocol.js @@ -926,6 +926,13 @@ Pool.prototype = extend(EventEmitter.prototype, { }); exports.Pool = Pool; +/** + * Keep track of which actorSpecs have been created. If a replica of a spec + * is created, it can be caught, and specs which inherit from other specs will + * not overwrite eachother. + */ +var actorSpecs = new WeakMap(); + /** * An actor in the actor tree. * @@ -938,6 +945,7 @@ exports.Pool = Pool; var Actor = function(conn) { Pool.call(this, conn); + this._actorSpec = actorSpecs.get(Object.getPrototypeOf(this)); // Forward events to the connection. if (this._actorSpec && this._actorSpec.events) { for (let [name, request] of this._actorSpec.events.entries()) { @@ -1170,8 +1178,6 @@ var generateRequestHandlers = function(actorSpec, actorProto) { actorProto.requestTypes[spec.request.type] = handler; }); - actorProto._actorSpec = actorSpec; - return actorProto; }; @@ -1197,6 +1203,8 @@ var ActorClassWithSpec = function(actorSpec, actorProto) { }; cls.prototype = extend(Actor.prototype, generateRequestHandlers(actorSpec, actorProto)); + actorSpecs.set(cls.prototype, actorSpec); + return cls; }; exports.ActorClassWithSpec = ActorClassWithSpec;