michael@0: /* This Source Code Form is subject to the terms of the Mozilla Public michael@0: * License, v. 2.0. If a copy of the MPL was not distributed with this michael@0: * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ michael@0: michael@0: "use strict"; michael@0: michael@0: /** michael@0: * Tab actor for documents living in a child process. michael@0: * michael@0: * Depends on TabActor, defined in webbrowser.js. michael@0: */ michael@0: michael@0: /** michael@0: * Creates a tab actor for handling requests to the single tab, like michael@0: * attaching and detaching. ContentActor respects the actor factories michael@0: * registered with DebuggerServer.addTabActor. michael@0: * michael@0: * @param connection DebuggerServerConnection michael@0: * The conection to the client. michael@0: * @param chromeGlobal michael@0: * The content script global holding |content| and |docShell| properties for a tab. michael@0: */ michael@0: function ContentActor(connection, chromeGlobal) michael@0: { michael@0: this._chromeGlobal = chromeGlobal; michael@0: TabActor.call(this, connection, chromeGlobal); michael@0: this.traits.reconfigure = false; michael@0: } michael@0: michael@0: ContentActor.prototype = Object.create(TabActor.prototype); michael@0: michael@0: ContentActor.prototype.constructor = ContentActor; michael@0: michael@0: Object.defineProperty(ContentActor.prototype, "docShell", { michael@0: get: function() { michael@0: return this._chromeGlobal.docShell; michael@0: }, michael@0: enumerable: true, michael@0: configurable: false michael@0: }); michael@0: michael@0: ContentActor.prototype.exit = function() { michael@0: TabActor.prototype.exit.call(this); michael@0: }; michael@0: michael@0: // Override grip just to rename this._tabActorPool to this._tabActorPool2 michael@0: // in order to prevent it to be cleaned on detach. michael@0: // We have to keep tab actors alive as we keep the ContentActor michael@0: // alive after detach and reuse it for multiple debug sessions. michael@0: ContentActor.prototype.grip = function () { michael@0: let response = { michael@0: 'actor': this.actorID, michael@0: 'title': this.title, michael@0: 'url': this.url michael@0: }; michael@0: michael@0: // Walk over tab actors added by extensions and add them to a new ActorPool. michael@0: let actorPool = new ActorPool(this.conn); michael@0: this._createExtraActors(DebuggerServer.tabActorFactories, actorPool); michael@0: if (!actorPool.isEmpty()) { michael@0: this._tabActorPool2 = actorPool; michael@0: this.conn.addActorPool(this._tabActorPool2); michael@0: } michael@0: michael@0: this._appendExtraActors(response); michael@0: return response; michael@0: }; michael@0: