mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-08-19 08:51:57 +00:00
LibWeb: Throw error in insertRule
when rule violates constraints
This commit is contained in:
parent
6144154e4f
commit
ef7ba02842
Notes:
github-actions[bot]
2025-06-23 11:53:57 +00:00
Author: https://github.com/Calme1709
Commit: ef7ba02842
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/5158
Reviewed-by: https://github.com/AtkinsSJ ✅
Reviewed-by: https://github.com/tcl3
3 changed files with 125 additions and 1 deletions
78
Tests/LibWeb/Text/input/css/insert-rule-constraints.html
Normal file
78
Tests/LibWeb/Text/input/css/insert-rule-constraints.html
Normal file
|
@ -0,0 +1,78 @@
|
|||
<!DOCTYPE html>
|
||||
<html>
|
||||
<style>
|
||||
div {
|
||||
}
|
||||
</style>
|
||||
<style>
|
||||
div {
|
||||
}
|
||||
</style>
|
||||
<style>
|
||||
@import url("foo.css");
|
||||
</style>
|
||||
<style>
|
||||
@namespace abc url("https://www.w3.org/1999/xhtml");
|
||||
</style>
|
||||
<style>
|
||||
@media (all) {
|
||||
* {
|
||||
}
|
||||
}
|
||||
</style>
|
||||
<script src="../include.js"></script>
|
||||
<script>
|
||||
test(() => {
|
||||
try {
|
||||
document.styleSheets[0].insertRule('@import url("foo.css");', 1);
|
||||
println(
|
||||
"Fail! insertRule should not allow inserting import rules after style rules."
|
||||
);
|
||||
} catch (e) {
|
||||
println(`Inserting import rules after style rule throws: ${e.name}`);
|
||||
}
|
||||
|
||||
try {
|
||||
document.styleSheets[1].insertRule(
|
||||
'@namespace abc url("https://www.w3.org/1999/xhtml");',
|
||||
1
|
||||
);
|
||||
println(
|
||||
"Fail! insertRule should not allow inserting namespace rules after style rules."
|
||||
);
|
||||
} catch (e) {
|
||||
println(`Inserting namespace rules after style rule throws: ${e.name}`);
|
||||
}
|
||||
|
||||
try {
|
||||
document.styleSheets[2].insertRule(
|
||||
'@namespace abc url("https://www.w3.org/1999/xhtml");',
|
||||
0
|
||||
);
|
||||
println(
|
||||
"Fail! insertRule should not allow inserting namespace rules before import rule."
|
||||
);
|
||||
} catch (e) {
|
||||
println(`Inserting namespace rules before import rule throws: ${e.name}`);
|
||||
}
|
||||
|
||||
try {
|
||||
document.styleSheets[2].insertRule("div { color: red; }", 0);
|
||||
println(
|
||||
"Fail! insertRule should not allow inserting style rules before import rule."
|
||||
);
|
||||
} catch (e) {
|
||||
println(`Inserting style rules before import rule throws: ${e.name}`);
|
||||
}
|
||||
|
||||
try {
|
||||
document.styleSheets[3].insertRule("div { color: red }", 0);
|
||||
println(
|
||||
"Fail! insertRule should not allow inserting style rules before namespace rule."
|
||||
);
|
||||
} catch (e) {
|
||||
println(`Inserting style rules before namespace rule throws: ${e.name}`);
|
||||
}
|
||||
});
|
||||
</script>
|
||||
</html>
|
Loading…
Add table
Add a link
Reference in a new issue