1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/toolkit/devtools/server/actors/childtab.js Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,68 @@ 1.4 +/* This Source Code Form is subject to the terms of the Mozilla Public 1.5 + * License, v. 2.0. If a copy of the MPL was not distributed with this 1.6 + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ 1.7 + 1.8 +"use strict"; 1.9 + 1.10 +/** 1.11 + * Tab actor for documents living in a child process. 1.12 + * 1.13 + * Depends on TabActor, defined in webbrowser.js. 1.14 + */ 1.15 + 1.16 +/** 1.17 + * Creates a tab actor for handling requests to the single tab, like 1.18 + * attaching and detaching. ContentActor respects the actor factories 1.19 + * registered with DebuggerServer.addTabActor. 1.20 + * 1.21 + * @param connection DebuggerServerConnection 1.22 + * The conection to the client. 1.23 + * @param chromeGlobal 1.24 + * The content script global holding |content| and |docShell| properties for a tab. 1.25 + */ 1.26 +function ContentActor(connection, chromeGlobal) 1.27 +{ 1.28 + this._chromeGlobal = chromeGlobal; 1.29 + TabActor.call(this, connection, chromeGlobal); 1.30 + this.traits.reconfigure = false; 1.31 +} 1.32 + 1.33 +ContentActor.prototype = Object.create(TabActor.prototype); 1.34 + 1.35 +ContentActor.prototype.constructor = ContentActor; 1.36 + 1.37 +Object.defineProperty(ContentActor.prototype, "docShell", { 1.38 + get: function() { 1.39 + return this._chromeGlobal.docShell; 1.40 + }, 1.41 + enumerable: true, 1.42 + configurable: false 1.43 +}); 1.44 + 1.45 +ContentActor.prototype.exit = function() { 1.46 + TabActor.prototype.exit.call(this); 1.47 +}; 1.48 + 1.49 +// Override grip just to rename this._tabActorPool to this._tabActorPool2 1.50 +// in order to prevent it to be cleaned on detach. 1.51 +// We have to keep tab actors alive as we keep the ContentActor 1.52 +// alive after detach and reuse it for multiple debug sessions. 1.53 +ContentActor.prototype.grip = function () { 1.54 + let response = { 1.55 + 'actor': this.actorID, 1.56 + 'title': this.title, 1.57 + 'url': this.url 1.58 + }; 1.59 + 1.60 + // Walk over tab actors added by extensions and add them to a new ActorPool. 1.61 + let actorPool = new ActorPool(this.conn); 1.62 + this._createExtraActors(DebuggerServer.tabActorFactories, actorPool); 1.63 + if (!actorPool.isEmpty()) { 1.64 + this._tabActorPool2 = actorPool; 1.65 + this.conn.addActorPool(this._tabActorPool2); 1.66 + } 1.67 + 1.68 + this._appendExtraActors(response); 1.69 + return response; 1.70 +}; 1.71 +