Need some way to persist prefs from within a test between restarts

RESOLVED WORKSFORME

Status

RESOLVED WORKSFORME
4 years ago
2 years ago

People

(Reporter: chmanchester, Unassigned)

Tracking

Version 3
x86_64
Linux
Points:
---

Firefox Tracking Flags

(Not tracked)

Details

Attachments

(1 attachment)

(Reporter)

Description

4 years ago
Splitting this blocker for update tests from the discussion in bug 1129713. It seems like we need finer grained control than other consumers of mozprofile right now. If this ability is ever added there we can re-assess.
(Reporter)

Comment 1

4 years ago
ahal had a suggestion in https://bugzilla.mozilla.org/show_bug.cgi?id=1129713#c7 I'll try adding to our prefs library.
(Reporter)

Comment 2

4 years ago
Created attachment 8568205 [details] [review]
Add a function to persist prefs through restarts
Attachment #8568205 - Flags: review?(hskupin)
Comment on attachment 8568205 [details] [review]
Add a function to persist prefs through restarts

r- because the test is not testing what I was talking about in the other bug. I put more details on the PR.
Attachment #8568205 - Flags: review?(hskupin) → review-
(Reporter)

Comment 4

4 years ago
Harness set preferences are re-enforced after a restart, so this needs a different fix.
(Reporter)

Comment 5

4 years ago
This needs a small change to marionette automation to work. Henrik, if we were able to pass a dictionary of preferences to the call to restart to ensure they persist, would that be sufficient?
Flags: needinfo?(hskupin)
It should but how do you wanna do that? You would have to mess around with mozprofile to get that working, given that utils.js will already be present in that profile.
Flags: needinfo?(hskupin)
(Reporter)

Comment 7

4 years ago
(In reply to Henrik Skupin (:whimboo) from comment #6)
> It should but how do you wanna do that? You would have to mess around with
> mozprofile to get that working, given that utils.js will already be present
> in that profile.

Marionette's restart machinery has a way to specify prefs that will become the new "required prefs" that are enforced after the restart. This will just be a matter of exposing that parameter to marionette.restart (it's already defined for geckoinstance.restart).
If that all works wonderful! We only have to ensure that for the next test, all the default prefs are in place again.
(Reporter)

Comment 9

4 years ago
Comment on attachment 8568205 [details] [review]
Add a function to persist prefs through restarts

I pushed a more extensive test with the proposed behavior to the branch in the PR (it passes with the proposed marionette patch). To get back to the harness defaults after a test we can call self.marionette.enforce_gecko_prefs with the harness defaults in tearDown.
Attachment #8568205 - Flags: review- → feedback?(hskupin)
Comment on attachment 8568205 [details] [review]
Add a function to persist prefs through restarts

I gave a couple of comments on the PR. I still don't think this is the right way to handle that. Maybe it needs a more detailed discussion first.
Attachment #8568205 - Flags: feedback?(hskupin) → feedback-
(Reporter)

Comment 11

4 years ago
Discussion in the PR lead us to bug 1137388. That needs to be resolved before we proceed here.
(Reporter)

Comment 12

4 years ago
I think what we're talking about is a way to persist the override of a pref that gets set in user.js at the beginning of the test run. Marionette lets us do this with enforce_gecko_prefs, which causes a hard restart if the pref needs to be updated, and it looks like self.marionette.instance.profile.set_preferences() will let us write to a user.js file at any point.
Sounds good. Can Marionette automatically reset the value of this preferences to the one as given by the harness at the end of the test?
(Reporter)

Comment 14

4 years ago
(In reply to Henrik Skupin (:whimboo) from comment #13)
> Sounds good. Can Marionette automatically reset the value of this
> preferences to the one as given by the harness at the end of the test?

We can implement that by calling enforce_gecko_prefs with the defaults after the test runs.
That sounds perfect.
(Assignee)

Updated

3 years ago
Product: Mozilla QA → Testing
I think there is no actionable item left on this bug given that enforce_gecko_prefs() gives us what we need.
Status: NEW → RESOLVED
Last Resolved: 2 years ago
Resolution: --- → WORKSFORME
You need to log in before you can comment on or make changes to this bug.