mirror of
https://github.com/mozilla/gecko-dev.git
synced 2025-01-27 15:55:16 +00:00
Bug 845935 - Don't perform FHR activities unless fully initialized; r=rnewman
This commit is contained in:
parent
018a85ed75
commit
264e923d17
@ -499,6 +499,10 @@ AbstractHealthReporter.prototype = Object.freeze({
|
||||
* Collect all measurements for all registered providers.
|
||||
*/
|
||||
collectMeasurements: function () {
|
||||
if (!this._initialized) {
|
||||
return Promise.reject(new Error("Not initialized."));
|
||||
}
|
||||
|
||||
return Task.spawn(function doCollection() {
|
||||
try {
|
||||
TelemetryStopwatch.start(TELEMETRY_COLLECT_CONSTANT, this);
|
||||
@ -548,6 +552,10 @@ AbstractHealthReporter.prototype = Object.freeze({
|
||||
* @return Promise<Object | string>
|
||||
*/
|
||||
collectAndObtainJSONPayload: function (asObject=false) {
|
||||
if (!this._initialized) {
|
||||
return Promise.reject(new Error("Not initialized."));
|
||||
}
|
||||
|
||||
return Task.spawn(function collectAndObtain() {
|
||||
yield this._providerManager.ensurePullOnlyProvidersRegistered();
|
||||
|
||||
@ -591,6 +599,10 @@ AbstractHealthReporter.prototype = Object.freeze({
|
||||
* @return Promise<string|object>
|
||||
*/
|
||||
getJSONPayload: function (asObject=false) {
|
||||
if (!this._initialized) {
|
||||
return Promise.reject(new Error("Not initialized."));
|
||||
}
|
||||
|
||||
TelemetryStopwatch.start(TELEMETRY_GENERATE_PAYLOAD, this);
|
||||
let deferred = Promise.defer();
|
||||
|
||||
@ -1011,6 +1023,10 @@ HealthReporter.prototype = Object.freeze({
|
||||
* The passed argument is a `DataSubmissionRequest` from policy.jsm.
|
||||
*/
|
||||
requestDataUpload: function (request) {
|
||||
if (!this._initialized) {
|
||||
return Promise.reject(new Error("Not initialized."));
|
||||
}
|
||||
|
||||
return Task.spawn(function doUpload() {
|
||||
yield this._providerManager.ensurePullOnlyProvidersRegistered();
|
||||
try {
|
||||
|
@ -630,3 +630,29 @@ add_task(function test_collect_when_upload_disabled() {
|
||||
reporter._shutdown();
|
||||
}
|
||||
});
|
||||
|
||||
add_task(function test_failure_if_not_initialized() {
|
||||
let reporter = yield getReporter("failure_if_not_initialized");
|
||||
reporter._shutdown();
|
||||
|
||||
let error = false;
|
||||
try {
|
||||
yield reporter.requestDataUpload();
|
||||
} catch (ex) {
|
||||
error = true;
|
||||
do_check_true(ex.message.contains("Not initialized."));
|
||||
} finally {
|
||||
do_check_true(error);
|
||||
error = false;
|
||||
}
|
||||
|
||||
try {
|
||||
yield reporter.collectMeasurements();
|
||||
} catch (ex) {
|
||||
error = true;
|
||||
do_check_true(ex.message.contains("Not initialized."));
|
||||
} finally {
|
||||
do_check_true(error);
|
||||
error = false;
|
||||
}
|
||||
});
|
||||
|
Loading…
x
Reference in New Issue
Block a user