| OLD | NEW |
| 1 <!DOCTYPE html> | 1 <!DOCTYPE html> |
| 2 <div style="width: 1600px; height:100px; background-color: red;"></div> | 2 <div style="width: 1600px; height:100px; background-color: red;"></div> |
| 3 <iframe id="iframe" style="width:820px; height:820px;" | 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; t
op: 400px;'> <input id='textbox' type='text'></div></div></body>"></iframe> | 4 src="data:text/html,<body><div style='position: relative; width: 800px; height
: 800px; background-color: green;'><div style='position:absolute; left: 400px; t
op: 400px;'> <input id='textbox' type='text'></div></div></body>"></iframe> |
| 5 | 5 |
| 6 <div id="console"></div> | 6 <div id="console"></div> |
| 7 | 7 |
| 8 <script src="../../resources/js-test.js"></script> | 8 <script src="../../resources/js-test.js"></script> |
| 9 <script> | 9 <script> |
| 10 description('Tests that scrolling to rect works for an element inside an ifram
e.'); | 10 description('Tests that scrolling to rect works for an element inside an ifram
e.'); |
| 11 | 11 |
| 12 window.jsTestIsAsync = true; | 12 window.jsTestIsAsync = true; |
| 13 if (window.testRunner) | 13 if (window.testRunner) |
| 14 testRunner.waitUntilDone(); | 14 testRunner.waitUntilDone(); |
| 15 | 15 |
| 16 onload = function() { | 16 onload = function() { |
| 17 var iframe = document.getElementById('iframe'); | 17 var iframe = document.getElementById('iframe'); |
| 18 var frameDoc = iframe.contentWindow.document; | 18 var frameDoc = iframe.contentWindow.document; |
| 19 var box = frameDoc.getElementById('textbox'); | 19 var box = frameDoc.getElementById('textbox'); |
| 20 | 20 |
| 21 if (window.internals) { | 21 if (window.internals) { |
| 22 window.internals.scrollElementToRect(box, 0, 100, 300, 300); | 22 window.internals.scrollElementToRect(box, 0, 100, 300, 300); |
| 23 window.internals.scrollElementToRect(box, 0, 0, 300, 300); | 23 window.internals.scrollElementToRect(box, 0, 0, 300, 300); |
| 24 debug('Scrolled element to rect.'); | 24 debug('Scrolled element to rect.'); |
| 25 } else { | 25 } else { |
| 26 debug('This test requires window.internals API to be available.'); | 26 debug('This test requires window.internals API to be available.'); |
| 27 } | 27 } |
| 28 | 28 |
| 29 window.rect = window.internals.boundsInRootViewSpace(box); | 29 window.rect = window.internals.boundsInViewportSpace(box); |
| 30 window.computedLeft = Math.floor((300 - rect.width) / 2); | 30 window.computedLeft = Math.floor((300 - rect.width) / 2); |
| 31 window.computedTop = Math.floor((300 - rect.height) / 2); | 31 window.computedTop = Math.floor((300 - rect.height) / 2); |
| 32 shouldBe('rect.left', 'computedLeft'); | 32 shouldBe('rect.left', 'computedLeft'); |
| 33 shouldBe('rect.top', 'computedTop'); | 33 shouldBe('rect.top', 'computedTop'); |
| 34 | 34 |
| 35 finishJSTest(); | 35 finishJSTest(); |
| 36 }; | 36 }; |
| 37 </script> | 37 </script> |
| OLD | NEW |