Skip to content

Commit

Permalink
AX: Fix for multiple issues concerning <label> elements containing in…
Browse files Browse the repository at this point in the history
…put elements.

https://bugs.webkit.org/show_bug.cgi?id=269607
<rdar://problem/123111075>

Reviewed by Tyler Wilcock.

This patch fixes ~20 test cases under:
    LayoutTests/imported/w3c/web-platform-tests/accname/name

We were failing to get the proper text for a <label> taht contains varios types of input fields, e.g., <label>some text<input type="text">more text</label>. This patch involves several fixes to obtain the proper stringValue for coboboxes, listboxes, list items, and an handling of the case described above in the method textAsLabelFor.

* LayoutTests/imported/w3c/web-platform-tests/accname/name/comp_embedded_control-expected.txt:
* LayoutTests/imported/w3c/web-platform-tests/accname/name/comp_host_language_label-expected.txt:
* LayoutTests/platform/ios/imported/w3c/web-platform-tests/accname/name/comp_host_language_label-expected.txt:
Changed the test cases from failing to passing.

* LayoutTests/platform/glib/imported/w3c/web-platform-tests/accname/name/comp_embedded_control-expected.txt: Added.
Added this file because the WPT tests that are now passing in COCOA are still failing in glib. This file is identical to the original expectation under the non-platform dir.

* LayoutTests/platform/ios-simulator/accessibility/changing-aria-hidden-with-display-none-parent-expected.txt:
* LayoutTests/platform/mac-ventura/imported/w3c/web-platform-tests/accname/name/comp_host_language_label-expected.txt:
Removed, no longer needed since now the output is identical to non-platform specific expectation.

* LayoutTests/platform/mac/accessibility/lists-expected.txt:
* Source/WebCore/accessibility/AccessibilityLabel.h:
* Source/WebCore/accessibility/AccessibilityNodeObject.cpp:
(WebCore::AccessibilityNodeObject::textAsLabelFor const):
(WebCore::AccessibilityNodeObject::textForLabelElements const):
(WebCore::appendNameToStringBuilder):
(WebCore::AccessibilityNodeObject::textUnderElement const):
(WebCore::AccessibilityNodeObject::stringValue const):
(WebCore::accessibleNameForNode):
(WebCore::AccessibilityNodeObject::accessibilityDescriptionForChildren const):
(WebCore::AccessibilityNodeObject::textAsLabel const): Renamed.
(WebCore::shouldAddSpaceBeforeAppendingNextElement): Deleted.
* Source/WebCore/accessibility/AccessibilityNodeObject.h:
* Source/WebCore/accessibility/AccessibilityRenderObject.cpp:
(WebCore::AccessibilityRenderObject::stringValue const):

Canonical link: https://commits.webkit.org/275180@main
  • Loading branch information
AndresGonzalezApple committed Feb 22, 2024
1 parent 5e5e744 commit 684b75a
Show file tree
Hide file tree
Showing 11 changed files with 171 additions and 182 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -33,30 +33,30 @@ Tests the #comp_embedded_control portions of the AccName Name Computation algori
Flash the screen 3.0 times


