diff options
-rw-r--r-- | components/style/properties/longhand/background.mako.rs | 6 | ||||
-rw-r--r-- | tests/unit/style/properties/background.rs | 19 | ||||
-rw-r--r-- | tests/unit/style/properties/mod.rs | 1 |
3 files changed, 23 insertions, 3 deletions
diff --git a/components/style/properties/longhand/background.mako.rs b/components/style/properties/longhand/background.mako.rs index 57c193bedeb..b4b0686e542 100644 --- a/components/style/properties/longhand/background.mako.rs +++ b/components/style/properties/longhand/background.mako.rs @@ -373,7 +373,7 @@ ${helpers.single_keyword("background-origin", }) } - pub fn parse(context: &ParserContext, input: &mut Parser) -> Result<SpecifiedValue,()> { + pub fn parse(_context: &ParserContext, input: &mut Parser) -> Result<SpecifiedValue,()> { let width; if let Ok(value) = input.try(|input| { match input.next() { @@ -389,7 +389,7 @@ ${helpers.single_keyword("background-origin", }) { return Ok(value) } else { - width = try!(specified::LengthOrPercentageOrAuto::parse(context, input)) + width = try!(specified::LengthOrPercentageOrAuto::parse_non_negative(input)) } let height; @@ -401,7 +401,7 @@ ${helpers.single_keyword("background-origin", }) { height = value } else { - height = try!(specified::LengthOrPercentageOrAuto::parse(context, input)); + height = try!(specified::LengthOrPercentageOrAuto::parse_non_negative(input)); } Ok(SpecifiedValue::Explicit(ExplicitSize { diff --git a/tests/unit/style/properties/background.rs b/tests/unit/style/properties/background.rs new file mode 100644 index 00000000000..493e12e3dcf --- /dev/null +++ b/tests/unit/style/properties/background.rs @@ -0,0 +1,19 @@ +/* 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 cssparser::Parser; +use media_queries::CSSErrorReporterTest; +use style::parser::ParserContext; +use style::properties::longhands::background_size; +use style::stylesheets::Origin; + +#[test] +fn background_size_should_reject_negative_values() { + let url = ::servo_url::ServoUrl::parse("http://localhost").unwrap(); + let context = ParserContext::new(Origin::Author, &url, Box::new(CSSErrorReporterTest)); + + let parse_result = background_size::parse(&context, &mut Parser::new("-40% -40%")); + + assert_eq!(parse_result.is_err(), true); +} diff --git a/tests/unit/style/properties/mod.rs b/tests/unit/style/properties/mod.rs index 639ce9222f7..68713440b45 100644 --- a/tests/unit/style/properties/mod.rs +++ b/tests/unit/style/properties/mod.rs @@ -2,6 +2,7 @@ * 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/. */ +mod background; mod scaffolding; mod serialization; mod viewport; |