summaryrefslogtreecommitdiffstats
path: root/layout/style/test/test_compute_data_with_start_struct.html
diff options
context:
space:
mode:
authorMatt A. Tobin <mattatobin@localhost.localdomain>2018-02-02 04:16:08 -0500
committerMatt A. Tobin <mattatobin@localhost.localdomain>2018-02-02 04:16:08 -0500
commit5f8de423f190bbb79a62f804151bc24824fa32d8 (patch)
tree10027f336435511475e392454359edea8e25895d /layout/style/test/test_compute_data_with_start_struct.html
parent49ee0794b5d912db1f95dce6eb52d781dc210db5 (diff)
downloadUXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar
UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.gz
UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.lz
UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.xz
UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.zip
Add m-esr52 at 52.6.0
Diffstat (limited to 'layout/style/test/test_compute_data_with_start_struct.html')
-rw-r--r--layout/style/test/test_compute_data_with_start_struct.html109
1 files changed, 109 insertions, 0 deletions
diff --git a/layout/style/test/test_compute_data_with_start_struct.html b/layout/style/test/test_compute_data_with_start_struct.html
new file mode 100644
index 000000000..fab111e34
--- /dev/null
+++ b/layout/style/test/test_compute_data_with_start_struct.html
@@ -0,0 +1,109 @@
+<!DOCTYPE HTML>
+<html>
+<head>
+ <title>Test for correct handling of aStartStruct parameter to nsRuleNode::Compute*Data</title>
+ <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>
+<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=216456">Mozilla Bug 216456</a>
+<p id="display">
+ <span id="base"></span>
+ <span id="test"></span>
+</p>
+<div id="content" style="display: none">
+
+</div>
+<pre id="test">
+<script class="testbody" type="text/javascript">
+
+/**
+ * The purpose of this test is to test that nsRuleNode::Compute*Data
+ * functions are written correctly. In particular, in these functions,
+ * when the specified value of a property has unit eCSSUnit_Null,
+ * touching the computed data is forbidden. This is because we
+ * sometimes stop walking up the rule tree when we find computed data
+ * for an initial subsequence of our rules (i.e., an ancestor rule node)
+ * that we can use as a starting point (aStartStruct) for the
+ * computation for the current rule node.
+ *
+ * If one of these tests fails, you should look for a case where the
+ * property's code in nsRuleNode::Compute*Data touches the computed
+ * value when the specified value has eCSSUnit_Null, and fix it.
+ *
+ * The test works by maintaining one style rule that has every CSS
+ * property specified, and a second style rule that has different values
+ * for every property, an element that matches only the first rule (so
+ * that we'll have a cached struct), and *later* an element that matches
+ * both rules (for whose computation we'll find the struct cached from
+ * the first element). (It does this twice, once with the overriding in
+ * each direction, because one of the cases might match the incorrect
+ * overwriting.) Then, in the second style rule, it unsets each
+ * property, one at a time, and checks that the computation works
+ * correctly. (The reason to want every property set is to hit a case
+ * where we can store the data in the rule tree... though this isn't
+ * guaranteed.)
+ */
+
+function xfail_computecheck(prop, roundnum) {
+ return false;
+}
+
+function xfail_test(prop, roundnum) {
+ return false;
+}
+
+var gStyleSheet = document.getElementById("stylesheet").sheet;
+var gRule1 = gStyleSheet.cssRules[gStyleSheet.insertRule("#base, #test {}", gStyleSheet.cssRules.length)];
+var gRule2 = gStyleSheet.cssRules[gStyleSheet.insertRule("#test {}", gStyleSheet.cssRules.length)];
+
+var gBase = getComputedStyle(document.getElementById("base"), "");
+var gTest = getComputedStyle(document.getElementById("test"), "");
+
+function round(lower_set, higher_set, roundnum) {
+
+ for (var prop in gCSSProperties) {
+ var info = gCSSProperties[prop];
+ if (info.subproperties || info.get_computed)
+ continue;
+ gRule1.style.setProperty(prop, info[lower_set][0], "");
+ gRule2.style.setProperty(prop, info[higher_set][0], "");
+ }
+
+ for (var prop in gCSSProperties) {
+ var info = gCSSProperties[prop];
+ if (info.subproperties || info.get_computed)
+ continue;
+
+ if ("prerequisites" in info) {
+ for (var prereq in info.prerequisites) {
+ gRule2.style.setProperty(prereq, info.prerequisites[prereq], "");
+ }
+ }
+
+ gBase.getPropertyValue(prop);
+ var higher_set_val = gTest.getPropertyValue(prop);
+ gRule2.style.setProperty(prop, info[lower_set][0], "");
+ var lower_set_val = gTest.getPropertyValue(prop);
+ (xfail_computecheck(prop, roundnum) ? todo_isnot : isnot)(higher_set_val, lower_set_val, "initial and other values of " + prop + " are different");
+ gRule2.style.removeProperty(prop);
+ (xfail_test(prop, roundnum) ? todo_is : is)(gTest.getPropertyValue(prop), lower_set_val, prop + " is not touched when its value comes from aStartStruct");
+
+ gRule2.style.setProperty(prop, info[higher_set][0], "");
+ if ("prerequisites" in info) {
+ for (var prereq in info.prerequisites) {
+ gRule2.style.setProperty(prereq, gCSSProperties[prereq][higher_set][0], "");
+ }
+ }
+ }
+}
+
+round("other_values", "initial_values", 1);
+round("initial_values", "other_values", 2);
+
+</script>
+</pre>
+</body>
+</html>