mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-26 14:22:01 +00:00
Bug 1621849 - Add CSS Error for DisallowedImportRule r=emilio
- 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 --HG-- extra : moz-landing-system : lando
This commit is contained in:
parent
47aa8b6b4d
commit
8dfda8ef7c
@ -39,6 +39,7 @@ PEMQNoMinMaxWithoutValue=Media features with min- or max- must have a value.
|
||||
PEMQExpectedFeatureValue=Found invalid value for media feature.
|
||||
PEExpectedNoneOrURL=Expected ‘none’ or URL but found ‘%1$S’.
|
||||
PEExpectedNoneOrURLOrFilterFunction=Expected ‘none’, URL, or filter function but found ‘%1$S’.
|
||||
PEDisallowedImportRule=@import rules are not yet valid in constructed stylesheets.
|
||||
|
||||
TooLargeDashedRadius=Border radius is too large for ‘dashed’ style (the limit is 100000px). Rendering as solid.
|
||||
TooLargeDottedRadius=Border radius is too large for ‘dotted’ style (the limit is 100000px). Rendering as solid.
|
||||
|
@ -10,6 +10,7 @@
|
||||
<style id="testbench"></style>
|
||||
<script>
|
||||
SpecialPowers.wrap(window).docShell.cssErrorReportingEnabled = true;
|
||||
// Tests that apply to all types of style sheets
|
||||
var tests = [
|
||||
{
|
||||
css: "@unknown {}",
|
||||
@ -118,6 +119,14 @@
|
||||
},
|
||||
];
|
||||
|
||||
// Tests that apply only to constructed style sheets
|
||||
var constructedSheetTests = [
|
||||
{
|
||||
css: '@import url("sheet.css");',
|
||||
error: "@import rules are not yet valid in constructed stylesheets."
|
||||
}
|
||||
];
|
||||
|
||||
function assertMessages(messages, action) {
|
||||
return new Promise(resolve => {
|
||||
SimpleTest.expectConsoleMessages(action, messages, resolve);
|
||||
@ -129,6 +138,12 @@
|
||||
let messages = [ { cssSelectors, errorMessage: error } ];
|
||||
await assertMessages(messages, () => { testbench.innerHTML = css });
|
||||
await assertMessages(messages, () => { new CSSStyleSheet().replaceSync(css) });
|
||||
await assertMessages(messages, async () => { await new CSSStyleSheet().replace(css) });
|
||||
}
|
||||
for (let {css, cssSelectors = "", error} of constructedSheetTests) {
|
||||
let messages = [ { cssSelectors, errorMessage: error } ];
|
||||
await assertMessages(messages, () => { new CSSStyleSheet().replaceSync(css) });
|
||||
await assertMessages(messages, async () => { await new CSSStyleSheet().replace(css) });
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -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
|
||||
|
@ -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.
|
||||
|
@ -298,6 +298,13 @@ impl<'a> ErrorHelpers<'a> for ContextualParseError<'a> {
|
||||
..
|
||||
},
|
||||
) => (cstr!("PEAtNSUnexpected"), Action::Nothing),
|
||||
ContextualParseError::InvalidRule(
|
||||
_,
|
||||
ParseError {
|
||||
kind: ParseErrorKind::Custom(StyleParseErrorKind::DisallowedImportRule),
|
||||
..
|
||||
},
|
||||
) => (cstr!("PEDisallowedImportRule"), Action::Nothing),
|
||||
ContextualParseError::InvalidRule(
|
||||
_,
|
||||
ParseError {
|
||||
|
Loading…
Reference in New Issue
Block a user