Bug 1462725 - Uninit study on Firefox shutdown; r=rhelmer
Intended to undo study-related changes that don't need to persist between sessions: clear prefs, remove observers, etc.
MozReview-Commit-ID: 4Eyyq7vMm13
--- a/browser/components/nsBrowserGlue.js
+++ b/browser/components/nsBrowserGlue.js
@@ -1109,16 +1109,18 @@ BrowserGlue.prototype = {
DateTimePickerHelper.uninit();
// Browser errors are only collected on Nightly
if (AppConstants.NIGHTLY_BUILD && AppConstants.MOZ_DATA_REPORTING) {
this.browserErrorReporter.uninit();
}
Normandy.uninit();
+
+ SavantShieldStudy.uninit();
},
// All initial windows have opened.
_onWindowsRestored: function BG__onWindowsRestored() {
if (this._windowsWereRestored) {
return;
}
this._windowsWereRestored = true;
--- a/browser/modules/SavantShieldStudy.jsm
+++ b/browser/modules/SavantShieldStudy.jsm
@@ -38,16 +38,19 @@ class SavantShieldStudyClass {
this.TELEMETRY_CLIENT_ID);
// TODO: implement eligibility (#13)
const isEligible = true;
if (!isEligible) {
this.endStudy("ineligible");
return;
}
+
+ // TODO check expiration, add study duration override pref
+
// check the pref in case Normandy flipped it on before we could add the pref listener
this.shouldCollect = Services.prefs.getBoolPref(this.STUDY_PREF);
if (this.shouldCollect) {
this.TelemetryEvents.enableCollection();
}
Services.prefs.addObserver(this.STUDY_PREF, this);
}
@@ -71,20 +74,17 @@ class SavantShieldStudyClass {
endStudy(reason) {
this.TelemetryEvents.disableCollection();
// Services.telemetry.recordEvent(this.STUDY_TELEMETRY_CATEGORY, "end_study", reason);
this.uninit();
}
// Called on every Firefox shutdown and endStudy
uninit() {
- // TODO: Make sure uninit() is called on every Firefox shutdown (look inside
- // nsBrowserGlue.js to see where Normandy uninits)
- // TODO: See what happens during Normandy's uninit method to ensure nothing
- // is forgotten.
+ // TODO: clear study expiration override pref and remove its listener
Services.prefs.removeObserver(this.STUDY_PREF, this);
Services.prefs.clearUserPref(this.STUDY_PREF);
Services.prefs.clearUserPref(PREF_LOG_LEVEL);
}
async getFlowID(str) {
return this.TelemetryEvents.getFlowID(str);
}