Bug 152663

Summary: AX: incorrect accessible name from multiple label elements
Product: WebKit Reporter: Zoë Bijl <webkit>
Component: AccessibilityAssignee: Tyler Wilcock <tyler_w>
Status: RESOLVED FIXED    
Severity: Normal CC: aboxhall, andresg_22, apinheiro, cdumez, cfleizach, dmazzoni, esprehn+autocc, ews-watchlist, giacomo.petri, jcraig, jdiggs, kangil.han, samuel_white, thibaudcolas, tyler_w, webkit-bug-importer
Priority: P2 Keywords: InRadar
Version: WebKit Nightly Build   
Hardware: All   
OS: All   
Attachments:
Description Flags
Error message mechanism with multiple labels
none
Patch
ews-feeder: commit-queue-
Patch none

Description Zoë Bijl 2016-01-03 08:39:35 PST
Created attachment 268138 [details]
Error message mechanism with multiple labels

When multiple <label> elements are associated with a label-able element, the accessible name should be the product of the text content of each of the labels concatenated by DOM source order and space separated.

Expected result:
All associated label elements are used, in DOM order, for name calculation.

Actual result:
Only the first associated label element that is encountered in the DOM is used for name calculation.

Code example courtesy of Steve Faulkner.
Comment 1 Radar WebKit Bug Importer 2016-01-03 08:39:46 PST
<rdar://problem/24033482>
Comment 2 Thibaud Colas 2021-06-16 01:28:28 PDT
The report is pretty clear as it is but I’ve had to discover and research this bug myself so adding the details here.

Relevant specification on accessible name computation: https://www.w3.org/TR/html-aam-1.0/#input-type-text-input-type-password-input-type-search-input-type-tel-input-type-url-and-textarea-element

Extract (matching what Zoë has reported):

> Otherwise use the associated label element(s) accessible name(s) - if more than one label is associated; concatenate by DOM order, delimited by spaces.

Real-world example of this bug if it helps: https://github.com/django/django/pull/14389, https://code.djangoproject.com/ticket/32338
Comment 3 Tyler Wilcock 2023-07-15 15:52:59 PDT
*** Bug 254812 has been marked as a duplicate of this bug. ***
Comment 4 Tyler Wilcock 2023-07-15 15:57:25 PDT
Created attachment 467052 [details]
Patch
Comment 5 Tyler Wilcock 2023-07-15 18:36:03 PDT
Created attachment 467053 [details]
Patch
Comment 6 chris fleizach 2023-07-18 14:19:45 PDT
Comment on attachment 467053 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=467053&action=review

> Source/WebCore/accessibility/AccessibilityNodeObject.cpp:248
> +    return labels.isEmpty() ? nullptr : labels.first();

does labels.first() return nil if it's empty anyway? or does it crash
Comment 7 Tyler Wilcock 2023-07-18 14:25:11 PDT
(In reply to chris fleizach from comment #6)
> Comment on attachment 467053 [details]
> Patch
> 
> View in context:
> https://bugs.webkit.org/attachment.cgi?id=467053&action=review
> 
> > Source/WebCore/accessibility/AccessibilityNodeObject.cpp:248
> > +    return labels.isEmpty() ? nullptr : labels.first();
> 
> does labels.first() return nil if it's empty anyway? or does it crash
It would crash, as Vector::first() does an unchecked access into the vector.
Comment 8 EWS 2023-07-18 19:03:31 PDT
Committed 266151@main (3c4dcc0a6eb0): <https://commits.webkit.org/266151@main>

All reviewed patches have been landed. Closing bug and clearing flags on attachment 467053 [details].
Comment 9 Zoë Bijl 2023-07-19 07:12:59 PDT
Woohoo, thank you!