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