Bug 1667407: Skip Fission preference tests when pref is locked on release/beta. r=nika
authorKris Maglione <maglione.k@gmail.com>
Thu, 01 Oct 2020 01:52:47 +0000
changeset 551171 5954ef1f0b60bda0131a77ba5edf8c563d24d875
parent 551170 225e361e5b8c001260196b63d6ae4f8e748121df
child 551172 e7a07501dc07f46d12642df102f2e58a0171c525
push id127713
push usermaglione.k@gmail.com
push dateThu, 01 Oct 2020 23:45:48 +0000
treeherderautoland@5954ef1f0b60 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersnika
bugs1667407
milestone83.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 1667407: Skip Fission preference tests when pref is locked on release/beta. r=nika Differential Revision: https://phabricator.services.mozilla.com/D91984
toolkit/xre/test/marionette/test_fission_autostart.py
--- a/toolkit/xre/test/marionette/test_fission_autostart.py
+++ b/toolkit/xre/test/marionette/test_fission_autostart.py
@@ -48,16 +48,38 @@ class TestFissionAutostart(MarionetteTes
         status = self.get_fission_status()
 
         for prop, value in expected.items():
             self.assertEqual(
                 status[prop], value,
                 '%s should have the value `%r`, but has `%r`'
                 % (prop, value, status[prop]))
 
+    def check_pref_locked(self):
+        PREF = Prefs.FISSION_AUTOSTART
+
+        if PREF in self.marionette.instance.required_prefs:
+            return True
+
+        res = self.execute_script(r'''
+          const { AppConstants } = ChromeUtils.import(
+            "resource://gre/modules/AppConstants.jsm"
+          );
+          return {
+            prefLocked: Services.prefs.prefIsLocked(arguments[0]),
+            releaseOrBeta: AppConstants.RELEASE_OR_BETA,
+          };
+        ''', script_args=(PREF,))
+
+        if res['prefLocked']:
+            self.assertTrue(res['releaseOrBeta'],
+                            'Preference should only be locked on release/beta')
+            return True
+        return False
+
     def set_env(self, env, value):
         self.execute_script('env.set(arguments[0], arguments[1]);',
                             script_args=(env, value))
 
     def get_env(self, env):
         return self.execute_script('return env.get(arguments[0]);',
                                    script_args=(env,))
 
@@ -112,17 +134,17 @@ class TestFissionAutostart(MarionetteTes
         self.marionette.restart(clean=True)
 
         super(TestFissionAutostart, self).tearDown()
 
     def test_runtime_changes(self):
         """Tests that changes to preferences during runtime do not have any
         effect on the current session."""
 
-        if self.marionette.instance.required_prefs.get(Prefs.FISSION_AUTOSTART):
+        if self.check_pref_locked():
             # Need to be able to flip Fission prefs for this test to work.
             return
 
         self.restart(prefs={Prefs.FISSION_AUTOSTART: True})
 
         self.check_fission_status(enabled=True,
                                   experiment=ExperimentStatus.UNKNOWN)
 
@@ -145,17 +167,17 @@ class TestFissionAutostart(MarionetteTes
         self.check_fission_status(enabled=False,
                                   experiment=ExperimentStatus.ENROLLED_CONTROL)
 
         self.set_env(ENV_ENABLE_FISSION, '1')
         self.check_fission_status(enabled=False,
                                   experiment=ExperimentStatus.ENROLLED_CONTROL)
 
     def test_fission_precedence(self):
-        if self.marionette.instance.required_prefs.get(Prefs.FISSION_AUTOSTART):
+        if self.check_pref_locked():
             # Need to be able to flip Fission prefs for this test to work.
             return
 
         self.restart(prefs={Prefs.FISSION_AUTOSTART: False},
                      env={ENV_ENABLE_FISSION: '1'})
         self.check_fission_status(enabled=True,
                                   experiment=ExperimentStatus.UNKNOWN)