haikuwebkit/LayoutTests/accessibility/scroll-to-make-visible-nest...

74 lines
2.6 KiB
HTML
Raw Permalink Normal View History

AX: When navigating the elements of a scrollable element with VoiceOver, the scrollTop() position of the element does not permanently change https://bugs.webkit.org/show_bug.cgi?id=125720 Reviewed by Daniel Bates. Source/WebCore: The scrollToVisible code did not account for scrollable elements that are larger than their viewports. First, we need to pass the sub-focus up the scroll chain (otherwise we'll scroll some parent to y=0). Second, we should try to center the focus within the viewport, rather than positioning at the bottom for a better experience. This change was adapted from Blink r183926: https://src.chromium.org/viewvc/blink?view=rev&revision=183926 Tests: accessibility/scroll-to-global-point-iframe-nested.html accessibility/scroll-to-global-point-iframe.html accessibility/scroll-to-global-point-main-window.html accessibility/scroll-to-global-point-nested.html accessibility/scroll-to-make-visible-div-overflow.html accessibility/scroll-to-make-visible-iframe.html accessibility/scroll-to-make-visible-nested-2.html accessibility/scroll-to-make-visible-nested.html accessibility/scroll-to-make-visible-with-subfocus.html * accessibility/AccessibilityObject.cpp: (WebCore::computeBestScrollOffset): (WebCore::AccessibilityObject::isOnscreen): (WebCore::AccessibilityObject::scrollToMakeVisibleWithSubFocus): (WebCore::AccessibilityObject::scrollToGlobalPoint): * accessibility/mac/WebAccessibilityObjectWrapperMac.mm: (-[WebAccessibilityObjectWrapper accessibilityScrollToVisible]): (-[WebAccessibilityObjectWrapper _accessibilityScrollToMakeVisibleWithSubFocus:]): (-[WebAccessibilityObjectWrapper _accessibilityScrollToGlobalPoint:]): (-[WebAccessibilityObjectWrapper accessibilityPerformAction:]): Tools: Add support for scrollToMakeVisibleWithSubFocus and scrollToGlobalPoint. * DumpRenderTree/AccessibilityUIElement.cpp: (pressCallback): (scrollToMakeVisibleWithSubFocusCallback): (scrollToGlobalPointCallback): (scrollToMakeVisibleCallback): (AccessibilityUIElement::getJSClass): * DumpRenderTree/ios/AccessibilityUIElementIOS.mm: (AccessibilityUIElement::scrollToMakeVisible): (AccessibilityUIElement::scrollToMakeVisibleWithSubFocus): (AccessibilityUIElement::scrollToGlobalPoint): (AccessibilityUIElement::selectedTextRange): * DumpRenderTree/mac/AccessibilityUIElementMac.mm: (AccessibilityUIElement::AccessibilityUIElement): (AccessibilityUIElement::mathPrescriptsDescription): (AccessibilityUIElement::scrollToMakeVisible): (AccessibilityUIElement::scrollToMakeVisibleWithSubFocus): (AccessibilityUIElement::scrollToGlobalPoint): * WebKitTestRunner/InjectedBundle/AccessibilityUIElement.cpp: (WTR::AccessibilityUIElement::isTextMarkerValid): (WTR::AccessibilityUIElement::textMarkerForIndex): (WTR::AccessibilityUIElement::scrollToMakeVisible): (WTR::AccessibilityUIElement::scrollToGlobalPoint): (WTR::AccessibilityUIElement::scrollToMakeVisibleWithSubFocus): (WTR::AccessibilityUIElement::supportedActions): (WTR::AccessibilityUIElement::mathPostscriptsDescription): (WTR::AccessibilityUIElement::mathPrescriptsDescription): * WebKitTestRunner/InjectedBundle/AccessibilityUIElement.h: * WebKitTestRunner/InjectedBundle/Bindings/AccessibilityUIElement.idl: * WebKitTestRunner/InjectedBundle/ios/AccessibilityUIElementIOS.mm: (WTR::AccessibilityUIElement::scrollToMakeVisible): (WTR::AccessibilityUIElement::scrollToGlobalPoint): (WTR::AccessibilityUIElement::scrollToMakeVisibleWithSubFocus): (WTR::AccessibilityUIElement::selectedTextRange): * WebKitTestRunner/InjectedBundle/mac/AccessibilityUIElementMac.mm: (WTR::AccessibilityUIElement::scrollToMakeVisible): (WTR::AccessibilityUIElement::scrollToGlobalPoint): (WTR::AccessibilityUIElement::scrollToMakeVisibleWithSubFocus): (WTR::AccessibilityUIElement::selectedTextRange): LayoutTests: * accessibility/scroll-to-global-point-iframe-expected.txt: Added. * accessibility/scroll-to-global-point-iframe-nested-expected.txt: Added. * accessibility/scroll-to-global-point-iframe-nested.html: Added. * accessibility/scroll-to-global-point-iframe.html: Added. * accessibility/scroll-to-global-point-main-window-expected.txt: Added. * accessibility/scroll-to-global-point-main-window.html: Added. * accessibility/scroll-to-global-point-nested-expected.txt: Added. * accessibility/scroll-to-global-point-nested.html: Added. * accessibility/scroll-to-make-visible-div-overflow-expected.txt: Added. * accessibility/scroll-to-make-visible-div-overflow.html: Added. * accessibility/scroll-to-make-visible-iframe-expected.txt: Added. * accessibility/scroll-to-make-visible-iframe.html: Added. * accessibility/scroll-to-make-visible-nested-2-expected.txt: Added. * accessibility/scroll-to-make-visible-nested-2.html: Added. * accessibility/scroll-to-make-visible-nested-expected.txt: Added. * accessibility/scroll-to-make-visible-nested.html: Added. * accessibility/scroll-to-make-visible-with-subfocus-expected.txt: Added. * accessibility/scroll-to-make-visible-with-subfocus.html: Added. Canonical link: https://commits.webkit.org/166727@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@189149 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2015-08-29 07:41:46 +00:00
<!DOCTYPE html>
<head>
<script src="../resources/js-test.js"></script>
</head>
<body>
<p id="description"></p>
<div id="container" style="width: 100px; overflow: scroll">
<div style="border: 1px solid #000; width: 1000px; height: 5000px;">5000-pixel box</div>
<button id="target1">Target</button>
<button id="target2">Target</button>
<button id="target3">Target</button>
<div style="border: 1px solid #000; width: 1000px; height: 5000px;">5000-pixel box</div>
</div>
<div id="console"></div>
<script>
description("Tests that scrolling to make an element visible works when the inner scroll container doesn't need to be scrolled, but the other one does.");
function runTest() {
window.container = document.getElementById("container");
window.target1 = document.getElementById("target1");
window.target2 = document.getElementById("target2");
window.target3 = document.getElementById("target3");
var target1AccessibleObject;
var target2AccessibleObject;
var target3AccessibleObject;
if (window.accessibilityController) {
target1.focus();
target1AccessibleObject = accessibilityController.focusedElement;
target2.focus();
target2AccessibleObject = accessibilityController.focusedElement;
target3.focus();
target3AccessibleObject = accessibilityController.focusedElement;
}
// Reset the initial scroll positions (since calling focus() can scroll the page too).
window.scrollTo(0, 0);
container.scrollTop = 0;
shouldBeZero("window.pageYOffset");
shouldBeZero("container.scrollTop");
shouldBeGreaterThanOrEqual("target1.getBoundingClientRect().top", "5000");
// Scroll to make the middle target visible.
if (window.accessibilityController)
target2AccessibleObject.scrollToMakeVisible();
// Instead of testing the exact scroll offsets of the two containers, just test that
// the new absolute position of the target is on-screen.
shouldBeGreaterThanOrEqual("window.innerHeight", "target2.getBoundingClientRect().bottom");
// Make sure that calling scrollToMakeVisible on target1 and target3 don't result in any
// scrolling, because they should already be within the viewport.
window.target2top = target2.getBoundingClientRect().top;
if (window.accessibilityController)
target1AccessibleObject.scrollToMakeVisible();
shouldBe("target2top", "target2.getBoundingClientRect().top");
if (window.accessibilityController)
target3AccessibleObject.scrollToMakeVisible();
shouldBe("target2top", "target2.getBoundingClientRect().top");
finishJSTest();
}
runTest();
</script>
</body>
</html>