mirror of
https://github.com/servo/servo.git
synced 2025-08-03 04:30:10 +01:00
117 lines
No EOL
4.7 KiB
HTML
117 lines
No EOL
4.7 KiB
HTML
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
|
|
<html xmlns="http://www.w3.org/1999/xhtml"><head>
|
|
<title>CSSOM CSSRule CSSImportRule interface</title>
|
|
<link href="mailto:lew.letitia@gmail.com" rel="author" title="Letitia Lew" />
|
|
<link href="http://www.w3.org/TR/cssom/#css-rules" rel="help" />
|
|
<link href="http://www.w3.org/TR/cssom/#the-cssrule-interface" rel="help" />
|
|
<link href="http://www.w3.org/TR/cssom/#the-cssimportrule-interface" rel="help" />
|
|
<meta content="dom" name="flags" />
|
|
<meta content="All properties for this CSSImportRule instance of CSSRule are initialized correctly" name="assert" />
|
|
<script src="/resources/testharness.js"></script>
|
|
<script src="/resources/testharnessreport.js"></script>
|
|
|
|
<style type="text/css" id="styleElement">
|
|
@import url("support/a-green.css");
|
|
@import url("support/a-green.css") screen;
|
|
</style>
|
|
|
|
<script id="metadata_cache">/*
|
|
{
|
|
"CSSRule and CSSImportRule types": { "assert": "rule is an instance of CSSRule and CSSImportRule" },
|
|
"Rule_type_property": { "assert": "CSSRule type property has correct type and constants" },
|
|
"CSSRule_properties": {
|
|
"assert": ["cssText, parentRule, parentStyleSheet properties exist on CSSRule",
|
|
"type, parentRule, parentStyleSheet properties on CSSRule are readonly"]
|
|
},
|
|
"CSSRule_properties_values": { "assert": "type, parentRule, parentStyleSheet initial property values on CSSRule are correct" },
|
|
"CSSImportRule_properties": {
|
|
"assert": ["href, media, styleSheet properties exist on CSSImportsRule",
|
|
"href, media, styleSheet properties are readonly"]
|
|
},
|
|
"CSSImportRule_properties_values": { "assert": "Initial values of href, media, styleSheet properties on CSSImportRule 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 ruleWithMedia = ruleList[1];
|
|
|
|
test(function() {
|
|
assert_true(rule instanceof CSSRule);
|
|
assert_true(rule instanceof CSSImportRule);
|
|
assert_true(ruleWithMedia instanceof CSSRule);
|
|
assert_true(ruleWithMedia instanceof CSSImportRule);
|
|
}, "CSSRule and CSSImportRule types",
|
|
{ assert: "rule is an instance of CSSRule and CSSImportRule" }
|
|
);
|
|
|
|
test(function() {
|
|
assert_equals(rule.STYLE_RULE, 1);
|
|
assert_equals(rule.IMPORT_RULE, 3);
|
|
assert_equals(rule.MEDIA_RULE, 4);
|
|
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" }
|
|
);
|
|
|
|
test(function() {
|
|
assert_true(rule instanceof CSSRule);
|
|
assert_own_property(rule, "cssText");
|
|
assert_own_property(rule, "parentRule");
|
|
assert_own_property(rule, "parentStyleSheet");
|
|
|
|
assert_readonly(rule, "type");
|
|
assert_readonly(rule, "parentRule");
|
|
assert_readonly(rule, "parentStyleSheet");
|
|
}, "CSSRule_properties",
|
|
{ assert: ["cssText, parentRule, parentStyleSheet properties exist on CSSRule", "type, parentRule, parentStyleSheet properties on CSSRule are readonly"] }
|
|
);
|
|
|
|
test(function() {
|
|
assert_equals(rule.type, rule.IMPORT_RULE);
|
|
assert_equals(typeof rule.cssText, "string");
|
|
assert_equals(rule.cssText, "@import url(\"cssimportrule.css\");");
|
|
assert_equals(ruleWithMedia.cssText, "@import url(\"cssimportrule.css\") screen;");
|
|
assert_equals(rule.parentRule, null);
|
|
assert_true(rule.parentStyleSheet instanceof CSSStyleSheet);
|
|
}, "CSSRule_properties_values",
|
|
{ assert: "type, parentRule, parentStyleSheet initial property values on CSSRule are correct" }
|
|
);
|
|
|
|
test(function() {
|
|
assert_own_property(rule, "href");
|
|
assert_own_property(rule, "media");
|
|
assert_own_property(rule, "styleSheet");
|
|
|
|
assert_readonly(rule, "href");
|
|
assert_readonly(rule, "media");
|
|
assert_readonly(rule, "styleSheet");
|
|
}, "CSSImportRule_properties",
|
|
{ assert: ["href, media, styleSheet properties exist on CSSImportsRule", "href, media, styleSheet properties are readonly"] }
|
|
);
|
|
|
|
test(function() {
|
|
assert_equals(typeof rule.href, "string");
|
|
assert_true(rule.media instanceof MediaList);
|
|
assert_true(rule.styleSheet instanceof CSSStyleSheet);
|
|
assert_true(ruleWithMedia.media.length > 0);
|
|
assert_equals(ruleWithMedia.media.mediaText, "screen");
|
|
}, "CSSImportRule_properties_values",
|
|
{ assert: "Initial values of href, media, styleSheet properties on CSSImportRule are correct" }
|
|
);
|
|
|
|
</script>
|
|
|
|
|
|
</body></html> |