Allow setting preferences from the reftest manifest. Add a command-line arg to enable a given preference.

This commit is contained in:
Josh Matthews 2015-08-27 10:56:36 -04:00
parent a3ee9b5dd9
commit 6e26fefad1
5 changed files with 30 additions and 16 deletions

View file

@ -10,6 +10,7 @@ use geometry::ScreenPx;
use euclid::size::{Size2D, TypedSize2D};
use getopts::Options;
use num_cpus;
use prefs;
use std::cmp;
use std::default::Default;
use std::env;
@ -455,6 +456,8 @@ pub fn from_cmdline_args(args: &[String]) {
opts.optflag("h", "help", "Print this message");
opts.optopt("", "resources-path", "Path to find static resources", "/home/servo/resources");
opts.optflag("", "sniff-mime-types" , "Enable MIME sniffing");
opts.optmulti("", "pref",
"A preference to set to enable", "dom.mozbrowser.enabled");
let opt_match = match opts.parse(args) {
Ok(m) => m,
@ -623,6 +626,12 @@ pub fn from_cmdline_args(args: &[String]) {
};
set_defaults(opts);
// 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, true);
}
}
// Make Opts available globally. This saves having to clone and pass

View file

@ -45,6 +45,6 @@ pub fn get_pref(name: &str, default: bool) -> bool {
*PREFS.lock().unwrap().get(name).unwrap_or(&default)
}
pub fn set_pref(name: String, value: bool) {
let _ = PREFS.lock().unwrap().insert(name, value);
pub fn set_pref(name: &str, value: bool) {
let _ = PREFS.lock().unwrap().insert(name.to_owned(), value);
}

View file

@ -98,8 +98,8 @@ flaky_cpu == append_style_a.html append_style_b.html
== first_child_pseudo_a.html first_child_pseudo_b.html
== first_of_type_pseudo_a.html first_of_type_pseudo_b.html
== fixed_width_overrides_child_intrinsic_width_a.html fixed_width_overrides_child_intrinsic_width_ref.html
experimental == flex_column_direction.html flex_column_direction_ref.html
experimental == flex_row_direction.html flex_row_direction_ref.html
prefs:"layout.flex-direction.enabled,layout.flex.enabled" == flex_column_direction.html flex_column_direction_ref.html
prefs:"layout.flex.enabled" == flex_row_direction.html flex_row_direction_ref.html
== float_clearance_a.html float_clearance_ref.html
== float_clearance_intrinsic_width_a.html float_clearance_intrinsic_width_ref.html
== float_intrinsic_height.html float_intrinsic_height_ref.html
@ -138,7 +138,7 @@ experimental == flex_row_direction.html flex_row_direction_ref.html
== iframe/simple_inline_width_height.html iframe/simple_inline_width_height_ref.html
== iframe/simple_inline_width_percentage.html iframe/simple_inline_width_percentage_ref.html
== iframe/size_attributes.html iframe/size_attributes_ref.html
experimental == iframe/size_attributes_vertical_writing_mode.html iframe/size_attributes_vertical_writing_mode_ref.html
prefs:"layout.writing-mode.enabled" == iframe/size_attributes_vertical_writing_mode.html iframe/size_attributes_vertical_writing_mode_ref.html
== iframe/stacking_context.html iframe/stacking_context_ref.html
!= image_rendering_auto_a.html image_rendering_pixelated_a.html
@ -357,7 +357,7 @@ flaky_cpu == linebreak_simple_a.html linebreak_simple_b.html
== transform_simple_a.html transform_simple_ref.html
== transform_stacking_context_a.html transform_stacking_context_ref.html
== upper_id_attr.html upper_id_attr_ref.html
flaky_cpu,experimental == vertical-lr-blocks.html vertical-lr-blocks_ref.html
flaky_cpu,prefs:"layout.writing-mode.enabled" == vertical-lr-blocks.html vertical-lr-blocks_ref.html
== vertical_align_bottom_a.html vertical_align_bottom_ref.html
== vertical_align_inline_block_a.html vertical_align_inline_block_ref.html
== vertical_align_inside_table_a.html vertical_align_inside_table_ref.html
@ -373,7 +373,7 @@ resolution=800x600 == viewport_percentage_vmin_vmax.html viewport_percentage_vmi
# resolution=600x800 == viewport_percentage_vmin_vmax.html viewport_percentage_vmin_vmax_b.html
resolution=800x600 == viewport_percentage_vw_vh.html viewport_percentage_vw_vh_a.html
# resolution=600x800 == viewport_percentage_vw_vh.html viewport_percentage_vw_vh_b.html
experimental == viewport_rule.html viewport_rule_ref.html
prefs:"layout.viewport.enabled" == viewport_rule.html viewport_rule_ref.html
== visibility_hidden.html visibility_hidden_ref.html
== webgl-context/clearcolor.html webgl-context/clearcolor_ref.html

19
tests/reftest.rs vendored
View file

@ -140,7 +140,7 @@ struct Reftest {
servo_args: Vec<String>,
render_mode: RenderMode,
is_flaky: bool,
experimental: bool,
prefs: Vec<String>,
fragment_identifier: Option<String>,
resolution: Option<String>,
}
@ -198,7 +198,7 @@ fn parse_lists(file: &Path, servo_args: &[String], render_mode: RenderMode, id_o
let conditions_list = test_line.conditions.split(',');
let mut flakiness = RenderMode::empty();
let mut experimental = false;
let mut prefs = vec![];
let mut fragment_identifier = None;
let mut resolution = None;
for condition in conditions_list {
@ -207,8 +207,12 @@ fn parse_lists(file: &Path, servo_args: &[String], render_mode: RenderMode, id_o
"flaky_gpu" => flakiness.insert(GPU_RENDERING),
"flaky_linux" => flakiness.insert(LINUX_TARGET),
"flaky_macos" => flakiness.insert(MACOS_TARGET),
"experimental" => experimental = true,
_ => (),
_ => ()
}
if condition.starts_with("prefs:\"") {
if let Some(joined) = condition.split("\"").nth(1) {
prefs.extend(joined.split(",").map(str::to_owned));
}
}
if condition.starts_with("fragment=") {
fragment_identifier = Some(condition["fragment=".len()..].to_string());
@ -226,7 +230,7 @@ fn parse_lists(file: &Path, servo_args: &[String], render_mode: RenderMode, id_o
render_mode: render_mode,
servo_args: servo_args.to_vec(),
is_flaky: render_mode.intersects(flakiness),
experimental: experimental,
prefs: prefs,
fragment_identifier: fragment_identifier,
resolution: resolution,
};
@ -275,8 +279,9 @@ fn capture(reftest: &Reftest, side: usize) -> (u32, u32, Vec<u8>) {
if reftest.render_mode.contains(GPU_RENDERING) {
command.arg("-g");
}
if reftest.experimental {
command.arg("--experimental");
for pref in &reftest.prefs {
command.arg("--pref");
command.arg(pref);
}
if let Some(ref resolution) = reftest.resolution {
command.arg("--resolution");

View file

@ -25,7 +25,7 @@ fn test_viewport_rule<F>(css: &str,
callback: F)
where F: Fn(&Vec<ViewportDescriptorDeclaration>, &str)
{
::util::opts::set_experimental_enabled(true);
::util::prefs::set_pref("layout.viewport.enabled", true);
let stylesheet = stylesheet!(css, Author);
let mut rule_count = 0;
@ -172,7 +172,7 @@ fn cascading_within_viewport_rule() {
#[test]
fn multiple_stylesheets_cascading() {
::util::opts::set_experimental_enabled(true);
::util::prefs::set_pref("layout.viewport.enabled", true);
let device = Device::new(MediaType::Screen, Size2D::typed(800., 600.));
let stylesheets = vec![