FAIL checkbox label with embedded textfield assert_equals: <input type="checkbox" data-expectedlabel="Flash the screen 3 times" data-testname="checkbox label with embedded textfield" class="ex"> expected "Flash the screen 3 times" but got "Flash the screen number of times times"
PASS checkbox label with embedded textfield
PASS label of embedded textfield inside checkbox label
FAIL checkbox label with embedded select:not([size]) assert_equals: <input type="checkbox" data-expectedlabel="Flash the screen 3 times" data-testname="checkbox label with embedded select:not([size])" class="ex"> expected "Flash the screen 3 times" but got "Flash the screen number of times times"
PASS checkbox label with embedded select:not([size])
PASS label of embedded select:not([size]) inside checkbox label
FAIL checkbox label with embedded select[size] assert_equals: <input type="checkbox" data-expectedlabel="Flash the screen 3 times" data-testname="checkbox label with embedded select[size]" class="ex"> expected "Flash the screen 3 times" but got "Flash the screen number of times times"
PASS checkbox label with embedded select[size]
PASS label of embedded select[size] inside checkbox label
FAIL checkbox label with embedded combobox (input[type=text]) assert_equals: <input type="checkbox" data-expectedlabel="Flash the screen 3 times" data-testname="checkbox label with embedded combobox (input[type=text])" class="ex"> expected "Flash the screen 3 times" but got "Flash the screen number of times times"
PASS checkbox label with embedded combobox (input[type=text])
PASS label of embedded combobox (input[type=text]) inside checkbox label
FAIL checkbox label with embedded combobox (span) assert_equals: <input type="checkbox" data-expectedlabel="Flash the screen 3 times" data-testname="checkbox label with embedded combobox (span)" class="ex"> expected "Flash the screen 3 times" but got "Flash the screen number of times times"
PASS checkbox label with embedded combobox (span)
PASS label of embedded combobox (span) inside checkbox label
FAIL checkbox label with embedded combobox (div) assert_equals: <input type="checkbox" data-expectedlabel="Flash the screen 3 times" data-testname="checkbox label with embedded combobox (div)" class="ex"> expected "Flash the screen 3 times" but got "Flash the screen number of times times"
PASS checkbox label with embedded combobox (div)
PASS label of embedded combobox (div) inside checkbox label
FAIL checkbox label with embedded listbox>option[aria-selected=true] assert_equals: <input type="checkbox" data-expectedlabel="Flash the screen 3 times" data-testname="checkbox label with embedded listbox>option[aria-selected=true]" class="ex"> expected "Flash the screen 3 times" but got "Flash the screen number of times times"
PASS checkbox label with embedded listbox>option[aria-selected=true]
PASS label of embedded listbox>option[aria-selected=true] inside checkbox label
FAIL checkbox label with embedded input[type=range] assert_equals: <input type="checkbox" data-expectedlabel="Flash the screen 3 times" data-testname="checkbox label with embedded input[type=range]" class="ex"> expected "Flash the screen 3 times" but got "Flash the screen number of times times"
PASS checkbox label with embedded input[type=range]
PASS label of embedded input[type=range] inside checkbox label
FAIL checkbox label with embedded input[type=number] assert_equals: <input type="checkbox" data-expectedlabel="Flash the screen 3 times" data-testname="checkbox label with embedded input[type=number]" class="ex"> expected "Flash the screen 3 times" but got "Flash the screen number of times times"
PASS checkbox label with embedded input[type=number]
PASS label of embedded input[type=number] inside checkbox label
FAIL checkbox label with embedded ARIA slider (aria-valuenow) assert_equals: <input type="checkbox" data-expectedlabel="Flash the screen 3 times" data-testname="checkbox label with embedded ARIA slider (aria-valuenow)" class="ex"> expected "Flash the screen 3 times" but got "Flash the screen number of times times"
PASS checkbox label with embedded ARIA slider (aria-valuenow)
PASS label of embedded ARIA slider (aria-valuenow) inside checkbox label
FAIL checkbox label with embedded ARIA slider (aria-valuetext) assert_equals: <input type="checkbox" data-expectedlabel="Flash the screen 3 times" data-testname="checkbox label with embedded ARIA slider (aria-valuetext)" class="ex"> expected "Flash the screen 3 times" but got "Flash the screen number of times times"
PASS checkbox label with embedded ARIA slider (aria-valuetext)
PASS label of embedded ARIA slider (aria-valuetext) inside checkbox label
FAIL checkbox label with embedded ARIA spinbutton (aria-valuenow) assert_equals: <input type="checkbox" data-expectedlabel="Flash the screen 3 times" data-testname="checkbox label with embedded ARIA spinbutton (aria-valuenow)" class="ex"> expected "Flash the screen 3 times" but got "Flash the screen number of times times"
PASS checkbox label with embedded ARIA spinbutton (aria-valuenow)
PASS label of embedded ARIA spinbutton (aria-valuenow) inside checkbox label
FAIL checkbox label with embedded ARIA spinbutton (aria-valuetext) assert_equals: <input type="checkbox" data-expectedlabel="Flash the screen 3 times" data-testname="checkbox label with embedded ARIA spinbutton (aria-valuetext)" class="ex"> expected "Flash the screen 3 times" but got "Flash the screen number of times times"
PASS checkbox label with embedded ARIA spinbutton (aria-valuetext)
PASS label of embedded ARIA spinbutton (aria-valuetext) inside checkbox label

