-
Notifications
You must be signed in to change notification settings - Fork 1.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Improve firefox profile prefs merging: #423
Conversation
@@ -334,11 +334,12 @@ impl MarionetteHandler { | |||
.map_err(|_| WebDriverError::new(ErrorStatus::UnknownError, | |||
"Unable to read profile preferences file"))); | |||
|
|||
prefs.insert("marionette.defaultPrefs.port", Pref::new(port as i64)); | |||
for &(ref name, ref value) in prefs::DEFAULT.iter() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure this is obviously the correct behaviour. If you set a custom profile you might reasonably expect to get the prefs you set, except any that are actually required to make marionette function correctly. If you want the default set you can always set those explicitly.
What's the specific problem here that you're trying to solve? (n.b. I hope that in the future we can enable more things that currently require an entire custom profile via more fine grained capabilities e.g. extension installation).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I guess this might be a result of 2bfdc3e.
Many of the preferences in prefs::DEFAULT
are actually required for Marionette to function correctly, and some of these we can’t set at runtime. We should probably move those that are absolute requirements over to prefs::REQUIRED
, and we should set those we can set at runtime in Marionette. I filed https://bugzilla.mozilla.org/show_bug.cgi?id=1323290 about the latter before Christmas.
As I read this code, the default prefs will only get written to the profile if a custom profile is not provided. The intention of prefs::DEFAULT
is to say “we recommend these settings for running Marionette”, and triggering another code path that doesn’t set these if the user provides a profile a bit surprising in my opinion.
I’m also curious what the reason for this change is. I guess you are providing a profile with some preferences that get overridden by geckodriver?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
With the customers I support, the usual pattern is that they start by using the default settings, and at some point they realize that they need to install an extension or set up some certs that can (currently) most easily be accomplished by providing a custom profile. It is then surprising when a profile created with the sole purpose of doing this causes other behavior changes because DEFAULT prefs are no longer being set. My goal with the change is to make that transition from no profile to providing a profile more seamless by only changing things that the user has explicitly chosen to change when providing the profile.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
My thinking at the moment is to move those preferences that are absolutely required to meet WebDriver conformance from prefs::DEFAULT
to prefs::REQUIRED
and to accept this change. This would change the meaning of ‘default preferences’ towards ‘suggested preferences’, as they would not take effect if a custom profile with custom preferences is provided.
@@ -347,6 +348,8 @@ impl MarionetteHandler { | |||
prefs.insert("marionette.logging", Pref::new(level.to_string())); | |||
}; | |||
|
|||
prefs.insert("marionette.defaultPrefs.port", Pref::new(port as i64)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
But this part I agree is correct :)
Any additional thoughts on this change? |
@jgraham r? |
- Merge prefs::Default prefs into custom profile unless the custom profile explicitly sets that preference. - Set the marionette.defaultPrefs.port preference last so users cannot accidentally overwrite its value by providing it in capabilities.
The long term goal is to make users less reliant on passing full profiles. The two most common reasons for passing profiles today is for (1) setting preferences and (2) installing extensions. We already have the ability to pass a Concurrently I’ve also done work on setting recommended automation preferences in the Marionette server at runtime. This currently duplicates most of the preferences set by geckodriver, but we will keep these around for backwards compatibility with earlier Firefoxen that doesn’t have the recommended automation prefs patch. The required set of prefs in geckodriver I would probably say are not all required: pub static ref REQUIRED: [(&'static str, Pref); 5] = [
// Do not warn on quitting Firefox
("browser.warnOnQuit", Pref::new(false)),
// Do not warn on exit when multiple tabs are open
("browser.tabs.warnOnClose", Pref::new(false)),
// Do not warn when quitting with multiple tabs
("browser.showQuitWarning", Pref::new(false)),
// Until bug 1238095 is fixed, we have to disable safe CPOW checks
("dom.ipc.cpows.forbid-unsafe-from-browser", Pref::new(false)),
// TODO(ato): Should not be needed, as Marionette is enabled by
// passing the --marionette flag to the binary
("marionette.defaultPrefs.enabled", Pref::new(true)),
]; I’d argue that if you provide a profile that wants to override The only true and real requirement is to set To resolve this PR, I suggest the following approach:
|
@DrMarcII My apologies this took a long time to land. )-: |
When a user provides a profile that wnats to override browser.warnOnQuit, browser.tabs.warnOnClose, or browser.showQuitWarning, we should allow users to do stupid things. We should not prevent the profile's preferences from being applied. dom.ipc.cpows.forbid-unsafe-from-browser is being removed because all targetted Firefoxen are not using any unsafe CPOWs in Marionette code. marionette.defaultPrefs.enabled is superfluous for as long as the --marionette flag is being passed to the Firefox binary. Remaining relevant prefs from prefs::REQUIRED have been merged into prefs::DEFAULT. This is a follow-up to the discussion around #423.
When a user provides a profile that wnats to override browser.warnOnQuit, browser.tabs.warnOnClose, or browser.showQuitWarning, we should allow users to do stupid things. We should not prevent the profile's preferences from being applied. dom.ipc.cpows.forbid-unsafe-from-browser is being removed because all targetted Firefoxen are not using any unsafe CPOWs in Marionette code. marionette.defaultPrefs.enabled is superfluous for as long as the --marionette flag is being passed to the Firefox binary. Remaining relevant prefs from prefs::REQUIRED have been merged into prefs::DEFAULT. This is a follow-up to the discussion around mozilla/geckodriver#423. Source-Repo: https://github.com/mozilla/geckodriver Source-Revision: 2e0054b90ecf1acbe8b442af54441e3cc746933f committer: jgraham <james@hoppipolla.co.uk> --HG-- extra : rebase_source : 0d5230475735d09d5e7220b8d8b7b91308074900
When a user provides a profile that wnats to override browser.warnOnQuit, browser.tabs.warnOnClose, or browser.showQuitWarning, we should allow users to do stupid things. We should not prevent the profile's preferences from being applied. dom.ipc.cpows.forbid-unsafe-from-browser is being removed because all targetted Firefoxen are not using any unsafe CPOWs in Marionette code. marionette.defaultPrefs.enabled is superfluous for as long as the --marionette flag is being passed to the Firefox binary. Remaining relevant prefs from prefs::REQUIRED have been merged into prefs::DEFAULT. This is a follow-up to the discussion around mozilla/geckodriver#423. Source-Repo: https://github.com/mozilla/geckodriver Source-Revision: 2e0054b90ecf1acbe8b442af54441e3cc746933f committer: jgraham <james@hoppipolla.co.uk>
When a user provides a profile that wnats to override browser.warnOnQuit, browser.tabs.warnOnClose, or browser.showQuitWarning, we should allow users to do stupid things. We should not prevent the profile's preferences from being applied. dom.ipc.cpows.forbid-unsafe-from-browser is being removed because all targetted Firefoxen are not using any unsafe CPOWs in Marionette code. marionette.defaultPrefs.enabled is superfluous for as long as the --marionette flag is being passed to the Firefox binary. Remaining relevant prefs from prefs::REQUIRED have been merged into prefs::DEFAULT. This is a follow-up to the discussion around mozilla/geckodriver#423. Source-Repo: https://github.com/mozilla/geckodriver Source-Revision: 2e0054b90ecf1acbe8b442af54441e3cc746933f committer: jgraham <james@hoppipolla.co.uk>
When a user provides a profile that wnats to override browser.warnOnQuit, browser.tabs.warnOnClose, or browser.showQuitWarning, we should allow users to do stupid things. We should not prevent the profile's preferences from being applied. dom.ipc.cpows.forbid-unsafe-from-browser is being removed because all targetted Firefoxen are not using any unsafe CPOWs in Marionette code. marionette.defaultPrefs.enabled is superfluous for as long as the --marionette flag is being passed to the Firefox binary. Remaining relevant prefs from prefs::REQUIRED have been merged into prefs::DEFAULT. This is a follow-up to the discussion around mozilla/geckodriver#423. Source-Repo: https://github.com/mozilla/geckodriver Source-Revision: 2e0054b90ecf1acbe8b442af54441e3cc746933f committer: jgraham <jameshoppipolla.co.uk> UltraBlame original commit: f6dce7699b3d73bed7cdba691195387c003551c7
When a user provides a profile that wnats to override browser.warnOnQuit, browser.tabs.warnOnClose, or browser.showQuitWarning, we should allow users to do stupid things. We should not prevent the profile's preferences from being applied. dom.ipc.cpows.forbid-unsafe-from-browser is being removed because all targetted Firefoxen are not using any unsafe CPOWs in Marionette code. marionette.defaultPrefs.enabled is superfluous for as long as the --marionette flag is being passed to the Firefox binary. Remaining relevant prefs from prefs::REQUIRED have been merged into prefs::DEFAULT. This is a follow-up to the discussion around mozilla/geckodriver#423. Source-Repo: https://github.com/mozilla/geckodriver Source-Revision: 2e0054b90ecf1acbe8b442af54441e3cc746933f committer: jgraham <jameshoppipolla.co.uk> UltraBlame original commit: f6dce7699b3d73bed7cdba691195387c003551c7
When a user provides a profile that wnats to override browser.warnOnQuit, browser.tabs.warnOnClose, or browser.showQuitWarning, we should allow users to do stupid things. We should not prevent the profile's preferences from being applied. dom.ipc.cpows.forbid-unsafe-from-browser is being removed because all targetted Firefoxen are not using any unsafe CPOWs in Marionette code. marionette.defaultPrefs.enabled is superfluous for as long as the --marionette flag is being passed to the Firefox binary. Remaining relevant prefs from prefs::REQUIRED have been merged into prefs::DEFAULT. This is a follow-up to the discussion around mozilla/geckodriver#423. Source-Repo: https://github.com/mozilla/geckodriver Source-Revision: 2e0054b90ecf1acbe8b442af54441e3cc746933f committer: jgraham <jameshoppipolla.co.uk> UltraBlame original commit: f6dce7699b3d73bed7cdba691195387c003551c7
profile explicitly sets that preference.
accidentally overwrite its value by providing it in capabilities.
This change is