diff --git a/components/style/properties/longhand/effects.mako.rs b/components/style/properties/longhand/effects.mako.rs index e651cc57a2e..5c44a737b83 100644 --- a/components/style/properties/longhand/effects.mako.rs +++ b/components/style/properties/longhand/effects.mako.rs @@ -487,7 +487,7 @@ pub fn parse_origin(context: &ParserContext, input: &mut Parser) -> Result { if horizontal.is_none() { horizontal = Some(value); diff --git a/tests/unit/style/parsing/effects.rs b/tests/unit/style/parsing/effects.rs index d335604773b..baa1e2ada16 100644 --- a/tests/unit/style/parsing/effects.rs +++ b/tests/unit/style/parsing/effects.rs @@ -6,6 +6,7 @@ use cssparser::Parser; use media_queries::CSSErrorReporterTest; use servo_url::ServoUrl; use style::parser::ParserContext; +use style::properties::longhands::{self, perspective_origin, transform_origin}; use style::stylesheets::Origin; use style_traits::ToCss; @@ -33,3 +34,32 @@ fn test_clip() { "rect(auto, auto, auto, auto)"); } +#[test] +fn test_longhands_parse_origin() { + let url = ServoUrl::parse("http://localhost").unwrap(); + let context = ParserContext::new(Origin::Author, &url, Box::new(CSSErrorReporterTest)); + + let mut parser = Parser::new("1px some-rubbish"); + let parsed = longhands::parse_origin(&context, &mut parser); + assert!(parsed.is_ok()); + assert_eq!(parser.is_exhausted(), false); + + let mut parser = Parser::new("1px 2px"); + let parsed = longhands::parse_origin(&context, &mut parser); + assert!(parsed.is_ok()); + assert_eq!(parser.is_exhausted(), true); + + let mut parser = Parser::new("1px"); + let parsed = longhands::parse_origin(&context, &mut parser); + assert!(parsed.is_ok()); + assert_eq!(parser.is_exhausted(), true); +} + +#[test] +fn test_effects_parser_exhaustion() { + assert_parser_exhausted!(perspective_origin, "1px 1px", true); + assert_parser_exhausted!(transform_origin, "1px 1px", true); + + assert_parser_exhausted!(perspective_origin, "1px some-rubbish", false); + assert_parser_exhausted!(transform_origin, "1px some-rubbish", false); +}