mirror of
https://github.com/servo/servo.git
synced 2025-08-04 13:10:20 +01:00
Allow setting preferences to false in WPT tests. closes #10161
This commit is contained in:
parent
f2f05869d6
commit
b1ff30f752
7 changed files with 38 additions and 3 deletions
|
@ -27,6 +27,7 @@ use js::jsval::{JSVal, NullValue};
|
||||||
use std::borrow::ToOwned;
|
use std::borrow::ToOwned;
|
||||||
use std::ptr;
|
use std::ptr;
|
||||||
use std::rc::Rc;
|
use std::rc::Rc;
|
||||||
|
use util::prefs::{get_pref};
|
||||||
use util::str::DOMString;
|
use util::str::DOMString;
|
||||||
|
|
||||||
#[dom_struct]
|
#[dom_struct]
|
||||||
|
@ -486,6 +487,9 @@ impl TestBindingMethods for TestBinding {
|
||||||
fn PassVariadicUnion6(&self, _: Vec<UnsignedLongOrBoolean>) {}
|
fn PassVariadicUnion6(&self, _: Vec<UnsignedLongOrBoolean>) {}
|
||||||
fn PassVariadicAny(&self, _: *mut JSContext, _: Vec<HandleValue>) {}
|
fn PassVariadicAny(&self, _: *mut JSContext, _: Vec<HandleValue>) {}
|
||||||
fn PassVariadicObject(&self, _: *mut JSContext, _: Vec<*mut JSObject>) {}
|
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 {
|
impl TestBinding {
|
||||||
|
|
|
@ -398,4 +398,5 @@ interface TestBinding {
|
||||||
|
|
||||||
static attribute boolean booleanAttributeStatic;
|
static attribute boolean booleanAttributeStatic;
|
||||||
static void receiveVoidStatic();
|
static void receiveVoidStatic();
|
||||||
|
boolean BooleanMozPreference(DOMString pref_name);
|
||||||
};
|
};
|
||||||
|
|
|
@ -507,6 +507,7 @@ pub fn default_opts() -> Opts {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[allow(str_to_string)]
|
||||||
pub fn from_cmdline_args(args: &[String]) -> ArgumentParsingResult {
|
pub fn from_cmdline_args(args: &[String]) -> ArgumentParsingResult {
|
||||||
let (app_name, args) = args.split_first().unwrap();
|
let (app_name, args) = args.split_first().unwrap();
|
||||||
|
|
||||||
|
@ -767,7 +768,14 @@ pub fn from_cmdline_args(args: &[String]) -> ArgumentParsingResult {
|
||||||
// This must happen after setting the default options, since the prefs rely on
|
// This must happen after setting the default options, since the prefs rely on
|
||||||
// on the resource path.
|
// on the resource path.
|
||||||
for pref in opt_match.opt_strs("pref").iter() {
|
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
|
ArgumentParsingResult::ChromeProcess
|
||||||
|
|
|
@ -74,8 +74,8 @@ class ServoTestharnessExecutor(ProcessTestExecutor):
|
||||||
"-z", self.test_url(test)]
|
"-z", self.test_url(test)]
|
||||||
for stylesheet in self.browser.user_stylesheets:
|
for stylesheet in self.browser.user_stylesheets:
|
||||||
args += ["--user-stylesheet", stylesheet]
|
args += ["--user-stylesheet", stylesheet]
|
||||||
for pref in test.environment.get('prefs', {}):
|
for pref, value in test.environment.get('prefs', {}).iteritems():
|
||||||
args += ["--pref", pref]
|
args += ["--pref", "%s=%s" % (pref, value)]
|
||||||
debug_args, command = browser_command(self.binary, args, self.debug_info)
|
debug_args, command = browser_command(self.binary, args, self.debug_info)
|
||||||
|
|
||||||
self.command = command
|
self.command = command
|
||||||
|
|
|
@ -6144,6 +6144,12 @@
|
||||||
"url": "/_mozilla/mozilla/parentnodes.html"
|
"url": "/_mozilla/mozilla/parentnodes.html"
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
|
"mozilla/preferences.html": [
|
||||||
|
{
|
||||||
|
"path": "mozilla/preferences.html",
|
||||||
|
"url": "/_mozilla/mozilla/preferences.html"
|
||||||
|
}
|
||||||
|
],
|
||||||
"mozilla/preserve_wrapper_callback.html": [
|
"mozilla/preserve_wrapper_callback.html": [
|
||||||
{
|
{
|
||||||
"path": "mozilla/preserve_wrapper_callback.html",
|
"path": "mozilla/preserve_wrapper_callback.html",
|
||||||
|
|
3
tests/wpt/mozilla/meta/mozilla/preferences.html.ini
Normal file
3
tests/wpt/mozilla/meta/mozilla/preferences.html.ini
Normal file
|
@ -0,0 +1,3 @@
|
||||||
|
[preferences.html]
|
||||||
|
type: testharness
|
||||||
|
prefs: [dom.testbinding.preference_value.falsy:false, dom.testbinding.preference_value.truthy:true]
|
13
tests/wpt/mozilla/tests/mozilla/preferences.html
Normal file
13
tests/wpt/mozilla/tests/mozilla/preferences.html
Normal file
|
@ -0,0 +1,13 @@
|
||||||
|
<!doctype html>
|
||||||
|
<meta charset="utf-8">
|
||||||
|
<title></title>
|
||||||
|
<script src="/resources/testharness.js"></script>
|
||||||
|
<script src="/resources/testharnessreport.js"></script>
|
||||||
|
<script>
|
||||||
|
test(function() {
|
||||||
|
var testBinding = new TestBinding();
|
||||||
|
assert_equals(typeof testBinding.BooleanMozPreference, "function");
|
||||||
|
assert_equals(testBinding.BooleanMozPreference("dom.testbinding.preference_value.falsy"), false);
|
||||||
|
assert_equals(testBinding.BooleanMozPreference("dom.testbinding.preference_value.truthy"), true);
|
||||||
|
}, "prefs");
|
||||||
|
</script>
|
Loading…
Add table
Add a link
Reference in a new issue