66 lines
2.2 KiB
HTML
66 lines
2.2 KiB
HTML
<!DOCTYPE html>
|
|
<head>
|
|
<script src="../resources/js-test.js"></script>
|
|
</head>
|
|
<body>
|
|
|
|
<p id="description"></p>
|
|
|
|
<iframe id="frame" src="data:text/html,<body><button id='upper_target'>Upper Target</button><div style='border: 1px solid %23000; height: 5000px;'>5000-pixel box</div><button id='lower_target'>Lower Target</button></body>"></iframe>
|
|
|
|
<div id="console"></div>
|
|
|
|
<script>
|
|
description("Tests that scrolling to make an element visible successfully scrolls an iframe.");
|
|
|
|
window.jsTestIsAsync = true;
|
|
|
|
function runTest() {
|
|
window.frame = document.getElementById("frame");
|
|
window.frameWindow = frame.contentWindow;
|
|
window.frameDoc = frameWindow.document;
|
|
|
|
var upperTarget = frameDoc.getElementById("upper_target");
|
|
var lowerTarget = frameDoc.getElementById("lower_target");
|
|
|
|
var lowerTargetAccessibleObject;
|
|
var upperTargetAccessibleObject;
|
|
if (window.accessibilityController) {
|
|
lowerTarget.focus();
|
|
lowerTargetAccessibleObject = accessibilityController.focusedElement;
|
|
upperTarget.focus();
|
|
upperTargetAccessibleObject = accessibilityController.focusedElement;
|
|
}
|
|
|
|
// Reset the initial scroll position (since calling focus() can scroll the page too).
|
|
frameWindow.scrollTo(0, 0);
|
|
shouldBeZero("frameWindow.pageYOffset");
|
|
|
|
// Scroll to make lower target visible and check.
|
|
if (window.accessibilityController)
|
|
lowerTargetAccessibleObject.scrollToMakeVisible();
|
|
window.minYOffset = lowerTarget.offsetTop + lowerTarget.offsetHeight - frameWindow.innerHeight;
|
|
window.maxYOffset = lowerTarget.offsetTop;
|
|
shouldBeTrue("frameWindow.pageYOffset >= minYOffset");
|
|
shouldBeTrue("frameWindow.pageYOffset <= maxYOffset");
|
|
|
|
// Scroll to make upper target visible and check.
|
|
if (window.accessibilityController)
|
|
upperTargetAccessibleObject.scrollToMakeVisible();
|
|
window.minYOffset = upperTarget.offsetTop + upperTarget.offsetHeight - frameWindow.innerHeight;
|
|
window.maxYOffset = upperTarget.offsetTop;
|
|
shouldBeTrue("frameWindow.pageYOffset >= minYOffset");
|
|
shouldBeTrue("frameWindow.pageYOffset <= maxYOffset");
|
|
|
|
finishJSTest();
|
|
}
|
|
|
|
window.addEventListener("load", function() {
|
|
setTimeout(runTest, 0);
|
|
}, false);
|
|
|
|
</script>
|
|
|
|
</body>
|
|
</html>
|