6 <title>Test for computation of CSS 'inherit'
</title>
7 <script type=
"text/javascript" src=
"/MochiKit/MochiKit.js"></script>
8 <script type=
"text/javascript" src=
"/tests/SimpleTest/SimpleTest.js"></script>
9 <script type=
"text/javascript" src=
"property_database.js"></script>
10 <style type=
"text/css" id=
"stylesheet"></style>
11 <link rel=
"stylesheet" type=
"text/css" href=
"/tests/SimpleTest/test.css" />
14 <p id=
"display"><span id=
"fparent"><span id=
"fchild"></span></span></p>
15 <div id=
"content" style=
"display: none">
17 <div id=
"testnode"><span id=
"nparent"><span id=
"nchild"></span></span></div>
21 <script class=
"testbody" type=
"text/javascript">
23 /** Test for computation of CSS 'inherit' **/
25 var gBrokenInherit = {
26 // Not implemented in nsRuleNode
27 "-moz-border-bottom-colors": true,
28 "-moz-border-left-colors": true,
29 "-moz-border-right-colors": true,
30 "-moz-border-top-colors": true,
33 function xfail_inherit(property, matching_initial) {
34 return property in gBrokenInherit;
37 // elements without a frame
38 var gNParent = document.getElementById(
"nparent");
39 var gNChild = document.getElementById(
"nchild");
40 // elements with a frame
41 var gFParent = document.getElementById(
"fparent");
42 var gFChild = document.getElementById(
"fchild");
44 var gStyleSheet = document.getElementById(
"stylesheet").sheet;
45 var gChildRule1 = gStyleSheet.cssRules[gStyleSheet.insertRule(
"#nchild, #fchild {}", gStyleSheet.cssRules.length)];
46 var gChildRule2 = gStyleSheet.cssRules[gStyleSheet.insertRule(
"#nchild, #fchild {}", gStyleSheet.cssRules.length)];
47 var gChildRule3 = gStyleSheet.cssRules[gStyleSheet.insertRule(
"#nchild.allother, #fchild.allother {}", gStyleSheet.cssRules.length)];
48 var gChildRuleTop = gStyleSheet.cssRules[gStyleSheet.insertRule(
"#nchild, #nchild.allother, #fchild, #fchild.allother {}", gStyleSheet.cssRules.length)];
49 var gParentRuleTop = gStyleSheet.cssRules[gStyleSheet.insertRule(
"#nparent, #fparent {}", gStyleSheet.cssRules.length)];
51 function get_computed_value_node(node, property)
53 var cs = getComputedStyle(node,
"");
54 return get_computed_value(cs, property);
57 function test_property(property)
59 var info = gCSSProperties[property];
60 if (info.backend_only)
63 if (
"prerequisites" in info) {
64 var prereqs = info.prerequisites;
65 for (var prereq in prereqs) {
66 gParentRuleTop.style.setProperty(prereq, prereqs[prereq],
"");
67 gChildRuleTop.style.setProperty(prereq, prereqs[prereq],
"");
72 gParentRuleTop.style.setProperty(property, info.initial_values[
0],
"");
73 var initial_computed_n = get_computed_value_node(gNChild, property);
74 var initial_computed_f = get_computed_value_node(gFChild, property);
75 gChildRule1.style.setProperty(property, info.other_values[
0],
"");
76 var other_computed_n = get_computed_value_node(gNChild, property);
77 var other_computed_f = get_computed_value_node(gFChild, property);
78 isnot(other_computed_n, initial_computed_n,
79 "should be testing with values that compute to different things " +
80 "for '" + property +
"'");
81 isnot(other_computed_f, initial_computed_f,
82 "should be testing with values that compute to different things " +
83 "for '" + property +
"'");
84 gChildRule3.style.setProperty(property,
"inherit",
"");
85 gFChild.
className=
"allother";
86 gNChild.
className=
"allother";
87 var inherit_initial_computed_n = get_computed_value_node(gNChild, property);
88 var inherit_initial_computed_f = get_computed_value_node(gFChild, property);
89 (xfail_inherit(property, true) ? todo_is : is)(
90 inherit_initial_computed_n, initial_computed_n,
91 "inherit should cause inheritance of initial value for '" +
93 (xfail_inherit(property, true) ? todo_is : is)(
94 inherit_initial_computed_f, initial_computed_f,
95 "inherit should cause inheritance of initial value for '" +
97 gParentRuleTop.style.setProperty(property, info.other_values[
0],
"");
98 var inherit_other_computed_n = get_computed_value_node(gNChild, property);
99 var inherit_other_computed_f = get_computed_value_node(gFChild, property);
100 (xfail_inherit(property, false) ? todo_is : is)(
101 inherit_other_computed_n, other_computed_n,
102 "inherit should cause inheritance of other value for '" +
104 (xfail_inherit(property, false) ? todo_is : is)(
105 inherit_other_computed_f, other_computed_f,
106 "inherit should cause inheritance of other value for '" +
108 gParentRuleTop.style.removeProperty(property);
109 gChildRule1.style.removeProperty(property);
110 gChildRule3.style.setProperty(property, info.other_values[
0],
"");
111 gFChild.
className=
"";
112 gNChild.
className=
"";
114 gParentRuleTop.style.setProperty(property, info.other_values[
0],
"");
115 var initial_computed_n = get_computed_value_node(gNChild, property);
116 var initial_computed_f = get_computed_value_node(gFChild, property);
117 var other_computed_n = get_computed_value_node(gNParent, property);
118 var other_computed_f = get_computed_value_node(gFParent, property);
119 isnot(other_computed_n, initial_computed_n,
120 "should be testing with values that compute to different things " +
121 "for '" + property +
"'");
122 isnot(other_computed_f, initial_computed_f,
123 "should be testing with values that compute to different things " +
124 "for '" + property +
"'");
125 gChildRule2.style.setProperty(property,
"inherit",
"");
126 var inherit_other_computed_n = get_computed_value_node(gNChild, property);
127 var inherit_other_computed_f = get_computed_value_node(gFChild, property);
128 (xfail_inherit(property, false) ? todo_is : is)(
129 inherit_other_computed_n, other_computed_n,
130 "inherit should cause inheritance of other value for '" +
132 (xfail_inherit(property, false) ? todo_is : is)(
133 inherit_other_computed_f, other_computed_f,
134 "inherit should cause inheritance of other value for '" +
136 gParentRuleTop.style.removeProperty(property);
137 gChildRule1.style.setProperty(property, info.other_values[
0],
"");
138 var inherit_initial_computed_n = get_computed_value_node(gNChild, property);
139 var inherit_initial_computed_f = get_computed_value_node(gFChild, property);
140 (xfail_inherit(property, true) ? todo_is : is)(
141 inherit_initial_computed_n, initial_computed_n,
142 "inherit should cause inheritance of initial value for '" +
144 (xfail_inherit(property, true) ? todo_is : is)(
145 inherit_initial_computed_f, initial_computed_f,
146 "inherit should cause inheritance of initial value for '" +
148 gParentRuleTop.style.removeProperty(property);
149 gChildRule1.style.removeProperty(property);
150 gChildRule2.style.removeProperty(property);
153 if (
"prerequisites" in info) {
154 var prereqs = info.prerequisites;
155 for (var prereq in prereqs) {
156 gParentRuleTop.style.removeProperty(prereq);
157 gChildRuleTop.style.removeProperty(prereq);
162 for (var prop in gCSSProperties) {
163 var info = gCSSProperties[prop];
164 gChildRule3.style.setProperty(prop, info.other_values[
0],
"");
167 for (var prop in gCSSProperties)