Update CSS tests to revision 0698c2aa9ead844b6d7d10eafb096cb1118e13ef

This commit is contained in:
Ms2ger 2015-12-09 01:48:05 -05:00
parent 9aa1b1e408
commit 35c74aecc2
11290 changed files with 92400 additions and 49214 deletions

View file

@ -39,10 +39,10 @@
var outer = document.getElementById("outside");
var inner = document.getElementById("inside");
var innerStyle;
test(function() {
innerStyle = window.getComputedStyle(inner);
assert_throws( "NO_MODIFICATION_ALLOWED_ERR",
assert_throws( "NO_MODIFICATION_ALLOWED_ERR",
function() { innerStyle.cssText = "color: blue;"; },
"do not allow setting cssText on a readonly CSSStyleDeclaration");
assert_throws( "NO_MODIFICATION_ALLOWED_ERR",
@ -51,10 +51,10 @@
assert_throws( "NO_MODIFICATION_ALLOWED_ERR",
function() { innerStyle.color = "blue"; },
"do not allow setting a property on a readonly CSSStyleDeclaration");
}, "read_only", {
}, "read_only", {
assert: "do not allow modifications to a computed CSSStyleDeclaration"
});
test(function() {
assert_equals(innerStyle.getPropertyValue("height"), "100px");
}, "property_values", {
@ -66,7 +66,7 @@
}, "inherited_property_values", {
assert: "Inherited properties are resolved"
});
test(function() {
assert_equals(innerStyle.getPropertyValue("width"), "100px");
}, "relative_property_values", {

View file

@ -10,87 +10,54 @@
<style id="styleElement">
#test { color: green; }
</style>
<script id="metadata_cache">/*
{
"CSSStyleDeclaration_accessible": {
"help": ["http://www.w3.org/TR/cssom/#the-cssstylesheet-interface",
"http://www.w3.org/TR/cssom/#the-cssrulelist-interface",
"http://www.w3.org/TR/cssom/#the-cssstylerule-interface"],
"assert": "Can access CSSStyleDeclaration through CSSOM"
},
"read": { "assert": "initial property values are correct" },
"csstext_write": {
"assert": ["setting cssText adds new properties",
"setting cssText removes existing properties",
"properties set through cssText are reflected in the computed style"]
},
"property_write": {
"assert": ["setProperty adds new properties",
"properties set through setProperty are reflected in the computed style"]
}
}
*/</script>
</head>
<body>
<noscript>Test not run - javascript required.</noscript>
<div id="log"></div>
<div id="test"></div>
<script type="text/javascript">
var styleElement = document.getElementById("styleElement");
var styleDeclaration;
test(function() {
assert_own_property(styleElement, "sheet");
assert_own_property(styleElement.sheet, "cssRules");
assert_true(styleElement.sheet.cssRules instanceof CSSRuleList);
assert_true(styleElement.sheet.cssRules.item(0) instanceof CSSStyleRule);
declaration = styleElement.sheet.cssRules.item(0).style;
}, "CSSStyleDeclaration_accessible",
{ help: [ "http://www.w3.org/TR/cssom/#the-cssstylesheet-interface",
"http://www.w3.org/TR/cssom/#the-cssrulelist-interface",
"http://www.w3.org/TR/cssom/#the-cssstylerule-interface" ],
assert: "Can access CSSStyleDeclaration through CSSOM" });
var declaration;
setup(function() {
var styleElement = document.getElementById("styleElement");
declaration = styleElement.sheet.cssRules.item(0).style;
});
test(function() {
assert_regexp_match(declaration.cssText, /color: green;\s*/);
test(function() {
assert_equals(declaration.cssText, "color: green;");
assert_equals(declaration.getPropertyValue("color"), "green");
}, "read",
{ assert: "initial property values are correct" });
}, "Reading CSSStyleDeclaration initialized from a style element");
test(function() {
declaration.cssText = "margin-left: 10px; padding-left: 10px;";
assert_regexp_match(declaration.cssText, /margin-left: 10px;\s+padding-left: 10px;\s+/);
declaration.cssText = "margin-left:10px; padding-left:10px";
assert_equals(declaration.cssText, "margin-left: 10px; padding-left: 10px;");
assert_equals(declaration.length, 2);
assert_equals(declaration.item(0), "margin-left");
assert_equals(declaration.item(1), "padding-left");
assert_equals(declaration.getPropertyValue("margin-left"), "10px");
assert_equals(declaration.getPropertyValue("padding-left"), "10px");
var computedStyle = window.getComputedStyle(document.getElementById("test"));
assert_equals(computedStyle.getPropertyValue("margin-left"), "10px");
assert_equals(computedStyle.getPropertyValue("padding-left"), "10px");
}, "csstext_write",
{ assert: [ "setting cssText adds new properties",
"setting cssText removes existing properties",
"properties set through cssText are reflected in the computed style"] });
}, "Setting CSSStyleDeclaration#cssText");
test(function() {
while(declaration.length > 0)
while (declaration.length > 0) {
declaration.removeProperty(declaration.item(0));
}
declaration.setProperty("margin-left", "15px");
declaration.setProperty("padding-left", "15px");
assert_equals(declaration.length, 2);
assert_equals(declaration.item(0), "margin-left");
assert_equals(declaration.item(1), "padding-left");
assert_equals(declaration.getPropertyValue("margin-left"), "15px");
assert_equals(declaration.getPropertyValue("padding-left"), "15px");
var computedStyle = window.getComputedStyle(document.getElementById("test"));
assert_equals(computedStyle.getPropertyValue("margin-left"), "15px");
assert_equals(computedStyle.getPropertyValue("padding-left"), "15px");
}, "property_write",
{ assert: [ "setProperty adds new properties",
"properties set through setProperty are reflected in the computed style"] });
}, "Calling CSSStyleDeclaration#setProperty");
</script>
</body></html>

