blob: 9fc30b797ec8cf68281bf2d8aedba3fe51558871 [file] [log] [blame]
<!DOCTYPE html>
<head>
<script src="../resources/js-test.js"></script>
<style>
button {
border: 0;
}
</style>
</head>
<body>
<p id="description"></p>
<div style="border: 1px solid #000; height: 5000px;">5000-pixel box</div>
<div id="outer_container" style="height: 100px; overflow: scroll">
<div style="border: 1px solid #000; height: 5000px;">5000-pixel box</div>
<div id="inner_container" style="height: 100px; overflow: scroll">
<div style="border: 1px solid #000; height: 5000px;">5000-pixel box</div>
<button id="target">Target</button>
<div style="border: 1px solid #000; height: 5000px;">5000-pixel box</div>
</div>
<div style="border: 1px solid #000; height: 5000px;">5000-pixel box</div>
</div>
<div style="border: 1px solid #000; height: 5000px;">5000-pixel box</div>
<div id="console"></div>
<script>
description("Tests that scrolling an element to a specific point can successfully scroll multiple nested scrolling views'.");
function runTest() {
window.outerContainer = document.getElementById("outer_container");
window.innerContainer = document.getElementById("inner_container");
window.target = document.getElementById("target");
var targetAccessibleObject;
if (window.accessibilityController) {
target.focus();
targetAccessibleObject = accessibilityController.focusedElement;
}
// Reset the initial scroll positions (since calling focus() can scroll the page too).
window.scrollTo(0, 0);
outerContainer.scrollTop = 0;
innerContainer.scrollTop = 0;
shouldBeZero("window.pageYOffset");
shouldBeZero("outerContainer.scrollTop");
shouldBeZero("innerContainer.scrollTop");
shouldBeGreaterThanOrEqual("target.getBoundingClientRect().top", "15000");
// Scroll to various locations and check.
if (window.accessibilityController)
targetAccessibleObject.scrollToGlobalPoint(0, 0);
shouldBeZero("target.getBoundingClientRect().top");
if (window.accessibilityController)
targetAccessibleObject.scrollToGlobalPoint(0, 300);
shouldBe("target.getBoundingClientRect().top", "300");
if (window.accessibilityController)
targetAccessibleObject.scrollToGlobalPoint(0, 3000);
shouldBe("target.getBoundingClientRect().top", "3000");
finishJSTest();
}
runTest();
</script>
</body>
</html>