Commit 577cd2cd authored by David Tseng's avatar David Tseng Committed by Commit Bot

Region and text field roles should respect role description

1. region's output rule currently omits role *if* a page sets focus to it directly. This was done to omit verbose region announcements in Docs's live region. However, this meant we don't pick up on role description (which is part of the $role). Include it explicitly.

2. text fields have a slightly more involved role string computation which excluded role description. Include it.

Bug:
Test: chromevox_tests

Cq-Include-Trybots: master.tryserver.chromium.linux:closure_compilation
Change-Id: If034a3e1070f1cf022f63084982f59d1d9e16321
Reviewed-on: https://chromium-review.googlesource.com/843236Reviewed-by: default avatarDominic Mazzoni <dmazzoni@chromium.org>
Commit-Queue: David Tseng <dtseng@chromium.org>
Cr-Commit-Position: refs/heads/master@{#526095}
parent ca33023d
...@@ -95,7 +95,8 @@ AutomationPredicate.button = function(node) { ...@@ -95,7 +95,8 @@ AutomationPredicate.button = function(node) {
* @return {boolean} * @return {boolean}
*/ */
AutomationPredicate.editText = function(node) { AutomationPredicate.editText = function(node) {
return node.state.editable && node.parent && !node.parent.state.editable; return node.role == Role.TEXT_FIELD ||
(node.state.editable && node.parent && !node.parent.state.editable);
}; };
/** @type {AutomationPredicate.Unary} */ /** @type {AutomationPredicate.Unary} */
......
...@@ -427,7 +427,7 @@ Output.RULES = { ...@@ -427,7 +427,7 @@ Output.RULES = {
$description $state $restriction` $description $state $restriction`
}, },
rootWebArea: {enter: `$name`, speak: `$if($name, $name, $docUrl)`}, rootWebArea: {enter: `$name`, speak: `$if($name, $name, $docUrl)`},
region: {speak: `$state $nameOrTextContent $description`}, region: {speak: `$state $nameOrTextContent $description $roleDescription`},
row: {enter: `$node(tableRowHeader)`}, row: {enter: `$node(tableRowHeader)`},
rowHeader: {speak: `$nameOrTextContent $description $state`}, rowHeader: {speak: `$nameOrTextContent $description $state`},
staticText: {speak: `$name=`}, staticText: {speak: `$name=`},
...@@ -452,8 +452,11 @@ Output.RULES = { ...@@ -452,8 +452,11 @@ Output.RULES = {
$description`, $description`,
}, },
textField: { textField: {
speak: `$name $value $if($multiline, @tag_textarea, speak: `$name $value
$if($inputType, $inputType, $role)) $description $state $restriction`, $if($roleDescription, $roleDescription,
$if($multiline, @tag_textarea,
$if($inputType, $inputType, $role)))
$description $state $restriction`,
braille: `` braille: ``
}, },
timer: {speak: `$nameFromNode $descendants $value $state $description`}, timer: {speak: `$nameFromNode $descendants $value $state $description`},
......
...@@ -883,3 +883,24 @@ TEST_F('OutputE2ETest', 'InlineBraille', function() { ...@@ -883,3 +883,24 @@ TEST_F('OutputE2ETest', 'InlineBraille', function() {
o.brailleOutputForTest.string_); o.brailleOutputForTest.string_);
}); });
}); });
TEST_F('OutputE2ETest', 'TextFieldObeysRoleDescription', function() {
this.runWithLoadedTree(function(root) {/*!
<div role="textbox" aria-roledescription="square"></div>
<div role="region" aria-roledescription="circle"></div>
*/}, function(root) {
var text = root.find({role: RoleType.TEXT_FIELD});
// True even though |text| does not have editable state.
assertTrue(AutomationPredicate.editText(text));
var o = new Output().withRichSpeechAndBraille(cursors.Range.fromNode(text));
assertEquals('|square', o.speechOutputForTest.string_);
assertEquals('square', o.brailleOutputForTest.string_);
var region = root.find({role: RoleType.REGION});
o = new Output().withRichSpeechAndBraille(cursors.Range.fromNode(region));
assertEquals('circle', o.speechOutputForTest.string_);
assertEquals('circle', o.brailleOutputForTest.string_);
});
});
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