blob: 3f4956cb3ad4dadc9937af32989a95da9f5a4e4e [file] [log] [blame]
<!DOCTYPE html>
<html>
<head>
<title>CSS Test: CSSOM StyleSheet Initial Values</title>
<link rel="author" title="Bear Travis" href="mailto:betravis@adobe.com">
<link rel="help" href="http://www.w3.org/TR/cssom-1/#css-style-sheets">
<meta name="flags" content="dom">
<meta name="assert" content="StyleSheet and CSSStyleSheet objects have the properties specified in their interfaces">
<script src="/resources/testharness.js" type="text/javascript"></script>
<script src="/resources/testharnessreport.js" type="text/javascript"></script>
<style id="styleElement" type="text/css" media="all" title="internal style sheet" disabled="disabled">
@import url('support/a-green.css');
* { margin: 0; padding: 0; }
</style>
<link id="linkElement" rel="stylesheet" href="support/b-green.css">
<script id="metadata_cache">/*
{
"sheet_property": {
"help": "http://www.w3.org/TR/cssom-1/#the-linkstyle-interface",
"assert": ["styleElement.sheet exists",
"styleElement.sheet is a CSSStyleSheet",
"linkElement.sheet exists",
"linkElement.sheet is a CSSStyleSheet"]
},
"CSSStyleSheet_properties": {
"assert": ["ownerRule, cssRules, insertRule and deleteRule properties exist on CSSStyleSheet",
"ownerRule, cssRules are read only"]
},
"CSSStyleSheet_property_values": {
"help": ["http://www.w3.org/TR/cssom-1/#css-style-sheets",
"http://www.w3.org/TR/cssom-1/#cssimportrule"],
"assert": "CSSStyleSheet initial property values are correct"
},
"StyleSheet_properties": {
"assert": ["type, disabled, ownerNode, parentStyleSheet, href, title, and media properties exist on StyleSheet",
"type, ownerNode, parentStyleSheet, href, title, media properties are read only"]
},
"StyleSheet_property_values": { "assert": "StyleSheet initial property values are correct" }
}
*/</script>
</head>
<body>
<noscript>Test not run - javascript required.</noscript>
<div id="log"></div>
<script type="text/javascript">
var styleElement = document.getElementById("styleElement");
var linkElement = document.getElementById("linkElement");
var styleSheet;
var linkSheet;
test(function() {
assert_own_property(styleElement, "sheet");
assert_readonly(styleElement, "sheet");
styleSheet = styleElement.sheet;
assert_true(styleSheet instanceof CSSStyleSheet);
assert_own_property(linkElement, "sheet");
linkSheet = linkElement.sheet;
assert_true(linkSheet instanceof CSSStyleSheet);
}, "sheet_property",
{ help: "http://www.w3.org/TR/cssom-1/#the-linkstyle-interface",
assert: [ "styleElement.sheet exists", "styleElement.sheet is a CSSStyleSheet",
"linkElement.sheet exists", "linkElement.sheet is a CSSStyleSheet"] });
test(function() {
assert_own_property(styleSheet, "ownerRule");
assert_own_property(styleSheet, "cssRules");
assert_inherits(styleSheet, "insertRule");
assert_inherits(styleSheet, "deleteRule");
assert_readonly(styleSheet, "ownerRule");
assert_readonly(styleSheet, "cssRules");
}, "CSSStyleSheet_properties",
{ assert: [ "ownerRule, cssRules, insertRule and deleteRule properties exist on CSSStyleSheet",
"ownerRule, cssRules are read only"] });
var importSheet;
test(function() {
assert_equals(styleSheet.ownerRule, null);
assert_true(styleSheet.cssRules.length > 0);
assert_true(styleSheet.cssRules.item(0) instanceof CSSImportRule);
importSheet = styleSheet.cssRules.item(0).styleSheet;
}, "CSSStyleSheet_property_values",
{ help: [ "http://www.w3.org/TR/cssom-1/#css-style-sheets",
"http://www.w3.org/TR/cssom-1/#cssimportrule" ],
assert: "CSSStyleSheet initial property values are correct" });
test(function() {
assert_own_property(styleSheet, "type");
assert_own_property(styleSheet, "disabled");
assert_own_property(styleSheet, "ownerNode");
assert_own_property(styleSheet, "parentStyleSheet");
assert_own_property(styleSheet, "href");
assert_own_property(styleSheet, "title");
assert_own_property(styleSheet, "media");
assert_readonly(styleSheet, "type");
assert_readonly(styleSheet, "ownerNode");
assert_readonly(styleSheet, "parentStyleSheet");
assert_readonly(styleSheet, "href");
assert_readonly(styleSheet, "title");
assert_readonly(styleSheet, "media");
}, "StyleSheet_properties",
{ assert: [ "type, disabled, ownerNode, parentStyleSheet, href, title, and media properties exist on StyleSheet",
"type, ownerNode, parentStyleSheet, href, title, media properties are read only" ] });
test(function() {
assert_equals(styleSheet.type, "text/css");
assert_equals(styleSheet.disabled, false);
assert_equals(styleSheet.ownerNode, styleElement);
assert_equals(linkSheet.ownerNode, linkElement);
assert_equals(importSheet.ownerNode, null);
assert_equals(styleSheet.href, null);
assert_regexp_match(linkSheet.href, /support\/b-green.css$/);
assert_regexp_match(importSheet.href, /support\/a-green.css$/);
assert_equals(styleSheet.parentStyleSheet, null);
assert_equals(linkSheet.parentStyleSheet, null);
assert_equals(importSheet.parentStyleSheet, styleSheet);
assert_equals(styleSheet.title, "internal style sheet");
assert_equals(styleSheet.media.item(0), "all");
}, "StyleSheet_property_values",
{ assert: "StyleSheet initial property values are correct" });
</script>
</body>
</html>