Original file line number Diff line number Diff line change
Expand Up @@ -84,24 +84,22 @@ PASS html: label[for] input[type=url]
PASS html: label[for] input[type=week]
PASS html: label input[type=checkbox] encapsulation
PASS html: label input[type=color] encapsulation
FAIL html: label input[type=date] encapsulation assert_equals: <input type="date" data-expectedlabel="date label" data-testname="html: label input[type=date] encapsulation" class="ex"> expected "date label" but got "month / day / year date label"
FAIL html: label input[type=datetime-local] encapsulation assert_equals: <input type="datetime-local" data-expectedlabel="datetime-local label" data-testname="html: label input[type=datetime-local] encapsulation" class="ex"> expected "datetime-local label" but got "month / day / year , 12 : 30   PM datetime-local label"
PASS html: label input[type=date] encapsulation
PASS html: label input[type=datetime-local] encapsulation
PASS html: label input[type=email] encapsulation
FAIL html: label input[type=month] encapsulation assert_equals: <input type="month" data-expectedlabel="month label" data-testname="html: label input[type=month] encapsulation" class="ex"> expected "month label" but got "month / year month label"
PASS html: label input[type=month] encapsulation
PASS html: label input[type=number] encapsulation
PASS html: label input[type=password] encapsulation
PASS html: label input[type=radio] encapsulation
FAIL html: label input[type=range] encapsulation assert_equals: <input type="range" data-expectedlabel="range label" data-testname="html: label input[type=range] encapsulation" class="ex"> expected "range label" but got "50 range label"
FAIL html: label input[type=search] encapsulation assert_equals: <input type="search" data-expectedlabel="search label" data-testname="html: label input[type=search] encapsulation" class="ex"> expected "search label" but got "cancel search label"
PASS html: label input[type=range] encapsulation
PASS html: label input[type=search] encapsulation
PASS html: label input[type=tel] encapsulation
PASS html: label[for] input[type=text] encapsulation
FAIL html: label input[type=time] encapsulation assert_equals: <input type="time" data-expectedlabel="time label" data-testname="html: label input[type=time] encapsulation" class="ex"> expected "time label" but got "12 : 30   PM time label"
PASS html: label input[type=time] encapsulation
PASS html: label input[type=url] encapsulation
PASS html: label input[type=week] encapsulation
PASS html: select for/id
FAIL html: select encapsulation assert_equals: <select data-expectedlabel="select label" data-testname="html: select encapsulation" class="ex">
<option>foo</option>
</select> expected "select label" but got "select label foo"
PASS html: select encapsulation
PASS html: img[alt] (non-empty)
PASS html: picture > img[alt] (non-empty)
FAIL html: fieldset > legend assert_equals: <fieldset data-expectedlabel="fieldset legend label" data-testname="html: fieldset > legend" class="ex">
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
Tests the #comp_embedded_control portions of the AccName Name Computation algorithm.

Flash the screen times

Flash the screen times

Flash the screen times

Flash the screen times

Flash the screen 3 times

Flash the screen 3 times

Flash the screen
1
2
3
4
5
times

Flash the screen times

Flash the screen times

Flash the screen 3.0 times

Flash the screen 3.0 times

Flash the screen 3.0 times

Flash the screen 3.0 times


