Skip to content
This repository has been archived by the owner on Dec 18, 2018. It is now read-only.

Commit

Permalink
Improve cssstylerule.html.
Browse files Browse the repository at this point in the history
  • Loading branch information
Ms2ger committed Feb 21, 2017
1 parent 71b6e19 commit 2b54520
Showing 1 changed file with 21 additions and 46 deletions.
67 changes: 21 additions & 46 deletions cssom-1/cssstylerule.html
Expand Up @@ -14,35 +14,22 @@
<style id="styleElement" type="text/css">
div { margin: 10px; padding: 0px; }
</style>

<script id="metadata_cache">/*
{
"CSSRule and CSSStyleRule": { "assert": "rule is an instance of CSSRule and CSSStyleRule" },
"Rule_type_property": { "assert": "CSSRule type property has correct type and constants" },
"Rule_properties": { "assert": "cssText, parentRule, parentStyleSheet properties exist on CSSRule" },
"Rule_properties_readonly": { "assert": "type, parentRule, parentStyleSheet properties on CSSRule are readonly" },
"Rule_properties_values": { "assert": "type, parentRule, parentStyleSheet initial property values on CSSRule are correct" },
"StyleRule_properties": { "assert": "selectorText, style properties on CSSStyleRule" },
"StyleRule_properties_values": { "assert": "Initial values of selectorText, style properties on CSSStyleRule are correct" }
}
*/</script>
</head>
<body>
<noscript>Test not run -- JavaScript required.</noscript>
<div id="log"></div>

<script type="text/javascript">
var styleSheet = document.getElementById("styleElement").sheet;
var ruleList = styleSheet.cssRules;

var rule = ruleList[0];
var rule;
setup(function() {
var styleSheet = document.getElementById("styleElement").sheet;
var ruleList = styleSheet.cssRules;
rule = ruleList[0];
});

test(function() {
assert_true(rule instanceof CSSRule);
assert_true(rule instanceof CSSStyleRule);
}, "CSSRule and CSSStyleRule",
{ assert: "rule is an instance of CSSRule and CSSStyleRule" }
);
}, "CSSRule and CSSStyleRule types");

test(function() {
assert_equals(rule.STYLE_RULE, 1);
Expand All @@ -51,54 +38,42 @@
assert_equals(rule.FONT_FACE_RULE, 5);
assert_equals(rule.PAGE_RULE, 6);
assert_equals(rule.NAMESPACE_RULE, 10);
assert_own_property(rule, "type");
assert_true(typeof rule.type === "number");
}, "Rule_type_property",
{ assert: "CSSRule type property has correct type and constants" }
);
assert_idl_attribute(rule, "type");
assert_equals(typeof rule.type, "number");
}, "Type of CSSRule#type and constant values");

test(function() {
assert_true(rule instanceof CSSRule);
assert_own_property(rule, "cssText");
assert_own_property(rule, "parentRule");
assert_own_property(rule, "parentStyleSheet");
}, "Rule_properties",
{ assert: "cssText, parentRule, parentStyleSheet properties exist on CSSRule" }
);
assert_idl_attribute(rule, "cssText");
assert_idl_attribute(rule, "parentRule");
assert_idl_attribute(rule, "parentStyleSheet");
}, "Existence of CSSRule attributes");

test(function() {
assert_readonly(rule, "type");
assert_readonly(rule, "parentRule");
assert_readonly(rule, "parentStyleSheet");
}, "Rule_properties_readonly",
{ assert: "type, parentRule, parentStyleSheet properties on CSSRule are readonly" }
);
}, "Writability of CSSRule attributes");

test(function() {
assert_equals(rule.type, rule.STYLE_RULE);
assert_equals(typeof rule.cssText, "string");
assert_equals(rule.cssText.replace(/\s+/g, ''), "div{margin:10px;padding:0px;}"); // remove whitespace because serialization is not specified yet
assert_equals(rule.cssText, "div { margin: 10px; padding: 0px; }");
assert_equals(rule.parentRule, null);
assert_true(rule.parentStyleSheet instanceof CSSStyleSheet);
}, "Rule_properties_values",
{ assert: "type, parentRule, parentStyleSheet initial property values on CSSRule are correct" }
);
}, "Values of CSSRule attributes");

test(function() {
assert_own_property(rule, "selectorText");
assert_idl_attribute(rule, "selectorText");
assert_equals(typeof rule.selectorText, "string");
assert_own_property(rule, "style");
assert_idl_attribute(rule, "style");
assert_readonly(rule, "style");
}, "StyleRule_properties",
{ assert: "selectorText, style properties on CSSStyleRule" }
);
}, "Existence, writability and type of CSSStyleRule attributes");

test(function() {
assert_equals(rule.selectorText, "div");
assert_true(rule.style instanceof CSSStyleDeclaration);
}, "StyleRule_properties_values",
{ assert: "Initial values of selectorText, style properties on CSSStyleRule are correct" }
);
}, "Values of CSSStyleRule attributes");
</script>
</body>
</html>

0 comments on commit 2b54520

Please sign in to comment.