Commit 0d5f170f authored by dtseng's avatar dtseng Committed by Commit bot

Allow tree walker to escape roots

Scenario:
In the launcher subtree of the desktop tree, we have:
dialog
...
  web view
    root web area
    ...
   files button

A dialog with mixed web and views content.

When navigating forward, we search downward and get into the web view and find nothing inside, but when unwinding upward, we stop at the root web area because it gets matched by the root predicate.

In the end, we don't end up on the native views next in document order.

TEST=navigate with ChromeVox keys. Ensure we can get to the buttons.
BUG=
CQ_INCLUDE_TRYBOTS=master.tryserver.chromium.linux:closure_compilation

Review-Url: https://codereview.chromium.org/2559343002
Cr-Commit-Position: refs/heads/master@{#437539}
parent e4d9f70e
......@@ -178,7 +178,8 @@ AutomationTreeWalker.prototype = {
var searchNode = node;
while (searchNode) {
// We have crossed out of the initial node's subtree.
// We have crossed out of the initial node's subtree for either a
// sibling or parent move.
if (searchNode == this.initialNode_)
this.phase_ = AutomationTreeWalkerPhase.OTHER;
......@@ -186,7 +187,16 @@ AutomationTreeWalker.prototype = {
this.node_ = searchNode.nextSibling;
return;
}
if (searchNode.parent && this.rootPred_(searchNode.parent))
// Update the phase based on the parent if needed since we may exit below.
if (searchNode.parent == this.initialNode_)
this.phase_ = AutomationTreeWalkerPhase.OTHER;
// Exit if we encounter a root-like node and are not searching descendants
// of the initial node.
if (searchNode.parent &&
this.rootPred_(searchNode.parent) &&
this.phase_ != AutomationTreeWalkerPhase.DESCENDANT)
break;
searchNode = searchNode.parent;
......
......@@ -126,6 +126,7 @@ TEST_F('AutomationTreeWalkerTest', 'RootLeafRestriction', function() {
var walker = new AutomationTreeWalker(node2, 'forward', restrictions);
while (walker.next().node) {}
assertEquals('35', visited);
assertEquals(AutomationTreeWalkerPhase.OTHER, walker.phase);
// And the reverse.
// Note that walking into a root is allowed.
......
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