Commit 801d6b45 authored by Tanmoy Mollik's avatar Tanmoy Mollik Committed by Commit Bot

Revert "Fix accessible name for input type=file"

This reverts commit 21c89bbc.

Reason for revert: This cl is causing failures in different bots. See the bug to failed bot links

Original change's description:
> Fix accessible name for input type=file
> 
> A file picker control (<input type=file>) is exposed as
> a button in the accessibility tree. Previously the
> filename chosen was only exposed in the accessible value,
> like with other input elements - but most screen readers
> were not reading the value, since it's not normal to
> read the value of a button. So users couldn't tell what
> file was chosen, or whether a file was chosen at all.
> 
> Fix this by making the accessible name include both the
> filename (as already exposed in the value) and the
> text of the "Choose File" button.
> 
> Add a test to confirm this is working correctly when a
> file is selected.
> 
> Bug: 903655
> 
> Change-Id: Iaa22ee66e21079014999e8af3d762ee481c85c54
> Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2340163
> Commit-Queue: Dominic Mazzoni <dmazzoni@chromium.org>
> Reviewed-by: Aaron Leventhal <aleventhal@chromium.org>
> Cr-Commit-Position: refs/heads/master@{#795655}

TBR=dmazzoni@chromium.org,aleventhal@chromium.org

Change-Id: I06b265ba4e46e428ac62e17bb186f711f3226224
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Bug: 1114139
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2339627Reviewed-by: default avatarTanmoy Mollik <triploblastic@chromium.org>
Commit-Queue: Tanmoy Mollik <triploblastic@chromium.org>
Cr-Commit-Position: refs/heads/master@{#795891}
parent 32bcfa48
......@@ -2151,7 +2151,7 @@ Output.ROLE_INFO_ = {
article: {msgId: 'role_article', inherits: 'abstractItem'},
application: {msgId: 'role_application', inherits: 'abstractContainer'},
banner: {msgId: 'role_banner', inherits: 'abstractContainer'},
button: {msgId: 'role_button', earconId: 'BUTTON', inherits: 'button'},
button: {msgId: 'role_button', earconId: 'BUTTON'},
buttonDropDown: {msgId: 'role_button', earconId: 'BUTTON'},
checkBox: {msgId: 'role_checkbox'},
columnHeader: {msgId: 'role_columnheader', inherits: 'cell'},
......@@ -2420,10 +2420,6 @@ Output.RULES = {
speak: `$earcon(ALERT_MODAL) $name $nameOrTextContent $description $state
$role`
},
button: {
speak: `$name $node(activeDescendant) $state $restriction $role
$description`
},
cell: {
enter: {
speak: `$cellIndexText $node(tableCellColumnHeaders) $nameFromNode
......
......@@ -327,11 +327,12 @@ TEST_F('ChromeVoxOutputE2ETest', 'Input', function() {
['Time control', [{value: 'role', start: 0, end: 12}]],
['Date control', [{value: 'role', start: 0, end: 12}]],
[
'No file chosen, Choose File|Button',
'Choose File|No file chosen|Button',
[
{value: 'name', start: 0, end: 27},
{value: new Output.EarconAction('BUTTON'), start: 0, end: 27},
{value: 'role', start: 28, end: 34}
{value: 'name', start: 0, end: 11},
{value: new Output.EarconAction('BUTTON'), start: 0, end: 11},
{value: 'value', start: 12, end: 26},
{value: 'role', start: 27, end: 33}
]
],
'||Search', '||Edit text'
......@@ -341,7 +342,7 @@ TEST_F('ChromeVoxOutputE2ETest', 'Input', function() {
const expectedBrailleValues = [
' ed', ' @ed 8dot', ' pwded', ' #ed', {string_: 'spnbtn', spans_: []},
{string_: 'time'}, {string_: 'date'},
{string_: 'No file chosen, Choose File btn'}, ' search', ' ed'
{string_: 'Choose File No file chosen btn'}, ' search', ' ed'
];
assertEquals(expectedSpeechValues.length, expectedBrailleValues.length);
......
[document web]
++[section]
++++[push button] name='No file chosen, Choose File'
++++++[push button] name='Choose File'
\ No newline at end of file
++++[push button] name='Choose File'
++++++[push button] name='Choose File'
rootWebArea
++genericContainer ignored
++++genericContainer
++++++button inputType='file' name='No file chosen, Choose File' value='No file chosen'
++++++button inputType='file' name='Choose File' value='No file chosen'
++++++++button inputType='button' name='Choose File'
++++++++++staticText name='Choose File'
++++++++++++inlineTextBox name='Choose File'
\ No newline at end of file
++++++++++++inlineTextBox name='Choose File'
AXWebArea
++AXGroup
++++AXButton AXTitle='No file chosen, Choose File'
++++++AXButton AXTitle='Choose File'
\ No newline at end of file
++++AXButton AXTitle='Choose File'
++++++AXButton AXTitle='Choose File'
Document
++Group IsControlElement=false
++++Button Name='No file chosen, Choose File'
++++++Button Name='Choose File'
\ No newline at end of file
++++Button Name='Choose File'
++++++Button Name='Choose File'
ROLE_SYSTEM_DOCUMENT READONLY FOCUSABLE ia2_hypertext='<obj0>'
++IA2_ROLE_SECTION ia2_hypertext='<obj0>'
++++ROLE_SYSTEM_PUSHBUTTON name='No file chosen, Choose File' value='No file chosen' FOCUSABLE ia2_hypertext='<obj0>'
++++++ROLE_SYSTEM_PUSHBUTTON name='Choose File' FOCUSABLE ia2_hypertext='Choose File'
\ No newline at end of file
++++ROLE_SYSTEM_PUSHBUTTON name='Choose File' value='No file chosen' FOCUSABLE ia2_hypertext='<obj0>'
++++++ROLE_SYSTEM_PUSHBUTTON name='Choose File' FOCUSABLE ia2_hypertext='Choose File'
......@@ -11,5 +11,5 @@ rootWebArea
++++++++popUpButton collapsed ignored invisible value='This should be pruned out of the tree.'
++++++++++menuListPopup invisible
++++++++++++menuListOption ignored name='This should be pruned out of the tree.' selected=true
++++++button ignored invisible name='No file chosen, Choose File' value='No file chosen'
++++++dialog ignored invisible
\ No newline at end of file
++++++button ignored invisible name='Choose File' value='No file chosen'
++++++dialog ignored invisible
......@@ -3949,6 +3949,8 @@ String AXNodeObject::NativeTextAlternative(
String text_alternative;
AXRelatedObjectVector local_related_objects;
const auto* input_element = DynamicTo<HTMLInputElement>(GetNode());
// 5.1/5.5 Text inputs, Other labelable Elements
// If you change this logic, update AXNodeObject::nameFromLabelElement, too.
auto* html_element = DynamicTo<HTMLElement>(GetNode());
......@@ -3999,7 +4001,6 @@ String AXNodeObject::NativeTextAlternative(
}
// 5.2 input type="button", input type="submit" and input type="reset"
const auto* input_element = DynamicTo<HTMLInputElement>(GetNode());
if (input_element && input_element->IsTextButton()) {
// value attribute.
name_from = ax::mojom::blink::NameFrom::kValue;
......@@ -4145,31 +4146,6 @@ String AXNodeObject::NativeTextAlternative(
}
}
// Input type=file. Not part of the spec, but Blink implements it
// as a single control that has both a button ("Choose file...") and
// some text showing the filename, and we need to concatenate both into
// the name of the button.
if (input_element && input_element->type() == input_type_names::kFile) {
name_from = ax::mojom::blink::NameFrom::kValue;
String displayed_file_path = StringValue();
String upload_button_text = input_element->UploadButton()->value();
if (!displayed_file_path.IsEmpty()) {
text_alternative = displayed_file_path + ", " + upload_button_text;
} else {
text_alternative = upload_button_text;
}
*found_text_alternative = true;
if (name_sources) {
name_sources->push_back(NameSource(true, kValueAttr));
name_sources->back().type = name_from;
name_sources->back().text = text_alternative;
} else {
return text_alternative;
}
}
// Also check for aria-placeholder.
if (IsTextControl()) {
name_from = ax::mojom::blink::NameFrom::kPlaceholder;
......
<!DOCTYPE HTML>
<html>
<head>
<script src="file:///gen/layout_test_data/mojo/public/js/mojo_bindings.js"></script>
<script src="file:///gen/third_party/blink/public/mojom/choosers/file_chooser.mojom.js"></script>
<script src="../fast/forms/resources/mock-file-chooser.js"></script>
<script src="../resources/testharness.js"></script>
<script src="../resources/testharnessreport.js"></script>
</head>
<body>
<input id="filetype" type="file">
<script>
async_test((t) => {
testRunner.waitUntilDone();
// Initially the name is just the button title.
var fileChooser = document.getElementById("filetype");
let axFileChooser = accessibilityController.accessibleElementById("filetype");
assert_equals(axFileChooser.name, "No file chosen, Choose File");
assert_equals(axFileChooser.stringValue, "AXValue: No file chosen");
// After a file is selected, the value should be the file chosen,
// and the name should concatenate both - because ATs think of this as a single
// control and they're only going to read the name.
axFileChooser.addNotificationListener((e) => {
assert_equals(axFileChooser.name, "cake.png, Choose File");
assert_equals(axFileChooser.stringValue, "AXValue: cake.png");
t.done();
});
// Simulate dragging a file to the file control.
eventSender.beginDragWithFiles(['resources/cake.png']);
var centerX = fileChooser.offsetLeft + fileChooser.offsetWidth / 2;
var centerY = fileChooser.offsetTop + fileChooser.offsetHeight / 2;
eventSender.mouseMoveTo(centerX, centerY);
eventSender.mouseUp();
}, "Test that the accessible name of a file control changes when you choose a file.");
</script>
</body>
</html>
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