Wed, 31 Dec 2014 06:55:50 +0100
Added tag UPSTREAM_283F7C6 for changeset ca08bd8f51b2
1 <!DOCTYPE HTML>
2 <html>
3 <head>
4 <title>Test for correct handling of aStartStruct parameter to nsRuleNode::Compute*Data</title>
5 <script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
6 <script type="text/javascript" src="property_database.js"></script>
7 <style type="text/css" id="stylesheet"></style>
8 <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
9 </head>
10 <body>
11 <a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=216456">Mozilla Bug 216456</a>
12 <p id="display">
13 <span id="base"></span>
14 <span id="test"></span>
15 </p>
16 <div id="content" style="display: none">
18 </div>
19 <pre id="test">
20 <script class="testbody" type="text/javascript">
22 /**
23 * The purpose of this test is to test that nsRuleNode::Compute*Data
24 * functions are written correctly. In particular, in these functions,
25 * when the specified value of a property has unit eCSSUnit_Null,
26 * touching the computed data is forbidden. This is because we
27 * sometimes stop walking up the rule tree when we find computed data
28 * for an initial subsequence of our rules (i.e., an ancestor rule node)
29 * that we can use as a starting point (aStartStruct) for the
30 * computation for the current rule node.
31 *
32 * If one of these tests fails, you should look for a case where the
33 * property's code in nsRuleNode::Compute*Data touches the computed
34 * value when the specified value has eCSSUnit_Null, and fix it.
35 *
36 * The test works by maintaining one style rule that has every CSS
37 * property specified, and a second style rule that has different values
38 * for every property, an element that matches only the first rule (so
39 * that we'll have a cached struct), and *later* an element that matches
40 * both rules (for whose computation we'll find the struct cached from
41 * the first element). (It does this twice, once with the overriding in
42 * each direction, because one of the cases might match the incorrect
43 * overwriting.) Then, in the second style rule, it unsets each
44 * property, one at a time, and checks that the computation works
45 * correctly. (The reason to want every property set is to hit a case
46 * where we can store the data in the rule tree... though this isn't
47 * guaranteed.)
48 */
50 function xfail_computecheck(prop, roundnum) {
51 return false;
52 }
54 function xfail_test(prop, roundnum) {
55 return false;
56 }
58 var gStyleSheet = document.getElementById("stylesheet").sheet;
59 var gRule1 = gStyleSheet.cssRules[gStyleSheet.insertRule("#base, #test {}", gStyleSheet.cssRules.length)];
60 var gRule2 = gStyleSheet.cssRules[gStyleSheet.insertRule("#test {}", gStyleSheet.cssRules.length)];
62 var gBase = getComputedStyle(document.getElementById("base"), "");
63 var gTest = getComputedStyle(document.getElementById("test"), "");
65 function round(lower_set, higher_set, roundnum) {
67 for (var prop in gCSSProperties) {
68 var info = gCSSProperties[prop];
69 if (info.backend_only || info.subproperties || info.get_computed)
70 continue;
71 gRule1.style.setProperty(prop, info[lower_set][0], "");
72 gRule2.style.setProperty(prop, info[higher_set][0], "");
73 }
75 for (var prop in gCSSProperties) {
76 var info = gCSSProperties[prop];
77 if (info.backend_only || info.subproperties || info.get_computed)
78 continue;
80 if ("prerequisites" in info) {
81 for (var prereq in info.prerequisites) {
82 gRule2.style.setProperty(prereq, info.prerequisites[prereq], "");
83 }
84 }
86 gBase.getPropertyValue(prop);
87 var higher_set_val = gTest.getPropertyValue(prop);
88 gRule2.style.setProperty(prop, info[lower_set][0], "");
89 var lower_set_val = gTest.getPropertyValue(prop);
90 (xfail_computecheck(prop, roundnum) ? todo_isnot : isnot)(higher_set_val, lower_set_val, "initial and other values of " + prop + " are different");
91 gRule2.style.removeProperty(prop);
92 (xfail_test(prop, roundnum) ? todo_is : is)(gTest.getPropertyValue(prop), lower_set_val, prop + " is not touched when its value comes from aStartStruct");
94 gRule2.style.setProperty(prop, info[higher_set][0], "");
95 if ("prerequisites" in info) {
96 for (var prereq in info.prerequisites) {
97 gRule2.style.setProperty(prereq, gCSSProperties[prereq][higher_set][0], "");
98 }
99 }
100 }
101 }
103 round("other_values", "initial_values", 1);
104 round("initial_values", "other_values", 2);
106 </script>
107 </pre>
108 </body>
109 </html>