Auto merge of #7391 - jdm:prefs, r=Ms2ger

Replace catch-all experimental flag with fine-grained boolean prefere…

…nces initialized from a JSON document.

<!-- Reviewable:start -->
[<img src="https://reviewable.io/review_button.png" height=40 alt="Review on Reviewable"/>](https://reviewable.io/reviews/servo/servo/7391)
<!-- Reviewable:end -->
This commit is contained in:
bors-servo 2015-08-28 10:08:32 -06:00
commit 72125f070d
14 changed files with 122 additions and 59 deletions

View file

@ -54,8 +54,8 @@ use style::viewport::ViewportConstraints;
use url::Url; use url::Url;
use util::cursor::Cursor; use util::cursor::Cursor;
use util::geometry::PagePx; use util::geometry::PagePx;
use util::opts;
use util::task::spawn_named; use util::task::spawn_named;
use util::{opts, prefs};
/// Maintains the pipelines and navigation context and grants permission to composite. /// Maintains the pipelines and navigation context and grants permission to composite.
/// ///
@ -891,7 +891,7 @@ impl<LTF: LayoutTaskFactory, STF: ScriptTaskFactory> Constellation<LTF, STF> {
containing_pipeline_id: PipelineId, containing_pipeline_id: PipelineId,
subpage_id: SubpageId, subpage_id: SubpageId,
event: MozBrowserEvent) { event: MozBrowserEvent) {
assert!(opts::experimental_enabled()); assert!(prefs::get_pref("dom.mozbrowser.enabled", false));
// Find the script channel for the given parent pipeline, // Find the script channel for the given parent pipeline,
// and pass the event to that script task. // and pass the event to that script task.
@ -1373,7 +1373,7 @@ impl<LTF: LayoutTaskFactory, STF: ScriptTaskFactory> Constellation<LTF, STF> {
// https://developer.mozilla.org/en-US/docs/Web/Events/mozbrowserlocationchange // https://developer.mozilla.org/en-US/docs/Web/Events/mozbrowserlocationchange
fn trigger_mozbrowserlocationchange(&self, pipeline_id: PipelineId) { fn trigger_mozbrowserlocationchange(&self, pipeline_id: PipelineId) {
if opts::experimental_enabled() { if prefs::get_pref("dom.mozbrowser.enabled", false) {
// Work around borrow checker // Work around borrow checker
let event_info = { let event_info = {
let pipeline = self.pipeline(pipeline_id); let pipeline = self.pipeline(pipeline_id);

View file

@ -31,7 +31,7 @@ use url::Url;
use util; use util;
use util::geometry::{PagePx, ViewportPx}; use util::geometry::{PagePx, ViewportPx};
use util::ipc::OptionalIpcSender; use util::ipc::OptionalIpcSender;
use util::opts; use util::prefs;
/// A uniquely-identifiable pipeline of script task, layout task, and paint task. /// A uniquely-identifiable pipeline of script task, layout task, and paint task.
pub struct Pipeline { pub struct Pipeline {
@ -269,7 +269,7 @@ impl Pipeline {
pub fn trigger_mozbrowser_event(&self, pub fn trigger_mozbrowser_event(&self,
subpage_id: SubpageId, subpage_id: SubpageId,
event: MozBrowserEvent) { event: MozBrowserEvent) {
assert!(opts::experimental_enabled()); assert!(prefs::get_pref("dom.mozbrowser.enabled", false));
let event = ConstellationControlMsg::MozBrowserEvent(self.id, let event = ConstellationControlMsg::MozBrowserEvent(self.id,
subpage_id, subpage_id,

View file

@ -50,7 +50,7 @@ use dom::htmlcollection::{HTMLCollection, CollectionFilter};
use dom::htmlelement::{HTMLElement, HTMLElementTypeId}; use dom::htmlelement::{HTMLElement, HTMLElementTypeId};
use dom::htmlheadelement::HTMLHeadElement; use dom::htmlheadelement::HTMLHeadElement;
use dom::htmlhtmlelement::HTMLHtmlElement; use dom::htmlhtmlelement::HTMLHtmlElement;
use dom::htmliframeelement::HTMLIFrameElement; use dom::htmliframeelement::{self, HTMLIFrameElement};
use dom::htmlscriptelement::HTMLScriptElement; use dom::htmlscriptelement::HTMLScriptElement;
use dom::keyboardevent::KeyboardEvent; use dom::keyboardevent::KeyboardEvent;
use dom::location::Location; use dom::location::Location;
@ -79,7 +79,6 @@ use net_traits::CookieSource::NonHTTP;
use net_traits::{Metadata, PendingAsyncLoad, AsyncResponseTarget}; use net_traits::{Metadata, PendingAsyncLoad, AsyncResponseTarget};
use script_task::Runnable; use script_task::Runnable;
use script_traits::{MouseButton, UntrustedNodeAddress}; use script_traits::{MouseButton, UntrustedNodeAddress};
use util::opts;
use util::str::{DOMString, split_html_space_chars}; use util::str::{DOMString, split_html_space_chars};
use euclid::point::Point2D; use euclid::point::Point2D;
@ -856,7 +855,7 @@ impl Document {
} }
pub fn trigger_mozbrowser_event(&self, event: MozBrowserEvent) { pub fn trigger_mozbrowser_event(&self, event: MozBrowserEvent) {
if opts::experimental_enabled() { if htmliframeelement::mozbrowser_enabled() {
let window = self.window.root(); let window = self.window.root();
if let Some((containing_pipeline_id, subpage_id)) = window.r().parent_info() { if let Some((containing_pipeline_id, subpage_id)) = window.r().parent_info() {

View file

@ -30,7 +30,7 @@ use msg::constellation_msg::IFrameSandboxState::{IFrameSandboxed, IFrameUnsandbo
use msg::constellation_msg::Msg as ConstellationMsg; use msg::constellation_msg::Msg as ConstellationMsg;
use msg::constellation_msg::{PipelineId, SubpageId, ConstellationChan, MozBrowserEvent, NavigationDirection}; use msg::constellation_msg::{PipelineId, SubpageId, ConstellationChan, MozBrowserEvent, NavigationDirection};
use string_cache::Atom; use string_cache::Atom;
use util::opts; use util::prefs;
use util::str::DOMString; use util::str::DOMString;
use js::jsapi::{RootedValue, JSAutoRequest, JSAutoCompartment}; use js::jsapi::{RootedValue, JSAutoRequest, JSAutoCompartment};
@ -41,6 +41,10 @@ use std::cell::Cell;
use url::{Url, UrlParser}; use url::{Url, UrlParser};
use util::str::{self, LengthOrPercentageOrAuto}; use util::str::{self, LengthOrPercentageOrAuto};
pub fn mozbrowser_enabled() -> bool {
prefs::get_pref("dom.mozbrowser.enabled", false)
}
#[derive(HeapSizeOf)] #[derive(HeapSizeOf)]
enum SandboxAllowance { enum SandboxAllowance {
AllowNothing = 0x00, AllowNothing = 0x00,
@ -117,7 +121,7 @@ impl HTMLIFrameElement {
old_subpage_id, old_subpage_id,
sandboxed)).unwrap(); sandboxed)).unwrap();
if opts::experimental_enabled() { if mozbrowser_enabled() {
// https://developer.mozilla.org/en-US/docs/Web/Events/mozbrowserloadstart // https://developer.mozilla.org/en-US/docs/Web/Events/mozbrowserloadstart
self.dispatch_mozbrowser_event(MozBrowserEvent::LoadStart); self.dispatch_mozbrowser_event(MozBrowserEvent::LoadStart);
} }
@ -136,7 +140,7 @@ impl HTMLIFrameElement {
// TODO(gw): Support mozbrowser event types that have detail which is not a string. // TODO(gw): Support mozbrowser event types that have detail which is not a string.
// See https://developer.mozilla.org/en-US/docs/Web/API/Using_the_Browser_API // See https://developer.mozilla.org/en-US/docs/Web/API/Using_the_Browser_API
// for a list of mozbrowser events. // for a list of mozbrowser events.
assert!(opts::experimental_enabled()); assert!(mozbrowser_enabled());
if self.Mozbrowser() { if self.Mozbrowser() {
let window = window_from_node(self); let window = window_from_node(self);
@ -298,7 +302,7 @@ impl HTMLIFrameElementMethods for HTMLIFrameElement {
// https://developer.mozilla.org/en-US/docs/Web/HTML/Element/iframe#attr-mozbrowser // https://developer.mozilla.org/en-US/docs/Web/HTML/Element/iframe#attr-mozbrowser
fn Mozbrowser(&self) -> bool { fn Mozbrowser(&self) -> bool {
if opts::experimental_enabled() { if mozbrowser_enabled() {
let element = ElementCast::from_ref(self); let element = ElementCast::from_ref(self);
element.has_attribute(&Atom::from_slice("mozbrowser")) element.has_attribute(&Atom::from_slice("mozbrowser"))
} else { } else {
@ -308,7 +312,7 @@ impl HTMLIFrameElementMethods for HTMLIFrameElement {
// https://developer.mozilla.org/en-US/docs/Web/HTML/Element/iframe#attr-mozbrowser // https://developer.mozilla.org/en-US/docs/Web/HTML/Element/iframe#attr-mozbrowser
fn SetMozbrowser(&self, value: bool) -> ErrorResult { fn SetMozbrowser(&self, value: bool) -> ErrorResult {
if opts::experimental_enabled() { if mozbrowser_enabled() {
let element = ElementCast::from_ref(self); let element = ElementCast::from_ref(self);
element.set_bool_attribute(&Atom::from_slice("mozbrowser"), value); element.set_bool_attribute(&Atom::from_slice("mozbrowser"), value);
} }

View file

@ -16,7 +16,7 @@ use dom::uievent::{UIEvent, UIEventTypeId};
use dom::window::Window; use dom::window::Window;
use std::cell::Cell; use std::cell::Cell;
use std::default::Default; use std::default::Default;
use util::opts; use util::prefs;
use util::str::DOMString; use util::str::DOMString;
#[dom_struct] #[dom_struct]
@ -171,7 +171,7 @@ impl MouseEventMethods for MouseEvent {
// This returns the same result as current gecko. // This returns the same result as current gecko.
// https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/which // https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/which
fn Which(&self) -> i32 { fn Which(&self) -> i32 {
if opts::experimental_enabled() { if prefs::get_pref("dom.mouseevent.which.enabled", false) {
(self.button.get() + 1) as i32 (self.button.get() + 1) as i32
} else { } else {
0 0

View file

@ -51,7 +51,7 @@ class Longhand(object):
self.ident = to_rust_ident(name) self.ident = to_rust_ident(name)
self.camel_case = to_camel_case(self.ident) self.camel_case = to_camel_case(self.ident)
self.style_struct = THIS_STYLE_STRUCT self.style_struct = THIS_STYLE_STRUCT
self.experimental = experimental self.experimental = ("layout.%s.enabled" % name) if experimental else None
self.custom_cascade = custom_cascade self.custom_cascade = custom_cascade
if derived_from is None: if derived_from is None:
self.derived_from = None self.derived_from = None
@ -64,7 +64,7 @@ class Shorthand(object):
self.ident = to_rust_ident(name) self.ident = to_rust_ident(name)
self.camel_case = to_camel_case(self.ident) self.camel_case = to_camel_case(self.ident)
self.derived_from = None self.derived_from = None
self.experimental = experimental self.experimental = ("layout.%s.enabled" % name) if experimental else None
self.sub_properties = [LONGHANDS_BY_NAME[s] for s in sub_properties] self.sub_properties = [LONGHANDS_BY_NAME[s] for s in sub_properties]
class StyleStruct(object): class StyleStruct(object):
@ -450,7 +450,9 @@ pub mod longhands {
% for value in values[:-1]: % for value in values[:-1]:
"${value}" => { "${value}" => {
% if value in experimental_values: % if value in experimental_values:
if !::util::opts::experimental_enabled() { return Err(()) } if !::util::prefs::get_pref("layout.${value}.enabled", false) {
return Err(())
}
% endif % endif
Ok(computed_value::T::${to_rust_ident(value)}) Ok(computed_value::T::${to_rust_ident(value)})
}, },
@ -458,7 +460,9 @@ pub mod longhands {
% for value in values[-1:]: % for value in values[-1:]:
"${value}" => { "${value}" => {
% if value in experimental_values: % if value in experimental_values:
if !::util::opts::experimental_enabled() { return Err(()) } if !::util::prefs::get_pref("layout.${value}.enabled", false) {
return Err(())
}
% endif % endif
Ok(computed_value::T::${to_rust_ident(value)}) Ok(computed_value::T::${to_rust_ident(value)})
} }
@ -5720,7 +5724,7 @@ impl PropertyDeclaration {
% if property.derived_from is None: % if property.derived_from is None:
"${property.name}" => { "${property.name}" => {
% if property.experimental: % if property.experimental:
if !::util::opts::experimental_enabled() { if !::util::prefs::get_pref("${property.experimental}", false) {
return PropertyDeclarationParseResult::ExperimentalProperty return PropertyDeclarationParseResult::ExperimentalProperty
} }
% endif % endif
@ -5739,7 +5743,7 @@ impl PropertyDeclaration {
% for shorthand in SHORTHANDS: % for shorthand in SHORTHANDS:
"${shorthand.name}" => { "${shorthand.name}" => {
% if shorthand.experimental: % if shorthand.experimental:
if !::util::opts::experimental_enabled() { if !::util::prefs::get_pref("${shorthand.experimental}", false) {
return PropertyDeclarationParseResult::ExperimentalProperty return PropertyDeclarationParseResult::ExperimentalProperty
} }
% endif % endif

View file

@ -429,7 +429,7 @@ impl<'a, 'b> AtRuleParser for NestedRuleParser<'a, 'b> {
Ok(AtRuleType::WithBlock(AtRulePrelude::FontFace)) Ok(AtRuleType::WithBlock(AtRulePrelude::FontFace))
}, },
"viewport" => { "viewport" => {
if ::util::opts::experimental_enabled() { if ::util::prefs::get_pref("layout.viewport.enabled", false) {
Ok(AtRuleType::WithBlock(AtRulePrelude::Viewport)) Ok(AtRuleType::WithBlock(AtRulePrelude::Viewport))
} else { } else {
Err(()) Err(())

View file

@ -60,6 +60,7 @@ pub mod logical_geometry;
pub mod mem; pub mod mem;
pub mod opts; pub mod opts;
pub mod persistent_list; pub mod persistent_list;
pub mod prefs;
pub mod range; pub mod range;
pub mod resource_files; pub mod resource_files;
pub mod str; pub mod str;

View file

@ -10,6 +10,7 @@ use geometry::ScreenPx;
use euclid::size::{Size2D, TypedSize2D}; use euclid::size::{Size2D, TypedSize2D};
use getopts::Options; use getopts::Options;
use num_cpus; use num_cpus;
use prefs;
use std::cmp; use std::cmp;
use std::default::Default; use std::default::Default;
use std::env; use std::env;
@ -17,7 +18,6 @@ use std::fs::{File, PathExt};
use std::io::{self, Read, Write}; use std::io::{self, Read, Write};
use std::path::Path; use std::path::Path;
use std::process; use std::process;
use std::sync::atomic::{AtomicBool, Ordering, ATOMIC_BOOL_INIT};
use url::{self, Url}; use url::{self, Url};
/// Global flags for Servo, currently set on the command line. /// Global flags for Servo, currently set on the command line.
@ -50,9 +50,6 @@ pub struct Opts {
/// and cause it to produce output on that interval (`-m`). /// and cause it to produce output on that interval (`-m`).
pub mem_profiler_period: Option<f64>, pub mem_profiler_period: Option<f64>,
/// Enable experimental web features (`-e`).
pub enable_experimental: bool,
/// The number of threads to use for layout (`-y`). Defaults to 1, which results in a recursive /// The number of threads to use for layout (`-y`). Defaults to 1, which results in a recursive
/// sequential algorithm. /// sequential algorithm.
pub layout_threads: usize, pub layout_threads: usize,
@ -384,7 +381,6 @@ pub fn default_opts() -> Opts {
device_pixels_per_px: None, device_pixels_per_px: None,
time_profiler_period: None, time_profiler_period: None,
mem_profiler_period: None, mem_profiler_period: None,
enable_experimental: false,
layout_threads: 1, layout_threads: 1,
nonincremental_layout: false, nonincremental_layout: false,
nossl: false, nossl: false,
@ -434,7 +430,6 @@ pub fn from_cmdline_args(args: &[String]) {
opts.optopt("o", "output", "Output file", "output.png"); opts.optopt("o", "output", "Output file", "output.png");
opts.optopt("s", "size", "Size of tiles", "512"); opts.optopt("s", "size", "Size of tiles", "512");
opts.optopt("", "device-pixel-ratio", "Device pixels per px", ""); opts.optopt("", "device-pixel-ratio", "Device pixels per px", "");
opts.optflag("e", "experimental", "Enable experimental web features");
opts.optopt("t", "threads", "Number of paint threads", "1"); opts.optopt("t", "threads", "Number of paint threads", "1");
opts.optflagopt("p", "profile", "Profiler flag and output interval", "10"); opts.optflagopt("p", "profile", "Profiler flag and output interval", "10");
opts.optflagopt("m", "memory-profile", "Memory profiler flag and output interval", "10"); opts.optflagopt("m", "memory-profile", "Memory profiler flag and output interval", "10");
@ -461,6 +456,8 @@ pub fn from_cmdline_args(args: &[String]) {
opts.optflag("h", "help", "Print this message"); opts.optflag("h", "help", "Print this message");
opts.optopt("", "resources-path", "Path to find static resources", "/home/servo/resources"); opts.optopt("", "resources-path", "Path to find static resources", "/home/servo/resources");
opts.optflag("", "sniff-mime-types" , "Enable MIME sniffing"); 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) { let opt_match = match opts.parse(args) {
Ok(m) => m, Ok(m) => m,
@ -589,7 +586,6 @@ pub fn from_cmdline_args(args: &[String]) {
device_pixels_per_px: device_pixels_per_px, device_pixels_per_px: device_pixels_per_px,
time_profiler_period: time_profiler_period, time_profiler_period: time_profiler_period,
mem_profiler_period: mem_profiler_period, mem_profiler_period: mem_profiler_period,
enable_experimental: opt_match.opt_present("e"),
layout_threads: layout_threads, layout_threads: layout_threads,
nonincremental_layout: nonincremental_layout, nonincremental_layout: nonincremental_layout,
nossl: nossl, nossl: nossl,
@ -630,19 +626,12 @@ pub fn from_cmdline_args(args: &[String]) {
}; };
set_defaults(opts); set_defaults(opts);
}
static EXPERIMENTAL_ENABLED: AtomicBool = ATOMIC_BOOL_INIT; // This must happen after setting the default options, since the prefs rely on
// on the resource path.
/// Turn on experimental features globally. Normally this is done for pref in opt_match.opt_strs("pref").iter() {
/// during initialization by `set` or `from_cmdline_args`, but prefs::set_pref(pref, true);
/// tests that require experimental features will also set it. }
pub fn set_experimental_enabled(new_value: bool) {
EXPERIMENTAL_ENABLED.store(new_value, Ordering::SeqCst);
}
pub fn experimental_enabled() -> bool {
EXPERIMENTAL_ENABLED.load(Ordering::SeqCst)
} }
// Make Opts available globally. This saves having to clone and pass // Make Opts available globally. This saves having to clone and pass
@ -653,7 +642,7 @@ const INVALID_OPTIONS: *mut Opts = 0x01 as *mut Opts;
lazy_static! { lazy_static! {
static ref OPTIONS: Opts = { static ref OPTIONS: Opts = {
let opts = unsafe { unsafe {
let initial = if !DEFAULT_OPTIONS.is_null() { let initial = if !DEFAULT_OPTIONS.is_null() {
let opts = Box::from_raw(DEFAULT_OPTIONS); let opts = Box::from_raw(DEFAULT_OPTIONS);
*opts *opts
@ -662,9 +651,7 @@ lazy_static! {
}; };
DEFAULT_OPTIONS = INVALID_OPTIONS; DEFAULT_OPTIONS = INVALID_OPTIONS;
initial initial
}; }
set_experimental_enabled(opts.enable_experimental);
opts
}; };
} }

50
components/util/prefs.rs Normal file
View file

@ -0,0 +1,50 @@
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
use resource_files::resources_dir_path;
use rustc_serialize::json::Json;
use std::collections::HashMap;
use std::fs::File;
use std::sync::{Arc, Mutex};
lazy_static! {
static ref PREFS: Arc<Mutex<HashMap<String, bool>>> = {
let prefs = read_prefs().unwrap_or(HashMap::new());
Arc::new(Mutex::new(prefs))
};
}
fn read_prefs() -> Result<HashMap<String, bool>, ()> {
let mut path = resources_dir_path();
path.push("prefs.json");
let mut file = try!(File::open(path).or_else(|e| {
println!("Error opening preferences: {:?}.", e);
Err(())
}));
let json = try!(Json::from_reader(&mut file).or_else(|e| {
println!("Ignoring invalid JSON in preferences: {:?}.", e);
Err(())
}));
let mut prefs = HashMap::new();
if let Some(obj) = json.as_object() {
for (name, value) in obj.iter() {
if let Some(bool_value) = value.as_boolean() {
prefs.insert(name.clone(), bool_value);
} else {
println!("Ignoring non-boolean preference value for {:?}", name);
}
}
}
Ok(prefs)
}
pub fn get_pref(name: &str, default: bool) -> bool {
*PREFS.lock().unwrap().get(name).unwrap_or(&default)
}
pub fn set_pref(name: &str, value: bool) {
let _ = PREFS.lock().unwrap().insert(name.to_owned(), value);
}

13
resources/prefs.json Normal file
View file

@ -0,0 +1,13 @@
{
"dom.mouseevent.which.enabled": false,
"dom.mozbrowser.enabled": false,
"layout.columns.enabled": false,
"layout.column-width.enabled": false,
"layout.column-count.enabled": false,
"layout.column-gap.enabled": false,
"layout.flex.enabled": false,
"layout.flex-direction.enabled": false,
"layout.text-orientation.enabled": false,
"layout.viewport.enabled": false,
"layout.writing-mode.enabled": false
}

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_child_pseudo_a.html first_child_pseudo_b.html
== first_of_type_pseudo_a.html first_of_type_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 == 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 prefs:"layout.flex-direction.enabled,layout.flex.enabled" == flex_column_direction.html flex_column_direction_ref.html
experimental == flex_row_direction.html flex_row_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_a.html float_clearance_ref.html
== float_clearance_intrinsic_width_a.html float_clearance_intrinsic_width_ref.html == float_clearance_intrinsic_width_a.html float_clearance_intrinsic_width_ref.html
== float_intrinsic_height.html float_intrinsic_height_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_height.html iframe/simple_inline_width_height_ref.html
== iframe/simple_inline_width_percentage.html iframe/simple_inline_width_percentage_ref.html == iframe/simple_inline_width_percentage.html iframe/simple_inline_width_percentage_ref.html
== iframe/size_attributes.html iframe/size_attributes_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 == iframe/stacking_context.html iframe/stacking_context_ref.html
!= image_rendering_auto_a.html image_rendering_pixelated_a.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_simple_a.html transform_simple_ref.html
== transform_stacking_context_a.html transform_stacking_context_ref.html == transform_stacking_context_a.html transform_stacking_context_ref.html
== upper_id_attr.html upper_id_attr_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_bottom_a.html vertical_align_bottom_ref.html
== vertical_align_inline_block_a.html vertical_align_inline_block_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 == 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=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=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 # 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 == visibility_hidden.html visibility_hidden_ref.html
== webgl-context/clearcolor.html webgl-context/clearcolor_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>, servo_args: Vec<String>,
render_mode: RenderMode, render_mode: RenderMode,
is_flaky: bool, is_flaky: bool,
experimental: bool, prefs: Vec<String>,
fragment_identifier: Option<String>, fragment_identifier: Option<String>,
resolution: 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 conditions_list = test_line.conditions.split(',');
let mut flakiness = RenderMode::empty(); let mut flakiness = RenderMode::empty();
let mut experimental = false; let mut prefs = vec![];
let mut fragment_identifier = None; let mut fragment_identifier = None;
let mut resolution = None; let mut resolution = None;
for condition in conditions_list { 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_gpu" => flakiness.insert(GPU_RENDERING),
"flaky_linux" => flakiness.insert(LINUX_TARGET), "flaky_linux" => flakiness.insert(LINUX_TARGET),
"flaky_macos" => flakiness.insert(MACOS_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=") { if condition.starts_with("fragment=") {
fragment_identifier = Some(condition["fragment=".len()..].to_string()); 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, render_mode: render_mode,
servo_args: servo_args.to_vec(), servo_args: servo_args.to_vec(),
is_flaky: render_mode.intersects(flakiness), is_flaky: render_mode.intersects(flakiness),
experimental: experimental, prefs: prefs,
fragment_identifier: fragment_identifier, fragment_identifier: fragment_identifier,
resolution: resolution, resolution: resolution,
}; };
@ -275,8 +279,9 @@ fn capture(reftest: &Reftest, side: usize) -> (u32, u32, Vec<u8>) {
if reftest.render_mode.contains(GPU_RENDERING) { if reftest.render_mode.contains(GPU_RENDERING) {
command.arg("-g"); command.arg("-g");
} }
if reftest.experimental { for pref in &reftest.prefs {
command.arg("--experimental"); command.arg("--pref");
command.arg(pref);
} }
if let Some(ref resolution) = reftest.resolution { if let Some(ref resolution) = reftest.resolution {
command.arg("--resolution"); command.arg("--resolution");

View file

@ -25,7 +25,7 @@ fn test_viewport_rule<F>(css: &str,
callback: F) callback: F)
where F: Fn(&Vec<ViewportDescriptorDeclaration>, &str) 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 stylesheet = stylesheet!(css, Author);
let mut rule_count = 0; let mut rule_count = 0;
@ -172,7 +172,7 @@ fn cascading_within_viewport_rule() {
#[test] #[test]
fn multiple_stylesheets_cascading() { 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 device = Device::new(MediaType::Screen, Size2D::typed(800., 600.));
let stylesheets = vec![ let stylesheets = vec![