mirror of
https://github.com/servo/servo.git
synced 2025-07-19 21:33:49 +01:00
43 lines
2.7 KiB
HTML
43 lines
2.7 KiB
HTML
<!doctype html>
|
|
<html>
|
|
<head>
|
|
<meta charset="utf-8">
|
|
<title>CSSOM - CSSStyleSheet interface</title>
|
|
<script src="/resources/testharness.js"></script>
|
|
<script src="/resources/testharnessreport.js"></script>
|
|
<style id="my-stylesheet">
|
|
body { width: 50%; }
|
|
#foo { height: 100px; }
|
|
</style>
|
|
|
|
<script>
|
|
test(function () {
|
|
var styleSheet = document.styleSheets[0];
|
|
styleSheet.cssRules[0].randomProperty = 1;
|
|
styleSheet.cssRules[1].randomProperty = 2;
|
|
|
|
assert_equals(styleSheet, document.getElementById("my-stylesheet").sheet, "CSSStyleSheet and LinkStyle's sheet attribute");
|
|
assert_equals(styleSheet.cssRules.length, 2, "CSSStyleSheet cssRules attribute");
|
|
assert_equals(styleSheet.cssRules[0].cssText, "body { width: 50%; }", "CSSStyleSheet cssRules attribute");
|
|
assert_equals(styleSheet.cssRules[1].cssText, "#foo { height: 100px; }", "CSSStyleSheet cssRules attribute");
|
|
assert_equals(styleSheet.cssRules[2], undefined, "CSSStyleSheet cssRules attribute");
|
|
|
|
styleSheet.insertRule("#bar { margin: 10px; }", 1);
|
|
assert_equals(styleSheet.cssRules.length, 3, "CSSStyleSheet cssRules attribute after insertRule function");
|
|
assert_equals(styleSheet.cssRules[0].cssText, "body { width: 50%; }", "CSSStyleSheet cssRules attribute");
|
|
assert_equals(styleSheet.cssRules[1].cssText, "#bar { margin: 10px; }", "CSSStyleSheet cssRules attribute after insertRule function");
|
|
assert_equals(styleSheet.cssRules[2].cssText, "#foo { height: 100px; }", "CSSStyleSheet cssRules attribute after insertRule function");
|
|
assert_equals(styleSheet.cssRules[0].randomProperty, 1, "[SameObject] cssRules attribute after insertRule function");
|
|
assert_equals(styleSheet.cssRules[2].randomProperty, 2, "[SameObject] cssRules attribute after insertRule function");
|
|
|
|
styleSheet.deleteRule(1);
|
|
assert_equals(styleSheet.cssRules.length, 2, "CSSStyleSheet cssRules attribute after deleteRule function");
|
|
assert_equals(styleSheet.cssRules[0].cssText, "body { width: 50%; }", "CSSStyleSheet cssRules attribute after deleteRule function");
|
|
assert_equals(styleSheet.cssRules[1].cssText, "#foo { height: 100px; }", "CSSStyleSheet cssRules attribute after deleteRule function");
|
|
assert_equals(styleSheet.cssRules[2], undefined, "CSSStyleSheet cssRules attribute after deleteRule function");
|
|
assert_equals(styleSheet.cssRules[0].randomProperty, 1, "[SameObject] cssRules attribute after deleteRule function");
|
|
assert_equals(styleSheet.cssRules[1].randomProperty, 2, "[SameObject] cssRules attribute after deleteRule function");
|
|
});
|
|
</script>
|
|
</head>
|
|
</html>
|