diff --git a/components/style/properties/longhand/text.mako.rs b/components/style/properties/longhand/text.mako.rs index f5769fa26be..9c78d8e7e1e 100644 --- a/components/style/properties/longhand/text.mako.rs +++ b/components/style/properties/longhand/text.mako.rs @@ -51,7 +51,7 @@ } pub fn parse(context: &ParserContext, input: &mut Parser) -> Result { let first = try!(Side::parse(context, input)); - let second = Side::parse(context, input).ok(); + let second = input.try(|input| Side::parse(context, input)).ok(); Ok(SpecifiedValue { first: first, second: second, diff --git a/tests/unit/style/parsing/text_overflow.rs b/tests/unit/style/parsing/text_overflow.rs index d8c2a2323f4..fd2b6b91cab 100644 --- a/tests/unit/style/parsing/text_overflow.rs +++ b/tests/unit/style/parsing/text_overflow.rs @@ -22,3 +22,13 @@ fn test_text_overflow() { assert_roundtrip_with_context!(text_overflow::parse, r#""x" "y""#); } + +#[test] +fn test_text_overflow_parser_exhaustion() { + use style::properties::longhands::text_overflow; + + assert_parser_exhausted!(text_overflow, r#"clip rubbish"#, false); + assert_parser_exhausted!(text_overflow, r#"clip"#, true); + assert_parser_exhausted!(text_overflow, r#"ellipsis"#, true); + assert_parser_exhausted!(text_overflow, r#"clip ellipsis"#, true); +}