| <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 testRect; |
| function testClientRect(toTest, expectedRect) |
| { |
| testRect = toTest; |
| |
| debug("testRect.top " + testRect.top); |
| debug("testRect.left " + testRect.left); |
| debug("testRect.width " + testRect.width); |
| debug("testRect.height " + testRect.height); |
| debug("testRect.bottom " + testRect.bottom); |
| debug("testRect.right " + testRect.right); |
| debug(""); |
| |
| shouldBe("testRect.top", String(expectedRect.top)); |
| shouldBe("testRect.left", String(expectedRect.left)); |
| shouldBe("testRect.width", String(expectedRect.width)); |
| shouldBe("testRect.height", String(expectedRect.height)); |
| shouldBe("testRect.bottom", "testRect.top + testRect.height"); |
| shouldBe("testRect.right", "testRect.left + testRect.width"); |
| 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*/ { top: 42, left: 8, width: 300, height: 100 }, |
| /*2*/ { top: 192, left: 8, width: 320, height: 120 }, |
| /*3*/ { top: 362, left: 18, width: 300, height: 100 }, |
| /*4*/ { top: 491, left: 37, width: 142, height: 142 }, |
| /*5*/ { top: 662, left: 8, width: 300, height: 234 }, |
| /*6*/ { top: fail, left: fail, width: fail, height: fail }, |
| /*7*/ { top: 1230, left: 8, width: 299, height: 180 }, |
| /*8*/ { top: 1460, left: 8, width: 300, height: 46 }, |
| /*9*/ { top: 1556, left: 8, width: 300, height: 64 }, |
| /*10*/ { top: 1672, left: 8, width: 300, height: 20 }, |
| /*11*/ { top: 1768, left: 10, width: 147, height: 20 }, |
| /*12*/ { top: 1862, left: 8, width: 100, height: 100 }, |
| /*13*/ { top: 2098, left: 8, width: 180, height: 18 }, |
| /*14*/ { top: 2166, left: 8, width: 200, height: 236 }, |
| /*15*/ { top: 2452, left: 8, width: 0, height: 0 } |
| ]; |
| |
| function test(number, element) |
| { |
| debug("Client bounding rect for #" + 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> |