Bug 1462725 - Uninit study on Firefox shutdown; r=rhelmer draft
authorBianca Danforth <bdanforth@mozilla.com>
Wed, 23 May 2018 07:23:44 -0700
changeset 803322 6320edb2aa39fa104c02147896a090fa556a7419
parent 803321 4fbcdc0e445b856ae79b6d19ee13e80505ca42ca
child 803323 f26a1112e2cadb3d0ec016cef2fd375e2dcdf5dd
push id112069
push userbdanforth@mozilla.com
push dateSun, 03 Jun 2018 04:54:10 +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: 4Eyyq7vMm13
browser/components/nsBrowserGlue.js
browser/modules/SavantShieldStudy.jsm
--- 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);
   }