blob: a7c117eca1d0e05a764f53dad8b96d5530085d56 [file] [log] [blame]
<link rel="stylesheet" href="../js/resources/js-test-style.css">
<script src="../js/resources/js-test-pre.js"></script>
<style>
#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();
var testRects;
function testClientRects(rects, expectedNumberOfRects)
{
testRects = rects;
shouldBe("testRects.length", String(expectedNumberOfRects));
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);
}
function addBBoxOverClientRects(rects)
{
for (var i = 0; i < rects.length; ++i)
addBBoxOverClientRect(rects[i]);
}
var expectedResults = [
1,
1,
1,
1,
1,
1,
10,
1,
2,
1,
1,
1,
1,
3,
1
];
function test(number, element)
{
debug("Client bounding rects for #" + number);
if (element.className.match("knownFailure")) {
debug("Known failure. Skipping.");
debug("");
return;
}
var boundingRects = element.getClientRects();
addBBoxOverClientRects(boundingRects);
testClientRects(boundingRects, 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>