mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-29 15:52:07 +00:00
Bug 1136083 - Fix |this._log| being null in tests using Telemetry. r=gfritzsche
This commit is contained in:
parent
af2df4e710
commit
81cd9b8312
@ -5,8 +5,14 @@
|
||||
|
||||
|
||||
Cu.import("resource:///modules/experiments/Experiments.jsm");
|
||||
Cu.import("resource://gre/modules/TelemetryPing.jsm", this);
|
||||
Cu.import("resource://gre/modules/TelemetrySession.jsm", this);
|
||||
|
||||
XPCOMUtils.defineLazyGetter(this, "gDatareportingService",
|
||||
() => Cc["@mozilla.org/datareporting/service;1"]
|
||||
.getService(Ci.nsISupports)
|
||||
.wrappedJSObject);
|
||||
|
||||
const FILE_MANIFEST = "experiments.manifest";
|
||||
const SEC_IN_ONE_DAY = 24 * 60 * 60;
|
||||
const MS_IN_ONE_DAY = SEC_IN_ONE_DAY * 1000;
|
||||
@ -45,6 +51,17 @@ function applicableFromManifestData(data, policy) {
|
||||
return entry.isApplicable();
|
||||
}
|
||||
|
||||
function initialiseTelemetry() {
|
||||
// Send the needed startup notifications to the datareporting service
|
||||
// to ensure that it has been initialized.
|
||||
if ("@mozilla.org/datareporting/service;1" in Cc) {
|
||||
gDatareportingService.observe(null, "app-startup", null);
|
||||
gDatareportingService.observe(null, "profile-after-change", null);
|
||||
}
|
||||
|
||||
return TelemetryPing.setup().then(TelemetrySession.setup);
|
||||
}
|
||||
|
||||
function run_test() {
|
||||
run_next_test();
|
||||
}
|
||||
@ -52,7 +69,7 @@ function run_test() {
|
||||
add_task(function* test_setup() {
|
||||
createAppInfo();
|
||||
gProfileDir = do_get_profile();
|
||||
yield TelemetrySession.setup();
|
||||
yield initialiseTelemetry();
|
||||
gPolicy = new Experiments.Policy();
|
||||
|
||||
gReporter = yield getReporter("json_payload_simple");
|
||||
|
@ -5,7 +5,14 @@ const Cu = Components.utils;
|
||||
const Cc = Components.classes;
|
||||
const Ci = Components.interfaces;
|
||||
Cu.import("resource://gre/modules/Services.jsm");
|
||||
Cu.import("resource://gre/modules/TelemetryPing.jsm", this);
|
||||
Cu.import("resource://gre/modules/TelemetrySession.jsm", this);
|
||||
Cu.import('resource://gre/modules/XPCOMUtils.jsm');
|
||||
|
||||
XPCOMUtils.defineLazyGetter(this, "gDatareportingService",
|
||||
() => Cc["@mozilla.org/datareporting/service;1"]
|
||||
.getService(Ci.nsISupports)
|
||||
.wrappedJSObject);
|
||||
|
||||
// The @mozilla/xre/app-info;1 XPCOM object provided by the xpcshell test harness doesn't
|
||||
// implement the nsIAppInfo interface, which is needed by Services.jsm and
|
||||
@ -17,6 +24,17 @@ function getSimpleMeasurementsFromTelemetryPing() {
|
||||
return TelemetrySession.getPayload().simpleMeasurements;
|
||||
}
|
||||
|
||||
function initialiseTelemetry() {
|
||||
// Send the needed startup notifications to the datareporting service
|
||||
// to ensure that it has been initialized.
|
||||
if ("@mozilla.org/datareporting/service;1" in Cc) {
|
||||
gDatareportingService.observe(null, "app-startup", null);
|
||||
gDatareportingService.observe(null, "profile-after-change", null);
|
||||
}
|
||||
|
||||
return TelemetryPing.setup().then(TelemetrySession.setup);
|
||||
}
|
||||
|
||||
function run_test() {
|
||||
// Make profile available for |TelemetrySession.shutdown()|.
|
||||
do_get_profile();
|
||||
@ -27,7 +45,7 @@ function run_test() {
|
||||
}
|
||||
|
||||
add_task(function* actualTest() {
|
||||
yield TelemetrySession.setup();
|
||||
yield initialiseTelemetry();
|
||||
|
||||
// Test the module logic
|
||||
let tmp = {};
|
||||
|
Loading…
Reference in New Issue
Block a user