1 <script src=
"../../../resources/ahem.js"></script>
2 <script src=
"../../../resources/js-test.js"></script>
14 border:
10px solid #
999;
26 transform: translateX(
50px) rotate(
45deg);
32 -webkit-column-count:
3;
60 background-color: green;
69 outline:
5px solid rgba(
255,
0,
0,
.75);
78 <div id=
"console"></div>
81 <p>1. Base
</p> <div id=
"base" class=
"testBox"></div>
82 <p>2. Border
</p> <div id=
"border" class=
"testBox"></div>
83 <p>3. Margin
</p> <div id=
"margin" class=
"testBox"></div>
84 <p>4. Transform
</p> <div id=
"transform" class=
"testBox"></div>
85 <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>
86 <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>
87 <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>
88 <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>
89 <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>
90 <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>
91 <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>
92 <p>12. Big block in little
</p> <div id=
"outer" class=
"testBox"><div id=
"inner"></div></div>
93 <p>13. Replaced in inline
</p> <span class=
"testBox">Lorem
<img>ipsum
</span>
94 <p>14. Block in inline
</p> <span class=
"testBox">Lorem
<div id=
"inner"></div>ipsum
</span>
95 <p>15. Float in inline
</p> <span class=
"testBox"><img style=
"float:right"></span>
100 if (window
.testRunner
)
101 testRunner
.dumpAsText();
103 alert("WARNING:\nThis test may show bogus FAILures if not run in DumpRenderTree, due to platform-specific differences in font metrics.");
105 function testClientRect(toTest
, expectedRect
)
108 shouldBeEqualToString("rect.left.toFixed(3)", expectedRect
.left
.toFixed(3));
109 shouldBeEqualToString("rect.top.toFixed(3)", expectedRect
.top
.toFixed(3));
110 shouldBeEqualToString("rect.width.toFixed(3)", expectedRect
.width
.toFixed(3));
111 shouldBeEqualToString("rect.height.toFixed(3)", expectedRect
.height
.toFixed(3));
112 shouldBe("rect.right", "rect.left + rect.width");
113 shouldBe("rect.bottom", "rect.top + rect.height");
117 function addBBoxOverClientRect(rect
)
119 var bbox
= document
.createElement('div');
120 bbox
.className
= "bbox";
122 style
+= "left: " + rect
.left
+ "px;";
123 style
+= "top: " + rect
.top
+ "px;";
124 style
+= "width: " + (rect
.right
- rect
.left
) + "px;";
125 style
+= "height: " + (rect
.bottom
- rect
.top
) + "px;";
126 bbox
.setAttribute("style", style
);
127 document
.documentElement
.appendChild(bbox
);
130 var fail
= undefined;
132 var expectedResults
= [
133 /*1*/ { left
: 8, top
: 40, width
: 300, height
: 100 },
134 /*2*/ { left
: 8, top
: 188, width
: 320, height
: 120 },
135 /*3*/ { left
: 18, top
: 356, width
: 300, height
: 100 },
136 /*4*/ { left
: 37.289, top
: 483.289, width
: 141.421, height
: 141.421 },
137 // On Mac, this fails because of crbug.com/498030.
138 /*5*/ { left
: 8, top
: 652, width
: 300, height
: 368 },
139 /*6*/ { left
: fail
, top
: fail
, width
: fail
, height
: fail
},
140 /*7*/ { left
: 8, top
: 1484, width
: 288, height
: 464 },
141 /*8*/ { left
: 8, top
: 1996, width
: 300, height
: 74 },
142 /*9*/ { left
: 8, top
: 2134, width
: 300, height
: 90 },
143 /*10*/ { left
: 8, top
: 2274, width
: 300, height
: 34 },
144 /*11*/ { left
: 10, top
: 2396, width
: 147, height
: 34 },
145 /*12*/ { left
: 8, top
: 2532, width
: 100, height
: 100 },
146 /*13*/ { left
: 8, top
: 2783, width
: 260, height
: 16 },
147 /*14*/ { left
: 8, top
: 2863, width
: 300, height
: 232 },
148 /*15*/ { left
: 8, top
: 3159, width
: 0, height
: 0 }
151 function test(number
, element
)
153 debug("Test " + number
);
155 if (element
.className
.match("knownFailure")) {
156 debug("Known failure. Skipping.");
161 var boundingRect
= element
.getBoundingClientRect();
162 addBBoxOverClientRect(boundingRect
);
163 testClientRect(boundingRect
, expectedResults
[number
- 1]);
166 var tests
= document
.getElementsByClassName("testBox");
167 for (var i
= 0; i
< tests
.length
; ++i
)
168 test(i
+ 1, tests
[i
]);
170 if (window
.testRunner
) {
171 var area
= document
.getElementById('testArea');
172 area
.parentNode
.removeChild(area
);