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
|
/* Any copyright is dedicated to the Public Domain.
http://creativecommons.org/publicdomain/zero/1.0/ */
"use strict";
/**
* Tests whether the profiler module is kept active when there are multiple
* client consumers and one requests deactivation.
*/
const Profiler = Cc["@mozilla.org/tools/profiler;1"].getService(Ci.nsIProfiler);
function run_test()
{
get_chrome_actors((client1, form1) => {
let actor1 = form1.profilerActor;
get_chrome_actors((client2, form2) => {
let actor2 = form2.profilerActor;
test_close(client1, actor1, client2, actor2, () => {
client1.close(() => {
client2.close(() => {
do_test_finished();
});
});
});
});
});
do_test_pending();
}
function activate_profiler(client, actor, callback)
{
client.request({ to: actor, type: "startProfiler" }, response => {
do_check_true(response.started);
do_check_true(Profiler.IsActive());
client.request({ to: actor, type: "isActive" }, response => {
do_check_true(response.isActive);
callback();
});
});
}
function deactivate_profiler(client, actor, callback)
{
client.request({ to: actor, type: "stopProfiler" }, response => {
do_check_false(response.started);
do_check_true(Profiler.IsActive());
client.request({ to: actor, type: "isActive" }, response => {
do_check_true(response.isActive);
callback();
});
});
}
function test_close(client1, actor1, client2, actor2, callback)
{
activate_profiler(client1, actor1, () => {
activate_profiler(client2, actor2, () => {
deactivate_profiler(client1, actor1, () => {
deactivate_profiler(client2, actor2, () => {
callback();
});
});
});
});
}
|