mirror of
https://github.com/servo/servo.git
synced 2025-06-06 16:45:39 +00:00
Allow prefs to be overridden from a file and set WPT-specific prefs from file (#33163)
* Allow prefs to be passed in from a separate file Signed-off-by: Daniel Adams <msub2official@gmail.com> * Add wpt-prefs.json for setting WPT-specific prefs Signed-off-by: Daniel Adams <msub2official@gmail.com> * fix argument to read_prefs_file Signed-off-by: Daniel Adams <msub2official@gmail.com> * Update test_parse_pref test Signed-off-by: Daniel Adams <msub2official@gmail.com> * Add line in executorservo.py to read from wpt-prefs.json Signed-off-by: Daniel Adams <msub2official@gmail.com> * Update MANIFEST.json Signed-off-by: Daniel Adams <msub2official@gmail.com> * Update expectations Signed-off-by: Daniel Adams <msub2official@gmail.com> * Disable dom.webxr.test for interfaces test Signed-off-by: Daniel Adams <msub2official@gmail.com> --------- Signed-off-by: Daniel Adams <msub2official@gmail.com>
This commit is contained in:
parent
2db9032e72
commit
e85491b5fc
10 changed files with 36 additions and 15 deletions
|
@ -45,6 +45,12 @@ pub fn main() {
|
|||
"A preference to set to disable",
|
||||
"dom.webgpu.enabled=false",
|
||||
);
|
||||
opts.optmulti(
|
||||
"",
|
||||
"prefs-file",
|
||||
"Load in additional prefs from a file.",
|
||||
"--prefs-file /path/to/prefs.json",
|
||||
);
|
||||
|
||||
let opts_matches;
|
||||
let content_process_token;
|
||||
|
|
|
@ -22,15 +22,17 @@ pub fn register_user_prefs(opts_matches: &Matches) {
|
|||
.filter(|path| path.exists());
|
||||
|
||||
let mut userprefs = if let Some(path) = user_prefs_path {
|
||||
let mut file = File::open(path).expect("Error opening user prefs");
|
||||
let mut txt = String::new();
|
||||
file.read_to_string(&mut txt)
|
||||
.expect("Can't read user prefs file");
|
||||
prefs::read_prefs_map(&txt).expect("Can't parse user prefs file")
|
||||
read_prefs_file(path.to_str().expect("Failed to read user prefs"))
|
||||
} else {
|
||||
HashMap::new()
|
||||
};
|
||||
|
||||
let prefs_from_files: Vec<HashMap<String, PrefValue>> = opts_matches
|
||||
.opt_strs("prefs-file")
|
||||
.iter()
|
||||
.map(|path| read_prefs_file(path))
|
||||
.collect();
|
||||
|
||||
let argprefs: HashMap<String, PrefValue> = opts_matches
|
||||
.opt_strs("pref")
|
||||
.iter()
|
||||
|
@ -54,16 +56,30 @@ pub fn register_user_prefs(opts_matches: &Matches) {
|
|||
})
|
||||
.collect();
|
||||
|
||||
// --pref overrides user prefs.json
|
||||
// Apply --prefs-file prefs first
|
||||
for prefs in prefs_from_files {
|
||||
userprefs.extend(prefs);
|
||||
}
|
||||
|
||||
// Then apply individually passed prefs from --pref
|
||||
userprefs.extend(argprefs);
|
||||
|
||||
prefs::add_user_prefs(userprefs);
|
||||
}
|
||||
|
||||
fn read_prefs_file(path: &str) -> HashMap<String, PrefValue> {
|
||||
let mut file = File::open(path).expect("Error opening user prefs");
|
||||
let mut txt = String::new();
|
||||
file.read_to_string(&mut txt)
|
||||
.expect("Can't read user prefs file");
|
||||
prefs::read_prefs_map(&txt).expect("Can't parse user prefs file")
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
fn test_parse_pref(arg: &str) {
|
||||
let mut opts = getopts::Options::new();
|
||||
opts.optmulti("", "pref", "", "");
|
||||
opts.optmulti("", "prefs-file", "", "");
|
||||
let args = vec!["servo".to_string(), "--pref".to_string(), arg.to_string()];
|
||||
let matches = match opts::from_cmdline_args(opts, &args) {
|
||||
opts::ArgumentParsingResult::ContentProcess(m, _) => m,
|
||||
|
|
3
resources/wpt-prefs.json
Normal file
3
resources/wpt-prefs.json
Normal file
|
@ -0,0 +1,3 @@
|
|||
{
|
||||
"dom.webxr.test": true
|
||||
}
|
2
tests/wpt/meta/MANIFEST.json
vendored
2
tests/wpt/meta/MANIFEST.json
vendored
|
@ -489596,7 +489596,7 @@
|
|||
[]
|
||||
],
|
||||
"executorservo.py": [
|
||||
"9c938b6e75e27c61167294a941629928fa33db73",
|
||||
"c23f7632c9ef5f0acbdbb569db41f741ccf9de89",
|
||||
[]
|
||||
],
|
||||
"executorservodriver.py": [
|
||||
|
|
1
tests/wpt/mozilla/meta-legacy-layout/mozilla/interfaces.html.ini
vendored
Normal file
1
tests/wpt/mozilla/meta-legacy-layout/mozilla/interfaces.html.ini
vendored
Normal file
|
@ -0,0 +1 @@
|
|||
prefs: [dom.webxr.test: false]
|
1
tests/wpt/mozilla/meta/mozilla/interfaces.html.ini
vendored
Normal file
1
tests/wpt/mozilla/meta/mozilla/interfaces.html.ini
vendored
Normal file
|
@ -0,0 +1 @@
|
|||
prefs: [dom.webxr.test: false]
|
|
@ -1,4 +0,0 @@
|
|||
[create_session.https.html]
|
||||
expected: ERROR
|
||||
[create_session]
|
||||
expected: TIMEOUT
|
|
@ -1,3 +0,0 @@
|
|||
[obtain_frame.https.html]
|
||||
[obtain_frame]
|
||||
expected: FAIL
|
|
@ -1,4 +1,4 @@
|
|||
[sessionavailable.https.html]
|
||||
expected: ERROR
|
||||
expected: TIMEOUT
|
||||
[Requesting immersive session in a sessionavailable handler should succeed]
|
||||
expected: TIMEOUT
|
||||
|
|
|
@ -78,6 +78,7 @@ class ServoExecutor(ProcessTestExecutor):
|
|||
args += ["--user-stylesheet", stylesheet]
|
||||
for pref, value in self.environment.get('prefs', {}).items():
|
||||
args += ["--pref", f"{pref}={value}"]
|
||||
args += ["--prefs-file", "resources/wpt-prefs.json"]
|
||||
if self.browser.ca_certificate_path:
|
||||
args += ["--certificate-path", self.browser.ca_certificate_path]
|
||||
if extra_args:
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue