blob: 16a18644e926e71f73b3580d57c39f6b4228540e (
plain)
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
|
/* Any copyright is dedicated to the Public Domain.
http://creativecommons.org/publicdomain/zero/1.0/
*/
// Enable the collection (during test) for all products so even products
// that don't collect the data will be able to run the test without failure.
Services.prefs.setBoolPref(
"toolkit.telemetry.testing.overrideProductsCheck",
true
);
add_setup(async function test_setup() {
// Addon manager needs a profile directory
do_get_profile();
});
add_task(async function test_register_twice_fails() {
TelemetryController.registerSyncPingShutdown(() => {});
Assert.throws(
() => TelemetryController.registerSyncPingShutdown(() => {}),
/The sync ping shutdown handler is already registered./
);
await TelemetryController.testReset();
});
add_task(async function test_reset_clears_handler() {
await TelemetryController.testSetup();
TelemetryController.registerSyncPingShutdown(() => {});
await TelemetryController.testReset();
// If this works the reset must have cleared it.
TelemetryController.registerSyncPingShutdown(() => {});
await TelemetryController.testReset();
});
add_task(async function test_shutdown_handler_submits() {
let handlerCalled = false;
await TelemetryController.testSetup();
TelemetryController.registerSyncPingShutdown(() => {
handlerCalled = true;
// and submit a ping.
let ping = {
why: "shutdown",
};
TelemetryController.submitExternalPing("sync", ping);
});
await TelemetryController.testShutdown();
Assert.ok(handlerCalled);
await TelemetryController.testReset();
});
add_task(async function test_shutdown_handler_no_submit() {
let handlerCalled = false;
await TelemetryController.testSetup();
TelemetryController.registerSyncPingShutdown(() => {
handlerCalled = true;
// but don't submit a ping.
});
await TelemetryController.testShutdown();
Assert.ok(handlerCalled);
});
// NB: The last test in this file *must not* restart TelemetryController, or it
// will cause intermittent timeouts for this test.
|