Bug 1401129 - Restore extensions.shield-recipe-client.api_url in automation tools. r?whimboo draft
authorAndreas Tolfsen <ato@sny.no>
Thu, 08 Mar 2018 15:47:09 +0000
changeset 766192 95594c605c7ce38ba966e1f63008791236a831e2
parent 766191 7ee4af16446f0bb17e346d0d54c9724d6f8bb868
child 766193 b26b6cb708468c2afe9e5e06aad4ff916b186e07
push id102248
push userbmo:ato@sny.no
push dateMon, 12 Mar 2018 11:49:43 +0000
reviewerswhimboo
bugs1401129, 1436113
milestone60.0a1
Bug 1401129 - Restore extensions.shield-recipe-client.api_url in automation tools. r?whimboo The extensions.shield-recipe-client.api_url preference was replaced with app.normandy.api_url in bug 1436113. There are multiple automation tools in the tree that target out-of-tree release channels and removing the old preference would break these. This patch re-adds the old preference with a note of when it was removed. MozReview-Commit-ID: HhTfRFkRQTC
testing/geckodriver/src/prefs.rs
testing/marionette/client/marionette_driver/geckoinstance.py
testing/marionette/components/marionette.js
testing/marionette/harness/marionette_harness/tests/unit/test_prefs.py
--- a/testing/geckodriver/src/prefs.rs
+++ b/testing/geckodriver/src/prefs.rs
@@ -1,12 +1,15 @@
 use mozprofile::preferences::Pref;
 
 lazy_static! {
-    pub static ref DEFAULT: [(&'static str, Pref); 79] = [
+    pub static ref DEFAULT: [(&'static str, Pref); 80] = [
+        // Make sure Shield doesn't hit the network.
+        ("app.normandy.api_url", Pref::new("")),
+
         // Disable automatic downloading of new releases
         ("app.update.auto", Pref::new(false)),
 
         // Disable automatically upgrading Firefox
         ("app.update.enabled", Pref::new(false)),
 
         // Increase the APZ content response timeout in tests to 1
         // minute.  This is to accommodate the fact that test environments
@@ -140,17 +143,18 @@ lazy_static! {
 
         // Disable metadata caching for installed add-ons by default
         ("extensions.getAddons.cache.enabled", Pref::new(false)),
 
         // Disable intalling any distribution extensions or add-ons
         ("extensions.installDistroAddons", Pref::new(false)),
 
         // Make sure Shield doesn't hit the network.
-        ("app.normandy.api_url", Pref::new("")),
+        // Removed in Firefox 60.
+        ("extensions.shield-recipe-client.api_url", Pref::new("")),
 
         ("extensions.showMismatchUI", Pref::new(false)),
 
         // Turn off extension updates so they do not bother tests
         ("extensions.update.enabled", Pref::new(false)),
         ("extensions.update.notifyUser", Pref::new(false)),
 
         // Make sure opening about:addons will not hit the network
--- a/testing/marionette/client/marionette_driver/geckoinstance.py
+++ b/testing/marionette/client/marionette_driver/geckoinstance.py
@@ -19,16 +19,19 @@ from mozprofile import Profile
 from mozrunner import Runner, FennecEmulatorRunner
 from six import reraise
 
 from . import errors
 
 
 class GeckoInstance(object):
     required_prefs = {
+        # Make sure Shield doesn't hit the network.
+        "app.normandy.api_url": "",
+
         # Increase the APZ content response timeout in tests to 1 minute.
         # This is to accommodate the fact that test environments tends to be slower
         # than production environments (with the b2g emulator being the slowest of them
         # all), resulting in the production timeout value sometimes being exceeded
         # and causing false-positive test failures. See bug 1176798, bug 1177018,
         # bug 1210465.
         "apz.content_response_timeout": 60000,
 
@@ -50,17 +53,18 @@ class GeckoInstance(object):
         # AddonManager.SCOPE_PROFILE + AddonManager.SCOPE_APPLICATION
         "extensions.autoDisableScopes": 0,
         "extensions.enabledScopes": 5,
         # Disable metadata caching for installed add-ons by default
         "extensions.getAddons.cache.enabled": False,
         # Disable intalling any distribution add-ons
         "extensions.installDistroAddons": False,
         # Make sure Shield doesn't hit the network.
-        "app.normandy.api_url": "",
+        # Removed in Firefox 60.
+        "extensions.shield-recipe-client.api_url": "",
         "extensions.showMismatchUI": False,
         # Turn off extension updates so they don't bother tests
         "extensions.update.enabled": False,
         "extensions.update.notifyUser": False,
         # Make sure opening about:addons won"t hit the network
         "extensions.webservice.discoverURL": "http://%(server)s/dummy/discoveryURL",
 
         # Allow the application to have focus even it runs in the background
--- a/testing/marionette/components/marionette.js
+++ b/testing/marionette/components/marionette.js
@@ -49,16 +49,19 @@ const ENV_PRESERVE_PREFS = "MOZ_MARIONET
 
 // Marionette sets preferences recommended for automation when it starts,
 // unless marionette.prefs.recommended has been set to false.
 // Where noted, some prefs should also be set in the profile passed to
 // Marionette to prevent them from affecting startup, since some of these
 // are checked before Marionette initialises.
 const RECOMMENDED_PREFS = new Map([
 
+  // Make sure Shield doesn't hit the network.
+  ["app.normandy.api_url", ""],
+
   // Disable automatic downloading of new releases.
   //
   // This should also be set in the profile prior to starting Firefox,
   // as it is picked up at runtime.
   ["app.update.auto", false],
 
   // Disable automatically upgrading Firefox.
   //
@@ -192,19 +195,16 @@ const RECOMMENDED_PREFS = new Map([
 
   // Disable metadata caching for installed add-ons by default
   ["extensions.getAddons.cache.enabled", false],
 
   // Disable installing any distribution extensions or add-ons.
   // Should be set in profile.
   ["extensions.installDistroAddons", false],
 
-  // Make sure Shield doesn't hit the network.
-  ["extensions.shield-recipe-client.api_url", ""],
-
   ["extensions.showMismatchUI", false],
 
   // Turn off extension updates so they do not bother tests
   ["extensions.update.enabled", false],
   ["extensions.update.notifyUser", false],
 
   // Make sure opening about:addons will not hit the network
   [
--- a/testing/marionette/harness/marionette_harness/tests/unit/test_prefs.py
+++ b/testing/marionette/harness/marionette_harness/tests/unit/test_prefs.py
@@ -27,18 +27,26 @@ class TestPreferences(MarionetteTestCase
             self.marionette.clear_pref(pref)
 
         super(TestPreferences, self).tearDown()
 
     def test_gecko_instance_preferences(self):
         required_prefs = geckoinstance.GeckoInstance.required_prefs
 
         for key, value in required_prefs.iteritems():
-            self.assertEqual(self.marionette.get_pref(key), value,
-                             "Preference {} hasn't been set to {}".format(key, value))
+            # The extensions.shield-recipe-client.* prefs branch
+            # is as of Firefox 60 migrated to app.normandy.*.
+            #
+            # This is a workaround that can be removed together
+            # with extensions.shield-recipe-client.api_url.
+            if key == "extensions.shield-recipe-client.api_url":
+                self.assertEqual(self.marionette.get_pref("app.normandy.api_url"), value)
+            else:
+                self.assertEqual(self.marionette.get_pref(key), value,
+                                 "Preference {} hasn't been set to {}".format(key, repr(value)))
 
     @skip_if_mobile("Only runnable with Firefox")
     def test_desktop_instance_preferences(self):
         required_prefs = geckoinstance.DesktopInstance.desktop_prefs
 
         for key, value in required_prefs.iteritems():
             if key in ["browser.tabs.remote.autostart"]:
                 return