Commit b4041643 authored by David Tseng's avatar David Tseng Committed by Commit Bot

Fixes undefined access in group node's location getter

R=anastasi@google.com, dmazzoni@chromium.org

AX-Relnotes: n/a
Fixed: 1126707
Change-Id: I812918d101fba188b7c6f488bb9658b571fe612b
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2410347
Commit-Queue: David Tseng <dtseng@chromium.org>
Reviewed-by: default avatarAkihiro Ota <akihiroota@chromium.org>
Cr-Commit-Position: refs/heads/master@{#806864}
parent f7c2731e
......@@ -105,6 +105,7 @@ js2gtest("switch_access_extjs_tests") {
"navigation_manager_test.js",
"nodes/basic_node_test.js",
"nodes/desktop_node_test.js",
"nodes/group_node_test.js",
"nodes/tab_node_test.js",
"switch_access_predicate_test.js",
"text_navigation_manager_test.js",
......
......@@ -35,7 +35,8 @@ class GroupNode extends SAChildNode {
/** @override */
get location() {
const childLocations = this.children_.map(c => c.location);
const childLocations =
this.children_.filter(c => c.isValidAndVisible()).map(c => c.location);
return RectUtil.unionAll(childLocations);
}
......
// Copyright 2020 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
GEN_INCLUDE(['../switch_access_e2e_test_base.js']);
/** Test fixture for the node wrapper type. */
SwitchAccessGroupNodeTest = class extends SwitchAccessE2ETest {};
TEST_F('SwitchAccessGroupNodeTest', 'NodesRemoved', function() {
const website = `<button></button>`;
this.runWithLoadedTree(website, (desktop) => {
const button = desktop.find({role: chrome.automation.RoleType.BUTTON});
assertNotEquals(undefined, button);
const root = new BasicRootNode(desktop);
assertEquals(0, root.children_.length);
// Add a group child which has two buttons (same underlying automation
// node).
const buttonNode = new BasicNode(button, root);
const otherButtonNode = new BasicNode(button, root);
const groupNode = new GroupNode([buttonNode, otherButtonNode]);
root.children_ = [groupNode];
// Try asking for the location of the group.
assertTrue(!!groupNode.location);
// Try again after clearing one of the button's underlying node.
buttonNode.baseNode_ = undefined;
assertTrue(!!groupNode.location);
});
});
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