Bug 1541469 - Don't write default values to feature gate preferences r=mossop
authorMichael Cooper <mcooper@mozilla.com>
Wed, 24 Apr 2019 20:10:29 +0000
changeset 530028 0489c7d0b8d13a4c26718fe7bbf06cf8281a65b2
parent 530027 62218e6b1c1105a94b3b48e689c0e87ab50f671d
child 530029 2e4a7bcc1a95d8761359d693f242453d2ceae6cf
push id11265
push userffxbld-merge
push dateMon, 13 May 2019 10:53:39 +0000
treeherdermozilla-beta@77e0fe8dbdd3 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmossop
bugs1541469
milestone68.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1541469 - Don't write default values to feature gate preferences r=mossop Differential Revision: https://phabricator.services.mozilla.com/D25950
browser/app/profile/firefox.js
toolkit/components/featuregates/FeatureGateImplementation.jsm
toolkit/components/featuregates/Features.toml
toolkit/components/featuregates/test/unit/test_FeatureGateImplementation.js
--- a/browser/app/profile/firefox.js
+++ b/browser/app/profile/firefox.js
@@ -1818,17 +1818,16 @@ pref("browser.chrome.errorReporter.infoU
 // Normandy client preferences
 pref("app.normandy.api_url", "https://normandy.cdn.mozilla.net/api/v1");
 pref("app.normandy.dev_mode", false);
 pref("app.normandy.enabled", true);
 pref("app.normandy.first_run", true);
 pref("app.normandy.logging.level", 50); // Warn
 pref("app.normandy.run_interval_seconds", 21600); // 6 hours
 pref("app.normandy.shieldLearnMoreUrl", "https://support.mozilla.org/1/firefox/%VERSION%/%OS%/%LOCALE%/shield");
-pref("features.normandy-remote-settings.enabled", false);
 #ifdef MOZ_DATA_REPORTING
 pref("app.shield.optoutstudies.enabled", true);
 #else
 pref("app.shield.optoutstudies.enabled", false);
 #endif
 
 // Multi-lingual preferences
 #ifdef RELEASE_OR_BETA
--- a/toolkit/components/featuregates/FeatureGateImplementation.jsm
+++ b/toolkit/components/featuregates/FeatureGateImplementation.jsm
@@ -29,26 +29,16 @@ class FeatureGateImplementation {
    * @param {string} definition.preference
    * @param {string} definition.defaultValue
    * @param {object} definition.isPublic
    * @param {object} definition.bugNumbers
    */
   constructor(definition) {
     this._definition = definition;
     this._observers = new Set();
-
-    switch (this.type) {
-      case "boolean": {
-        Services.prefs.getDefaultBranch("").setBoolPref(this.preference, this.defaultValue);
-        break;
-      }
-      default: {
-        throw new Error(`Unsupported feature gate type ${this.type}`);
-      }
-    }
   }
 
   // The below are all getters instead of direct access to make it easy to provide JSDocs.
 
   /**
    * A short string used to refer to this feature in code.
    * @type string
    */
--- a/toolkit/components/featuregates/Features.toml
+++ b/toolkit/components/featuregates/Features.toml
@@ -1,10 +1,10 @@
 [normandy-remote-settings]
 title = "Normandy: Remote Settings transport"
 description = """
 When enabled, the Normandy client will fetch recipes from Remote Settings \
-instead of direclty from the Normandy API."""
+instead of directly from the Normandy API."""
 restart-required = false
 type = "boolean"
 bug-numbers = [1519276]
 is-public = true
 default-value = false
\ No newline at end of file
--- a/toolkit/components/featuregates/test/unit/test_FeatureGateImplementation.js
+++ b/toolkit/components/featuregates/test/unit/test_FeatureGateImplementation.js
@@ -63,21 +63,21 @@ add_task(async function testGetValue() {
   const preference = "test.pref";
   equal(
     Services.prefs.getPrefType(preference),
     Services.prefs.PREF_INVALID,
     "Before creating the feature gate, the preference should not exist",
   );
   const feature = new FeatureGateImplementation(definitionFactory({ preference, defaultValue: false }));
   equal(
-    Services.prefs.getBoolPref(preference),
-    false,
-    "Creating a preference should set its default value",
+    Services.prefs.getPrefType(preference),
+    Services.prefs.PREF_INVALID,
+    "Instantiating a feature gate should not set its default value",
   );
-  equal(await feature.getValue(), false, "getValue() should return the same value");
+  equal(await feature.getValue(), false, "getValue() should return the feature gate's default");
 
   Services.prefs.setBoolPref(preference, true);
   equal(await feature.getValue(), true, "getValue() should return the new value");
 
   Services.prefs.setBoolPref(preference, false);
   equal(await feature.getValue(), false, "getValue() should return the third value");
 
   // cleanup