blob: 7bbfb8260bf3399cb949d9d839476ce19a2ee0f2 [file] [log] [blame] [edit]
<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
<html>
<head>
<script src="../resources/accessibility-helper.js"></script>
<script src="../resources/js-test.js"></script>
<style>
button { border: 0; }
</style>
</head>
<body>
<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>
<script>
var output = "Tests that scrolling an element to a specific point can successfully scroll multiple nested scrolling views\n\n";
if (window.accessibilityController) {
window.jsTestIsAsync = true;
window.outerContainer = document.getElementById("outer_container");
window.innerContainer = document.getElementById("inner_container");
window.target = document.getElementById("target");
var targetAccessibleObject;
target.focus();
setTimeout(async function() {
await waitFor(() => {
targetAccessibleObject = accessibilityController.focusedElement;
return targetAccessibleObject && targetAccessibleObject.domIdentifier === "target";
});
// Reset the initial scroll positions (since calling focus() can scroll the page too).
window.scrollTo(0, 0);
outerContainer.scrollTop = 0;
innerContainer.scrollTop = 0;
output += expect("window.pageYOffset", "0");
output += expect("outerContainer.scrollTop", "0");
output += expect("innerContainer.scrollTop", "0");
output += expect("target.getBoundingClientRect().top >= 15000", "true");
// Scroll to various locations and check.
targetAccessibleObject.scrollToGlobalPoint(0, 0);
output += await expectAsync("target.getBoundingClientRect().top", "0");
targetAccessibleObject.scrollToGlobalPoint(0, 300);
output += await expectAsync("target.getBoundingClientRect().top", "300");
targetAccessibleObject.scrollToGlobalPoint(0, 3000);
output += await expectAsync("target.getBoundingClientRect().top", "3000");
debug(output);
finishJSTest();
}, 0);
}
</script>
</body>
</html>