geckodriver: Improve firefox profile prefs merging (#423)

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.

Source-Repo: https://github.com/mozilla/geckodriver
Source-Revision: 95ef3b49bc3fbeac231be22c19f06b7d14f6959b

committer: Andreas Tolfsen <ato@mozilla.com>

--HG--
extra : rebase_source : 2785f3dffdc222b9c8002e7f0e81f438b249683e
This commit is contained in:
Marc Fisher 2017-04-04 15:02:09 +01:00
Родитель 5a6e3bf9bd
Коммит 6a1acfc103
1 изменённых файлов: 7 добавлений и 4 удалений

Просмотреть файл

@ -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[..]);
@ -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"))
}