| <script src="../resources/js-test.js"></script> |
| <div style="border: 1px solid #000; height: 5000px;">5000-pixel box</div> |
| <button id="target" style="height: 5000px;">Target</button> |
| description("Tests that scrolling to make a certain region within an element visible successfully scrolls the main window."); |
| var target = document.getElementById("target"); |
| var targetAccessibleObject; |
| if (window.accessibilityController) { |
| internals.updateLayoutIgnorePendingStylesheetsAndRunPostLayoutTasks(); |
| targetAccessibleObject = accessibilityController.focusedElement; |
| // Reset the initial scroll position (since calling focus() can scroll the page too). |
| shouldBeZero("window.pageYOffset"); |
| // Scroll to make the midpoint of the target visible and check. |
| if (window.accessibilityController) |
| targetAccessibleObject.scrollToMakeVisibleWithSubFocus(0, 2500, 100, 2600); |
| window.minYOffset = target.offsetTop + 2500 - window.innerHeight; |
| window.maxYOffset = target.offsetTop + 2500; |
| shouldBeTrue("window.pageYOffset >= minYOffset"); |
| shouldBeTrue("window.pageYOffset <= maxYOffset"); |