From b45686f2433ee89ae71b9389a5cbcd8292620a81 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Emilio=20Cobos=20=C3=81lvarez?= Date: Wed, 29 Nov 2017 22:16:46 +0100 Subject: [PATCH] style: Disable @-moz-document on author sheets on nightly and early beta. Bug: 1035091 Reviewed-by: xidorn MozReview-Commit-ID: AAUs1jJifjS --- components/style/stylesheets/rule_parser.rs | 25 ++++++++++++++++----- 1 file changed, 20 insertions(+), 5 deletions(-) diff --git a/components/style/stylesheets/rule_parser.rs b/components/style/stylesheets/rule_parser.rs index f046f5d3415..a06e68f335c 100644 --- a/components/style/stylesheets/rule_parser.rs +++ b/components/style/stylesheets/rule_parser.rs @@ -424,12 +424,27 @@ impl<'a, 'b, 'i, R: ParseErrorReporter> AtRuleParser<'i> for NestedRuleParser<'a } }, "-moz-document" => { - if cfg!(feature = "gecko") { - let cond = DocumentCondition::parse(self.context, input)?; - Ok(AtRuleType::WithBlock(AtRuleBlockPrelude::Document(cond, location))) - } else { - Err(input.new_custom_error(StyleParseErrorKind::UnsupportedAtRule(name.clone()))) + if !cfg!(feature = "gecko") { + return Err(input.new_custom_error( + StyleParseErrorKind::UnsupportedAtRule(name.clone()) + )) } + + #[cfg(feature = "gecko")] + { + use gecko_bindings::structs; + + if self.stylesheet_origin == Origin::Author && + unsafe { !structs::StylePrefs_sMozDocumentEnabledInContent } + { + return Err(input.new_custom_error( + StyleParseErrorKind::UnsupportedAtRule(name.clone()) + )) + } + } + + let cond = DocumentCondition::parse(self.context, input)?; + Ok(AtRuleType::WithBlock(AtRuleBlockPrelude::Document(cond, location))) }, _ => Err(input.new_custom_error(StyleParseErrorKind::UnsupportedAtRule(name.clone()))) }