Merge Chromium + Blink git repositories
[chromium-blink-merge.git] / third_party / WebKit / LayoutTests / fast / dom / scroll-element-in-iframe-to-rect.html
blob58e7235e69ce4135a825675defc324c8b5ccad2f
1 <!DOCTYPE html>
2 <div style="width: 1600px; height:100px; background-color: red;"></div>
3 <iframe id="iframe" style="width:820px; height:820px;"
4 src="data:text/html,<body><div style='position: relative; width: 800px; height: 800px; background-color: green;'><div style='position:absolute; left: 400px; top: 400px;'> <input id='textbox' type='text'></div></div></body>"></iframe>
6 <div id="console"></div>
8 <script src="../../resources/js-test.js"></script>
9 <script>
10 description('Tests that scrolling to rect works for an element inside an iframe.');
12 window.jsTestIsAsync = true;
13 if (window.testRunner)
14 testRunner.waitUntilDone();
16 onload = function() {
17 var iframe = document.getElementById('iframe');
18 var frameDoc = iframe.contentWindow.document;
19 var box = frameDoc.getElementById('textbox');
21 if (window.internals) {
22 window.internals.scrollElementToRect(box, 0, 100, 300, 300);
23 window.internals.scrollElementToRect(box, 0, 0, 300, 300);
24 debug('Scrolled element to rect.');
25 } else {
26 debug('This test requires window.internals API to be available.');
29 window.rect = window.internals.boundsInViewportSpace(box);
30 window.computedLeft = Math.floor((300 - rect.width) / 2);
31 window.computedTop = Math.floor((300 - rect.height) / 2);
32 shouldBe('rect.left', 'computedLeft');
33 shouldBe('rect.top', 'computedTop');
35 finishJSTest();
37 </script>