Issue #3053 - Implement CSSStyleSheet constructor

This commit is contained in:
Basilisk-Dev 2026-05-22 12:35:37 -04:00 committed by wuggy
commit 536619ee89
5 changed files with 79 additions and 0 deletions

View file

@ -164,6 +164,7 @@ support-files = file_bug1089417_iframe.html
[test_condition_text.html]
[test_condition_text_assignment.html]
[test_contain_formatting_context.html]
[test_constructed_stylesheet.html]
[test_counter_descriptor_storage.html]
[test_counter_style.html]
[test_css_cross_domain.html]

View file

@ -0,0 +1,39 @@
<!DOCTYPE HTML>
<html>
<head>
<meta charset="utf-8">
<title>Test CSSStyleSheet constructor</title>
<script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css">
</head>
<body>
<pre id="test"></pre>
<script type="application/javascript">
"use strict";
let sheet;
try {
sheet = new CSSStyleSheet();
ok(true, "CSSStyleSheet constructor should not throw");
} catch (e) {
ok(false, "CSSStyleSheet constructor should not throw: " + e);
}
if (sheet) {
ok(sheet instanceof CSSStyleSheet, "Constructor should create a CSSStyleSheet");
is(sheet.type, "text/css", "Constructed sheet should have CSS type");
is(sheet.href, null, "Constructed sheet should not have an href");
is(sheet.cssRules.length, 0, "Constructed sheet should start with no rules");
is(sheet.insertRule("#test { color: rgb(1, 2, 3); }", 0), 0,
"insertRule should work on a constructed sheet");
is(sheet.cssRules.length, 1, "insertRule should append a rule");
is(sheet.cssRules[0].selectorText, "#test", "Inserted rule should be readable");
sheet.deleteRule(0);
is(sheet.cssRules.length, 0, "deleteRule should remove the rule");
}
</script>
</body>
</html>