mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-05-30 23:12:56 +00:00
LibWeb: Throw on deleting CSS @namespace rule in disallowed conditions
Fixes one(!) WPT test :^)
This commit is contained in:
parent
223c9c91e6
commit
2f76b24b89
Notes:
github-actions[bot]
2025-04-24 16:28:42 +00:00
Author: https://github.com/awesomekling
Commit: 2f76b24b89
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/4455
Reviewed-by: https://github.com/AtkinsSJ ✅
3 changed files with 29 additions and 1 deletions
|
@ -116,7 +116,13 @@ WebIDL::ExceptionOr<void> CSSRuleList::remove_a_css_rule(u32 index)
|
|||
// 3. Set old rule to the indexth item in list.
|
||||
CSSRule& old_rule = m_rules[index];
|
||||
|
||||
// FIXME: 4. If old rule is an @namespace at-rule, and list contains anything other than @import at-rules, and @namespace at-rules, throw an InvalidStateError exception.
|
||||
// 4. If old rule is an @namespace at-rule, and list contains anything other than @import at-rules, and @namespace at-rules, throw an InvalidStateError exception.
|
||||
if (old_rule.type() == CSSRule::Type::Namespace) {
|
||||
for (auto& rule : m_rules) {
|
||||
if (rule->type() != CSSRule::Type::Import && rule->type() != CSSRule::Type::Namespace)
|
||||
return WebIDL::InvalidStateError::create(realm(), "Cannot remove @namespace rule from a stylesheet with non-namespace/import rules."_string);
|
||||
}
|
||||
}
|
||||
|
||||
// 5. Remove rule old rule from list at the zero-indexed position index.
|
||||
m_rules.remove(index);
|
||||
|
|
|
@ -0,0 +1,6 @@
|
|||
Harness status: OK
|
||||
|
||||
Found 1 tests
|
||||
|
||||
1 Pass
|
||||
Pass Deleting a @namespace rule when list contains anything other than @import or @namespace rules should throw InvalidStateError.
|
|
@ -0,0 +1,16 @@
|
|||
<!DOCTYPE html>
|
||||
<title>Deleting a @namespace rule when list contains anything other than @import or @namespace rules should throw InvalidStateError.</title>
|
||||
<link rel="help" href="https://drafts.csswg.org/cssom-1/#remove-a-css-rule">
|
||||
<script src="../../resources/testharness.js"></script>
|
||||
<script src="../../resources/testharnessreport.js"></script>
|
||||
<style>
|
||||
@namespace a url();
|
||||
</style>
|
||||
<script>
|
||||
test(function () {
|
||||
let styleSheet = document.styleSheets[0];
|
||||
styleSheet.cssRules[0];
|
||||
styleSheet.insertRule(`b {}`, 1);
|
||||
assert_throws_dom("InvalidStateError", () => styleSheet.deleteRule(0));
|
||||
}, "Deleting a @namespace rule when list contains anything other than @import or @namespace rules should throw InvalidStateError.");
|
||||
</script>
|
Loading…
Add table
Add a link
Reference in a new issue