Skip to content

Commit

Permalink
Bug 1732358 - Part 1: Override required_prefs in test_fission_autosta…
Browse files Browse the repository at this point in the history
…rt.py, r=whimboo,mccr8

Unfortunately we currently always configure the "fission.autostart" pref when
running tests, meaning that the test_fission_autostart.py test is always being
skipped on all platforms. This change force-disables the required pref when
running the test, rather than skipping the test if it is set.

It would be nice to handle this in a less hacky way, but this was the first way
I could think of.

Differential Revision: https://phabricator.services.mozilla.com/D133005
  • Loading branch information
mystor committed Dec 13, 2021
1 parent 6d6c87f commit 0d0306c
Showing 1 changed file with 16 additions and 41 deletions.
57 changes: 16 additions & 41 deletions toolkit/xre/test/marionette/test_fission_autostart.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,35 +85,6 @@ def check_fission_status(self, enabled, experiment, decision, dynamic=None):
% (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,
nightlyBuild: AppConstants.NIGHTLY_BUILD,
};
""",
script_args=(PREF,),
)

self.nightly_build = res["nightlyBuild"]

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)
Expand Down Expand Up @@ -180,9 +151,25 @@ def full_restart(self):
def setUp(self):
super(TestFissionAutostart, self).setUp()

# If we have configured marionette to require a particular value for
# `fission.autostart`, remove it as a forced pref until `tearDown`, and
# perform a clean restart, so we run this test without the pref
# pre-configured.
self.fissionRequired = None
if Prefs.FISSION_AUTOSTART in self.marionette.instance.required_prefs:
self.fissionRequired = self.marionette.instance.required_prefs[
Prefs.FISSION_AUTOSTART
]
del self.marionette.instance.required_prefs[Prefs.FISSION_AUTOSTART]
self.marionette.restart(clean=True)

self.setUpSession()

def tearDown(self):
if self.fissionRequired is not None:
self.marionette.instance.required_prefs[
Prefs.FISSION_AUTOSTART
] = self.fissionRequired
self.marionette.restart(clean=True)

super(TestFissionAutostart, self).tearDown()
Expand All @@ -191,10 +178,6 @@ def test_runtime_changes(self):
"""Tests that changes to preferences during runtime do not have any
effect on the current session."""

if self.check_pref_locked():
# Need to be able to flip Fission prefs for this test to work.
return

self.check_fission_status(
enabled=False,
experiment=ExperimentStatus.UNENROLLED,
Expand Down Expand Up @@ -256,10 +239,6 @@ def test_runtime_changes(self):
)

def test_fission_precedence(self):
if self.check_pref_locked():
# Need to be able to flip Fission prefs for this test to work.
return

self.check_fission_status(
enabled=False,
experiment=ExperimentStatus.UNENROLLED,
Expand Down Expand Up @@ -339,10 +318,6 @@ def test_fission_precedence(self):
)

def test_fission_startup(self):
if self.check_pref_locked():
# Need to be able to flip Fission prefs for this test to work.
return

# Starting the browser with STARTUP_ENROLLMENT_STATUS set to treatment
# should make the current session run under treatment.
with self.full_restart() as profile:
Expand Down

0 comments on commit 0d0306c

Please sign in to comment.