Commit 8a460e0f authored by Joanmarie Diggs's avatar Joanmarie Diggs Committed by Commit Bot

Don't calculate a button's accessible name from the selected popup item

We assign ax::mojom::Role::kPopUpButton for both native select elements
with a size of 1 and button widgets with a non-false aria-popup value.

In case of native select elements, it makes sense (and is specified)
that the selected item should participate in the accessible name
calculation. In the case of button widgets with a non-false value
for aria-popup, it does not make sense for this participation to occur,
however it was taking place as a side effect of
https://chromium-review.googlesource.com/1249887.

While we could create a new ax::mojom::Role type to distinguish these
two popup button widgets, for the most part they behave very similar
fashions. Therefore, fix the name calculation regression by checking
if the object with Role::kPopUpButton is a native select element.

Bug: 950761
Change-Id: I9c31c5d6e219bd31f80e6145dda38127fa353f08
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1562725
Auto-Submit: Joanmarie Diggs <jdiggs@igalia.com>
Reviewed-by: default avatarDominic Mazzoni <dmazzoni@chromium.org>
Commit-Queue: Joanmarie Diggs <jdiggs@igalia.com>
Cr-Commit-Position: refs/heads/master@{#650554}
parent 24e78a72
...@@ -1970,6 +1970,11 @@ IN_PROC_BROWSER_TEST_P(DumpAccessibilityTreeTest, AccessibilityNestedList) { ...@@ -1970,6 +1970,11 @@ IN_PROC_BROWSER_TEST_P(DumpAccessibilityTreeTest, AccessibilityNestedList) {
RunHtmlTest(FILE_PATH_LITERAL("nestedlist.html")); RunHtmlTest(FILE_PATH_LITERAL("nestedlist.html"));
} }
IN_PROC_BROWSER_TEST_P(DumpAccessibilityTreeTest,
AccessibilityButtonWithListboxPopup) {
RunHtmlTest(FILE_PATH_LITERAL("button-with-listbox-popup.html"));
}
// //
// Regression tests. These don't test a specific web platform feature, // Regression tests. These don't test a specific web platform feature,
// they test a specific web page that crashed or had some bad behavior // they test a specific web page that crashed or had some bad behavior
......
android.webkit.WebView focusable focused scrollable
++android.view.View
++++android.view.View name='Choose one:'
++++android.widget.Spinner role_description='pop up button' clickable focusable name='Choose one: Foo'
++++android.widget.ListView role_description='list box' clickable collection focusable name='Choose one:' item_count=3 row_count=3
++++++android.view.View clickable collection_item focusable name='Baz'
++++++android.view.View clickable collection_item focusable name='Bar' item_index=1 row_index=1
++++++android.view.View clickable collection_item focusable name='Foo' item_index=2 row_index=2
[document web]
++[section]
++++[section] label-for
++++++[text] name='Choose one:'
++++[push button] name='Choose one: Foo' labelled-by
++++++[text] name='Foo'
++++[list box] name='Choose one:' labelled-by
++++++[list item] name='Baz' selectable
++++++[list item] name='Bar' selectable
++++++[list item] name='Foo' selectable
rootWebArea
++genericContainer
++++genericContainer
++++++staticText name='Choose one:'
++++++++inlineTextBox name='Choose one:'
++++popUpButton name='Choose one: Foo'
++++++staticText name='Foo'
++++++++inlineTextBox name='Foo'
++++listBox name='Choose one:'
++++++listBoxOption name='Baz' selected=false
++++++listBoxOption name='Bar' selected=false
++++++listBoxOption name='Foo' selected=false
AXWebArea
++AXGroup
++++AXGroup
++++++AXStaticText AXValue='Choose one:'
++++AXPopUpButton AXTitle='Choose one: Foo'
++++++AXStaticText AXValue='Foo'
++++AXList AXTitle='Choose one:'
++++++AXStaticText AXValue='Baz'
++++++AXStaticText AXValue='Bar'
++++++AXStaticText AXValue='Foo'
region
++document
++++group
++++++group
++++++++description Name='Choose one:'
++++++menu Name='Choose one: Foo' ExpandCollapse.ExpandCollapseState='LeafNode'
++++++++description Name='Foo'
++++++listbox Name='Choose one:' Selection.CanSelectMultiple=false Selection.IsSelectionRequired=false
++++++++option Name='Baz' SelectionItem.IsSelected=false SelectionItem.SelectionContainer='Choose one:'
++++++++option Name='Bar' SelectionItem.IsSelected=false SelectionItem.SelectionContainer='Choose one:'
++++++++option Name='Foo' SelectionItem.IsSelected=false SelectionItem.SelectionContainer='Choose one:'
ROLE_SYSTEM_DOCUMENT READONLY FOCUSABLE
++IA2_ROLE_SECTION
++++IA2_ROLE_SECTION
++++++ROLE_SYSTEM_STATICTEXT name='Choose one:'
++++ROLE_SYSTEM_BUTTONMENU name='Choose one: Foo' FOCUSABLE HASPOPUP
++++++ROLE_SYSTEM_STATICTEXT name='Foo'
++++ROLE_SYSTEM_LIST name='Choose one:' FOCUSABLE
++++++ROLE_SYSTEM_LISTITEM name='Baz' FOCUSABLE
++++++ROLE_SYSTEM_LISTITEM name='Bar' FOCUSABLE
++++++ROLE_SYSTEM_LISTITEM name='Foo' FOCUSABLE
<html>
<body>
<div id="test1">
<span id="span">Choose one:</span>
<button aria-haspopup="listbox" aria-labelledby="span test" id="test">Foo</button>
<ul id="options" tabindex="-1" role="listbox" aria-labelledby="span">
<li id="option1" role="option">Baz</li>
<li id="option2" role="option">Bar</li>
<li id="option3" role="option">Foo</li>
</ul>
</div>
</body>
</html>
...@@ -42,6 +42,7 @@ ...@@ -42,6 +42,7 @@
#include "third_party/blink/renderer/core/frame/local_frame_view.h" #include "third_party/blink/renderer/core/frame/local_frame_view.h"
#include "third_party/blink/renderer/core/frame/settings.h" #include "third_party/blink/renderer/core/frame/settings.h"
#include "third_party/blink/renderer/core/html/forms/html_input_element.h" #include "third_party/blink/renderer/core/html/forms/html_input_element.h"
#include "third_party/blink/renderer/core/html/forms/html_select_element.h"
#include "third_party/blink/renderer/core/html/html_dialog_element.h" #include "third_party/blink/renderer/core/html/html_dialog_element.h"
#include "third_party/blink/renderer/core/html/html_frame_owner_element.h" #include "third_party/blink/renderer/core/html/html_frame_owner_element.h"
#include "third_party/blink/renderer/core/html/parser/html_parser_idioms.h" #include "third_party/blink/renderer/core/html/parser/html_parser_idioms.h"
...@@ -3087,8 +3088,11 @@ bool AXObject::NameFromSelectedOption(bool recursive) const { ...@@ -3087,8 +3088,11 @@ bool AXObject::NameFromSelectedOption(bool recursive) const {
case ax::mojom::Role::kComboBoxGrouping: case ax::mojom::Role::kComboBoxGrouping:
case ax::mojom::Role::kComboBoxMenuButton: case ax::mojom::Role::kComboBoxMenuButton:
case ax::mojom::Role::kListBox: case ax::mojom::Role::kListBox:
case ax::mojom::Role::kPopUpButton:
return recursive; return recursive;
// This can be either a button widget with a non-false value of
// aria-haspopup or a select element with size of 1.
case ax::mojom::Role::kPopUpButton:
return ToHTMLSelectElementOrNull(*GetNode()) ? recursive : false;
default: default:
return false; return false;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment