Auto merge of #10204 - awalGarg:fix10161, r=Manishearth

Allow setting preferences to false in WPT tests

First patch to servo - apologies if I did something stupid :)

This is a fix for #10161. I have squashed the commits into one.

<!-- 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/10204)
<!-- Reviewable:end -->
This commit is contained in:
bors-servo 2016-03-27 00:46:55 +05:30
commit 4cb626ae29
7 changed files with 38 additions and 3 deletions

View file

@ -518,6 +518,7 @@ pub fn default_opts() -> Opts {
}
}
#[allow(str_to_string)]
pub fn from_cmdline_args(args: &[String]) -> ArgumentParsingResult {
let (app_name, args) = args.split_first().unwrap();
@ -793,7 +794,14 @@ pub fn from_cmdline_args(args: &[String]) -> ArgumentParsingResult {
// This must happen after setting the default options, since the prefs rely on
// on the resource path.
for pref in opt_match.opt_strs("pref").iter() {
prefs::set_pref(pref, PrefValue::Boolean(true));
let split: Vec<&str> = pref.splitn(2, '=').collect();
let pref_name = split[0];
let value = split.get(1);
match value {
Some(&"false") => prefs::set_pref(pref_name, PrefValue::Boolean(false)),
Some(&"true") | None => prefs::set_pref(pref_name, PrefValue::Boolean(true)),
_ => prefs::set_pref(pref_name, PrefValue::String(value.unwrap().to_string()))
};
}
ArgumentParsingResult::ChromeProcess