layout/style/test/test_compute_data_with_start_struct.html

Wed, 31 Dec 2014 13:27:57 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 13:27:57 +0100
branch
TOR_BUG_3246
changeset 6
8bccb770b82d
permissions
-rw-r--r--

Ignore runtime configuration files generated during quality assurance.

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

mercurial