Closed
Bug 1164124
Opened 9 years ago
Closed 9 years ago
Create a 'using_prefs' context manager
Categories
(Remote Protocol :: Marionette, defect)
Remote Protocol
Marionette
Tracking
(firefox44 fixed)
RESOLVED
FIXED
mozilla44
Tracking | Status | |
---|---|---|
firefox44 | --- | fixed |
People
(Reporter: jgriffin, Assigned: TYLin)
References
Details
Attachments
(1 file)
We have pref setting code scattered throughout the marionette runner and tests; we should provide an easier way of dealing with these. Let's implement a 'with_pref' context manager that would set a pref and restore it at exit, similar to the 'with_permission' feature requested in bug 1161606.
Assignee | ||
Comment 1•9 years ago
|
||
Bug 1164124 - Add using_prefs context manager. r=jgriffin Add get_pref(), set_pref(), set_prefs() to make manipulate preferences easier. enforce_gecko_prefs() did the similar job as set_prefs(), but it will restart the browser if a preference to be set are different from what is already set in the system. Not all gecko preferences require a restart to work. Using set_prefs() should make testing faster. See bug 1048554.
Attachment #8666574 -
Flags: review?(jgriffin)
Reporter | ||
Comment 2•9 years ago
|
||
https://reviewboard.mozilla.org/r/20573/#review18447 ::: testing/marionette/driver/marionette_driver/marionette.py:953 (Diff revision 1) > + case Services.prefs.PREF_INVALID: There's a slight mismatch here between get_pref and set_pref. If get_pref is called on a pref which doesn't exist, it will return None. But if you pass None to set_pref, it will thrown an error. Instead, set_pref should probably delete the pref (via clearUserValue) in this case. Otherwise, there's no way to use this context manager to temporarily set a pref which may not have already had a value.
Assignee | ||
Updated•9 years ago
|
Assignee: nobody → tlin
Assignee | ||
Comment 3•9 years ago
|
||
Comment on attachment 8666574 [details] MozReview Request: Bug 1164124 - Add using_prefs context manager. r=jgriffin Bug 1164124 - Add using_prefs context manager. r=jgriffin Add get_pref(), set_pref(), set_prefs() to make manipulate preferences easier. enforce_gecko_prefs() did the similar job as set_prefs(), but it will restart the browser if a preference to be set are different from what is already set in the system. Not all gecko preferences require a restart to work. Using set_prefs() should make testing faster. See bug 1048554.
Assignee | ||
Comment 4•9 years ago
|
||
https://reviewboard.mozilla.org/r/20573/#review18447 > There's a slight mismatch here between get_pref and set_pref. If get_pref is called on a pref which doesn't exist, it will return None. But if you pass None to set_pref, it will thrown an error. Instead, set_pref should probably delete the pref (via clearUserValue) in this case. > > Otherwise, there's no way to use this context manager to temporarily set a pref which may not have already had a value. In patch set 2, the pref will be cleared in set_pref if the value to be set in None. Unit test is also updated to ensure that.
Reporter | ||
Updated•9 years ago
|
Attachment #8666574 -
Flags: review?(jgriffin) → review+
Reporter | ||
Comment 5•9 years ago
|
||
Comment on attachment 8666574 [details] MozReview Request: Bug 1164124 - Add using_prefs context manager. r=jgriffin https://reviewboard.mozilla.org/r/20575/#review18571 Thanks, looks good.
Reporter | ||
Comment 6•9 years ago
|
||
https://reviewboard.mozilla.org/r/20575/#review18573 Thanks, looks good.
Assignee | ||
Comment 7•9 years ago
|
||
Thank you for the review.
Summary: Create a 'with_pref' context manager → Create a 'using_prefs' context manager
Assignee | ||
Comment 8•9 years ago
|
||
Comment on attachment 8666574 [details] MozReview Request: Bug 1164124 - Add using_prefs context manager. r=jgriffin Bug 1164124 - Add using_prefs context manager. r=jgriffin Add get_pref(), set_pref(), set_prefs() to make manipulate preferences easier. enforce_gecko_prefs() did the similar job as set_prefs(), but it will restart the browser if a preference to be set are different from what is already set in the system. Not all gecko preferences require a restart to work. Using set_prefs() should make testing faster. See bug 1048554.
Assignee | ||
Comment 9•9 years ago
|
||
https://reviewboard.mozilla.org/r/20575/#review18697 ::: testing/marionette/driver/marionette_driver/marionette.py:968 (Diff revision 3) > + with self.using_context(self.CONTEXT_CHROME): In patch set3, use CONTEXT_CHROME in set_pref and clear_pref to fix try fail in Mn-e10s
Assignee | ||
Comment 10•9 years ago
|
||
https://hg.mozilla.org/integration/mozilla-inbound/rev/0db5f3c2b00451cc7acab6bfb42f4eb93ce88074 Bug 1164124 - Add using_prefs context manager. r=jgriffin
Comment 11•9 years ago
|
||
https://hg.mozilla.org/mozilla-central/rev/0db5f3c2b004
Status: NEW → RESOLVED
Closed: 9 years ago
status-firefox44:
--- → fixed
Resolution: --- → FIXED
Target Milestone: --- → mozilla44
Updated•1 year ago
|
Product: Testing → Remote Protocol
You need to log in
before you can comment on or make changes to this bug.
Description
•