| <script src="../../../resources/js-test-pre.js"></script> |
| <style> |
| .bbox { |
| position:absolute; |
| outline: 5px solid rgba(255, 0, 0, .75); |
| z-index: -1; |
| } |
| |
| .box { |
| width: 400px; |
| line-height: 40px; |
| } |
| |
| .outer { |
| outline: 2px solid green; |
| } |
| |
| .inner { |
| display: inline-block; |
| width: 40px; |
| height: 20px; |
| outline: 2px solid blue; |
| } |
| |
| #test8 { |
| -webkit-transform: translate(50px, 100px) rotate(50deg); |
| } |
| |
| #test10 { |
| height: 400px; |
| -webkit-writing-mode: vertical-lr; |
| } |
| |
| #console { |
| position:absolute; |
| left: 500px; |
| } |
| #testArea { |
| width: 300px; |
| } |
| |
| </style> |
| <div id="console"></div> |
| <div id="testArea"> |
| |
| <div class="box" id="test1">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.</div> |
| |
| <br><br> |
| |
| <div class="box" id="test2">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.</div> |
| |
| <br><br> |
| |
| <div class="box" id="test3">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.</div> |
| |
| <br><br> |
| |
| <div class="box" id="test4">Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et<img src="../resources/abe.png" width="76" height="103"> dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.</div> |
| |
| <br><br> |
| |
| <div class="box" id="test5">Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et<img src="../resources/abe.png" width="76" height="103"> dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.</div> |
| |
| <br><br> |
| |
| <div class="box" id="test6">Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do <div class="outer">eiusmod <span class="inner"></span>tempor</div> incididunt ut labore etdolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.</div> |
| |
| <br><br> |
| |
| <div class="box" id="test7">Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do <div class="outer">eiusmod <span class="inner"></span>tempor</div> incididunt ut labore etdolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.</div> |
| |
| <br><br> |
| |
| <div class="box" id="test8">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.</div> |
| |
| <br><br> |
| |
| <div class="box" id="test9">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.</div> |
| |
| <br><br> |
| |
| <div class="box" id="test10">weee! 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.</div> |
| |
| <br><br> |
| |
| <div class="box" id="test11"><div>Lorem ipsum dolor sit amet,</div> 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.</div> |
| |
| <br><br> |
| |
| <div class="box" id="test12">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.</div> |
| |
| <br><br> |
| |
| <div class="box" id="test13">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.</div> |
| |
| </div> |
| |
| <script> |
| if (window.testRunner) |
| testRunner.dumpAsText(); |
| |
| 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]); |
| } |
| |
| function show(range) |
| { |
| if (window.testRunner) |
| return; |
| addBBoxOverClientRects(range.getClientRects()); |
| } |
| |
| // Test 1 |
| debug("Test 1") |
| var range1 = document.createRange(); |
| range1.selectNode(document.getElementById('test1')); |
| show(range1); |
| rects = range1.getClientRects(); |
| shouldBe("rects.length", "5"); |
| shouldBeEqualToString("rects[0].left.toFixed(2)", "8.00"); |
| shouldBeEqualToString("rects[0].top.toFixed(2)", "8.00"); |
| shouldBeEqualToString("rects[0].width.toFixed(2)", "400.00"); |
| shouldBeEqualToString("rects[0].height.toFixed(2)", "160.00"); |
| shouldBeEqualToString("rects[1].left.toFixed(2)", "8.00"); |
| shouldBeEqualToString("rects[1].top.toFixed(2)", "19.00"); |
| shouldBeEqualToString("rects[1].width.toFixed(2)", "386.58"); |
| shouldBeEqualToString("rects[1].height.toFixed(2)", "18.00"); |
| shouldBeEqualToString("rects[2].left.toFixed(2)", "8.00"); |
| shouldBeEqualToString("rects[2].top.toFixed(2)", "59.00"); |
| shouldBeEqualToString("rects[2].width.toFixed(2)", "359.91"); |
| shouldBeEqualToString("rects[2].height.toFixed(2)", "18.00"); |
| shouldBeEqualToString("rects[3].left.toFixed(2)", "8.00"); |
| shouldBeEqualToString("rects[3].top.toFixed(2)", "99.00"); |
| shouldBeEqualToString("rects[3].width.toFixed(2)", "381.25"); |
| shouldBeEqualToString("rects[3].height.toFixed(2)", "18.00"); |
| shouldBeEqualToString("rects[4].left.toFixed(2)", "8.00"); |
| shouldBeEqualToString("rects[4].top.toFixed(2)", "139.00"); |
| shouldBeEqualToString("rects[4].width.toFixed(2)", "368.36"); |
| shouldBeEqualToString("rects[4].height.toFixed(2)", "18.00"); |
| |
| // Test 2 |
| debug("Test 2") |
| var range2 = document.createRange(); |
| range2.selectNodeContents(document.getElementById('test2')); |
| show(range2); |
| rects = range2.getClientRects(); |
| shouldBe("rects.length", "4"); |
| shouldBeEqualToString("rects[0].left.toFixed(2)", "8.00"); |
| shouldBeEqualToString("rects[0].top.toFixed(2)", "215.00"); |
| shouldBeEqualToString("rects[0].width.toFixed(2)", "386.58"); |
| shouldBeEqualToString("rects[0].height.toFixed(2)", "18.00"); |
| shouldBeEqualToString("rects[1].left.toFixed(2)", "8.00"); |
| shouldBeEqualToString("rects[1].top.toFixed(2)", "255.00"); |
| shouldBeEqualToString("rects[1].width.toFixed(2)", "359.91"); |
| shouldBeEqualToString("rects[1].height.toFixed(2)", "18.00"); |
| shouldBeEqualToString("rects[2].left.toFixed(2)", "8.00"); |
| shouldBeEqualToString("rects[2].top.toFixed(2)", "295.00"); |
| shouldBeEqualToString("rects[2].width.toFixed(2)", "381.25"); |
| shouldBeEqualToString("rects[2].height.toFixed(2)", "18.00"); |
| shouldBeEqualToString("rects[3].left.toFixed(2)", "8.00"); |
| shouldBeEqualToString("rects[3].top.toFixed(2)", "335.00"); |
| shouldBeEqualToString("rects[3].width.toFixed(2)", "368.36"); |
| shouldBeEqualToString("rects[3].height.toFixed(2)", "18.00"); |
| |
| // Test 3 |
| debug("Test 3") |
| var range3 = document.createRange(); |
| range3.setStart(document.getElementById('test3').firstChild, 10); |
| range3.setEnd(document.getElementById('test3').lastChild, 200); |
| show(range3); |
| rects = range3.getClientRects(); |
| shouldBe("rects.length", "4"); |
| shouldBeEqualToString("rects[0].left.toFixed(2)", "81.00"); |
| shouldBeEqualToString("rects[0].top.toFixed(2)", "411.00"); |
| shouldBeEqualToString("rects[0].width.toFixed(2)", "313.58"); |
| shouldBeEqualToString("rects[0].height.toFixed(2)", "18.00"); |
| shouldBeEqualToString("rects[1].left.toFixed(2)", "8.00"); |
| shouldBeEqualToString("rects[1].top.toFixed(2)", "451.00"); |
| shouldBeEqualToString("rects[1].width.toFixed(2)", "359.91"); |
| shouldBeEqualToString("rects[1].height.toFixed(2)", "18.00"); |
| shouldBeEqualToString("rects[2].left.toFixed(2)", "8.00"); |
| shouldBeEqualToString("rects[2].top.toFixed(2)", "491.00"); |
| shouldBeEqualToString("rects[2].width.toFixed(2)", "381.25"); |
| shouldBeEqualToString("rects[2].height.toFixed(2)", "18.00"); |
| shouldBeEqualToString("rects[3].left.toFixed(2)", "8.00"); |
| shouldBeEqualToString("rects[3].top.toFixed(2)", "531.00"); |
| shouldBeEqualToString("rects[3].width.toFixed(2)", "147.00"); |
| shouldBeEqualToString("rects[3].height.toFixed(2)", "18.00"); |
| |
| // Test 4 - Should not include rect of the img. |
| debug("Test 4") |
| var range4 = document.createRange(); |
| range4.selectNode(document.getElementById('test4')); |
| show(range4); |
| rects = range4.getClientRects(); |
| shouldBe("rects.length", "7"); |
| shouldBeEqualToString("rects[0].left.toFixed(2)", "8.00"); |
| shouldBeEqualToString("rects[0].top.toFixed(2)", "596.00"); |
| shouldBeEqualToString("rects[0].width.toFixed(2)", "400.00"); |
| shouldBeEqualToString("rects[0].height.toFixed(2)", "278.00"); |
| shouldBeEqualToString("rects[1].left.toFixed(2)", "8.00"); |
| shouldBeEqualToString("rects[1].top.toFixed(2)", "607.00"); |
| shouldBeEqualToString("rects[1].width.toFixed(2)", "386.58"); |
| shouldBeEqualToString("rects[1].height.toFixed(2)", "18.00"); |
| shouldBeEqualToString("rects[2].left.toFixed(2)", "8.00"); |
| shouldBeEqualToString("rects[2].top.toFixed(2)", "725.00"); |
| shouldBeEqualToString("rects[2].width.toFixed(2)", "268.39"); |
| shouldBeEqualToString("rects[2].height.toFixed(2)", "18.00"); |
| shouldBeEqualToString("rects[3].left.toFixed(2)", "352.39"); |
| shouldBeEqualToString("rects[3].top.toFixed(2)", "725.00"); |
| shouldBeEqualToString("rects[3].width.toFixed(2)", "44.88"); |
| shouldBeEqualToString("rects[3].height.toFixed(2)", "18.00"); |
| shouldBeEqualToString("rects[4].left.toFixed(2)", "8.00"); |
| shouldBeEqualToString("rects[4].top.toFixed(2)", "765.00"); |
| shouldBeEqualToString("rects[4].width.toFixed(2)", "348.38"); |
| shouldBeEqualToString("rects[4].height.toFixed(2)", "18.00"); |
| shouldBeEqualToString("rects[5].left.toFixed(2)", "8.00"); |
| shouldBeEqualToString("rects[5].top.toFixed(2)", "805.00"); |
| shouldBeEqualToString("rects[5].width.toFixed(2)", "375.90"); |
| shouldBeEqualToString("rects[5].height.toFixed(2)", "18.00"); |
| shouldBeEqualToString("rects[6].left.toFixed(2)", "8.00"); |
| shouldBeEqualToString("rects[6].top.toFixed(2)", "845.00"); |
| shouldBeEqualToString("rects[6].width.toFixed(2)", "67.98"); |
| shouldBeEqualToString("rects[6].height.toFixed(2)", "18.00"); |
| |
| // Test 5 - Should include rect of the img. |
| debug("Test 5"); |
| var range5 = document.createRange(); |
| range5.setStart(document.getElementById('test5').firstChild, 10); |
| range5.setEnd(document.getElementById('test5').lastChild, 50); |
| show(range5); |
| rects = range5.getClientRects(); |
| shouldBe("rects.length", "5"); |
| shouldBeEqualToString("rects[0].left.toFixed(2)", "81.00"); |
| shouldBeEqualToString("rects[0].top.toFixed(2)", "921.00"); |
| shouldBeEqualToString("rects[0].width.toFixed(2)", "313.58"); |
| shouldBeEqualToString("rects[0].height.toFixed(2)", "18.00"); |
| shouldBeEqualToString("rects[1].left.toFixed(2)", "8.00"); |
| shouldBeEqualToString("rects[1].top.toFixed(2)", "1039.00"); |
| shouldBeEqualToString("rects[1].width.toFixed(2)", "268.39"); |
| shouldBeEqualToString("rects[1].height.toFixed(2)", "18.00"); |
| shouldBeEqualToString("rects[2].left.toFixed(2)", "276.39"); |
| shouldBeEqualToString("rects[2].top.toFixed(2)", "950.00"); |
| shouldBeEqualToString("rects[2].width.toFixed(2)", "76.00"); |
| shouldBeEqualToString("rects[2].height.toFixed(2)", "103.00"); |
| shouldBeEqualToString("rects[3].left.toFixed(2)", "352.39"); |
| shouldBeEqualToString("rects[3].top.toFixed(2)", "1039.00"); |
| shouldBeEqualToString("rects[3].width.toFixed(2)", "44.88"); |
| shouldBeEqualToString("rects[3].height.toFixed(2)", "18.00"); |
| shouldBeEqualToString("rects[4].left.toFixed(2)", "8.00"); |
| shouldBeEqualToString("rects[4].top.toFixed(2)", "1079.00"); |
| shouldBeEqualToString("rects[4].width.toFixed(2)", "291.00"); |
| shouldBeEqualToString("rects[4].height.toFixed(2)", "18.00"); |
| |
| // Test 6 - Should not include green or blue boxes |
| debug("Test 6"); |
| var range6 = document.createRange(); |
| range6.selectNode(document.getElementById('test6')); |
| show(range6); |
| rects = range6.getClientRects(); |
| shouldBe("rects.length", "8"); |
| shouldBeEqualToString("rects[0].left.toFixed(2)", "8.00"); |
| shouldBeEqualToString("rects[0].top.toFixed(2)", "1224.00"); |
| shouldBeEqualToString("rects[0].width.toFixed(2)", "400.00"); |
| shouldBeEqualToString("rects[0].height.toFixed(2)", "240.00"); |
| shouldBeEqualToString("rects[1].left.toFixed(2)", "8.00"); |
| shouldBeEqualToString("rects[1].top.toFixed(2)", "1235.00"); |
| shouldBeEqualToString("rects[1].width.toFixed(2)", "386.58"); |
| shouldBeEqualToString("rects[1].height.toFixed(2)", "18.00"); |
| shouldBeEqualToString("rects[2].left.toFixed(2)", "8.00"); |
| shouldBeEqualToString("rects[2].top.toFixed(2)", "1275.00"); |
| shouldBeEqualToString("rects[2].width.toFixed(2)", "16.00"); |
| shouldBeEqualToString("rects[2].height.toFixed(2)", "18.00"); |
| shouldBeEqualToString("rects[3].left.toFixed(2)", "8.00"); |
| shouldBeEqualToString("rects[3].top.toFixed(2)", "1315.00"); |
| shouldBeEqualToString("rects[3].width.toFixed(2)", "58.22"); |
| shouldBeEqualToString("rects[3].height.toFixed(2)", "18.00"); |
| shouldBeEqualToString("rects[4].left.toFixed(2)", "106.22"); |
| shouldBeEqualToString("rects[4].top.toFixed(2)", "1315.00"); |
| shouldBeEqualToString("rects[4].width.toFixed(2)", "45.32"); |
| shouldBeEqualToString("rects[4].height.toFixed(2)", "18.00"); |
| shouldBeEqualToString("rects[5].left.toFixed(2)", "8.00"); |
| shouldBeEqualToString("rects[5].top.toFixed(2)", "1355.00"); |
| shouldBeEqualToString("rects[5].width.toFixed(2)", "396.34"); |
| shouldBeEqualToString("rects[5].height.toFixed(2)", "18.00"); |
| shouldBeEqualToString("rects[6].left.toFixed(2)", "8.00"); |
| shouldBeEqualToString("rects[6].top.toFixed(2)", "1395.00"); |
| shouldBeEqualToString("rects[6].width.toFixed(2)", "359.93"); |
| shouldBeEqualToString("rects[6].height.toFixed(2)", "18.00"); |
| shouldBeEqualToString("rects[7].left.toFixed(2)", "8.00"); |
| shouldBeEqualToString("rects[7].top.toFixed(2)", "1435.00"); |
| shouldBeEqualToString("rects[7].width.toFixed(2)", "221.71"); |
| shouldBeEqualToString("rects[7].height.toFixed(2)", "18.00"); |
| |
| // Test 7 - Should include green but not blue box |
| debug("Test 7"); |
| var range7 = document.createRange(); |
| range7.selectNodeContents(document.getElementById('test7')); |
| show(range7); |
| rects = range7.getClientRects(); |
| shouldBe("rects.length", "8"); |
| shouldBeEqualToString("rects[0].left.toFixed(2)", "8.00"); |
| shouldBeEqualToString("rects[0].top.toFixed(2)", "1511.00"); |
| shouldBeEqualToString("rects[0].width.toFixed(2)", "386.58"); |
| shouldBeEqualToString("rects[0].height.toFixed(2)", "18.00"); |
| shouldBeEqualToString("rects[1].left.toFixed(2)", "8.00"); |
| shouldBeEqualToString("rects[1].top.toFixed(2)", "1551.00"); |
| shouldBeEqualToString("rects[1].width.toFixed(2)", "16.00"); |
| shouldBeEqualToString("rects[1].height.toFixed(2)", "18.00"); |
| shouldBeEqualToString("rects[2].left.toFixed(2)", "8.00"); |
| shouldBeEqualToString("rects[2].top.toFixed(2)", "1580.00"); |
| shouldBeEqualToString("rects[2].width.toFixed(2)", "400.00"); |
| shouldBeEqualToString("rects[2].height.toFixed(2)", "40.00"); |
| shouldBeEqualToString("rects[3].left.toFixed(2)", "8.00"); |
| shouldBeEqualToString("rects[3].top.toFixed(2)", "1591.00"); |
| shouldBeEqualToString("rects[3].width.toFixed(2)", "58.22"); |
| shouldBeEqualToString("rects[3].height.toFixed(2)", "18.00"); |
| shouldBeEqualToString("rects[4].left.toFixed(2)", "106.22"); |
| shouldBeEqualToString("rects[4].top.toFixed(2)", "1591.00"); |
| shouldBeEqualToString("rects[4].width.toFixed(2)", "45.32"); |
| shouldBeEqualToString("rects[4].height.toFixed(2)", "18.00"); |
| shouldBeEqualToString("rects[5].left.toFixed(2)", "8.00"); |
| shouldBeEqualToString("rects[5].top.toFixed(2)", "1631.00"); |
| shouldBeEqualToString("rects[5].width.toFixed(2)", "396.34"); |
| shouldBeEqualToString("rects[5].height.toFixed(2)", "18.00"); |
| shouldBeEqualToString("rects[6].left.toFixed(2)", "8.00"); |
| shouldBeEqualToString("rects[6].top.toFixed(2)", "1671.00"); |
| shouldBeEqualToString("rects[6].width.toFixed(2)", "359.93"); |
| shouldBeEqualToString("rects[6].height.toFixed(2)", "18.00"); |
| shouldBeEqualToString("rects[7].left.toFixed(2)", "8.00"); |
| shouldBeEqualToString("rects[7].top.toFixed(2)", "1711.00"); |
| shouldBeEqualToString("rects[7].width.toFixed(2)", "221.71"); |
| shouldBeEqualToString("rects[7].height.toFixed(2)", "18.00"); |
| |
| // Test 8 |
| debug("Test 8"); |
| var range8 = document.createRange(); |
| range8.selectNodeContents(document.getElementById('test8')); |
| show(range8); |
| rects = range8.getClientRects(); |
| shouldBe("rects.length", "4"); |
| shouldBeEqualToString("rects[0].left.toFixed(2)", "168.51"); |
| shouldBeEqualToString("rects[0].top.toFixed(2)", "1758.44"); |
| shouldBeEqualToString("rects[0].width.toFixed(2)", "262.28"); |
| shouldBeEqualToString("rects[0].height.toFixed(2)", "307.71"); |
| shouldBeEqualToString("rects[1].left.toFixed(2)", "137.87"); |
| shouldBeEqualToString("rects[1].top.toFixed(2)", "1784.15"); |
| shouldBeEqualToString("rects[1].width.toFixed(2)", "245.14"); |
| shouldBeEqualToString("rects[1].height.toFixed(2)", "287.28"); |
| shouldBeEqualToString("rects[2].left.toFixed(2)", "107.23"); |
| shouldBeEqualToString("rects[2].top.toFixed(2)", "1809.86"); |
| shouldBeEqualToString("rects[2].width.toFixed(2)", "258.85"); |
| shouldBeEqualToString("rects[2].height.toFixed(2)", "303.62"); |
| shouldBeEqualToString("rects[3].left.toFixed(2)", "76.59"); |
| shouldBeEqualToString("rects[3].top.toFixed(2)", "1835.57"); |
| shouldBeEqualToString("rects[3].width.toFixed(2)", "250.57"); |
| shouldBeEqualToString("rects[3].height.toFixed(2)", "293.75"); |
| |
| debug("Test 9"); |
| var range9 = document.createRange(); |
| // This case should match test 9b's results. Currently though getClientRects returns an empty list. |
| range9.setStart(document.getElementById('test9'), 0); |
| show(range9); |
| rects = range9.getClientRects(); |
| shouldBe("rects.length", "0"); |
| |
| debug("Test 9b"); |
| var range9 = document.createRange(); |
| range9.setStart(document.getElementById('test9').firstChild, 0); |
| show(range9); |
| rects = range9.getClientRects(); |
| shouldBe("rects.length", "1"); |
| shouldBeEqualToString("rects[0].left.toFixed(2)", "8.00"); |
| shouldBeEqualToString("rects[0].top.toFixed(2)", "1983.00"); |
| shouldBeEqualToString("rects[0].width.toFixed(2)", "0.00"); |
| shouldBeEqualToString("rects[0].height.toFixed(2)", "18.00"); |
| |
| // Test 10 |
| debug("Test 10"); |
| var range10 = document.createRange(); |
| range10.selectNodeContents(document.getElementById('test10')); |
| show(range10); |
| rects = range10.getClientRects(); |
| shouldBe("rects.length", "5"); |
| shouldBeEqualToString("rects[0].left.toFixed(2)", "19.00"); |
| shouldBeEqualToString("rects[0].top.toFixed(2)", "2168.00"); |
| shouldBeEqualToString("rects[0].width.toFixed(2)", "18.00"); |
| shouldBeEqualToString("rects[0].height.toFixed(2)", "375.00"); |
| shouldBeEqualToString("rects[1].left.toFixed(2)", "59.00"); |
| shouldBeEqualToString("rects[1].top.toFixed(2)", "2168.00"); |
| shouldBeEqualToString("rects[1].width.toFixed(2)", "18.00"); |
| shouldBeEqualToString("rects[1].height.toFixed(2)", "367.03"); |
| shouldBeEqualToString("rects[2].left.toFixed(2)", "99.00"); |
| shouldBeEqualToString("rects[2].top.toFixed(2)", "2168.00"); |
| shouldBeEqualToString("rects[2].width.toFixed(2)", "18.00"); |
| shouldBeEqualToString("rects[2].height.toFixed(2)", "348.38"); |
| shouldBeEqualToString("rects[3].left.toFixed(2)", "139.00"); |
| shouldBeEqualToString("rects[3].top.toFixed(2)", "2168.00"); |
| shouldBeEqualToString("rects[3].width.toFixed(2)", "18.00"); |
| shouldBeEqualToString("rects[3].height.toFixed(2)", "375.90"); |
| shouldBeEqualToString("rects[4].left.toFixed(2)", "179.00"); |
| shouldBeEqualToString("rects[4].top.toFixed(2)", "2168.00"); |
| shouldBeEqualToString("rects[4].width.toFixed(2)", "18.00"); |
| shouldBeEqualToString("rects[4].height.toFixed(2)", "67.98"); |
| |
| // Test 11 |
| debug("Test 11"); |
| var range11 = document.createRange(); |
| range11.setStartBefore(document.getElementById('test11')); |
| range11.setEndAfter(document.getElementById('test11').firstChild); |
| show(range11); |
| rects = range11.getClientRects(); |
| shouldBe("rects.length", "2"); |
| shouldBeEqualToString("rects[0].left.toFixed(2)", "8.00"); |
| shouldBeEqualToString("rects[0].top.toFixed(2)", "2604.00"); |
| shouldBeEqualToString("rects[0].width.toFixed(2)", "400.00"); |
| shouldBeEqualToString("rects[0].height.toFixed(2)", "40.00"); |
| shouldBeEqualToString("rects[1].left.toFixed(2)", "8.00"); |
| shouldBeEqualToString("rects[1].top.toFixed(2)", "2615.00"); |
| shouldBeEqualToString("rects[1].width.toFixed(2)", "181.75"); |
| shouldBeEqualToString("rects[1].height.toFixed(2)", "18.00"); |
| |
| // Test 12 |
| debug("Test 12"); |
| var range12 = document.createRange(); |
| range12.setStartBefore(document.getElementById('test12')); |
| range12.setEndBefore(document.getElementById('test12').firstChild); |
| show(range12); |
| rects = range12.getClientRects(); |
| shouldBe("rects.length", "1"); |
| shouldBeEqualToString("rects[0].left.toFixed(2)", "8.00"); |
| shouldBeEqualToString("rects[0].top.toFixed(2)", "2840.00"); |
| shouldBeEqualToString("rects[0].width.toFixed(2)", "400.00"); |
| shouldBeEqualToString("rects[0].height.toFixed(2)", "160.00"); |
| |
| // Test 13 |
| debug("Test 13"); |
| var range13 = document.createRange(); |
| range13.setStartBefore(document.getElementById('test13')); |
| range13.setEndAfter(document.getElementById('test13').firstChild); |
| show(range13); |
| rects = range13.getClientRects(); |
| shouldBe("rects.length", "4"); |
| shouldBeEqualToString("rects[0].left.toFixed(2)", "8.00"); |
| shouldBeEqualToString("rects[0].top.toFixed(2)", "3047.00"); |
| shouldBeEqualToString("rects[0].width.toFixed(2)", "386.58"); |
| shouldBeEqualToString("rects[0].height.toFixed(2)", "18.00"); |
| shouldBeEqualToString("rects[1].left.toFixed(2)", "8.00"); |
| shouldBeEqualToString("rects[1].top.toFixed(2)", "3087.00"); |
| shouldBeEqualToString("rects[1].width.toFixed(2)", "359.91"); |
| shouldBeEqualToString("rects[1].height.toFixed(2)", "18.00"); |
| shouldBeEqualToString("rects[2].left.toFixed(2)", "8.00"); |
| shouldBeEqualToString("rects[2].top.toFixed(2)", "3127.00"); |
| shouldBeEqualToString("rects[2].width.toFixed(2)", "381.25"); |
| shouldBeEqualToString("rects[2].height.toFixed(2)", "18.00"); |
| shouldBeEqualToString("rects[3].left.toFixed(2)", "8.00"); |
| shouldBeEqualToString("rects[3].top.toFixed(2)", "3167.00"); |
| shouldBeEqualToString("rects[3].width.toFixed(2)", "368.36"); |
| shouldBeEqualToString("rects[3].height.toFixed(2)", "18.00"); |
| |
| // Test 14 |
| debug("Test 14"); |
| var range14 = document.createRange(); |
| rects = range14.getClientRects(); |
| shouldBe("rects.length", "0"); |
| |
| if (window.testRunner) { |
| var area = document.getElementById('testArea'); |
| area.parentNode.removeChild(area); |
| } |
| </script> |
| <script src="../../../resources/js-test-post.js"></script> |