Commit 72482e62 authored by Dominic Mazzoni's avatar Dominic Mazzoni Committed by Commit Bot

Fix crash when AXTreeCombiner is called with an empty tree.

BUG=727290

Change-Id: Id54681bca8dce8b6a19d40c713a397a43e761d33
Reviewed-on: https://chromium-review.googlesource.com/527912Reviewed-by: default avatarPaul Miller <paulmiller@chromium.org>
Commit-Queue: Dominic Mazzoni <dmazzoni@chromium.org>
Cr-Commit-Position: refs/heads/master@{#480288}
parent 9b8a9e24
......@@ -40,7 +40,7 @@ bool AXTreeCombiner::Combine() {
ProcessTree(root);
// Set the root id.
combined_.root_id = combined_.nodes[0].id;
combined_.root_id = combined_.nodes.size() > 0 ? combined_.nodes[0].id : 0;
// Finally, handle the tree ID, taking into account which subtree might
// have focus and mapping IDs from the tree data appropriately.
......
......@@ -192,4 +192,15 @@ TEST(CombineAXTreesTest, FocusedTree) {
EXPECT_EQ(6, combined.tree_data.focus_id);
}
TEST(CombineAXTreesTest, EmptyTree) {
AXTreeUpdate tree;
AXTreeCombiner combiner;
combiner.AddTree(tree, true);
combiner.Combine();
const AXTreeUpdate& combined = combiner.combined();
ASSERT_EQ(0U, combined.nodes.size());
}
} // namespace ui
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