mirror of
https://github.com/RGBCube/serenity
synced 2025-07-26 04:27:44 +00:00
LibWeb: Disallow inserting @import rules into a constructed stylesheet
This commit is contained in:
parent
b0f57a2785
commit
811033ec19
3 changed files with 17 additions and 1 deletions
|
@ -0,0 +1 @@
|
||||||
|
Inserting an @import rule into a constructed stylesheet throws: SyntaxError
|
|
@ -0,0 +1,13 @@
|
||||||
|
<!DOCTYPE html>
|
||||||
|
<script src="../include.js"></script>
|
||||||
|
<script>
|
||||||
|
test(() => {
|
||||||
|
try {
|
||||||
|
const sheet = new CSSStyleSheet();
|
||||||
|
sheet.insertRule(`@import url("style-sheet-with-byte-order-mark.css")`);
|
||||||
|
println("FAIL");
|
||||||
|
} catch (e) {
|
||||||
|
println(`Inserting an @import rule into a constructed stylesheet throws: ${e.name}`);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
</script>
|
|
@ -140,7 +140,9 @@ WebIDL::ExceptionOr<unsigned> CSSStyleSheet::insert_rule(StringView rule, unsign
|
||||||
if (!parsed_rule)
|
if (!parsed_rule)
|
||||||
return WebIDL::SyntaxError::create(realm(), "Unable to parse CSS rule."_fly_string);
|
return WebIDL::SyntaxError::create(realm(), "Unable to parse CSS rule."_fly_string);
|
||||||
|
|
||||||
// FIXME: 5. If parsed rule is an @import rule, and the constructed flag is set, throw a SyntaxError DOMException.
|
// 5. If parsed rule is an @import rule, and the constructed flag is set, throw a SyntaxError DOMException.
|
||||||
|
if (constructed() && parsed_rule->type() == CSSRule::Type::Import)
|
||||||
|
return WebIDL::SyntaxError::create(realm(), "Can't insert @import rules into a constructed stylesheet."_fly_string);
|
||||||
|
|
||||||
// 6. Return the result of invoking insert a CSS rule rule in the CSS rules at index.
|
// 6. Return the result of invoking insert a CSS rule rule in the CSS rules at index.
|
||||||
auto result = m_rules->insert_a_css_rule(parsed_rule, index);
|
auto result = m_rules->insert_a_css_rule(parsed_rule, index);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue