Bug 1462725 - Uninit study on Firefox shutdown; r=rhelmer draft
authorBianca Danforth <bdanforth@mozilla.com>
Mon, 04 Jun 2018 16:20:54 -0700
changeset 803872 5679a48de8e7e95c2b02619738582948032b2c19
parent 803871 175a029e1d0c3c536cc601e6382568832258aad5
child 803873 9bb6eb2d876f6b2a9e3d9dcc9585b9e12e14e8c4
push id112222
push userbdanforth@mozilla.com
push dateMon, 04 Jun 2018 23:26:13 +0000
reviewersrhelmer
bugs1462725
milestone62.0a1
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: GsoDhxf6CVJ
browser/components/nsBrowserGlue.js
browser/modules/SavantShieldStudy.jsm
--- a/browser/components/nsBrowserGlue.js
+++ b/browser/components/nsBrowserGlue.js
@@ -1110,16 +1110,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
@@ -32,16 +32,19 @@ class SavantShieldStudyClass {
     this.TelemetryEvents = new TelemetryEvents(this.STUDY_TELEMETRY_CATEGORY);
 
     // 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);
   }
 
@@ -65,20 +68,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);
   }
 }
 
 const SavantShieldStudy = new SavantShieldStudyClass();