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
|
<link rel="stylesheet" href="../../js/resources/js-test-style.css">
<script src="../../js/resources/js-test-pre.js"></script>
<style>
body {
font: 16px Ahem;
}
#base {
width: 300px;
height: 100px;
}
#border {
border: 10px solid #999;
width: 300px;
height: 100px;
}
#margin {
margin: 10px;
width: 300px;
height: 100px;
}
#transform {
-webkit-transform: translateX(50px) rotate(45deg);
width: 100px;
height: 100px;
}
#columns {
-webkit-column-count: 3;
width: 300px;
}
#inline {
display: inline;
}
#outer {
width: 100px;
height: 100px;
}
#inner {
width: 200px;
height: 200px;
}
table {
width: 300px;
}
img {
width: 100px;
height: 100px;
}
.testBox {
background-color: green;
}
#testArea {
width: 300px;
}
.bbox {
position: absolute;
outline: 5px solid rgba(255, 0, 0, .75);
}
#console {
position: absolute;
left: 500px;
}
</style>
<div id="console"></div>
<div id="testArea">
<p>1. Base</p> <div id="base" class="testBox"></div>
<p>2. Border</p> <div id="border" class="testBox"></div>
<p>3. Margin</p> <div id="margin" class="testBox"></div>
<p>4. Transform</p> <div id="transform" class="testBox"></div>
<p>5. Column</p> <div id="columns" class="testBox">Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.</div>
<p>6. In a column</p> <div id="columns">Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.<span id="in-columns" class="testBox knownFailure">In columns</span> Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.</div>
<p>7. Inline</p> <div id="inline" class="testBox">Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.</div>
<p>8. Table</p> <table class="testBox"><tr><td>table data</td><td>table data</td></tr><tr><td>table data</td><td>table data</td></tr></table>
<p>9. Table with Caption</p> <table class="testBox"><caption>caption</caption><tr><td>table data</td><td>table data</td></tr><tr><td>table data</td><td>table data</td></tr></table>
<p>10. Table Row</p> <table><tr class="testBox"><td>table data</td><td>table data</td></tr><tr><td>table data</td><td>table data</td></tr></table>
<p>11. Table Cell</p> <table><tr><td class="testBox">table data</td><td>table data</td></tr><tr><td>table data</td><td>table data</td></tr></table>
<p>12. Big block in little</p> <div id="outer" class="testBox"><div id="inner"></div></div>
<p>13. Replaced in inline</p> <span class="testBox">Lorem<img>ipsum</span>
<p>14. Block in inline</p> <span class="testBox">Lorem<div id="inner"></div>ipsum</span>
<p>15. Float in inline</p> <span class="testBox"><img style="float:right"></span>
</div>
<script>
if (window.layoutTestController)
layoutTestController.dumpAsText();
else
alert("WARNING:\nThis test may show bogus FAILures if not run in DumpRenderTree, due to platform-specific differences in font metrics.");
function testClientRect(toTest, expectedRect)
{
rect = toTest;
shouldBeEqualToString("rect.left.toFixed(3)", expectedRect.left.toFixed(3));
shouldBeEqualToString("rect.top.toFixed(3)", expectedRect.top.toFixed(3));
shouldBeEqualToString("rect.width.toFixed(3)", expectedRect.width.toFixed(3));
shouldBeEqualToString("rect.height.toFixed(3)", expectedRect.height.toFixed(3));
shouldBe("rect.right", "rect.left + rect.width");
shouldBe("rect.bottom", "rect.top + rect.height");
debug("");
}
function addBBoxOverClientRect(rect)
{
var bbox = document.createElement('div');
bbox.className = "bbox";
var style = "";
style += "left: " + rect.left + "px;";
style += "top: " + rect.top + "px;";
style += "width: " + (rect.right - rect.left) + "px;";
style += "height: " + (rect.bottom - rect.top) + "px;";
bbox.setAttribute("style", style);
document.documentElement.appendChild(bbox);
}
var fail = undefined;
var expectedResults = [
/*1*/ { left: 8, top: 40, width: 300, height: 100 },
/*2*/ { left: 8, top: 188, width: 320, height: 120 },
/*3*/ { left: 18, top: 356, width: 300, height: 100 },
/*4*/ { left: 37.289, top: 483.289, width: 141.421, height: 141.421 },
/*5*/ { left: 8, top: 652, width: 300, height: 374 },
/*6*/ { left: fail, top: fail, width: fail, height: fail },
/*7*/ { left: 8, top: 1490, width: 288, height: 464 },
/*8*/ { left: 8, top: 2002, width: 300, height: 74 },
/*9*/ { left: 8, top: 2140, width: 300, height: 90 },
/*10*/ { left: 8, top: 2280, width: 300, height: 34 },
/*11*/ { left: 10, top: 2402, width: 147, height: 34 },
/*12*/ { left: 8, top: 2538, width: 100, height: 100 },
/*13*/ { left: 8, top: 2789, width: 260, height: 16 },
/*14*/ { left: 8, top: 2869, width: 300, height: 232 },
/*15*/ { left: 8, top: 3165, width: 0, height: 0 }
];
function test(number, element)
{
debug("Test " + number);
if (element.className.match("knownFailure")) {
debug("Known failure. Skipping.");
debug("");
return;
}
var boundingRect = element.getBoundingClientRect();
addBBoxOverClientRect(boundingRect);
testClientRect(boundingRect, expectedResults[number - 1]);
}
var tests = document.getElementsByClassName("testBox");
for (var i = 0; i < tests.length; ++i)
test(i + 1, tests[i]);
if (window.layoutTestController) {
var area = document.getElementById('testArea');
area.parentNode.removeChild(area);
}
successfullyParsed = true;
</script>
<script src="../../js/resources/js-test-post.js"></script>
|