1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
|
/* Any copyright is dedicated to the Public Domain.
* http://creativecommons.org/publicdomain/zero/1.0/ */
"use strict";
const protocol = require("devtools/shared/protocol");
const { FrontClassWithSpec } = protocol;
const {
DevToolsServerConnection,
} = require("devtools/server/devtools-server-connection");
const Services = require("Services");
const inContentSpec = protocol.generateActorSpec({
typeName: "inContent",
methods: {
isInContent: {
request: {},
response: {
isInContent: protocol.RetVal("boolean"),
},
},
spawnInParent: {
request: {
url: protocol.Arg(0),
},
response: protocol.RetVal("json"),
},
},
});
exports.InContentActor = protocol.ActorClassWithSpec(inContentSpec, {
initialize: function(conn) {
protocol.Actor.prototype.initialize.call(this, conn);
},
isInContent: function() {
return (
Services.appinfo.processType == Services.appinfo.PROCESS_TYPE_CONTENT
);
},
spawnInParent: async function(url) {
const actorID = await this.conn.spawnActorInParentProcess(this.actorID, {
module: url,
constructor: "InParentActor",
// In the browser mochitest script, we are asserting these arguments passed to
// InParentActor constructor
args: [1, 2, 3],
});
return {
inParentActor: actorID,
};
},
});
class InContentFront extends FrontClassWithSpec(inContentSpec) {}
exports.InContentFront = InContentFront;
const inParentSpec = protocol.generateActorSpec({
typeName: "inParent",
methods: {
test: {
request: {},
response: protocol.RetVal("json"),
},
},
});
exports.InParentActor = protocol.ActorClassWithSpec(inParentSpec, {
initialize: function(conn, a1, a2, a3, mm) {
protocol.Actor.prototype.initialize.call(this, conn);
// We save all arguments to later assert them in `test` request
this.conn = conn;
this.args = [a1, a2, a3];
this.mm = mm;
},
test: function() {
return {
args: this.args,
isInParent:
Services.appinfo.processType == Services.appinfo.PROCESS_TYPE_DEFAULT,
conn: this.conn instanceof DevToolsServerConnection,
// We don't have access to MessageListenerManager in Sandboxes,
// so fallback to constructor name checks...
mm: Object.getPrototypeOf(this.mm).constructor.name,
};
},
});
class InParentFront extends FrontClassWithSpec(inParentSpec) {}
exports.InParentFront = InParentFront;
|