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

Allow for focus on role unknown nodes

R=akihiroota@chromium.org

Test: browser_tests --gtest_filter=ChromeVox*.*Unknown
Change-Id: I918f738fc0e9fdee1db2bec579e43a8f3a0984e6
Fixed: 934968
AX-Relnotes: when a permission dialog pops up, ChromeVox places focus correctly.
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2283928
Commit-Queue: David Tseng <dtseng@chromium.org>
Reviewed-by: default avatarAkihiro Ota <akihiroota@chromium.org>
Cr-Commit-Position: refs/heads/master@{#785842}
parent 12998a32
...@@ -2659,3 +2659,42 @@ TEST_F('ChromeVoxBackgroundTest', 'HoverSkipsContainers', function() { ...@@ -2659,3 +2659,42 @@ TEST_F('ChromeVoxBackgroundTest', 'HoverSkipsContainers', function() {
.replay(); .replay();
}); });
}); });
TEST_F('ChromeVoxBackgroundTest', 'FocusOnUnknown', function() {
const mockFeedback = this.createMockFeedback();
this.runWithLoadedTree(
`
<p>start</p>
<div role="group" tabindex=0>
<p>hello<p>
</div>
<div role="group" tabindex=0></div>
`,
function(root) {
const [group1, group2] = root.findAll({role: RoleType.GROUP});
assertNotNullNorUndefined(group1);
assertNotNullNorUndefined(group2);
Object.defineProperty(group1, 'role', {
get() {
return chrome.automation.RoleType.UNKNOWN;
}
});
Object.defineProperty(group2, 'role', {
get() {
return chrome.automation.RoleType.UNKNOWN;
}
});
const evt2 = new CustomAutomationEvent(EventType.FOCUS, group2, '', []);
const currentRange = ChromeVoxState.instance.currentRange;
DesktopAutomationHandler.instance.onFocus(evt2);
assertEquals(currentRange, ChromeVoxState.instance.currentRange);
const evt1 = new CustomAutomationEvent(EventType.FOCUS, group1, '', []);
mockFeedback
.call(DesktopAutomationHandler.instance.onFocus.bind(
DesktopAutomationHandler.instance, evt1))
.expectSpeech('hello')
.replay();
});
});
...@@ -17,6 +17,7 @@ goog.require('editing.TextEditHandler'); ...@@ -17,6 +17,7 @@ goog.require('editing.TextEditHandler');
goog.scope(function() { goog.scope(function() {
const AutomationNode = chrome.automation.AutomationNode; const AutomationNode = chrome.automation.AutomationNode;
const Dir = constants.Dir;
const EventType = chrome.automation.EventType; const EventType = chrome.automation.EventType;
const RoleType = chrome.automation.RoleType; const RoleType = chrome.automation.RoleType;
const StateType = chrome.automation.StateType; const StateType = chrome.automation.StateType;
...@@ -206,7 +207,7 @@ DesktopAutomationHandler = class extends BaseAutomationHandler { ...@@ -206,7 +207,7 @@ DesktopAutomationHandler = class extends BaseAutomationHandler {
this.textEditHandler_ = null; this.textEditHandler_ = null;
} }
const node = evt.target; let node = evt.target;
// Discard focus events on embeddedObject and webView. // Discard focus events on embeddedObject and webView.
if (node.role == RoleType.EMBEDDED_OBJECT || if (node.role == RoleType.EMBEDDED_OBJECT ||
...@@ -215,7 +216,15 @@ DesktopAutomationHandler = class extends BaseAutomationHandler { ...@@ -215,7 +216,15 @@ DesktopAutomationHandler = class extends BaseAutomationHandler {
} }
if (node.role == RoleType.UNKNOWN) { if (node.role == RoleType.UNKNOWN) {
return; // Ideally, we'd get something more meaningful than focus on an unknown
// node, but this does sometimes occur. Sync downward to a more reasonable
// target.
node = AutomationUtil.findNodePre(
node, Dir.FORWARD, AutomationPredicate.object);
if (!node) {
return;
}
} }
if (!node.root) { if (!node.root) {
......
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