Commit 2063c5ec authored by dtseng's avatar dtseng Committed by Commit bot

Ensure focus() gets called when navigating to text fields

This was a recent regression. Logic was added to make a top level editable a container (so that navigation would descend into it). However, we were previously using the container predicate to decide whether or not to set focus; this prevents focus() on roots which sometimes triggered other side effects such as focusing a descendant.

Make the focus precondition check the structuralContainer predicate instead.

BUG=640587
TEST=chromevox_tests

Review-Url: https://codereview.chromium.org/2273373002
Cr-Commit-Position: refs/heads/master@{#414871}
parent 83797449
...@@ -381,7 +381,7 @@ Background.prototype = { ...@@ -381,7 +381,7 @@ Background.prototype = {
// Iframes, when focused, causes the child webArea to fire focus event. // Iframes, when focused, causes the child webArea to fire focus event.
// This can result in getting stuck when navigating backward. // This can result in getting stuck when navigating backward.
if (actionNode.role != RoleType.iframe && !actionNode.state.focused && if (actionNode.role != RoleType.iframe && !actionNode.state.focused &&
!AutomationPredicate.container(actionNode)) !AutomationPredicate.structuralContainer(actionNode))
actionNode.focus(); actionNode.focus();
} }
var prevRange = this.currentRange_; var prevRange = this.currentRange_;
......
...@@ -1155,3 +1155,17 @@ TEST_F('BackgroundTest', 'EditableNavigation', function() { ...@@ -1155,3 +1155,17 @@ TEST_F('BackgroundTest', 'EditableNavigation', function() {
.replay(); .replay();
}); });
}); });
TEST_F('BackgroundTest', 'NavigationMovesFocus', function() {
this.runWithLoadedTree(function(root) {/*!
<p>start</p>
<input type="text"></input>
*/}, function(root) {
this.listenOnce(root, 'focus', function(e) {
var focus = ChromeVoxState.instance.currentRange.start.node;
assertEquals(RoleType.textField, focus.role);
assertTrue(focus.state.focused);
});
doCmd('nextEditText')();
});
});
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