Commit ff85daec authored by Joanmarie Diggs's avatar Joanmarie Diggs Committed by Commit Bot

Prefer title over "submit" for accessible name of image input

Preferring the title attribute over "submit" means that end users will
potentially get a more precise name for the widget. In addition, because
both Gecko and WebKit prefer the title attribute, making this change will
increase interoperability. Lastly, the HTML-AAM does state user agents can
use the title attribute; using "submit" is presented as an option. Note
that a bug has been filed against the HTML-AAM because such options seem
to decrease rather than increase the likelihood of interoperability.

Bug: 889562
Change-Id: I73b4f6ed79488d7e2eb41e9ae80aabafe8590a88
Reviewed-on: https://chromium-review.googlesource.com/1246724
Commit-Queue: Dominic Mazzoni <dmazzoni@chromium.org>
Reviewed-by: default avatarDominic Mazzoni <dmazzoni@chromium.org>
Cr-Commit-Position: refs/heads/master@{#594481}
parent 3e746cda
......@@ -1844,6 +1844,11 @@ IN_PROC_BROWSER_TEST_F(DumpAccessibilityTreeTest,
RunHtmlTest(FILE_PATH_LITERAL("input-inside-label.html"));
}
IN_PROC_BROWSER_TEST_F(DumpAccessibilityTreeTest,
AccessibilityInputImageWithTitle) {
RunHtmlTest(FILE_PATH_LITERAL("input-image-with-title.html"));
}
//
// Regression tests. These don't test a specific web platform feature,
// they test a specific web page that crashed or had some bad behavior
......
rootWebArea
++genericContainer
++++button name='email'
<html>
<body>
<input type="image" src="envelope.png" id="test" title="email"/>
</body>
</html>
......@@ -27,7 +27,7 @@ test(function(t) {
test(function(t) {
var axImg2 = accessibilityController.accessibleElementById("img2");
assert_equals(axImg2.name, "img2-title");
assert_equals(axImg2.nameFrom, "attribute");
assert_equals(axImg2.nameFrom, "title");
}, "img element without alt, with title");
</script>
......
......@@ -223,8 +223,8 @@ test(function(t) {
<script>
test(function(t) {
var axImageInput5 = accessibilityController.accessibleElementById("image-input5");
assert_equals(axImageInput5.name, "Submit");
assert_equals(axImageInput5.nameFrom, "value");
assert_equals(axImageInput5.name, "image-input-title5");
assert_equals(axImageInput5.nameFrom, "title");
}, "Image input with title only");
</script>
......
......@@ -905,6 +905,10 @@ Tests name sources in input[type=button].
"type": "attribute",
"attribute": "value"
},
{
"type": "attribute",
"attribute": "title"
},
{
"type": "attribute",
"value": {
......@@ -978,6 +982,11 @@ Tests name sources in input[type=button].
},
"attribute": "value"
},
{
"type": "attribute",
"attribute": "title",
"superseded": true
},
{
"type": "attribute",
"value": {
......@@ -1057,6 +1066,11 @@ Tests name sources in input[type=button].
"attribute": "value",
"superseded": true
},
{
"type": "attribute",
"attribute": "title",
"superseded": true
},
{
"type": "attribute",
"value": {
......@@ -1140,6 +1154,11 @@ Tests name sources in input[type=button].
"attribute": "value",
"superseded": true
},
{
"type": "attribute",
"attribute": "title",
"superseded": true
},
{
"type": "attribute",
"value": {
......@@ -1188,7 +1207,7 @@ Tests name sources in input[type=button].
},
"name": {
"type": "computedString",
"value": "Submit",
"value": "image-input-title5",
"sources": [
{
"type": "relatedElement",
......@@ -1210,6 +1229,18 @@ Tests name sources in input[type=button].
"type": "attribute",
"attribute": "value"
},
{
"type": "attribute",
"value": {
"type": "computedString",
"value": "image-input-title5"
},
"attribute": "title",
"attributeValue": {
"type": "string",
"value": "image-input-title5"
}
},
{
"type": "attribute",
"value": {
......@@ -1220,7 +1251,8 @@ Tests name sources in input[type=button].
"attributeValue": {
"type": "string",
"value": "image"
}
},
"superseded": true
},
{
"type": "contents",
......@@ -1241,10 +1273,6 @@ Tests name sources in input[type=button].
}
]
},
"description": {
"type": "computedString",
"value": "image-input-title5"
},
"properties": [
{
"name": "invalid",
......
......@@ -2702,6 +2702,25 @@ String AXNodeObject::NativeTextAlternative(
}
}
// title attr
if (name_sources) {
name_sources->push_back(NameSource(*found_text_alternative, titleAttr));
name_sources->back().type = name_from;
}
name_from = ax::mojom::NameFrom::kTitle;
const AtomicString& title = input_element->getAttribute(titleAttr);
if (!title.IsNull()) {
text_alternative = title;
if (name_sources) {
NameSource& source = name_sources->back();
source.attribute_value = title;
source.text = text_alternative;
*found_text_alternative = true;
} else {
return text_alternative;
}
}
// localised default value ("Submit")
name_from = ax::mojom::NameFrom::kValue;
text_alternative = input_element->GetLocale().QueryString(
......
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