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
|
<!DOCTYPE HTML>
<script src="../../resources/testharness.js"></script>
<script src="../../resources/testharnessreport.js"></script>
<div id="log"></div>
<div id="container">
<p id="description">
This tests that changing the container's position from fixed or relative to absolute is safe,<br>
when child container with fixed position is present.<br>
PASS, if no crash or assert in debug.
</p>
</div>
<script>
var valueList = ["static", "relative", "absolute", "fixed"]
var tests = [];
for (var outerValue of valueList) {
for (var innerValue of valueList) {
for (var afterValue of valueList) {
var outerElement, innerElement, midElement;
if (outerValue !== afterValue) {
outerElement = document.createElement("div");
innerElement = document.createElement("div");
outerElement.style.position = outerValue;
innerElement.style.position = innerValue;
outerElement.appendChild(innerElement);
container.appendChild(outerElement);
tests.push(["position:" + outerValue + " with a " + innerValue + " child to " + afterValue, function () {
outerElement.style.position = afterValue;
}]);
outerElement = document.createElement("div");
innerElement = document.createElement("div");
outerElement.style.position = outerValue;
outerElement.style.transform = "rotate(3deg)";
innerElement.style.position = innerValue;
outerElement.appendChild(innerElement);
container.appendChild(outerElement);
tests.push(["position:" + outerValue + " with a " + innerValue + " child to " + afterValue, function () {
outerElement.style.position = afterValue;
}]);
outerElement = document.createElement("div");
innerElement = document.createElement("div");
outerElement.style.position = outerValue;
outerElement.style.transform = "rotate(3deg)";
innerElement.style.position = innerValue;
outerElement.appendChild(innerElement);
container.appendChild(outerElement);
tests.push(["position:" + outerValue + " and transform with a " + innerValue + " child to " + afterValue + " without transform", function () {
outerElement.style.position = afterValue;
outerElement.style.transform = "none";
innerElement.style.width = "50%";
}]);
}
outerElement = document.createElement("div");
midElement = document.createElement("div");
innerElement = document.createElement("div");
outerElement.style.position = outerValue;
innerElement.style.position = innerValue;
outerElement.appendChild(midElement);
midElement.appendChild(innerElement);
container.appendChild(outerElement);
tests.push(["position:static with a " + outerValue + " parent and a " + innerValue + " child to " + afterValue, function () {
midElement.style.position = afterValue;
innerElement.style.width = "50%";
}]);
}
outerElement = document.createElement("div");
midElement = document.createElement("div");
innerElement = document.createElement("div");
outerElement.style.position = outerValue;
innerElement.style.position = innerValue;
outerElement.appendChild(midElement);
midElement.appendChild(innerElement);
container.appendChild(outerElement);
tests.push(["position:static with a " + outerValue + " parent and a " + innerValue + " child to transform", function () {
midElement.style.transform = "translateX(0)";
innerElement.style.width = "50%";
}]);
outerElement = document.createElement("div");
midElement = document.createElement("div");
innerElement = document.createElement("div");
outerElement.style.position = outerValue;
midElement.style.transform = "translateX(0)";
innerElement.style.position = innerValue;
outerElement.appendChild(midElement);
midElement.appendChild(innerElement);
container.appendChild(outerElement);
tests.push(["position:static and transform with a " + outerValue + " parent and a " + innerValue + " child to without transform", function () {
midElement.style.transform = "none";
innerElement.style.width = "50%";
}]);
outerElement = document.createElement("div");
innerElement = document.createElement("div");
outerElement.style.position = outerValue;
innerElement.style.position = innerValue;
outerElement.appendChild(innerElement);
container.appendChild(outerElement);
tests.push(["Add transform position:" + outerValue + " with a " + innerValue + " child", function () {
outerElement.style.transform = "rotate(3deg)";
innerElement.style.width = "50%";
}]);
outerElement = document.createElement("div");
innerElement = document.createElement("div");
outerElement.style.position = outerValue;
outerElement.style.transform = "rotate(3deg)";
innerElement.style.position = innerValue;
outerElement.appendChild(innerElement);
container.appendChild(outerElement);
tests.push(["Remove transform from position:" + outerValue + " and transform with a " + innerValue + " child", function () {
outerElement.style.transform = "none";
innerElement.style.width = "50%";
}]);
}
}
document.body.offsetHeight;
for (var t of tests) {
test(function () {
t[1]();
// No assert() are needed, we just check layout hits no ASSERT nor crash.
document.body.offsetHeight;
}, t[0]);
}
</script>
|