View file

@ -6,51 +6,33 @@
<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">
<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];
var rule, ruleWithMedia;
setup(function() {
var styleSheet = document.getElementById("styleElement").sheet;
var ruleList = styleSheet.cssRules;
rule = ruleList[0];
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" }
);
}, "CSSRule and CSSImportRule types");
test(function() {
assert_equals(rule.STYLE_RULE, 1);
@ -59,47 +41,39 @@
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");
assert_idl_attribute(rule, "cssText");
assert_idl_attribute(rule, "parentRule");
assert_idl_attribute(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"] }
);
}, "Existence and writability of CSSRule attributes");
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.cssText, '@import url("support/a-green.css");');
assert_equals(ruleWithMedia.cssText, '@import url("support/a-green.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" }
);
}, "Values of CSSRule attributes");
test(function() {
assert_own_property(rule, "href");
assert_own_property(rule, "media");
assert_own_property(rule, "styleSheet");
assert_idl_attribute(rule, "href");
assert_idl_attribute(rule, "media");
assert_idl_attribute(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"] }
);
}, "Existence and writability of CSSImportRule attributes");
test(function() {
assert_equals(typeof rule.href, "string");
@ -107,10 +81,7 @@
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" }
);
}, "Values of CSSImportRule attributes");
</script>

View file

