diff options
author | Matt A. Tobin <mattatobin@localhost.localdomain> | 2018-02-02 04:16:08 -0500 |
---|---|---|
committer | Matt A. Tobin <mattatobin@localhost.localdomain> | 2018-02-02 04:16:08 -0500 |
commit | 5f8de423f190bbb79a62f804151bc24824fa32d8 (patch) | |
tree | 10027f336435511475e392454359edea8e25895d /toolkit/components/telemetry/tests/unit/test_TelemetryLog.js | |
parent | 49ee0794b5d912db1f95dce6eb52d781dc210db5 (diff) | |
download | UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.gz UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.lz UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.xz UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.zip |
Add m-esr52 at 52.6.0
Diffstat (limited to 'toolkit/components/telemetry/tests/unit/test_TelemetryLog.js')
-rw-r--r-- | toolkit/components/telemetry/tests/unit/test_TelemetryLog.js | 51 |
1 files changed, 51 insertions, 0 deletions
diff --git a/toolkit/components/telemetry/tests/unit/test_TelemetryLog.js b/toolkit/components/telemetry/tests/unit/test_TelemetryLog.js new file mode 100644 index 000000000..ea37a1bc5 --- /dev/null +++ b/toolkit/components/telemetry/tests/unit/test_TelemetryLog.js @@ -0,0 +1,51 @@ +/* Any copyright is dedicated to the Public Domain. + http://creativecommons.org/publicdomain/zero/1.0/ */ + +Cu.import("resource://gre/modules/TelemetryLog.jsm", this); +Cu.import("resource://gre/modules/TelemetrySession.jsm", this); + +const TEST_PREFIX = "TEST-"; +const TEST_REGEX = new RegExp("^" + TEST_PREFIX); + +function check_event(event, id, data) +{ + do_print("Checking message " + id); + do_check_eq(event[0], id); + do_check_true(event[1] > 0); + + if (data === undefined) { + do_check_true(event.length == 2); + } else { + do_check_eq(event.length, data.length + 2); + for (var i = 0; i < data.length; ++i) { + do_check_eq(typeof(event[i + 2]), "string"); + do_check_eq(event[i + 2], data[i]); + } + } +} + +add_task(function* () +{ + do_get_profile(); + // TODO: After Bug 1254550 lands we should not need to set the pref here. + Services.prefs.setBoolPref(PREF_TELEMETRY_ENABLED, true); + yield TelemetryController.testSetup(); + + TelemetryLog.log(TEST_PREFIX + "1", ["val", 123, undefined]); + TelemetryLog.log(TEST_PREFIX + "2", []); + TelemetryLog.log(TEST_PREFIX + "3"); + + var log = TelemetrySession.getPayload().log.filter(function(e) { + // Only want events that were generated by the test. + return TEST_REGEX.test(e[0]); + }); + + do_check_eq(log.length, 3); + check_event(log[0], TEST_PREFIX + "1", ["val", "123", "undefined"]); + check_event(log[1], TEST_PREFIX + "2", []); + check_event(log[2], TEST_PREFIX + "3", undefined); + do_check_true(log[0][1] <= log[1][1]); + do_check_true(log[1][1] <= log[2][1]); + + yield TelemetryController.testShutdown(); +}); |