blob: 8d382a5f66f4796951d3040adcee0e96dcde14fa [file] [log] [blame]
<!DOCTYPE html>
<head>
<script src="../resources/js-test.js"></script>
</head>
<body>
<p id="description"></p>
<div style="border: 1px solid #000; height: 5000px;">5000-pixel box</div>
<iframe id="frame" src="data:text/html,
<body>
<style>button { border: 0; }</style>
<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>
</body>"></iframe>
<div style="border: 1px solid #000; height: 5000px;">5000-pixel box</div>
<div id="console"></div>
<script>
description("Tests that scrolling to move an element to a specific point successfully scrolls an iframe.");
window.jsTestIsAsync = true;
function runTest() {
window.frame = document.getElementById("frame");
window.frameWindow = frame.contentWindow;
window.frameDoc = frameWindow.document;
window.target = frameDoc.getElementById("target");
var targetAccessibleObject;
if (window.accessibilityController) {
target.focus();
targetAccessibleObject = accessibilityController.focusedElement;
}
// Reset the initial scroll position (since calling focus() can scroll the page too).
window.scrollTo(0, 0);
frameWindow.scrollTo(0, 0);
shouldBeZero("window.pageYOffset");
shouldBeZero("frameWindow.pageYOffset");
// 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();
}
window.addEventListener("load", function() {
setTimeout(runTest, 0);
}, false);
</script>
</body>
</html>