mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-11-22 23:50:19 +00:00
LibWeb: Disallow inserting @import rules into a constructed stylesheet
This commit is contained in:
parent
b0f57a2785
commit
811033ec19
Notes:
sideshowbarker
2024-07-17 22:01:16 +09:00
Author: https://github.com/tcl3 Commit: https://github.com/SerenityOS/serenity/commit/811033ec19 Pull-request: https://github.com/SerenityOS/serenity/pull/23327 Reviewed-by: https://github.com/awesomekling
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)
|
||||
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.
|
||||
auto result = m_rules->insert_a_css_rule(parsed_rule, index);
|
||||
|
|
Loading…
Reference in a new issue