@ -54,7 +54,7 @@
test(function(){
var e = newElm();
var style = e.style;
style.color = 'red';
style.fontSize = '10pt';
style.fontWeight = 'bold';

View file

@ -6,7 +6,7 @@
<link href="http://www.w3.org/TR/cssom/#the-cssrule-interface" rel="help">
<link href="http://www.w3.org/TR/cssom/#the-cssstylerule-interface" rel="help">
<meta content="dom" name="flags">
<meta content="All properties for this CSSStyleRule instance of CSSRule are initialized correctly" name="assert">
<meta content="All properties for this CSSStyleRule instance of CSSRule are initialized correctly" name="assert">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>

View file

@ -19,12 +19,19 @@ test(function() {
}, "String conversion");
test(function() {
assert_throws('InvalidCharacterError', function() { CSS.escape('\0'); });
assert_throws('InvalidCharacterError', function() { CSS.escape('a\0'); });
assert_throws('InvalidCharacterError', function() { CSS.escape('\0b'); });
assert_throws('InvalidCharacterError', function() { CSS.escape('a\0b'); });
assert_equals(CSS.escape('\0'), '\uFFFD');
assert_equals(CSS.escape('a\0'), 'a\uFFFD');
assert_equals(CSS.escape('\0b'), '\uFFFDb');
assert_equals(CSS.escape('a\0b'), 'a\uFFFDb');
}, "Null bytes");
test(function() {
assert_equals(CSS.escape('\uFFFD'), '\uFFFD');
assert_equals(CSS.escape('a\uFFFD'), 'a\uFFFD');
assert_equals(CSS.escape('\uFFFDb'), '\uFFFDb');
assert_equals(CSS.escape('a\uFFFDb'), 'a\uFFFDb');
}, "Replacement character");
test(function() {
assert_equals(CSS.escape('0a'), '\\30 a');
assert_equals(CSS.escape('1a'), '\\31 a');

View file

@ -7,13 +7,13 @@
<meta content="The style value should be serialized to margin: 20px;" name="assert">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
</head>
</head>
<body>
<div id="cssomtestElm"></div>
<div id="log"></div>
<div id="log"></div>
<script>
var testElm = document.getElementById('cssomtestElm');
// Set the transform
// Set the transform
document.getElementById('cssomtestElm').style.margin = "20px 20px 20px 20px";
// Verify that the transform was set as expected

View file

@ -7,10 +7,10 @@
<meta content="Testing Serialization of Shorthand Values" name="assert">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
</head>
</head>
<body>
<div id="cssomtestElm"></div>
<div id="log"></div>
<div id="log"></div>
<script>
var tests = {
'border': [
@ -56,26 +56,26 @@
var testElm = document.getElementById('cssomtestElm');
for (var test in tests) {
console.log(test);
if(tests.hasOwnProperty(test)) {
results[test] = [];
results[test] = [];
var propertyTests = tests[test];
for (i = 0; i < propertyTests.length; i++) {
document.getElementById('cssomtestElm').setAttribute('style', propertyTests[i][0]);
results[test].push([
test + ' is expected to be ' + propertyTests[i][1],
test + ' is expected to be ' + propertyTests[i][1],
document.getElementById('cssomtestElm').style.cssText,
propertyTests[i][1]
]);
}
generate_tests(assert_equals, results[test]);
}
}
}
</script>

View file

@ -8,17 +8,17 @@
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<style id="s-0">
@namespace svg "http://www.w3.org/2000/svg";
@namespace svg "http://www.w3.org/2000/svg";
</style>
<style id="s-1">
@import url('main.css');
@import url('main.css');
</style>
<style id="s-2">
<style id="s-2">
h1 { background: indianred; }
</style>
</style>
<style id="s-3">
@namespace svg "http://www.w3.org/2000/svg";
svg|a { color: white; }
@namespace svg "http://www.w3.org/2000/svg";
svg|a { color: white; }
</style>
<style id="s-4">
@font-face {
@ -30,7 +30,7 @@
url('fonts/megalopolisextra-webfont.svg#MEgalopolisExtraRegular') format('svg');
font-weight: normal;
font-style: normal;
}
}
</style>
<style id="s-5">
@media (min-width: 200px) {
@ -42,14 +42,14 @@
h1 { color: #444; }
}
</style>
</head>
</head>
<body>
<div id="log"></div>
<div id="log"></div>
<script>
var stylesheets = document.styleSheets;
var ruletypes = {
1: 'Style Rule',
3: '@import rule',
3: '@import rule',
4: 'media rule',
5: '@font-face rule',
6: 'page rule',
@ -67,28 +67,28 @@
's-6': '@page :first'
}
var ruleOrder = [10, 3, 1, 1, 5, 4, 6];
var ruleOrder = [10, 3, 1, 1, 5, 4, 6];
var results = [];
for (i = 0; i < stylesheets.length; i++) {
for (i = 0; i < stylesheets.length; i++) {
if(i == 3) {
cssType = stylesheets[i].cssRules.length > 0 && stylesheets[i].cssRules[1] ? stylesheets[i].cssRules[1].type : 11;
cssType = stylesheets[i].cssRules.length > 0 && stylesheets[i].cssRules[1] ? stylesheets[i].cssRules[1].type : 11;
} else {
cssType = stylesheets[i].cssRules.length > 0 ? stylesheets[i].cssRules[0].type : 11;
cssType = stylesheets[i].cssRules.length > 0 ? stylesheets[i].cssRules[0].type : 11;
}
results.push([
ruletypes[ruleOrder[i]] + ' is expected to be ' + types['s-' + i],
ruletypes[cssType],
ruletypes[ruleOrder[i]]
]);
]);
}
generate_tests(assert_equals, results);
generate_tests(assert_equals, results);
</script>

View file

@ -41,8 +41,8 @@
test(function() {
assert_regexp_match(declaration.cssText, /margin-left: 5px;\s*/);
assert_equals(declaration.getPropertyValue("margin-left"), "5px");
}, "read", {
assert: "initial property values are correct"
}, "read", {
assert: "initial property values are correct"
});
test(function() {
@ -53,14 +53,14 @@
assert_equals(declaration.item(1), "padding-left");
assert_equals(declaration.getPropertyValue("margin-left"), "10px");
assert_equals(declaration.getPropertyValue("padding-left"), "10px");
var computedStyle = window.getComputedStyle(document.getElementById("test"));
assert_equals(computedStyle.getPropertyValue("margin-left"), "10px");
assert_equals(computedStyle.getPropertyValue("padding-left"), "10px");
}, "csstext_write", {
}, "csstext_write", {
assert: [ "setting cssText adds new properties",
"setting cssText removes existing properties",
"properties set through cssText are reflected in the computed style"]
"properties set through cssText are reflected in the computed style"]
});
test(function() {
@ -68,19 +68,19 @@
declaration.removeProperty(declaration.item(0));
declaration.setProperty("margin-left", "15px");
declaration.setProperty("padding-left", "15px");
assert_equals(declaration.length, 2);
assert_equals(declaration.item(0), "margin-left");
assert_equals(declaration.item(1), "padding-left");
assert_equals(declaration.getPropertyValue("margin-left"), "15px");
assert_equals(declaration.getPropertyValue("padding-left"), "15px");
var computedStyle = window.getComputedStyle(document.getElementById("test"));
assert_equals(computedStyle.getPropertyValue("margin-left"), "15px");
assert_equals(computedStyle.getPropertyValue("padding-left"), "15px");
}, "property_write", {
assert: [ "setProperty adds new properties",
"properties set through setProperty are reflected in the computed style"]
}, "property_write", {
assert: [ "setProperty adds new properties",
"properties set through setProperty are reflected in the computed style"]
});
test(function() {
@ -96,4 +96,5 @@
});
</script>
</body></html>

View file

@ -0,0 +1,163 @@
<!DOCTYPE html>
<html><head><meta charset="utf-8">
<title>CSSOM automated IDL tests</title>
<link href="mailto:Ms2ger@gmail.com" rel="author" title="Ms2ger">
<link href="https://drafts.csswg.org/cssom-1/#idl-index" rel="help">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="/resources/WebIDLParser.js"></script>
<script src="/resources/idlharness.js"></script>
<style id="styleElement">
#test { color: green; }
</style>
</head><body><div id="log"></div>
<script type="text/plain" id="untested_idl">
interface EventTarget {};
interface Node : EventTarget {};
interface Document : Node {};
interface ProcessingInstruction : Node {};
interface Element : Node {};
interface HTMLElement : Element {};
interface SVGElement : Element {};
[PrimaryGlobal] interface Window {};
</script>
<script type="text/plain" id="idl">
[ArrayClass]interface MediaList {
[TreatNullAs=EmptyString] stringifier attribute DOMString mediaText;
readonly attribute unsigned long length;
getter DOMString? item(unsigned long index);
void appendMedium(DOMString medium);
void deleteMedium(DOMString medium);
};
interface StyleSheet {
readonly attribute DOMString type;
readonly attribute DOMString? href;
readonly attribute (Element or ProcessingInstruction)? ownerNode;
readonly attribute StyleSheet? parentStyleSheet;
readonly attribute DOMString? title;
[SameObject, PutForwards=mediaText] readonly attribute MediaList media;
attribute boolean disabled;
};
interface CSSStyleSheet : StyleSheet {
readonly attribute CSSRule? ownerRule;
[SameObject] readonly attribute CSSRuleList cssRules;
unsigned long insertRule(DOMString rule, unsigned long index);
void deleteRule(unsigned long index);
};
[ArrayClass]interface StyleSheetList {
getter StyleSheet? item(unsigned long index);
readonly attribute unsigned long length;
};
partial interface Document { [SameObject] readonly attribute StyleSheetList styleSheets;
attribute DOMString? selectedStyleSheetSet;
readonly attribute DOMString? lastStyleSheetSet;
readonly attribute DOMString? preferredStyleSheetSet;
readonly attribute DOMString[] styleSheetSets;
void enableStyleSheetsForSet(DOMString? name);
};
[NoInterfaceObject]interface LinkStyle {
readonly attribute StyleSheet? sheet;
};
ProcessingInstruction implements LinkStyle;
[ArrayClass]interface CSSRuleList {
getter CSSRule? item(unsigned long index);
readonly attribute unsigned long length;
};
interface CSSRule { const unsigned short STYLE_RULE = 1;
const unsigned short CHARSET_RULE = 2; // historical
const unsigned short IMPORT_RULE = 3;
const unsigned short MEDIA_RULE = 4;
const unsigned short FONT_FACE_RULE = 5;
const unsigned short PAGE_RULE = 6;
const unsigned short MARGIN_RULE = 9;
const unsigned short NAMESPACE_RULE = 10;
readonly attribute unsigned short type;
attribute DOMString cssText;
readonly attribute CSSRule? parentRule;
readonly attribute CSSStyleSheet? parentStyleSheet;
};
interface CSSStyleRule : CSSRule { attribute DOMString selectorText;
[SameObject, PutForwards=cssText] readonly attribute CSSStyleDeclaration style;
};
interface CSSImportRule : CSSRule { readonly attribute DOMString href;
[SameObject, PutForwards=mediaText] readonly attribute MediaList media;
[SameObject] readonly attribute CSSStyleSheet styleSheet;
};
interface CSSGroupingRule : CSSRule { [SameObject] readonly attribute CSSRuleList cssRules;
unsigned long insertRule(DOMString rule, unsigned long index);
void deleteRule(unsigned long index);
};
interface CSSMediaRule : CSSGroupingRule { [SameObject, PutForwards=mediaText] readonly attribute MediaList media;
};
interface CSSPageRule : CSSGroupingRule { attribute DOMString selectorText;
[SameObject, PutForwards=cssText] readonly attribute CSSStyleDeclaration style;
};
interface CSSMarginRule : CSSRule { readonly attribute DOMString name;
[SameObject, PutForwards=cssText] readonly attribute CSSStyleDeclaration style;
};
interface CSSNamespaceRule : CSSRule { readonly attribute DOMString namespaceURI;
readonly attribute DOMString prefix;
};
interface CSSStyleDeclaration { attribute DOMString cssText;
readonly attribute unsigned long length;
getter DOMString item(unsigned long index);
DOMString getPropertyValue(DOMString property);
DOMString getPropertyPriority(DOMString property);
void setProperty(DOMString property, [TreatNullAs=EmptyString] DOMString value, [TreatNullAs=EmptyString] optional DOMString priority = "");
void setPropertyValue(DOMString property, [TreatNullAs=EmptyString] DOMString value);
void setPropertyPriority(DOMString property, [TreatNullAs=EmptyString] DOMString priority);
DOMString removeProperty(DOMString property);
readonly attribute CSSRule? parentRule;
[TreatNullAs=EmptyString] attribute DOMString cssFloat;
};
partial interface CSSStyleDeclaration { [TreatNullAs=EmptyString] attribute DOMString _camel_cased_attribute;
};
partial interface CSSStyleDeclaration { [TreatNullAs=EmptyString] attribute DOMString _dashed_attribute;
};
[NoInterfaceObject]interface ElementCSSInlineStyle {
[SameObject, PutForwards=cssText] readonly attribute CSSStyleDeclaration style;
};
HTMLElement implements ElementCSSInlineStyle;
SVGElement implements ElementCSSInlineStyle;
partial interface Window { [NewObject] CSSStyleDeclaration getComputedStyle(Element elt, optional DOMString? pseudoElt);
};
[NoInterfaceObject]interface GetStyleUtils {
[SameObject] readonly attribute CSSStyleDeclaration cascadedStyle;
[SameObject] readonly attribute CSSStyleDeclaration defaultStyle;
[SameObject] readonly attribute CSSStyleDeclaration rawComputedStyle;
[SameObject] readonly attribute CSSStyleDeclaration usedStyle;
};
partial interface Element { PseudoElement? pseudo(DOMString pseudoElt);
};
Element implements GetStyleUtils;
interface PseudoElement {
};
PseudoElement implements GetStyleUtils;
interface CSS { static DOMString escape(DOMString ident);
};
</script>
<script>
var idl_array, style_element;
setup(function() {
idl_array = new IdlArray();
var idls = document.getElementById("idl").textContent;
var untested_idls = document.getElementById("untested_idl").textContent;
idl_array.add_untested_idls(untested_idls);
idl_array.add_idls(idls);
style_element = document.getElementById('styleElement');
idl_array.add_objects({
"Document": ["document", "new Document()"],
"StyleSheetList": ["document.styleSheets"],
"CSSStyleSheet": ["style_element.sheet"],
"CSSRuleList": ["style_element.sheet.cssRules"],
"CSSStyleRule": ["style_element.sheet.cssRules[0]"],
});
});
idl_array.test();
</script>
</body></html>

View file

@ -37,15 +37,15 @@
<noscript>Test not run - javascript required.</noscript>
<div id="log"></div>
<script type="text/javascript">
var styleElement;
var styleSheet;
var mediaList;
// Setup
function setup() {
styleElement = document.getElementById("styleElement");
if (styleElement) {
// teardown
document.getElementsByTagName("head")[0].removeChild(styleElement);
@ -53,57 +53,58 @@
styleSheet = undefined;
mediaList = undefined;
}
styleElement = document.createElement("style");
styleElement.id = "styleElement";
styleElement.type = "text/css";
styleElement.media = "all";
document.getElementsByTagName("head")[0].appendChild(styleElement);
document.getElementsByTagName("head")[0].appendChild(styleElement);
styleSheet = styleElement.sheet;
mediaList = styleSheet.media;
}
test(function() {
setup();
assert_equals(mediaList.mediaText, "all");
assert_equals(mediaList.mediaText, "all");
}, "mediatest_medialist_serialize_element",
{ help: ["http://www.w3.org/TR/cssom/#the-medialist-interface", "http://www.w3.org/TR/cssom/#serializing-media-queries"],
assert: ["MediaList.mediaText equals the 'media' value of the initial 'style' element."] });
test(function() {
test(function() {
setup();
mediaList.appendMedium('screen');
assert_equals(mediaList.mediaText, "all, screen");
assert_equals(mediaList.mediaText, "all, screen");
}, "mediatest_medialist_serialize_comma",
{ help: ["http://www.w3.org/TR/cssom/#the-medialist-interface", "http://www.w3.org/TR/cssom/#serializing-media-queries"],
assert: ["To serialize a comma-separated list concatenate all items of the list in list order while separating them by \",\" (U+002C), followed by a space (U+0020)."] });
test(function() {
setup();
mediaList.deleteMedium('all');
assert_equals(mediaList.mediaText, "");
assert_equals(mediaList.mediaText, "");
}, "mediatest_medialist_serialize_empty",
{ help: ["http://www.w3.org/TR/cssom/#the-medialist-interface", "http://www.w3.org/TR/cssom/#serializing-media-queries"],
assert: ["If the media query list is empty return the empty string."] });
test(function() {
setup();
mediaList.appendMedium('screen');
mediaList.appendMedium('print');
assert_equals(mediaList.mediaText, "all, print, screen");
assert_equals(mediaList.mediaText, "all, print, screen");
}, "mediatest_medialist_serialize_lexicographical",
{ help: ["http://www.w3.org/TR/cssom/#the-medialist-interface", "http://www.w3.org/TR/cssom/#serializing-media-queries"],
assert: ["Each media query in the list of media queries should be sorted in lexicographical order."] });
</script>
</body></html>

View file

@ -23,15 +23,15 @@
<noscript>Test not run - javascript required.</noscript>
<div id="log"></div>
<script type="text/javascript">
var styleElement;
var styleSheet;
var mediaList;
// Setup - accepts media value for style element, e.g. <style media=???">
function setupMedia(media) {
styleElement = document.getElementById("styleElement");
if (styleElement) {
// teardown
document.getElementsByTagName("head")[0].removeChild(styleElement);
@ -39,33 +39,34 @@
styleSheet = undefined;
mediaList = undefined;
}
styleElement = document.createElement("style");
styleElement.id = "styleElement";
styleElement.type = "text/css";
styleElement.media = media;
document.getElementsByTagName("head")[0].appendChild(styleElement);
document.getElementsByTagName("head")[0].appendChild(styleElement);
styleSheet = styleElement.sheet;
mediaList = styleSheet.media;
}
test(function() {
setupMedia('not screen and (min-WIDTH:5px) AND (max-width:40px )');
assert_equals(mediaList.mediaText, "not screen and (max-width: 40px) and (min-width: 5px)");
assert_equals(mediaList.mediaText, "not screen and (max-width: 40px) and (min-width: 5px)");
}, "mediatest_mediaquery_serialize_1",
{ assert: ["First explicit example input (first column) and output (second column) in specification."] });
test(function() {
setupMedia('all and (color) and (color) ');
assert_equals(mediaList.mediaText, "(color)");
assert_equals(mediaList.mediaText, "(color)");
}, "mediatest_mediaquery_serialize_2",
{ assert: ["Second explicit example input (first column) and output (second column) in specification."] });
{ assert: ["Second explicit example input (first column) and output (second column) in specification."] });
</script>
</body></html>

View file

@ -65,7 +65,7 @@
assert_own_property(styleSheet, "cssRules");
assert_inherits(styleSheet, "insertRule");
assert_inherits(styleSheet, "deleteRule");
assert_readonly(styleSheet, "ownerRule");
assert_readonly(styleSheet, "cssRules");
}, "CSSStyleSheet_properties",
@ -113,7 +113,7 @@
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);
@ -124,4 +124,5 @@
{ assert: "StyleSheet initial property values are correct" });
</script>
</body></html>

View file

@ -36,7 +36,7 @@
assert: [ "Initial rule list is of size 1",
"Can add a rule at first index" ]
});
test(function() {
sheet.deleteRule(0);
assert_equals(sheet.cssRules.length, 1);