FAIL checkbox label with embedded textfield assert_equals: <input type="checkbox" data-expectedlabel="Flash the screen 3 times" data-testname="checkbox label with embedded textfield" class="ex"> expected "Flash the screen 3 times" but got "Flash the screen number of times times"
PASS label of embedded textfield inside checkbox label
FAIL checkbox label with embedded select:not([size]) assert_equals: <input type="checkbox" data-expectedlabel="Flash the screen 3 times" data-testname="checkbox label with embedded select:not([size])" class="ex"> expected "Flash the screen 3 times" but got "Flash the screen number of times times"
PASS label of embedded select:not([size]) inside checkbox label
FAIL checkbox label with embedded select[size] assert_equals: <input type="checkbox" data-expectedlabel="Flash the screen 3 times" data-testname="checkbox label with embedded select[size]" class="ex"> expected "Flash the screen 3 times" but got "Flash the screen number of times times"
PASS label of embedded select[size] inside checkbox label
FAIL checkbox label with embedded combobox (input[type=text]) assert_equals: <input type="checkbox" data-expectedlabel="Flash the screen 3 times" data-testname="checkbox label with embedded combobox (input[type=text])" class="ex"> expected "Flash the screen 3 times" but got "Flash the screen number of times times"
PASS label of embedded combobox (input[type=text]) inside checkbox label
FAIL checkbox label with embedded combobox (span) assert_equals: <input type="checkbox" data-expectedlabel="Flash the screen 3 times" data-testname="checkbox label with embedded combobox (span)" class="ex"> expected "Flash the screen 3 times" but got "Flash the screen number of times times"
PASS label of embedded combobox (span) inside checkbox label
FAIL checkbox label with embedded combobox (div) assert_equals: <input type="checkbox" data-expectedlabel="Flash the screen 3 times" data-testname="checkbox label with embedded combobox (div)" class="ex"> expected "Flash the screen 3 times" but got "Flash the screen number of times times"
PASS label of embedded combobox (div) inside checkbox label
FAIL checkbox label with embedded listbox>option[aria-selected=true] assert_equals: <input type="checkbox" data-expectedlabel="Flash the screen 3 times" data-testname="checkbox label with embedded listbox>option[aria-selected=true]" class="ex"> expected "Flash the screen 3 times" but got "Flash the screen number of times times"
PASS label of embedded listbox>option[aria-selected=true] inside checkbox label
FAIL checkbox label with embedded input[type=range] assert_equals: <input type="checkbox" data-expectedlabel="Flash the screen 3 times" data-testname="checkbox label with embedded input[type=range]" class="ex"> expected "Flash the screen 3 times" but got "Flash the screen number of times times"
PASS label of embedded input[type=range] inside checkbox label
FAIL checkbox label with embedded input[type=number] assert_equals: <input type="checkbox" data-expectedlabel="Flash the screen 3 times" data-testname="checkbox label with embedded input[type=number]" class="ex"> expected "Flash the screen 3 times" but got "Flash the screen number of times times"
PASS label of embedded input[type=number] inside checkbox label
FAIL checkbox label with embedded ARIA slider (aria-valuenow) assert_equals: <input type="checkbox" data-expectedlabel="Flash the screen 3 times" data-testname="checkbox label with embedded ARIA slider (aria-valuenow)" class="ex"> expected "Flash the screen 3 times" but got "Flash the screen number of times times"
PASS label of embedded ARIA slider (aria-valuenow) inside checkbox label
FAIL checkbox label with embedded ARIA slider (aria-valuetext) assert_equals: <input type="checkbox" data-expectedlabel="Flash the screen 3 times" data-testname="checkbox label with embedded ARIA slider (aria-valuetext)" class="ex"> expected "Flash the screen 3 times" but got "Flash the screen number of times times"
PASS label of embedded ARIA slider (aria-valuetext) inside checkbox label
FAIL checkbox label with embedded ARIA spinbutton (aria-valuenow) assert_equals: <input type="checkbox" data-expectedlabel="Flash the screen 3 times" data-testname="checkbox label with embedded ARIA spinbutton (aria-valuenow)" class="ex"> expected "Flash the screen 3 times" but got "Flash the screen number of times times"
PASS label of embedded ARIA spinbutton (aria-valuenow) inside checkbox label
FAIL checkbox label with embedded ARIA spinbutton (aria-valuetext) assert_equals: <input type="checkbox" data-expectedlabel="Flash the screen 3 times" data-testname="checkbox label with embedded ARIA spinbutton (aria-valuetext)" class="ex"> expected "Flash the screen 3 times" but got "Flash the screen number of times times"
PASS label of embedded ARIA spinbutton (aria-valuetext) inside checkbox label

Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@ This test ensures that we don't crash when removing an object from the AX tree w

ApplicationGroup AXTitle: AXLabel:
List AXTitle: AXLabel:
ListItem AXTitle: AXLabel:
ListItem AXTitle: One AXLabel: One
ListMarker AXTitle: • AXLabel: •
StaticText AXTitle: One AXLabel: One
ListItem AXTitle: AXLabel:
ListItem AXTitle: Two AXLabel: Two
ListMarker AXTitle: • AXLabel: •
StaticText AXTitle: Two AXLabel: Two
ListItem AXTitle: AXLabel:
ListItem AXTitle: Three AXLabel: Three
ListMarker AXTitle: • AXLabel: •
StaticText AXTitle: Three AXLabel: Three

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,17 +91,15 @@ PASS html: label input[type=month] encapsulation
PASS html: label input[type=number] encapsulation
PASS html: label input[type=password] encapsulation
PASS html: label input[type=radio] encapsulation
FAIL html: label input[type=range] encapsulation assert_equals: <input type="range" data-expectedlabel="range label" data-testname="html: label input[type=range] encapsulation" class="ex"> expected "range label" but got "50 range label"
PASS html: label input[type=range] encapsulation
PASS html: label input[type=search] encapsulation
PASS html: label input[type=tel] encapsulation
PASS html: label[for] input[type=text] encapsulation
PASS html: label input[type=time] encapsulation
PASS html: label input[type=url] encapsulation
PASS html: label input[type=week] encapsulation
PASS html: select for/id
FAIL html: select encapsulation assert_equals: <select data-expectedlabel="select label" data-testname="html: select encapsulation" class="ex">
<option>foo</option>
</select> expected "select label" but got "select label foo"
PASS html: select encapsulation
PASS html: img[alt] (non-empty)
PASS html: picture > img[alt] (non-empty)
FAIL html: fieldset > legend assert_equals: <fieldset data-expectedlabel="fieldset legend label" data-testname="html: fieldset > legend" class="ex">
Expand Down
Loading

0 comments on commit 684b75a

Please sign in to comment.