1 <html xmlns="http://www.w3.org/1999/xhtml">
4 <body style="margin:0; border:0; padding:0;" onload="runRepaintTest()">
6 <div style="width:500px;height=100px">
7 <svg xmlns="http://www.w3.org/2000/svg" version="1.1"
8 width="100px" height="100px">
9 <rect id="r1" x="20" y="30" width="40" height="50" fill="blue" />
10 </svg><svg xmlns="http://www.w3.org/2000/svg" version="1.1"
11 width="200px" height="100px" viewBox="0 0 50 200"
12 preserveAspectRatio="none">
13 <rect id="r2" x="20" y="30" width="40" height="50" fill="green" />
14 </svg><svg xmlns="http://www.w3.org/2000/svg" version="1.1"
15 width="200px" height="100px">
16 <svg x="0" y="0" width="100px" height="100px">
17 <rect id="r3" x="0" y="0" width="210px" height="50px" fill="yellow" overflow="hidden" />
18 <rect id="r4" x="0" y="50px" width="210px" height="60px" fill="orange" overflow="visible" />
23 <div id="description"></div>
24 <div id="console"></div>
27 function executeTest() {
28 description("This test checks getBoundingClientRect() on rectangles");
30 debug("Checking a rectangle of absolute size at absolute coordinates:");
31 r1 = document.getElementById("r1").getBoundingClientRect();
32 shouldBeEqualToString('r1.left.toFixed(2)', '20.00');
33 shouldBeEqualToString('r1.top.toFixed(2)', '30.00');
34 shouldBeEqualToString('r1.width.toFixed(2)', '40.00');
35 shouldBeEqualToString('r1.height.toFixed(2)', '50.00');
36 shouldBeEqualToString('r1.right.toFixed(2)', '60.00');
37 shouldBeEqualToString('r1.bottom.toFixed(2)', '80.00');
40 debug("Checking a resized rectangle at relative coordinates:");
41 r2 = document.getElementById("r2").getBoundingClientRect();
42 shouldBeEqualToString('r2.left.toFixed(2)', '180.00');
43 shouldBeEqualToString('r2.top.toFixed(2)', '15.00');
44 shouldBeEqualToString('r2.width.toFixed(2)', '160.00');
45 shouldBeEqualToString('r2.height.toFixed(2)', '25.00');
46 shouldBeEqualToString('r2.right.toFixed(2)', '340.00');
47 shouldBeEqualToString('r2.bottom.toFixed(2)', '40.00');
50 debug("Checking rectangles with overflow:");
51 r3 = document.getElementById("r3").getBoundingClientRect();
52 shouldBeEqualToString('r3.left.toFixed(2)', '300.00');
53 shouldBeEqualToString('r3.top.toFixed(2)', '0.00');
54 shouldBeEqualToString('r3.width.toFixed(2)', '210.00');
55 shouldBeEqualToString('r3.height.toFixed(2)', '50.00');
56 shouldBeEqualToString('r3.right.toFixed(2)', '510.00');
57 shouldBeEqualToString('r3.bottom.toFixed(2)', '50.00');
59 r4 = document.getElementById("r4").getBoundingClientRect();
60 shouldBeEqualToString('r4.left.toFixed(2)', '300.00');
61 shouldBeEqualToString('r4.top.toFixed(2)', '50.00');
62 shouldBeEqualToString('r4.width.toFixed(2)', '210.00');
63 shouldBeEqualToString('r4.height.toFixed(2)', '60.00');
64 shouldBeEqualToString('r4.right.toFixed(2)', '510.00');
65 shouldBeEqualToString('r4.bottom.toFixed(2)', '110.00');
71 if (window.layoutTestController) {
72 layoutTestController.waitUntilDone();
73 window.postZoomCallback = executeTest;
75 debug("This test only works in DRT.");
79 <script src="../../../fast/js/resources/js-test-pre.js"></script>
80 <script>var zoomCount = 2;</script>
81 <script src="../../../fast/repaint/resources/repaint.js"></script>
82 <script src="../resources/testPageZoom.js"></script>