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
|
<!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>
body {
margin: 40px;
}
.flexWrapper {
display: flex;
width: 400px;
}
.nonFlexWrapper {
display: block;
width: 400px;
}
.oh {
overflow: hidden;
}
.box {
background-color: #444;
color: #fff;
}
</style>
<script>
"use strict";
SimpleTest.waitForExplicitFinish();
function runTests() {
// Test 1: elements styled with display:flex
let idsWithFlex = [
"flexDiv",
"flexDivOh",
"flexFieldset",
"flexFieldsetEmpty",
"flexFieldsetOh",
"flexButton",
"flexButtonOh",
];
for (let id of idsWithFlex) {
let wrapper = document.getElementById(id);
// Test that we got a flex info object from the element.
let flex = wrapper.getAsFlexContainer();
ok(flex, `Expected that element id ${id} would have flex info.`);
}
// Test 2: elements styled without display:flex
let idsWithoutFlex = [
"boxA",
"nonFlexFieldset",
"nonFlexFieldsetOh",
"nonFlexButton",
"nonFlexButtonOh",
];
for (let id of idsWithoutFlex) {
let wrapper = document.getElementById(id);
// Test that we didn't get a flex info object from the element.
let flex = wrapper.getAsFlexContainer();
ok(!flex, `Expected that element id ${id} would not have flex info.`);
}
SimpleTest.finish();
}
</script>
</head>
<body onLoad="runTests();">
<div id="flexDiv" class="flexWrapper">
<div id="boxA" class="box">A</div>
</div>
<div id="flexDivOh" class="flexWrapper oh">
<div id="boxAOh" class="box">A</div>
</div>
<fieldset id="flexFieldset" class="flexWrapper">
<legend>a fieldset</legend>
<label for="name">name</label>
<input id="name">
</fieldset>
<fieldset id="flexFieldsetEmpty" class="flexWrapper">
</fieldset>
<fieldset id="flexFieldsetOh" class="flexWrapper oh">
<legend>a fieldset</legend>
<label for="nameOh">name</label>
<input id="nameOh">
</fieldset>
<button id="flexButton" class="flexWrapper">
<span>test</span>
</button>
<button id="flexButtonOh" class="flexWrapper oh">
<span>test</span>
</button>
<fieldset id="nonFlexFieldset" class="nonFlexWrapper">
<legend>a fieldset</legend>
<label for="name">name</label>
<input id="name">
</fieldset>
<fieldset id="nonFlexFieldsetOh" class="nonFlexWrapper oh">
<legend>a fieldset</legend>
<label for="name">name</label>
<input id="name">
</fieldset>
<button id="nonFlexButton" class="nonFlexWrapper">
<span>test</span>
</button>
<button id="nonFlexButtonOh" class="nonFlexWrapper oh">
<span>test</span>
</button>
</body>
</html>
|