Auto merge of #10114 - matthewbentley:master, r=Manishearth

Load prefs.json from profile-dir if --profile-dir is specified at launch

In response to #10098
Tries to load `prefs.json` from the profile-dir and merge them into the preferences if `--profile-dir` is specified at launch.  The profile-dir preferences take precedence over the default preferences, but command line preferences still take precedence over everything.

Also adds some tests for `prefs.rs`.  These rely on the contents of `resources/prefs.json` (at least `test_get_set_reset_extend()` does), so they may need to be re-worked a bit.

<!-- Reviewable:start -->
---
This change is [<img src="https://reviewable.io/review_button.svg" height="35" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/10114)
<!-- Reviewable:end -->
This commit is contained in:
bors-servo 2016-04-02 08:33:42 +05:30
commit ea24389b85
4 changed files with 89 additions and 10 deletions

View file

@ -805,8 +805,12 @@ pub fn from_cmdline_args(args: &[String]) -> ArgumentParsingResult {
set_defaults(opts);
// This must happen after setting the default options, since the prefs rely on
// These must happen after setting the default options, since the prefs rely on
// on the resource path.
// Note that command line preferences have the highest precedence
if get().profile_dir.is_some() {
prefs::add_user_prefs();
}
for pref in opt_match.opt_strs("pref").iter() {
let split: Vec<&str> = pref.splitn(2, '=').collect();
let pref_name = split[0];