4 https://bugzilla.mozilla.org/show_bug.cgi?id=799775
8 <title>Test for Bug
799775</title>
9 <script src=
"/tests/SimpleTest/SimpleTest.js"></script>
10 <script src=
"/tests/SimpleTest/WindowSnapshot.js"></script>
11 <link rel=
"stylesheet" type=
"text/css" href=
"/tests/SimpleTest/test.css"/>
12 <style type=
"text/css">
29 background: lightgreen
;
48 div#flexContainerParent
{
54 <a target=
"_blank" href=
"https://bugzilla.mozilla.org/show_bug.cgi?id=799775">Mozilla Bug
799775</a>
57 <!-- Reference cases (display:none; only shown during initRefSnapshots) -->
59 <div class=
"ref" id=
"abc"><refA></refA><refB></refB><refC></refC></div>
60 <div class=
"ref" id=
"acb"><refA></refA><refC></refC><refB></refB></div>
61 <div class=
"ref" id=
"bac"><refB></refB><refA></refA><refC></refC></div>
62 <div class=
"ref" id=
"bca"><refB></refB><refC></refC><refA></refA></div>
63 <div class=
"ref" id=
"cab"><refC></refC><refA></refA><refB></refB></div>
64 <div class=
"ref" id=
"cba"><refC></refC><refB></refB><refA></refA></div>
67 <div id=
"flexContainerParent">
68 <!-- The flex container that we'll be testing
69 (its parent is display:none initially) -->
70 <div id=
"flexContainer">
79 <script type=
"application/javascript">
82 /** Test for Bug
799775 **/
84 /* This testcase ensures that we honor the
"order" property when ordering
85 * tables as flex items within a flex container.
87 * Note: The items in this testcase don't overlap, so this testcase does _not_
88 * test paint ordering. It only tests horizontal ordering in a flex container.
94 // This will store snapshots of our reference divs
95 let gRefSnapshots = {};
97 // These are the sets of 'order' values that we'll test.
98 // The first three values in each array are the 'order' values that we'll
99 // assign to elements a, b, and c (respectively). The final value in each
100 // array is the ID of the expected reference rendering.
101 let gOrderTestcases = [
102 // The
6 basic permutations:
110 // Test negative values
112 [ -
50,
0, -
2,
"acb"],
114 // Non-integers should be ignored.
115 // (So, they'll leave their div with the initial 'order' value, which is
0.)
117 [
2.5,
3.4,
1,
"abc"],
118 [
0.5,
1,
1.5,
"acb"],
120 // Decimal values that happen to be equal to integers (e.g.
"3.0") are still
121 //
<numbers>, and are _not_
<integers>.
122 // Source: http://www.w3.org/TR/CSS21/syndata.html#value-def-integer
123 // (So, they'll leave their div with the initial 'order' value, which is
0.)
124 // (NOTE: We have to use quotes around
"3.0" and
"2.0" to be sure JS doesn't
125 // coerce them into integers before we get a chance to set them in CSS.)
126 [
"3.0",
"2.0",
"1.0",
"abc"],
127 [
3,
"2.0",
1,
"bca"],
133 function initRefSnapshots() {
134 let refIds = [
"abc",
"acb",
"bac",
"bca",
"cab",
"cba"];
135 for (let id of refIds) {
136 let elem = document.getElementById(id);
137 elem.style.display =
"block";
138 gRefSnapshots[id] = snapshotWindow(window, false);
139 elem.style.display =
"";
143 function complainIfSnapshotsDiffer(aSnap1, aSnap2, aMsg) {
144 let compareResult = compareSnapshots(aSnap1, aSnap2, true);
146 "flex container rendering should match expected (" + aMsg +
")");
147 if (!compareResult[
0]) {
148 todo(false,
"TESTCASE: " + compareResult[
1]);
149 todo(false,
"REFERENCE: "+ compareResult[
2]);
153 function runOrderTestcase(aOrderTestcase) {
155 ok(Array.isArray(aOrderTestcase),
"expecting testcase to be an array");
156 is(aOrderTestcase.length,
4,
"expecting testcase to have 4 elements");
158 document.getElementById(
"a").style.order = aOrderTestcase[
0];
159 document.getElementById(
"b").style.order = aOrderTestcase[
1];
160 document.getElementById(
"c").style.order = aOrderTestcase[
2];
162 let snapshot = snapshotWindow(window, false);
163 complainIfSnapshotsDiffer(snapshot, gRefSnapshots[aOrderTestcase[
3]],
167 for (let id of [
"a",
"b",
"c"]) {
168 document.getElementById(id).style.order =
"";
176 // un-hide the flex container's parent
177 let flexContainerParent = document.getElementById(
"flexContainerParent");
178 flexContainerParent.style.display =
"block";
180 // Initial sanity-check: should be in expected document order
181 let initialSnapshot = snapshotWindow(window, false);
182 complainIfSnapshotsDiffer(initialSnapshot, gRefSnapshots.abc,
183 "initial flex container rendering, " +
184 "no 'order' value yet");
186 // OK, now we run our tests
187 gOrderTestcases.forEach(runOrderTestcase);
189 // Re-hide the flex container at the end
190 flexContainerParent.style.display =
"";