diff --git a/components/script/dom/testbinding.rs b/components/script/dom/testbinding.rs index ae63c1f6e20..41a1ff188b2 100644 --- a/components/script/dom/testbinding.rs +++ b/components/script/dom/testbinding.rs @@ -27,6 +27,7 @@ use js::jsval::{JSVal, NullValue}; use std::borrow::ToOwned; use std::ptr; use std::rc::Rc; +use util::prefs::{get_pref}; use util::str::DOMString; #[dom_struct] @@ -486,6 +487,9 @@ impl TestBindingMethods for TestBinding { fn PassVariadicUnion6(&self, _: Vec) {} fn PassVariadicAny(&self, _: *mut JSContext, _: Vec) {} fn PassVariadicObject(&self, _: *mut JSContext, _: Vec<*mut JSObject>) {} + fn BooleanMozPreference(&self, pref_name: DOMString) -> bool { + get_pref(pref_name.as_ref()).as_boolean().unwrap_or(false) + } } impl TestBinding { diff --git a/components/script/dom/webidls/TestBinding.webidl b/components/script/dom/webidls/TestBinding.webidl index 269114dbf80..4a933dd2b28 100644 --- a/components/script/dom/webidls/TestBinding.webidl +++ b/components/script/dom/webidls/TestBinding.webidl @@ -398,4 +398,5 @@ interface TestBinding { static attribute boolean booleanAttributeStatic; static void receiveVoidStatic(); + boolean BooleanMozPreference(DOMString pref_name); }; diff --git a/components/util/opts.rs b/components/util/opts.rs index ccdaa17b27f..2a146a27642 100644 --- a/components/util/opts.rs +++ b/components/util/opts.rs @@ -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 diff --git a/tests/wpt/harness/wptrunner/executors/executorservo.py b/tests/wpt/harness/wptrunner/executors/executorservo.py index 0e73f1bd9ec..61ecbf06dab 100644 --- a/tests/wpt/harness/wptrunner/executors/executorservo.py +++ b/tests/wpt/harness/wptrunner/executors/executorservo.py @@ -74,8 +74,8 @@ class ServoTestharnessExecutor(ProcessTestExecutor): "-z", self.test_url(test)] for stylesheet in self.browser.user_stylesheets: args += ["--user-stylesheet", stylesheet] - for pref in test.environment.get('prefs', {}): - args += ["--pref", pref] + for pref, value in test.environment.get('prefs', {}).iteritems(): + args += ["--pref", "%s=%s" % (pref, value)] debug_args, command = browser_command(self.binary, args, self.debug_info) self.command = command diff --git a/tests/wpt/mozilla/meta/MANIFEST.json b/tests/wpt/mozilla/meta/MANIFEST.json index a72ebe0e24b..36534249492 100644 --- a/tests/wpt/mozilla/meta/MANIFEST.json +++ b/tests/wpt/mozilla/meta/MANIFEST.json @@ -6180,6 +6180,12 @@ "url": "/_mozilla/mozilla/parentnodes.html" } ], + "mozilla/preferences.html": [ + { + "path": "mozilla/preferences.html", + "url": "/_mozilla/mozilla/preferences.html" + } + ], "mozilla/preserve_wrapper_callback.html": [ { "path": "mozilla/preserve_wrapper_callback.html", diff --git a/tests/wpt/mozilla/meta/mozilla/preferences.html.ini b/tests/wpt/mozilla/meta/mozilla/preferences.html.ini new file mode 100644 index 00000000000..8b0c1df2aa3 --- /dev/null +++ b/tests/wpt/mozilla/meta/mozilla/preferences.html.ini @@ -0,0 +1,3 @@ +[preferences.html] + type: testharness + prefs: [dom.testbinding.preference_value.falsy:false, dom.testbinding.preference_value.truthy:true] diff --git a/tests/wpt/mozilla/tests/mozilla/preferences.html b/tests/wpt/mozilla/tests/mozilla/preferences.html new file mode 100644 index 00000000000..c13df703637 --- /dev/null +++ b/tests/wpt/mozilla/tests/mozilla/preferences.html @@ -0,0 +1,13 @@ + + + + + +