haikuwebkit/LayoutTests/accessibility/text-alternative-calculatio...

82 lines
2.5 KiB
HTML
Raw Permalink Normal View History

AX: Listbox and Combobox roles embedded in labels should participate in name calculation https://bugs.webkit.org/show_bug.cgi?id=185521 Reviewed by Chris Fleizach. Source/WebCore: Take selected children into account when computing the name in accessibleNameForNode. Add ListBox to the roles for which accessibleNameDerivesFromContent returns false so that native select elements with size > 1 are treated the same way as ARIA listbox. Also add ListBox to the roles which are treated as controls when used in ARIA. Finally, prevent labels which contain unrelated controls from being used as an AXTitleUIElement. This causes us to build a string from the label and its descendants, ensuring the latter participate in the name calculation. Test: accessibility/text-alternative-calculation-from-listbox.html * accessibility/AccessibilityLabel.cpp: (WebCore::childrenContainUnrelatedControls): (WebCore::AccessibilityLabel::containsUnrelatedControls const): * accessibility/AccessibilityLabel.h: * accessibility/AccessibilityNodeObject.cpp: (WebCore::accessibleNameForNode): * accessibility/AccessibilityObject.cpp: (WebCore::AccessibilityObject::accessibleNameDerivesFromContent const): (WebCore::AccessibilityObject::isARIAControl): * accessibility/AccessibilityRenderObject.cpp: (WebCore::AccessibilityRenderObject::exposesTitleUIElement const): (WebCore::AccessibilityRenderObject::computeAccessibilityIsIgnored const): LayoutTests: * accessibility/label-with-pseudo-elements-expected.txt: Updated for new behavior. * accessibility/text-alternative-calculation-from-listbox-expected.txt: Added. * accessibility/text-alternative-calculation-from-listbox.html: Added. * platform/mac/accessibility/label-with-pseudo-elements-expected.txt: Updated for new behavior. * platform/win/accessibility/label-with-pseudo-elements-expected.txt: Updated for new behavior. Canonical link: https://commits.webkit.org/201099@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@231778 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2018-05-15 00:32:06 +00:00
<!DOCTYPE html>
<html>
<head>
<script src="../resources/js-test-pre.js"></script>
<script src="../resources/accessibility-helper.js"></script>
</head>
<body>
<div id="content">
<div>
<input type="checkbox" id="test1" />
<label for="test1" id="label1">Flash the screen
<ul role="listbox" style="list-style-type: none;">
<li role="option" aria-selected="false">1</li>
<li role="option" aria-selected="true">2</li>
<li role="option">3</li>
</ul>
times.
</label>
</div>
<div>
<input type="checkbox" id="test2" />
<label for="test2" id="label2">Flash the screen
<div role="combobox" id="combobox">
<div role="textbox" id="textbox"></div>
<ul role="listbox" id="listbox" style="list-style-type: none;">
<li role="option" id="option1" aria-selected="false">1</li>
<li role="option" id="option2" aria-selected="true">2</li>
<li role="option" id="option3">3</li>
</ul>
</div>
times.
</label>
</div>
<div>
<input type="checkbox" id="test3" />
<label for="test3" id="label3">Flash the screen
<select size="1">
<option>1</option>
<option selected>2</option>
<option>3</option>
</select>
times.
</label>
</div>
<div>
<input type="checkbox" id="test4" />
<label for="test4" id="label4">Flash the screen
<select size="3">
<option>1</option>
<option selected>2</option>
<option>3</option>
</select>
times.
</label>
</div>
</div>
<p id="description"></p>
<div id="console"></div>
<script>
description("This tests text alternative calculation from label with an embedded listbox.");
if (window.accessibilityController) {
for (var i = 1; i <= 4; i++) {
// Touching the accessibility tree prevents test flakiness in macOS.
// In particular, when this file is viewed with Accessibility Inspector,
// the AXTitle is displayed as expected for all four tests. But when we
// run this test as a layout test without first touching the accessibility
// tree, the AXTitle is often the empty string for most if not all tests.
var axLabel = accessibilityController.accessibleElementById("label" + i);
touchAccessibilityTree(axLabel);
var axElement = accessibilityController.accessibleElementById("test" + i);
debug("Test " + i + ": " + axElement.title);
}
document.getElementById("content").style.visibility = "hidden";
}
</script>
<script src="../resources/js-test-post.js"></script>
</body>
</html>