Skip to content

Commit

Permalink
Improve firefox profile prefs merging (#423)
Browse files Browse the repository at this point in the history
Merges prefs::Default prefs into custom profile unless the custom
profile explicitly sets that preference.

Sets the marionette.defaultPrefs.port preference last so users cannot
accidentally overwrite its value by providing it in capabilities.
  • Loading branch information
DrMarcII authored and andreastt committed Apr 4, 2017
1 parent 68ca363 commit 95ef3b4
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions src/marionette.rs
Original file line number Diff line number Diff line change
Expand Up @@ -343,11 +343,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() {
if !custom_profile || !prefs.contains_key(name) {
prefs.insert((*name).clone(), (*value).clone());
}
}

if !custom_profile {
prefs.insert_slice(&prefs::DEFAULT[..]);
};
prefs.insert_slice(&extra_prefs[..]);

prefs.insert_slice(&prefs::REQUIRED[..]);
Expand All @@ -356,6 +357,8 @@ impl MarionetteHandler {
prefs.insert("marionette.logging", Pref::new(level.to_string()));
};

prefs.insert("marionette.defaultPrefs.port", Pref::new(port as i64));

prefs.write().map_err(|_| WebDriverError::new(ErrorStatus::UnknownError,
"Unable to write Firefox profile"))
}
Expand Down

0 comments on commit 95ef3b4

Please sign in to comment.