2007-04-19 06:49:44 +04:00
|
|
|
<!DOCTYPE HTML>
|
|
|
|
<html>
|
|
|
|
<!--
|
|
|
|
-->
|
|
|
|
<head>
|
|
|
|
<title>Test for computation 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="property_database.js"></script>
|
|
|
|
<style type="text/css" id="stylesheet"></style>
|
|
|
|
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
|
|
|
|
</head>
|
|
|
|
<body>
|
2007-04-26 03:27:36 +04:00
|
|
|
<p id="display"><span id="fparent"><span id="fchild"></span></span></p>
|
2007-04-19 06:49:44 +04:00
|
|
|
<div id="content" style="display: none">
|
|
|
|
|
2007-04-26 03:27:36 +04:00
|
|
|
<div id="testnode"><span id="nparent"><span id="nchild"></span></span></div>
|
2007-04-19 06:49:44 +04:00
|
|
|
|
|
|
|
</div>
|
|
|
|
<pre id="test">
|
|
|
|
<script class="testbody" type="text/javascript">
|
|
|
|
|
|
|
|
/** Test for computation of CSS 'inherit' **/
|
|
|
|
|
2007-04-26 03:27:36 +04:00
|
|
|
// elements without a frame
|
|
|
|
var gNParent = document.getElementById("nparent");
|
|
|
|
var gNChild = document.getElementById("nchild");
|
|
|
|
// elements with a frame
|
|
|
|
var gFParent = document.getElementById("fparent");
|
|
|
|
var gFChild = document.getElementById("fchild");
|
|
|
|
|
2007-04-19 06:49:44 +04:00
|
|
|
var gStyleSheet = document.getElementById("stylesheet").sheet;
|
2007-04-26 03:27:36 +04:00
|
|
|
var gChildRule1 = gStyleSheet.cssRules[gStyleSheet.insertRule("#nchild, #fchild {}", gStyleSheet.cssRules.length)];
|
|
|
|
var gChildRule2 = gStyleSheet.cssRules[gStyleSheet.insertRule("#nchild, #fchild {}", gStyleSheet.cssRules.length)];
|
2007-07-12 02:23:03 +04:00
|
|
|
var gChildRule3 = gStyleSheet.cssRules[gStyleSheet.insertRule("#nchild.allother, #fchild.allother {}", gStyleSheet.cssRules.length)];
|
|
|
|
var gChildRuleTop = gStyleSheet.cssRules[gStyleSheet.insertRule("#nchild, #nchild.allother, #fchild, #fchild.allother {}", gStyleSheet.cssRules.length)];
|
2007-04-26 03:27:36 +04:00
|
|
|
var gParentRuleTop = gStyleSheet.cssRules[gStyleSheet.insertRule("#nparent, #fparent {}", gStyleSheet.cssRules.length)];
|
2007-04-19 06:49:44 +04:00
|
|
|
|
2007-07-22 23:56:13 +04:00
|
|
|
function get_computed_value_node(node, property)
|
2007-04-19 06:49:44 +04:00
|
|
|
{
|
|
|
|
var cs = getComputedStyle(node, "");
|
2007-07-22 23:56:13 +04:00
|
|
|
return get_computed_value(cs, property);
|
2007-04-19 06:49:44 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
function test_property(property)
|
|
|
|
{
|
|
|
|
var info = gCSSProperties[property];
|
|
|
|
if (info.backend_only)
|
|
|
|
return;
|
|
|
|
|
|
|
|
if ("prerequisites" in info) {
|
|
|
|
var prereqs = info.prerequisites;
|
|
|
|
for (var prereq in prereqs) {
|
2007-04-26 03:27:36 +04:00
|
|
|
gParentRuleTop.style.setProperty(prereq, prereqs[prereq], "");
|
|
|
|
gChildRuleTop.style.setProperty(prereq, prereqs[prereq], "");
|
2007-04-19 06:49:44 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (info.inherited) {
|
2007-04-26 03:27:36 +04:00
|
|
|
gParentRuleTop.style.setProperty(property, info.initial_values[0], "");
|
2007-07-22 23:56:13 +04:00
|
|
|
var initial_computed_n = get_computed_value_node(gNChild, property);
|
|
|
|
var initial_computed_f = get_computed_value_node(gFChild, property);
|
2007-04-19 06:49:44 +04:00
|
|
|
gChildRule1.style.setProperty(property, info.other_values[0], "");
|
2007-07-22 23:56:13 +04:00
|
|
|
var other_computed_n = get_computed_value_node(gNChild, property);
|
|
|
|
var other_computed_f = get_computed_value_node(gFChild, property);
|
2007-07-22 23:57:15 +04:00
|
|
|
isnot(other_computed_n, initial_computed_n,
|
2007-04-26 03:27:36 +04:00
|
|
|
"should be testing with values that compute to different things " +
|
|
|
|
"for '" + property + "'");
|
2007-07-22 23:57:15 +04:00
|
|
|
isnot(other_computed_f, initial_computed_f,
|
2007-04-19 06:49:44 +04:00
|
|
|
"should be testing with values that compute to different things " +
|
|
|
|
"for '" + property + "'");
|
2007-07-12 02:23:03 +04:00
|
|
|
gChildRule3.style.setProperty(property, "inherit", "");
|
|
|
|
gFChild.className="allother";
|
|
|
|
gNChild.className="allother";
|
2007-07-22 23:56:13 +04:00
|
|
|
var inherit_initial_computed_n = get_computed_value_node(gNChild, property);
|
|
|
|
var inherit_initial_computed_f = get_computed_value_node(gFChild, property);
|
2008-12-23 17:06:56 +03:00
|
|
|
is(inherit_initial_computed_n, initial_computed_n,
|
2007-04-26 03:27:36 +04:00
|
|
|
"inherit should cause inheritance of initial value for '" +
|
|
|
|
property + "'");
|
2008-12-23 17:06:56 +03:00
|
|
|
is(inherit_initial_computed_f, initial_computed_f,
|
2007-04-19 06:49:44 +04:00
|
|
|
"inherit should cause inheritance of initial value for '" +
|
|
|
|
property + "'");
|
2007-04-26 03:27:36 +04:00
|
|
|
gParentRuleTop.style.setProperty(property, info.other_values[0], "");
|
2007-07-22 23:56:13 +04:00
|
|
|
var inherit_other_computed_n = get_computed_value_node(gNChild, property);
|
|
|
|
var inherit_other_computed_f = get_computed_value_node(gFChild, property);
|
2008-12-23 17:06:56 +03:00
|
|
|
is(inherit_other_computed_n, other_computed_n,
|
2007-04-26 03:27:36 +04:00
|
|
|
"inherit should cause inheritance of other value for '" +
|
|
|
|
property + "'");
|
2008-12-23 17:06:56 +03:00
|
|
|
is(inherit_other_computed_f, other_computed_f,
|
2007-04-19 06:49:44 +04:00
|
|
|
"inherit should cause inheritance of other value for '" +
|
|
|
|
property + "'");
|
2007-04-26 03:27:36 +04:00
|
|
|
gParentRuleTop.style.removeProperty(property);
|
2007-04-19 06:49:44 +04:00
|
|
|
gChildRule1.style.removeProperty(property);
|
2007-07-12 02:23:03 +04:00
|
|
|
gChildRule3.style.setProperty(property, info.other_values[0], "");
|
|
|
|
gFChild.className="";
|
|
|
|
gNChild.className="";
|
2007-04-19 06:49:44 +04:00
|
|
|
} else {
|
2007-04-26 03:27:36 +04:00
|
|
|
gParentRuleTop.style.setProperty(property, info.other_values[0], "");
|
2007-07-22 23:56:13 +04:00
|
|
|
var initial_computed_n = get_computed_value_node(gNChild, property);
|
|
|
|
var initial_computed_f = get_computed_value_node(gFChild, property);
|
|
|
|
var other_computed_n = get_computed_value_node(gNParent, property);
|
|
|
|
var other_computed_f = get_computed_value_node(gFParent, property);
|
2007-07-22 23:57:15 +04:00
|
|
|
isnot(other_computed_n, initial_computed_n,
|
2007-04-26 03:27:36 +04:00
|
|
|
"should be testing with values that compute to different things " +
|
|
|
|
"for '" + property + "'");
|
2007-07-22 23:57:15 +04:00
|
|
|
isnot(other_computed_f, initial_computed_f,
|
2007-04-19 06:49:44 +04:00
|
|
|
"should be testing with values that compute to different things " +
|
|
|
|
"for '" + property + "'");
|
|
|
|
gChildRule2.style.setProperty(property, "inherit", "");
|
2007-07-22 23:56:13 +04:00
|
|
|
var inherit_other_computed_n = get_computed_value_node(gNChild, property);
|
|
|
|
var inherit_other_computed_f = get_computed_value_node(gFChild, property);
|
2008-12-23 17:06:56 +03:00
|
|
|
is(inherit_other_computed_n, other_computed_n,
|
2007-04-19 06:49:44 +04:00
|
|
|
"inherit should cause inheritance of other value for '" +
|
|
|
|
property + "'");
|
2008-12-23 17:06:56 +03:00
|
|
|
is(inherit_other_computed_f, other_computed_f,
|
2007-04-26 03:27:36 +04:00
|
|
|
"inherit should cause inheritance of other value for '" +
|
|
|
|
property + "'");
|
|
|
|
gParentRuleTop.style.removeProperty(property);
|
2007-04-19 06:49:44 +04:00
|
|
|
gChildRule1.style.setProperty(property, info.other_values[0], "");
|
2007-07-22 23:56:13 +04:00
|
|
|
var inherit_initial_computed_n = get_computed_value_node(gNChild, property);
|
|
|
|
var inherit_initial_computed_f = get_computed_value_node(gFChild, property);
|
2008-12-23 17:06:56 +03:00
|
|
|
is(inherit_initial_computed_n, initial_computed_n,
|
2007-04-26 03:27:36 +04:00
|
|
|
"inherit should cause inheritance of initial value for '" +
|
|
|
|
property + "'");
|
2008-12-23 17:06:56 +03:00
|
|
|
is(inherit_initial_computed_f, initial_computed_f,
|
2007-04-19 06:49:44 +04:00
|
|
|
"inherit should cause inheritance of initial value for '" +
|
|
|
|
property + "'");
|
2007-04-26 03:27:36 +04:00
|
|
|
gParentRuleTop.style.removeProperty(property);
|
2007-04-19 06:49:44 +04:00
|
|
|
gChildRule1.style.removeProperty(property);
|
|
|
|
gChildRule2.style.removeProperty(property);
|
|
|
|
}
|
|
|
|
|
|
|
|
if ("prerequisites" in info) {
|
|
|
|
var prereqs = info.prerequisites;
|
|
|
|
for (var prereq in prereqs) {
|
2007-04-26 03:27:36 +04:00
|
|
|
gParentRuleTop.style.removeProperty(prereq);
|
|
|
|
gChildRuleTop.style.removeProperty(prereq);
|
2007-04-19 06:49:44 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2007-07-12 02:23:03 +04:00
|
|
|
for (var prop in gCSSProperties) {
|
|
|
|
var info = gCSSProperties[prop];
|
|
|
|
gChildRule3.style.setProperty(prop, info.other_values[0], "");
|
|
|
|
}
|
|
|
|
|
2007-04-19 06:49:44 +04:00
|
|
|
for (var prop in gCSSProperties)
|
|
|
|
test_property(prop);
|
|
|
|
|
|
|
|
</script>
|
|
|
|
</pre>
|
|
|
|
</body>
|
|
|
|
</html>
|