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
100
101
102
103
104
105
106
107
|
/* Any copyright is dedicated to the Public Domain.
http://creativecommons.org/publicdomain/zero/1.0/ */
var gClient;
var gActors;
/**
* The purpose of these tests is to verify that it's possible to add actors
* both before and after the DebuggerServer has been initialized, so addons
* that add actors don't have to poll the object for its initialization state
* in order to add actors after initialization but rather can add actors anytime
* regardless of the object's state.
*/
function run_test()
{
DebuggerServer.addActors("resource://test/pre_init_global_actors.js");
DebuggerServer.addActors("resource://test/pre_init_tab_actors.js");
DebuggerServer.init();
DebuggerServer.addBrowserActors();
DebuggerServer.addActors("resource://test/post_init_global_actors.js");
DebuggerServer.addActors("resource://test/post_init_tab_actors.js");
add_test(init);
add_test(test_pre_init_global_actor);
add_test(test_pre_init_tab_actor);
add_test(test_post_init_global_actor);
add_test(test_post_init_tab_actor);
add_test(test_stable_global_actor_instances);
add_test(close_client);
run_next_test();
}
function init()
{
gClient = new DebuggerClient(DebuggerServer.connectPipe());
gClient.connect()
.then(() => gClient.listTabs())
.then(aResponse => {
gActors = aResponse;
run_next_test();
});
}
function test_pre_init_global_actor()
{
gClient.request({ to: gActors.preInitGlobalActor, type: "ping" },
function onResponse(aResponse) {
do_check_eq(aResponse.message, "pong");
run_next_test();
}
);
}
function test_pre_init_tab_actor()
{
gClient.request({ to: gActors.preInitTabActor, type: "ping" },
function onResponse(aResponse) {
do_check_eq(aResponse.message, "pong");
run_next_test();
}
);
}
function test_post_init_global_actor()
{
gClient.request({ to: gActors.postInitGlobalActor, type: "ping" },
function onResponse(aResponse) {
do_check_eq(aResponse.message, "pong");
run_next_test();
}
);
}
function test_post_init_tab_actor()
{
gClient.request({ to: gActors.postInitTabActor, type: "ping" },
function onResponse(aResponse) {
do_check_eq(aResponse.message, "pong");
run_next_test();
}
);
}
// Get the object object, from the server side, for a given actor ID
function getActorInstance(connID, actorID) {
return DebuggerServer._connections[connID].getActor(actorID);
}
function test_stable_global_actor_instances()
{
// Consider that there is only one connection,
// and the first one is ours
let connID = Object.keys(DebuggerServer._connections)[0];
let postInitGlobalActor = getActorInstance(connID, gActors.postInitGlobalActor);
let preInitGlobalActor = getActorInstance(connID, gActors.preInitGlobalActor);
gClient.listTabs(function onListTabs(aResponse) {
do_check_eq(postInitGlobalActor, getActorInstance(connID, aResponse.postInitGlobalActor));
do_check_eq(preInitGlobalActor, getActorInstance(connID, aResponse.preInitGlobalActor));
run_next_test();
});
}
function close_client() {
gClient.close().then(() => run_next_test());
}
|