diff options
6 files changed, 57 insertions, 4 deletions
diff --git a/content/browser/accessibility/browser_accessibility_android.cc b/content/browser/accessibility/browser_accessibility_android.cc index ff1a973b91..1c708202f0 100644 --- a/content/browser/accessibility/browser_accessibility_android.cc +++ b/content/browser/accessibility/browser_accessibility_android.cc @@ -271,10 +271,21 @@ base::string16 BrowserAccessibilityAndroid::GetText() const { // See comment in browser_accessibility_win.cc for details. // The difference here is that we can only expose one accessible // name on Android, not 2 or 3 like on Windows or Mac. - // - // The basic rule is: prefer description (aria-labelledby or aria-label), - // then help (title), then name (inner text), then value (control value). - // However, if title_elem_id is set, that means there's a label element + + // First, always return the |value| attribute if this is an + // accessible text. + if (!value().empty() && + (GetRole() == ui::AX_ROLE_EDITABLE_TEXT || + GetRole() == ui::AX_ROLE_TEXT_AREA || + GetRole() == ui::AX_ROLE_TEXT_FIELD || + HasState(ui::AX_STATE_EDITABLE))) { + return base::UTF8ToUTF16(value()); + } + + // If there's no text value, the basic rule is: prefer description + // (aria-labelledby or aria-label), then help (title), then name + // (inner text), then value (control value). However, if + // title_elem_id is set, that means there's a label element // supplying the name and then name takes precedence over help. // TODO(dmazzoni): clean this up by providing more granular labels in // Blink, making the platform-specific mapping to accessible text simpler. diff --git a/content/browser/accessibility/dump_accessibility_tree_browsertest.cc b/content/browser/accessibility/dump_accessibility_tree_browsertest.cc index 85169bda02..b5bf72f6ec 100644 --- a/content/browser/accessibility/dump_accessibility_tree_browsertest.cc +++ b/content/browser/accessibility/dump_accessibility_tree_browsertest.cc @@ -475,6 +475,10 @@ IN_PROC_BROWSER_TEST_F(DumpAccessibilityTreeTest, RunTest(FILE_PATH_LITERAL("input-text-name-calc.html")); } +IN_PROC_BROWSER_TEST_F(DumpAccessibilityTreeTest, AccessibilityInputTextValue) { + RunTest(FILE_PATH_LITERAL("input-text-value.html")); +} + // crbug.com/98976 will cause new elements to be added to the Blink a11y tree // Re-baseline after the Blink change goes in IN_PROC_BROWSER_TEST_F(DumpAccessibilityTreeTest, diff --git a/content/test/data/accessibility/input-text-value-expected-android.txt b/content/test/data/accessibility/input-text-value-expected-android.txt new file mode 100644 index 0000000000..6fc9180ad3 --- /dev/null +++ b/content/test/data/accessibility/input-text-value-expected-android.txt @@ -0,0 +1,13 @@ +android.webkit.WebView focusable focused scrollable + android.view.View + android.view.View clickable name='l1' + android.widget.EditText editable_text focusable input_type=1 + android.view.View clickable name='l2' + android.widget.EditText clickable editable_text focusable name='value' input_type=1 + android.widget.EditText clickable editable_text focusable name='l2' input_type=1 + android.widget.EditText clickable editable_text focusable name='value' input_type=1 + android.view.View clickable name='Email' + android.widget.EditText clickable editable_text focusable name='Email' input_type=1 + android.widget.EditText clickable editable_text focusable name='value' input_type=1 + android.widget.EditText clickable editable_text focusable multiline name='l5' + android.widget.EditText clickable editable_text focusable multiline name='Value' diff --git a/content/test/data/accessibility/input-text-value-expected-mac.txt b/content/test/data/accessibility/input-text-value-expected-mac.txt new file mode 100644 index 0000000000..81e1652cc8 --- /dev/null +++ b/content/test/data/accessibility/input-text-value-expected-mac.txt @@ -0,0 +1 @@ +#<skip -- need to generate> diff --git a/content/test/data/accessibility/input-text-value-expected-win.txt b/content/test/data/accessibility/input-text-value-expected-win.txt new file mode 100644 index 0000000000..81e1652cc8 --- /dev/null +++ b/content/test/data/accessibility/input-text-value-expected-win.txt @@ -0,0 +1 @@ +#<skip -- need to generate> diff --git a/content/test/data/accessibility/input-text-value.html b/content/test/data/accessibility/input-text-value.html new file mode 100644 index 0000000000..d6f3697b1f --- /dev/null +++ b/content/test/data/accessibility/input-text-value.html @@ -0,0 +1,23 @@ +<!-- +@WIN-ALLOW:description* +--> +<html> +<body> + <label for="i1">l1</label> + <input id="i1"> + <label for="i2">l2</label> + <input id="i2" value="value"> + + <input aria-label="l2"> + <input aria-label="l2" value="value"> + + <label id="l3">Email</label> + <span id="l4"></span> + <input aria-labelledby="l3 42"> + <input aria-labelledby="l3 l4" value="value"> + + <textarea aria-label="l5"></textarea> + <textarea aria-label="l6">Value</textarea> + +</body> +</html> |