mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
226 lines
8.4 KiB
HTML
226 lines
8.4 KiB
HTML
<!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>
|
|
<p id="display"><span id="fparent"><span id="fchild"></span></span></p>
|
|
<div id="content" style="display: none">
|
|
|
|
<div id="testnode"><span id="nparent"><span id="nchild"></span></span></div>
|
|
|
|
</div>
|
|
<pre id="test">
|
|
<script class="testbody" type="text/javascript">
|
|
|
|
/** Test for computation of CSS 'inherit' **/
|
|
|
|
var gNoComputedStyle = {
|
|
"-moz-force-broken-image-icon": true,
|
|
"-moz-margin-end": true,
|
|
"-moz-margin-start": true,
|
|
"-moz-padding-end": true,
|
|
"-moz-padding-start": true,
|
|
"background-position": true,
|
|
"content": true,
|
|
"page-break-after": true,
|
|
"page-break-before": true,
|
|
"quotes": true,
|
|
"clip-path": true,
|
|
"clip-rule": true,
|
|
"color-interpolation": true,
|
|
"color-interpolation-filters": true,
|
|
"dominant-baseline": true,
|
|
"fill": true,
|
|
"fill-opacity": true,
|
|
"fill-rule": true,
|
|
"filter": true,
|
|
"flood-color": true,
|
|
"flood-opacity": true,
|
|
"marker": true, // NB: shorthand
|
|
"marker-end": true,
|
|
"marker-mid": true,
|
|
"marker-start": true,
|
|
"mask": true,
|
|
"pointer-events": true,
|
|
"shape-rendering": true,
|
|
"stop-color": true,
|
|
"stop-opacity": true,
|
|
"stroke": true,
|
|
"stroke-dasharray": true,
|
|
"stroke-dashoffset": true,
|
|
"stroke-linecap": true,
|
|
"stroke-linejoin": true,
|
|
"stroke-miterlimit": true,
|
|
"stroke-opacity": true,
|
|
"stroke-width": true,
|
|
"text-anchor": true,
|
|
"text-rendering": true,
|
|
};
|
|
|
|
function xfail_diffcomputed(property) {
|
|
return property in gNoComputedStyle;
|
|
}
|
|
|
|
var gBrokenInherit = {
|
|
// Not implemented in nsRuleNode
|
|
"-moz-border-bottom-colors": true,
|
|
"-moz-border-left-colors": true,
|
|
"-moz-border-right-colors": true,
|
|
"-moz-border-top-colors": true,
|
|
};
|
|
|
|
function xfail_inherit(property, matching_initial) {
|
|
return property in gBrokenInherit;
|
|
}
|
|
|
|
// 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");
|
|
|
|
var gStyleSheet = document.getElementById("stylesheet").sheet;
|
|
var gChildRule1 = gStyleSheet.cssRules[gStyleSheet.insertRule("#nchild, #fchild {}", gStyleSheet.cssRules.length)];
|
|
var gChildRule2 = gStyleSheet.cssRules[gStyleSheet.insertRule("#nchild, #fchild {}", gStyleSheet.cssRules.length)];
|
|
var gChildRuleTop = gStyleSheet.cssRules[gStyleSheet.insertRule("#nchild, #fchild {}", gStyleSheet.cssRules.length)];
|
|
var gParentRuleTop = gStyleSheet.cssRules[gStyleSheet.insertRule("#nparent, #fparent {}", gStyleSheet.cssRules.length)];
|
|
|
|
// Get the computed value for a property. For shorthands, return the
|
|
// computed values of all the subproperties, delimited by " ; ".
|
|
function get_computed_value(node, property)
|
|
{
|
|
var info = gCSSProperties[property];
|
|
var cs = getComputedStyle(node, "");
|
|
if (!("subproperties" in info)) {
|
|
return cs.getPropertyValue(property);
|
|
}
|
|
var results = [];
|
|
for (var idx in info.subproperties) {
|
|
var subprop = info.subproperties[idx];
|
|
results.push(cs.getPropertyValue(subprop));
|
|
}
|
|
return results.join(" ; ");
|
|
}
|
|
|
|
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) {
|
|
gParentRuleTop.style.setProperty(prereq, prereqs[prereq], "");
|
|
gChildRuleTop.style.setProperty(prereq, prereqs[prereq], "");
|
|
}
|
|
}
|
|
|
|
if (info.inherited) {
|
|
gParentRuleTop.style.setProperty(property, info.initial_values[0], "");
|
|
var initial_computed_n = get_computed_value(gNChild, property);
|
|
var initial_computed_f = get_computed_value(gFChild, property);
|
|
gChildRule1.style.setProperty(property, info.other_values[0], "");
|
|
var other_computed_n = get_computed_value(gNChild, property);
|
|
var other_computed_f = get_computed_value(gFChild, property);
|
|
(xfail_diffcomputed(property) ? todo_isnot : isnot)(
|
|
other_computed_n, initial_computed_n,
|
|
"should be testing with values that compute to different things " +
|
|
"for '" + property + "'");
|
|
(xfail_diffcomputed(property) ? todo_isnot : isnot)(
|
|
other_computed_f, initial_computed_f,
|
|
"should be testing with values that compute to different things " +
|
|
"for '" + property + "'");
|
|
gChildRule2.style.setProperty(property, "inherit", "");
|
|
var inherit_initial_computed_n = get_computed_value(gNChild, property);
|
|
var inherit_initial_computed_f = get_computed_value(gFChild, property);
|
|
(xfail_inherit(property, true) ? todo_is : is)(
|
|
inherit_initial_computed_n, initial_computed_n,
|
|
"inherit should cause inheritance of initial value for '" +
|
|
property + "'");
|
|
(xfail_inherit(property, true) ? todo_is : is)(
|
|
inherit_initial_computed_f, initial_computed_f,
|
|
"inherit should cause inheritance of initial value for '" +
|
|
property + "'");
|
|
gParentRuleTop.style.setProperty(property, info.other_values[0], "");
|
|
var inherit_other_computed_n = get_computed_value(gNChild, property);
|
|
var inherit_other_computed_f = get_computed_value(gFChild, property);
|
|
(xfail_inherit(property, false) ? todo_is : is)(
|
|
inherit_other_computed_n, other_computed_n,
|
|
"inherit should cause inheritance of other value for '" +
|
|
property + "'");
|
|
(xfail_inherit(property, false) ? todo_is : is)(
|
|
inherit_other_computed_f, other_computed_f,
|
|
"inherit should cause inheritance of other value for '" +
|
|
property + "'");
|
|
gParentRuleTop.style.removeProperty(property);
|
|
gChildRule1.style.removeProperty(property);
|
|
gChildRule2.style.removeProperty(property);
|
|
} else {
|
|
gParentRuleTop.style.setProperty(property, info.other_values[0], "");
|
|
var initial_computed_n = get_computed_value(gNChild, property);
|
|
var initial_computed_f = get_computed_value(gFChild, property);
|
|
var other_computed_n = get_computed_value(gNParent, property);
|
|
var other_computed_f = get_computed_value(gFParent, property);
|
|
(xfail_diffcomputed(property) ? todo_isnot : isnot)(
|
|
other_computed_n, initial_computed_n,
|
|
"should be testing with values that compute to different things " +
|
|
"for '" + property + "'");
|
|
(xfail_diffcomputed(property) ? todo_isnot : isnot)(
|
|
other_computed_f, initial_computed_f,
|
|
"should be testing with values that compute to different things " +
|
|
"for '" + property + "'");
|
|
gChildRule2.style.setProperty(property, "inherit", "");
|
|
var inherit_other_computed_n = get_computed_value(gNChild, property);
|
|
var inherit_other_computed_f = get_computed_value(gFChild, property);
|
|
(xfail_inherit(property, false) ? todo_is : is)(
|
|
inherit_other_computed_n, other_computed_n,
|
|
"inherit should cause inheritance of other value for '" +
|
|
property + "'");
|
|
(xfail_inherit(property, false) ? todo_is : is)(
|
|
inherit_other_computed_f, other_computed_f,
|
|
"inherit should cause inheritance of other value for '" +
|
|
property + "'");
|
|
gParentRuleTop.style.removeProperty(property);
|
|
gChildRule1.style.setProperty(property, info.other_values[0], "");
|
|
var inherit_initial_computed_n = get_computed_value(gNChild, property);
|
|
var inherit_initial_computed_f = get_computed_value(gFChild, property);
|
|
(xfail_inherit(property, true) ? todo_is : is)(
|
|
inherit_initial_computed_n, initial_computed_n,
|
|
"inherit should cause inheritance of initial value for '" +
|
|
property + "'");
|
|
(xfail_inherit(property, true) ? todo_is : is)(
|
|
inherit_initial_computed_f, initial_computed_f,
|
|
"inherit should cause inheritance of initial value for '" +
|
|
property + "'");
|
|
gParentRuleTop.style.removeProperty(property);
|
|
gChildRule1.style.removeProperty(property);
|
|
gChildRule2.style.removeProperty(property);
|
|
}
|
|
|
|
if ("prerequisites" in info) {
|
|
var prereqs = info.prerequisites;
|
|
for (var prereq in prereqs) {
|
|
gParentRuleTop.style.removeProperty(prereq);
|
|
gChildRuleTop.style.removeProperty(prereq);
|
|
}
|
|
}
|
|
}
|
|
|
|
for (var prop in gCSSProperties)
|
|
test_property(prop);
|
|
|
|
</script>
|
|
</pre>
|
|
</body>
|
|
</html>
|