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
95
96
97
98
99
|
/* Any copyright is dedicated to the Public Domain.
http://creativecommons.org/publicdomain/zero/1.0/ */
"use strict";
/**
* Client request stacks should span the entire process from before making the
* request to handling the reply from the server. The server frames are not
* included, nor can they be in most cases, since the server can be a remote
* device.
*/
var protocol = require("devtools/shared/protocol");
var { RetVal } = protocol;
function simpleHello() {
return {
from: "root",
applicationType: "xpcshell-tests",
traits: [],
};
}
const rootSpec = protocol.generateActorSpec({
typeName: "root",
methods: {
simpleReturn: {
response: { value: RetVal() },
},
},
});
var RootActor = protocol.ActorClassWithSpec(rootSpec, {
initialize: function(conn) {
protocol.Actor.prototype.initialize.call(this, conn);
// Root actor owns itself.
this.manage(this);
this.actorID = "root";
this.sequence = 0;
},
sayHello: simpleHello,
simpleReturn: function() {
return this.sequence++;
},
});
class RootFront extends protocol.FrontClassWithSpec(rootSpec) {
constructor(client) {
super(client);
this.actorID = "root";
// Root owns itself.
this.manage(this);
}
}
protocol.registerFront(RootFront);
function run_test() {
DevToolsServer.createRootActor = RootActor;
DevToolsServer.init();
const trace = connectPipeTracing();
const client = new DevToolsClient(trace);
let rootFront;
client.connect().then(function onConnect() {
rootFront = client.mainRoot;
rootFront
.simpleReturn()
.then(
() => {
let stack = Components.stack;
while (stack) {
info(stack.name);
if (stack.name.includes("onConnect")) {
// Reached back to outer function before request
ok(true, "Complete stack");
return;
}
stack = stack.asyncCaller || stack.caller;
}
ok(false, "Incomplete stack");
},
() => {
ok(false, "Request failed unexpectedly");
}
)
.then(() => {
client.close().then(() => {
do_test_finished();
});
});
});
do_test_pending();
}
|