Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
AX: incorrect accessible name from multiple label elements
https://bugs.webkit.org/show_bug.cgi?id=152663 rdar://problem/24033482 Reviewed by Chris Fleizach. Per https://www.w3.org/TR/html-aam-1.0/#input-type-text-input-type-password-input-type-number-input-type-search-input-type-tel-input-type-email-input-type-url-and-textarea-element-accessible-name-computation: > Otherwise use the associated label element(s) accessible name(s) - if more than one label is associated; concatenate by DOM order, delimited by spaces. Prior to this patch, we only used accessible text from the first associated label element. * LayoutTests/accessibility-isolated-tree/TestExpectations: * LayoutTests/accessibility/multiple-label-input-expected.txt: Added. * LayoutTests/accessibility/multiple-label-input.html: Added. * LayoutTests/accessibility/title-ui-element-correctness-expected.txt: * LayoutTests/accessibility/title-ui-element-correctness.html: * LayoutTests/platform/ios/accessibility/multiple-label-input-expected.txt: Added. * Source/WebCore/accessibility/AccessibilityNodeObject.cpp: (WebCore::labelForNode): (WebCore::AccessibilityNodeObject::checkboxOrRadioRect const): (WebCore::AccessibilityNodeObject::correspondingLabelForControlElement const): (WebCore::AccessibilityNodeObject::textForLabelElements const): (WebCore::AccessibilityNodeObject::titleElementText const): (WebCore::AccessibilityNodeObject::titleUIElement const): (WebCore::AccessibilityNodeObject::exposesTitleUIElement const): (WebCore::AccessibilityNodeObject::title const): (WebCore::AccessibilityNodeObject::labelForElement const): Deleted. (WebCore::AccessibilityNodeObject::textForLabelElement const): Deleted. * Source/WebCore/accessibility/AccessibilityNodeObject.h: * Source/WebCore/accessibility/cocoa/AccessibilityObjectCocoa.mm: (WebCore::AccessibilityObject::descriptionAttributeValue const): (WebCore::AccessibilityObject::helpTextAttributeValue const): * Source/WebCore/dom/TreeScope.cpp: (WebCore::TreeScope::labelElementForId): Deleted. * Source/WebCore/dom/TreeScope.h: * Source/WebCore/dom/TreeScopeOrderedMap.cpp: (WebCore:: const): (WebCore::TreeScopeOrderedMap::getElementByLabelForAttribute const): Deleted. * Source/WebCore/dom/TreeScopeOrderedMap.h: Canonical link: https://commits.webkit.org/266151@main
- Loading branch information
Showing
15 changed files
with
313 additions
and
144 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
19 changes: 19 additions & 0 deletions
19
LayoutTests/accessibility/multiple-label-input-expected.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
This test ensures that inputs with multiple labels have the correct accessibility text exposed. | ||
|
||
Initial AX text: | ||
AXTitle: Enter your color | ||
AXDescription: | ||
AXHelp: | ||
document.getElementById('label2').remove(); | ||
AXTitle: Enter color | ||
AXDescription: | ||
AXHelp: | ||
document.getElementById('label3').innerText = 'choice'; | ||
AXTitle: Enter choice | ||
AXDescription: | ||
AXHelp: | ||
|
||
PASS successfullyParsed is true | ||
|
||
TEST COMPLETE | ||
Enter choice |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN"> | ||
<html> | ||
<head> | ||
<script src="../resources/accessibility-helper.js"></script> | ||
<script src="../resources/js-test.js"></script> | ||
</head> | ||
<body> | ||
|
||
<input id="input" type="text"> | ||
<label for="input">Enter</label> | ||
<label id="label2" for="input">your</label> | ||
<label id="label3" for="input">color</label> | ||
|
||
<script> | ||
var output = "This test ensures that inputs with multiple labels have the correct accessibility text exposed.\n\n"; | ||
|
||
if (window.accessibilityController) { | ||
window.jsTestIsAsync = true; | ||
|
||
var input = accessibilityController.accessibleElementById("input"); | ||
output += `Initial AX text: \n${platformTextAlternatives(input)}\n`; | ||
|
||
output += evalAndReturn("document.getElementById('label2').remove();"); | ||
var newText; | ||
setTimeout(async function() { | ||
await waitFor(() => { | ||
newText = platformTextAlternatives(input); | ||
return !newText.includes("your"); | ||
}); | ||
output += `${newText}\n`; | ||
|
||
output += evalAndReturn("document.getElementById('label3').innerText = 'choice';"); | ||
await waitFor(() => { | ||
newText = platformTextAlternatives(input); | ||
return !newText.includes("color"); | ||
}); | ||
output += `${newText}\n`; | ||
|
||
debug(output); | ||
finishJSTest(); | ||
}, 0); | ||
} | ||
</script> | ||
</body> | ||
</html> | ||
|
35 changes: 19 additions & 16 deletions
35
LayoutTests/accessibility/title-ui-element-correctness-expected.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
16 changes: 16 additions & 0 deletions
16
LayoutTests/platform/glib/accessibility/multiple-label-input-expected.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
This test ensures that inputs with multiple labels have the correct accessibility text exposed. | ||
|
||
Initial AX text: | ||
AXTitle: Enter your color | ||
AXDescription: | ||
document.getElementById('label2').remove(); | ||
AXTitle: Enter color | ||
AXDescription: | ||
document.getElementById('label3').innerText = 'choice'; | ||
AXTitle: Enter choice | ||
AXDescription: | ||
|
||
PASS successfullyParsed is true | ||
|
||
TEST COMPLETE | ||
Enter choice |
26 changes: 26 additions & 0 deletions
26
LayoutTests/platform/glib/accessibility/title-ui-element-correctness-expected.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
This tests that titleUIElement works correctly even when things change dynamically. | ||
|
||
PASS: axElement('control1').titleUIElement().isEqual(axElement('label1')) === true | ||
PASS: axElement('control2').titleUIElement().isEqual(axElement('label2')) === true | ||
PASS: hasTitleUIElement(axElement('control3')) === false | ||
document.getElementById('label3').setAttribute('for', 'control3'); | ||
PASS: axElement('control3').titleUIElement().isEqual(axElement('label3')) === true | ||
label4Element = createLabelWithIdAndForAttribute('label4', 'control4'); | ||
PASS: hasTitleUIElement(axElement('control4')) === false | ||
document.getElementById('container').appendChild(label4Element); | ||
PASS: hasTitleUIElement(axElement('control4')) === true | ||
PASS: axElement('control4').titleUIElement().isEqual(axElement('label4')) === true | ||
label4Element.parentElement.removeChild(label4Element); | ||
PASS: hasTitleUIElement(axElement('control4')) === false | ||
PASS: hasTitleUIElement(axElement('control5')) === false | ||
reparentNodeIntoContainer(document.getElementById('control5'), document.getElementById('label5')); | ||
PASS: axElement('control5').titleUIElement() != null === true | ||
PASS: axElement('control5').titleUIElement().isEqual(axElement('label5')) === true | ||
PASS: hasTitleUIElement(axElement('control6')) === true | ||
document.getElementById('label6c').remove() | ||
PASS: axElement('control6').titleUIElement().isEqual(axElement('label6b')) === true | ||
|
||
PASS successfullyParsed is true | ||
|
||
TEST COMPLETE | ||
|
13 changes: 13 additions & 0 deletions
13
LayoutTests/platform/ios/accessibility/multiple-label-input-expected.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
This test ensures that inputs with multiple labels have the correct accessibility text exposed. | ||
|
||
Initial AX text: | ||
AXLabel: Enter your color | ||
document.getElementById('label2').remove(); | ||
AXLabel: Enter color | ||
document.getElementById('label3').innerText = 'choice'; | ||
AXLabel: Enter choice | ||
|
||
PASS successfullyParsed is true | ||
|
||
TEST COMPLETE | ||
Enter choice |
Oops, something went wrong.