Wed, 31 Dec 2014 06:09:35 +0100
Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.
michael@0 | 1 | /* This Source Code Form is subject to the terms of the Mozilla Public |
michael@0 | 2 | * License, v. 2.0. If a copy of the MPL was not distributed with this |
michael@0 | 3 | * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ |
michael@0 | 4 | |
michael@0 | 5 | "use strict"; |
michael@0 | 6 | |
michael@0 | 7 | /** |
michael@0 | 8 | * Tab actor for documents living in a child process. |
michael@0 | 9 | * |
michael@0 | 10 | * Depends on TabActor, defined in webbrowser.js. |
michael@0 | 11 | */ |
michael@0 | 12 | |
michael@0 | 13 | /** |
michael@0 | 14 | * Creates a tab actor for handling requests to the single tab, like |
michael@0 | 15 | * attaching and detaching. ContentActor respects the actor factories |
michael@0 | 16 | * registered with DebuggerServer.addTabActor. |
michael@0 | 17 | * |
michael@0 | 18 | * @param connection DebuggerServerConnection |
michael@0 | 19 | * The conection to the client. |
michael@0 | 20 | * @param chromeGlobal |
michael@0 | 21 | * The content script global holding |content| and |docShell| properties for a tab. |
michael@0 | 22 | */ |
michael@0 | 23 | function ContentActor(connection, chromeGlobal) |
michael@0 | 24 | { |
michael@0 | 25 | this._chromeGlobal = chromeGlobal; |
michael@0 | 26 | TabActor.call(this, connection, chromeGlobal); |
michael@0 | 27 | this.traits.reconfigure = false; |
michael@0 | 28 | } |
michael@0 | 29 | |
michael@0 | 30 | ContentActor.prototype = Object.create(TabActor.prototype); |
michael@0 | 31 | |
michael@0 | 32 | ContentActor.prototype.constructor = ContentActor; |
michael@0 | 33 | |
michael@0 | 34 | Object.defineProperty(ContentActor.prototype, "docShell", { |
michael@0 | 35 | get: function() { |
michael@0 | 36 | return this._chromeGlobal.docShell; |
michael@0 | 37 | }, |
michael@0 | 38 | enumerable: true, |
michael@0 | 39 | configurable: false |
michael@0 | 40 | }); |
michael@0 | 41 | |
michael@0 | 42 | ContentActor.prototype.exit = function() { |
michael@0 | 43 | TabActor.prototype.exit.call(this); |
michael@0 | 44 | }; |
michael@0 | 45 | |
michael@0 | 46 | // Override grip just to rename this._tabActorPool to this._tabActorPool2 |
michael@0 | 47 | // in order to prevent it to be cleaned on detach. |
michael@0 | 48 | // We have to keep tab actors alive as we keep the ContentActor |
michael@0 | 49 | // alive after detach and reuse it for multiple debug sessions. |
michael@0 | 50 | ContentActor.prototype.grip = function () { |
michael@0 | 51 | let response = { |
michael@0 | 52 | 'actor': this.actorID, |
michael@0 | 53 | 'title': this.title, |
michael@0 | 54 | 'url': this.url |
michael@0 | 55 | }; |
michael@0 | 56 | |
michael@0 | 57 | // Walk over tab actors added by extensions and add them to a new ActorPool. |
michael@0 | 58 | let actorPool = new ActorPool(this.conn); |
michael@0 | 59 | this._createExtraActors(DebuggerServer.tabActorFactories, actorPool); |
michael@0 | 60 | if (!actorPool.isEmpty()) { |
michael@0 | 61 | this._tabActorPool2 = actorPool; |
michael@0 | 62 | this.conn.addActorPool(this._tabActorPool2); |
michael@0 | 63 | } |
michael@0 | 64 | |
michael@0 | 65 | this._appendExtraActors(response); |
michael@0 | 66 | return response; |
michael@0 | 67 | }; |
michael@0 | 68 |