.: Refactor WebViewImpl::scrollFocusedNodeIntoRect to a better place and add tests
[WebKit-https.git] / LayoutTests / fast / dom / scroll-element-to-rect-centered.html
1 <html>
2   <head>
3     <body>
4       <div id="console"></div>
5       <div style="position: relative; width: 2400px; height: 2400px; background-color: white;">
6         <div style="position:fixed; left: 50px; top: 30px; width: 200px; height: 250px; background-color: green;"></div>
7         <div style="position:absolute; left: 600px; top: 800px;"> <input id="textbox" type="text"></div>
8       </div>
9     </body>
10     <script src="../js/resources/js-test-pre.js"></script>
11     <script>
12       if (window.internals) {
13         var box = document.getElementById('textbox');
14         window.internals.scrollElementToRect(box, 50, 30, 200, 250);
15       }
16       var rect = box.getBoundingClientRect();
17       var computedLeft = 50 + Math.floor((200 - rect.width) / 2);
18       var computedTop = 30 + Math.floor((250 - rect.height) / 2);
19       debug("Scrolled element to rect");
20       shouldBe("rect.left", "computedLeft");
21       shouldBe("rect.top", "computedTop");
22       if (window.layoutTestController) {
23         layoutTestController.dumpAsText();
24       }
25       successfullyParsed = true;
26     </script>
27     <script src="../js/resources/js-test-post.js"></script>
28     </script>
29   </head>
30 </html>