mirror of
https://github.com/mozilla/gecko-dev.git
synced 2025-01-24 13:52:37 +00:00
Test for inherit and initial on shorthand properties as well. b=258080
This commit is contained in:
parent
bda8a4f932
commit
5138fbff1b
@ -7,7 +7,7 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=375363
|
||||
<title>Test for parsing, storage, and serialization of CSS 'inherit'</title>
|
||||
<script type="text/javascript" src="/MochiKit/MochiKit.js"></script>
|
||||
<script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
|
||||
<script type="text/javascript" src="css_properties.js"></script>
|
||||
<script type="text/javascript" src="property_database.js"></script>
|
||||
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
|
||||
</head>
|
||||
<body>
|
||||
@ -25,41 +25,87 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=375363
|
||||
|
||||
var gDeclaration = document.getElementById("testnode").style;
|
||||
|
||||
var gKnownFails = {
|
||||
/* bug 377519: */
|
||||
"-moz-border-radius": true,
|
||||
"-moz-outline-radius": true,
|
||||
"background": true,
|
||||
"border": true,
|
||||
"border-bottom": true,
|
||||
"border-color": true,
|
||||
"border-left": true,
|
||||
"border-right": true,
|
||||
"border-style": true,
|
||||
"border-top": true,
|
||||
"border-width": true,
|
||||
"cue": true,
|
||||
"font": true,
|
||||
"list-style": true,
|
||||
"margin": true,
|
||||
"outline": true,
|
||||
"padding": true,
|
||||
"pause": true
|
||||
};
|
||||
|
||||
function test_property(property)
|
||||
{
|
||||
var pass = true;
|
||||
var match = true;
|
||||
|
||||
var val = gDeclaration.getPropertyValue(property.name);
|
||||
pass = pass && val == "";
|
||||
if (property.prop)
|
||||
match = match && gDeclaration[property.prop] == val;
|
||||
var info = gCSSProperties[property];
|
||||
|
||||
gDeclaration.setProperty(property.name, "inherit", "");
|
||||
|
||||
val = gDeclaration.getPropertyValue(property.name);
|
||||
pass = pass && val == "inherit";
|
||||
if (property.prop)
|
||||
match = match && gDeclaration[property.prop] == val;
|
||||
|
||||
gDeclaration.removeProperty(property.name);
|
||||
|
||||
val = gDeclaration.getPropertyValue(property.name);
|
||||
pass = pass && val == "";
|
||||
if (property.prop)
|
||||
match = match && gDeclaration[property.prop] == val;
|
||||
|
||||
ok(pass && match, "inherit parsed, stored, and serialized for CSS '" + property.name + "'");
|
||||
if (!match) {
|
||||
/* already included in above ok, but exceptional in itself */
|
||||
ok(match, "getPropertyValue matches nsICSSProperties for CSS '" + property.name + "'");
|
||||
function check_initial(sproperty) {
|
||||
var sinfo = gCSSProperties[sproperty];
|
||||
var val = gDeclaration.getPropertyValue(sproperty);
|
||||
is(val, "", "value of '" + sproperty + "' before we do anything");
|
||||
if (sinfo.domProp) {
|
||||
is(val, gDeclaration[sinfo.domProp],
|
||||
"consistency between decl.getPropertyValue('" + sproperty + "') and decl." + sinfo.domProp);
|
||||
}
|
||||
}
|
||||
check_initial(property);
|
||||
if ("subproperties" in info)
|
||||
for (var idx in info.subproperties)
|
||||
check_initial(info.subproperties[idx]);
|
||||
|
||||
gDeclaration.setProperty(property, "inherit", "");
|
||||
|
||||
function check_set(sproperty) {
|
||||
var sinfo = gCSSProperties[sproperty];
|
||||
val = gDeclaration.getPropertyValue(sproperty);
|
||||
if (sproperty == property && property in gKnownFails) {
|
||||
todo(val == "inherit", "inherit reported back for property '" + sproperty + "'");
|
||||
} else {
|
||||
is(val, "inherit", "inherit reported back for property '" + sproperty + "'");
|
||||
}
|
||||
if (sinfo.domProp) {
|
||||
is(val, gDeclaration[sinfo.domProp],
|
||||
"consistency between decl.getPropertyValue('" + sproperty + "') and decl." + sinfo.domProp);
|
||||
}
|
||||
}
|
||||
check_set(property);
|
||||
if ("subproperties" in info)
|
||||
for (var idx in info.subproperties)
|
||||
check_set(info.subproperties[idx]);
|
||||
|
||||
gDeclaration.removeProperty(property);
|
||||
|
||||
function check_final(sproperty) {
|
||||
var sinfo = gCSSProperties[sproperty];
|
||||
var val = gDeclaration.getPropertyValue(sproperty);
|
||||
is(val, "", "value of '" + sproperty + "' after removal of value");
|
||||
if (sinfo.domProp) {
|
||||
is(val, gDeclaration[sinfo.domProp],
|
||||
"consistency between decl.getPropertyValue('" + sproperty + "') and decl." + sinfo.domProp);
|
||||
}
|
||||
}
|
||||
check_final(property);
|
||||
if ("subproperties" in info)
|
||||
for (var idx in info.subproperties)
|
||||
check_final(info.subproperties[idx]);
|
||||
}
|
||||
|
||||
for (var idx in gLonghandProperties)
|
||||
test_property(gLonghandProperties[idx]);
|
||||
for (var idx in gShorthandPropertiesLikeLonghand)
|
||||
test_property(gShorthandPropertiesLikeLonghand[idx]);
|
||||
for (var prop in gCSSProperties)
|
||||
test_property(prop);
|
||||
|
||||
</script>
|
||||
</pre>
|
||||
|
@ -7,7 +7,7 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=375363
|
||||
<title>Test for parsing, storage, and serialization of CSS '-moz-initial'</title>
|
||||
<script type="text/javascript" src="/MochiKit/MochiKit.js"></script>
|
||||
<script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
|
||||
<script type="text/javascript" src="css_properties.js"></script>
|
||||
<script type="text/javascript" src="property_database.js"></script>
|
||||
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
|
||||
</head>
|
||||
<body>
|
||||
@ -25,41 +25,89 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=375363
|
||||
|
||||
var gDeclaration = document.getElementById("testnode").style;
|
||||
|
||||
var gKnownFails = {
|
||||
/* bug 377519: */
|
||||
"-moz-border-radius": true,
|
||||
"-moz-outline-radius": true,
|
||||
"background": true,
|
||||
"border": true,
|
||||
"border-bottom": true,
|
||||
"border-color": true,
|
||||
"border-left": true,
|
||||
"border-right": true,
|
||||
"border-style": true,
|
||||
"border-top": true,
|
||||
"border-width": true,
|
||||
"cue": true,
|
||||
"font": true,
|
||||
"list-style": true,
|
||||
"margin": true,
|
||||
"outline": true,
|
||||
"padding": true,
|
||||
"pause": true
|
||||
/* also see bug 377521 below */
|
||||
};
|
||||
|
||||
function test_property(property)
|
||||
{
|
||||
var pass = true;
|
||||
var match = true;
|
||||
|
||||
var val = gDeclaration.getPropertyValue(property.name);
|
||||
pass = pass && val == "";
|
||||
if (property.prop)
|
||||
match = match && gDeclaration[property.prop] == val;
|
||||
var info = gCSSProperties[property];
|
||||
|
||||
gDeclaration.setProperty(property.name, "-moz-initial", "");
|
||||
|
||||
val = gDeclaration.getPropertyValue(property.name);
|
||||
pass = pass && val == "-moz-initial";
|
||||
if (property.prop)
|
||||
match = match && gDeclaration[property.prop] == val;
|
||||
|
||||
gDeclaration.removeProperty(property.name);
|
||||
|
||||
val = gDeclaration.getPropertyValue(property.name);
|
||||
pass = pass && val == "";
|
||||
if (property.prop)
|
||||
match = match && gDeclaration[property.prop] == val;
|
||||
|
||||
ok(pass && match, "-moz-initial parsed, stored, and serialized for CSS '" + property.name + "'");
|
||||
if (!match) {
|
||||
/* already included in above ok, but exceptional in itself */
|
||||
ok(match, "getPropertyValue matches nsICSSProperties for CSS '" + property.name + "'");
|
||||
function check_initial(sproperty) {
|
||||
var sinfo = gCSSProperties[sproperty];
|
||||
var val = gDeclaration.getPropertyValue(sproperty);
|
||||
is(val, "", "value of '" + sproperty + "' before we do anything");
|
||||
if (sinfo.domProp) {
|
||||
is(val, gDeclaration[sinfo.domProp],
|
||||
"consistency between decl.getPropertyValue('" + sproperty + "') and decl." + sinfo.domProp);
|
||||
}
|
||||
}
|
||||
check_initial(property);
|
||||
if ("subproperties" in info)
|
||||
for (var idx in info.subproperties)
|
||||
check_initial(info.subproperties[idx]);
|
||||
|
||||
gDeclaration.setProperty(property, "-moz-initial", "");
|
||||
|
||||
function check_set(sproperty) {
|
||||
var sinfo = gCSSProperties[sproperty];
|
||||
val = gDeclaration.getPropertyValue(sproperty);
|
||||
if ((sproperty == property && property in gKnownFails) ||
|
||||
(property == "font" && sproperty != "font-family")) { /* bug 377521 */
|
||||
todo(val == "-moz-initial", "-moz-initial reported back for property '" + sproperty + "'");
|
||||
} else {
|
||||
is(val, "-moz-initial", "-moz-initial reported back for property '" + sproperty + "'");
|
||||
}
|
||||
if (sinfo.domProp) {
|
||||
is(val, gDeclaration[sinfo.domProp],
|
||||
"consistency between decl.getPropertyValue('" + sproperty + "') and decl." + sinfo.domProp);
|
||||
}
|
||||
}
|
||||
check_set(property);
|
||||
if ("subproperties" in info)
|
||||
for (var idx in info.subproperties)
|
||||
check_set(info.subproperties[idx]);
|
||||
|
||||
gDeclaration.removeProperty(property);
|
||||
|
||||
function check_final(sproperty) {
|
||||
var sinfo = gCSSProperties[sproperty];
|
||||
var val = gDeclaration.getPropertyValue(sproperty);
|
||||
is(val, "", "value of '" + sproperty + "' after removal of value");
|
||||
if (sinfo.domProp) {
|
||||
is(val, gDeclaration[sinfo.domProp],
|
||||
"consistency between decl.getPropertyValue('" + sproperty + "') and decl." + sinfo.domProp);
|
||||
}
|
||||
}
|
||||
check_final(property);
|
||||
if ("subproperties" in info)
|
||||
for (var idx in info.subproperties)
|
||||
check_final(info.subproperties[idx]);
|
||||
}
|
||||
|
||||
for (var idx in gLonghandProperties)
|
||||
test_property(gLonghandProperties[idx]);
|
||||
for (var idx in gShorthandPropertiesLikeLonghand)
|
||||
test_property(gShorthandPropertiesLikeLonghand[idx]);
|
||||
for (var prop in gCSSProperties)
|
||||
test_property(prop);
|
||||
|
||||
</script>
|
||||
</pre>
|
||||
|
@ -55,6 +55,38 @@ for (var idx in gShorthandPropertiesLikeLonghand) {
|
||||
"'" + prop.name + "' listed in gCSSProperties as CSS_TYPE_SHORTHAND_AND_LONGHAND with correct DOM property name");
|
||||
}
|
||||
|
||||
/*
|
||||
* Test that all shorthand properties have a subproperty list and all
|
||||
* longhand properties do not.
|
||||
*/
|
||||
for (var prop in gCSSProperties) {
|
||||
var info = gCSSProperties[prop];
|
||||
if (info.type == CSS_TYPE_LONGHAND) {
|
||||
ok(!("subproperties" in info),
|
||||
"longhand property '" + prop + "' must not have subproperty list");
|
||||
} else if (info.type == CSS_TYPE_TRUE_SHORTHAND) {
|
||||
ok("subproperties" in info,
|
||||
"shorthand property '" + prop + "' must have subproperty list");
|
||||
}
|
||||
/* optional for CSS_TYPE_SHORTHAND_AND_LONGHAND */
|
||||
|
||||
if ("subproperties" in info) {
|
||||
var good = true;
|
||||
if (info.subproperties.length < 1) {
|
||||
info("subproperty list for '" + prop + "' is empty");
|
||||
good = false;
|
||||
}
|
||||
for (var idx in info.subproperties) {
|
||||
var subprop = info.subproperties[idx];
|
||||
if (!(subprop in gCSSProperties)) {
|
||||
info("subproperty list for '" + prop + "' lists nonexistent subproperty '" + subprop + "'");
|
||||
good = false;
|
||||
}
|
||||
}
|
||||
ok(good, "property '" + prop + "' has a good subproperty list");
|
||||
}
|
||||
}
|
||||
|
||||
</script>
|
||||
</pre>
|
||||
</body>
|
||||
|
Loading…
x
Reference in New Issue
Block a user