From 87139a3ea2fb179fd3d55d2355b976d5646705f1 Mon Sep 17 00:00:00 2001 From: Erik Nordin Date: Wed, 8 Apr 2020 22:45:24 +0000 Subject: [PATCH] style: Add CSS Error for DisallowedImportRule. - Add new CSS Error - Add new test case for error - Ensure that test cases use `replace()` and `replaceSync()` Differential Revision: https://phabricator.services.mozilla.com/D69423 --- components/style/stylesheets/rule_parser.rs | 2 +- components/style_traits/lib.rs | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/components/style/stylesheets/rule_parser.rs b/components/style/stylesheets/rule_parser.rs index d380f179824..74425afafcd 100644 --- a/components/style/stylesheets/rule_parser.rs +++ b/components/style/stylesheets/rule_parser.rs @@ -193,7 +193,7 @@ impl<'a, 'i> AtRuleParser<'i> for TopLevelRuleParser<'a> { } if let AllowImportRules::No = self.allow_import_rules { - return Err(input.new_custom_error(StyleParseErrorKind::UnexpectedImportRule)) + return Err(input.new_custom_error(StyleParseErrorKind::DisallowedImportRule)) } // FIXME(emilio): We should always be able to have a loader diff --git a/components/style_traits/lib.rs b/components/style_traits/lib.rs index 516e7b6efba..be2d275b654 100644 --- a/components/style_traits/lib.rs +++ b/components/style_traits/lib.rs @@ -137,6 +137,8 @@ pub enum StyleParseErrorKind<'i> { UnexpectedNamespaceRule, /// @import must be before any rule but @charset UnexpectedImportRule, + /// @import rules are disallowed in the parser. + DisallowedImportRule, /// Unexpected @charset rule encountered. UnexpectedCharsetRule, /// Unsupported @ rule @@ -149,7 +151,6 @@ pub enum StyleParseErrorKind<'i> { ValueError(ValueParseErrorKind<'i>), /// An error was encountered while parsing a selector SelectorError(SelectorParseErrorKind<'i>), - /// The property declaration was for an unknown property. UnknownProperty(CowRcStr<'i>), /// The property declaration was for a disabled experimental property.