1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
|
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<script src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
<link rel="stylesheet" type="text/css" href="chrome://mochikit/content/tests/SimpleTest/test.css" />
<style>
f {
display: flex;
width: 400px;
height: 50px;
margin-bottom: 2px;
}
b {
background-color: gold;
width: 100px;
height: 15px;
}
b::after {
content: "B";
}
c {
background-color: yellow;
width: 100px;
height: 15px;
}
c::after {
content: "C";
}
d {
background-color: orange;
width: 100px;
height: 15px;
}
d::after {
content: "D";
}
.fdR {
flex-direction: row;
background-color: lightgrey;
}
.fdRR {
flex-direction: row-reverse;
background-color: lightgreen;
}
.fdC {
flex-direction: column;
background-color: lightblue;
}
.fdCR {
flex-direction: column-reverse;
background-color: lavender;
}
.wmHTB {
writing-mode: horizontal-tb;
}
.wmVLR {
writing-mode: vertical-lr;
}
.wmVRL {
writing-mode: vertical-rl;
}
.wmSLR {
writing-mode: sideways-lr;
}
.wmSRL {
writing-mode: sideways-rl;
}
.dLR {
direction: ltr;
}
.dRL {
direction: rtl;
}
</style>
<script>
"use strict";
SimpleTest.waitForExplicitFinish();
function testContainerMatchesExpectedValues(flex, values, flexIndex) {
is(flex.mainAxisDirection, values.m, "Flex index " + flexIndex + " should have expected mainAxisDirection.");
is(flex.crossAxisDirection, values.c, "Flex index " + flexIndex + " should have expected crossAxisDirection.");
}
function runTests() {
const expectedValues = [
{ m: "horizontal-lr", c: "vertical-tb" },
{ m: "horizontal-rl", c: "vertical-tb" },
{ m: "vertical-tb", c: "horizontal-lr" },
{ m: "vertical-bt", c: "horizontal-lr" },
{ m: "vertical-tb", c: "horizontal-rl" },
{ m: "vertical-bt", c: "horizontal-rl" },
{ m: "vertical-bt", c: "horizontal-lr" },
{ m: "vertical-tb", c: "horizontal-lr" },
{ m: "vertical-tb", c: "horizontal-rl" },
{ m: "vertical-bt", c: "horizontal-rl" },
{ m: "horizontal-rl", c: "vertical-tb" },
{ m: "horizontal-lr", c: "vertical-tb" },
{ m: "vertical-bt", c: "horizontal-lr" },
{ m: "vertical-tb", c: "horizontal-lr" },
{ m: "vertical-bt", c: "horizontal-rl" },
{ m: "vertical-tb", c: "horizontal-rl" },
{ m: "vertical-tb", c: "horizontal-lr" },
{ m: "vertical-bt", c: "horizontal-lr" },
{ m: "vertical-bt", c: "horizontal-rl" },
{ m: "vertical-tb", c: "horizontal-rl" },
{ m: "vertical-tb", c: "horizontal-lr" },
{ m: "vertical-tb", c: "horizontal-rl" },
{ m: "horizontal-lr", c: "vertical-tb" },
{ m: "horizontal-lr", c: "vertical-bt" },
{ m: "horizontal-rl", c: "vertical-tb" },
{ m: "horizontal-rl", c: "vertical-bt" },
{ m: "horizontal-lr", c: "vertical-bt" },
{ m: "horizontal-lr", c: "vertical-tb" },
{ m: "horizontal-rl", c: "vertical-tb" },
{ m: "horizontal-rl", c: "vertical-bt" },
{ m: "vertical-bt", c: "horizontal-lr" },
{ m: "vertical-bt", c: "horizontal-rl" },
{ m: "horizontal-rl", c: "vertical-tb" },
{ m: "horizontal-rl", c: "vertical-bt" },
{ m: "horizontal-lr", c: "vertical-tb" },
{ m: "horizontal-lr", c: "vertical-bt" },
{ m: "horizontal-rl", c: "vertical-bt" },
{ m: "horizontal-rl", c: "vertical-tb" },
{ m: "horizontal-lr", c: "vertical-tb" },
{ m: "horizontal-lr", c: "vertical-bt" },
];
const children = document.body.children;
is(children.length, expectedValues.length, "Document should have expected number of flex containers.");
for (let i = 0; i < children.length; ++i) {
const flex = children.item(i).getAsFlexContainer();
ok(flex, "Document child index " + i + " should be a flex container.");
if (flex) {
const values = expectedValues[i];
testContainerMatchesExpectedValues(flex, values, i);
}
}
SimpleTest.finish();
}
</script>
</head>
<body onLoad="runTests();">
<f class="fdR wmHTB dLR"><b></b><c></c><d></d></f>
<f class="fdR wmHTB dRL"><b></b><c></c><d></d></f>
<f class="fdR wmVLR dLR"><b></b><c></c><d></d></f>
<f class="fdR wmVLR dRL"><b></b><c></c><d></d></f>
<f class="fdR wmVRL dLR"><b></b><c></c><d></d></f>
<f class="fdR wmVRL dRL"><b></b><c></c><d></d></f>
<f class="fdR wmSLR dLR"><b></b><c></c><d></d></f>
<f class="fdR wmSLR dRL"><b></b><c></c><d></d></f>
<f class="fdR wmSRL dLR"><b></b><c></c><d></d></f>
<f class="fdR wmSRL dRL"><b></b><c></c><d></d></f>
<f class="fdRR wmHTB dLR"><b></b><c></c><d></d></f>
<f class="fdRR wmHTB dRL"><b></b><c></c><d></d></f>
<f class="fdRR wmVLR dLR"><b></b><c></c><d></d></f>
<f class="fdRR wmVLR dRL"><b></b><c></c><d></d></f>
<f class="fdRR wmVRL dLR"><b></b><c></c><d></d></f>
<f class="fdRR wmVRL dRL"><b></b><c></c><d></d></f>
<f class="fdRR wmSLR dLR"><b></b><c></c><d></d></f>
<f class="fdRR wmSLR dRL"><b></b><c></c><d></d></f>
<f class="fdRR wmSRL dLR"><b></b><c></c><d></d></f>
<f class="fdRR wmSRL dRL"><b></b><c></c><d></d></f>
<f class="fdC wmHTB dLR"><b></b><c></c><d></d></f>
<f class="fdC wmHTB dRL"><b></b><c></c><d></d></f>
<f class="fdC wmVLR dLR"><b></b><c></c><d></d></f>
<f class="fdC wmVLR dRL"><b></b><c></c><d></d></f>
<f class="fdC wmVRL dLR"><b></b><c></c><d></d></f>
<f class="fdC wmVRL dRL"><b></b><c></c><d></d></f>
<f class="fdC wmSLR dLR"><b></b><c></c><d></d></f>
<f class="fdC wmSLR dRL"><b></b><c></c><d></d></f>
<f class="fdC wmSRL dLR"><b></b><c></c><d></d></f>
<f class="fdC wmSRL dRL"><b></b><c></c><d></d></f>
<f class="fdCR wmHTB dLR"><b></b><c></c><d></d></f>
<f class="fdCR wmHTB dRL"><b></b><c></c><d></d></f>
<f class="fdCR wmVLR dLR"><b></b><c></c><d></d></f>
<f class="fdCR wmVLR dRL"><b></b><c></c><d></d></f>
<f class="fdCR wmVRL dLR"><b></b><c></c><d></d></f>
<f class="fdCR wmVRL dRL"><b></b><c></c><d></d></f>
<f class="fdCR wmSLR dLR"><b></b><c></c><d></d></f>
<f class="fdCR wmSLR dRL"><b></b><c></c><d></d></f>
<f class="fdCR wmSRL dLR"><b></b><c></c><d></d></f>
<f class="fdCR wmSRL dRL"><b></b><c></c><d></d></f>
</body>
</html>
|