3 <script src=
"../resources/js-test.js"></script>
7 <p id=
"description"></p>
9 <div style=
"border: 1px solid #000; height: 5000px;">5000-pixel box
</div>
10 <button id=
"target" style=
"height: 5000px;">Target
</button>
12 <div id=
"console"></div>
15 description("Tests that scrolling to make a certain region within an element visible successfully scrolls the main window.");
18 var target
= document
.getElementById("target");
20 if (window
.accessibilityController
) {
22 var targetAccessibleObject
= accessibilityController
.focusedElement
;
25 // Reset the initial scroll position (since calling focus() can scroll the page too).
26 window
.scrollTo(0, 0);
27 shouldBe("window.pageYOffset", "0");
29 // Scroll to make the midpoint of the target visible and check.
30 if (window
.accessibilityController
)
31 targetAccessibleObject
.scrollToMakeVisibleWithSubFocus(0, 2500, 100, 2600);
32 window
.minYOffset
= target
.offsetTop
+ 2500 - window
.innerHeight
;
33 window
.maxYOffset
= target
.offsetTop
+ 2500;
34 shouldBe("window.pageYOffset >= minYOffset", "true");
35 shouldBe("window.pageYOffset <= maxYOffset", "true");