Commit 3d3a3fd2 authored by David Tseng's avatar David Tseng Committed by Commit Bot

Fix tab switch recovery

ChromeVox's expectations with regard to tab switch recovery have changed. Namely:
- selection events appear to be fired unexpectedly on tabs at various points
- ChromeVox range is no longer over the root web area when a hit test result comes back even when we do want to recover

This change adjusts accordingly to TOT and adds tests for both tab switching and refresh recovery to ensure we don't regress again.

Bug: 887185
Change-Id: I3081830457fb62c14456368a819b00765659a824
Reviewed-on: https://chromium-review.googlesource.com/1246366Reviewed-by: default avatarDominic Mazzoni <dmazzoni@chromium.org>
Commit-Queue: David Tseng <dtseng@chromium.org>
Cr-Commit-Position: refs/heads/master@{#594815}
parent a0c85508
...@@ -1738,3 +1738,26 @@ TEST_F('BackgroundTest', 'LinesFilterWhitespace', function() { ...@@ -1738,3 +1738,26 @@ TEST_F('BackgroundTest', 'LinesFilterWhitespace', function() {
.replay(); .replay();
}); });
}); });
TEST_F('BackgroundTest', 'TabSwitchAndRefreshRecovery', function() {
var mockFeedback = this.createMockFeedback();
this.runWithLoadedTree(function() {/*
<p>tab1</p>
*/}, function(root1) {
this.runWithLoadedTree(function() {/*
<p>tab2</p>
*/}, function(root2) {
mockFeedback.expectSpeech('tab2')
.clearPendingOutput()
.call(press(9 /* tab */, {shift: true, ctrl: true}))
.expectSpeech('tab1')
.clearPendingOutput()
.call(press(9 /* tab */, {ctrl: true}))
.expectSpeech('tab2')
.clearPendingOutput()
.call(press(82 /* R */, {ctrl: true}))
.expectSpeech('tab2')
.replay();
});
});
});
...@@ -213,20 +213,19 @@ DesktopAutomationHandler.prototype = { ...@@ -213,20 +213,19 @@ DesktopAutomationHandler.prototype = {
* @param {!AutomationNode} node The hit result. * @param {!AutomationNode} node The hit result.
*/ */
onHitTestResult: function(node) { onHitTestResult: function(node) {
// It is possible that the user moved since we requested a hit test. // It is possible that the user moved since we requested a hit test. Bail
// The following events occur: // if the current range is valid and on the same page as the hit result (but
// load complete // not the root).
// a hit test with reply is requested
// user moves
// we end up here
// As a result, check to ensure we're still on a root web area, before
// continuing.
if (ChromeVoxState.instance.currentRange && if (ChromeVoxState.instance.currentRange &&
ChromeVoxState.instance.currentRange.start && ChromeVoxState.instance.currentRange.start &&
ChromeVoxState.instance.currentRange.start.node && ChromeVoxState.instance.currentRange.start.node &&
ChromeVoxState.instance.currentRange.start.node.role != ChromeVoxState.instance.currentRange.start.node.root) {
RoleType.ROOT_WEB_AREA) var cur = ChromeVoxState.instance.currentRange.start.node;
return; if (cur.role != RoleType.ROOT_WEB_AREA &&
AutomationUtil.getTopLevelRoot(node) ==
AutomationUtil.getTopLevelRoot(cur))
return;
}
chrome.automation.getFocus(function(focus) { chrome.automation.getFocus(function(focus) {
if (!focus && !node) if (!focus && !node)
...@@ -400,6 +399,9 @@ DesktopAutomationHandler.prototype = { ...@@ -400,6 +399,9 @@ DesktopAutomationHandler.prototype = {
if (node.role == RoleType.EMBEDDED_OBJECT || node.role == RoleType.WEB_VIEW) if (node.role == RoleType.EMBEDDED_OBJECT || node.role == RoleType.WEB_VIEW)
return; return;
if (node.role == RoleType.UNKNOWN)
return;
if (!node.root) if (!node.root)
return; return;
...@@ -600,12 +602,10 @@ DesktopAutomationHandler.prototype = { ...@@ -600,12 +602,10 @@ DesktopAutomationHandler.prototype = {
chrome.automation.getFocus(function(focus) { chrome.automation.getFocus(function(focus) {
// Desktop tabs get "selection" when there's a focused webview during tab // Desktop tabs get "selection" when there's a focused webview during tab
// switching. // switching. Ignore it.
if (focus.role == RoleType.WEB_VIEW && evt.target.role == RoleType.TAB) { if (evt.target.role == RoleType.TAB &&
ChromeVoxState.instance.setCurrentRange( evt.target.root.role == RoleType.DESKTOP)
cursors.Range.fromNode(focus.firstChild));
return; return;
}
// Some cases (e.g. in overview mode), require overriding the assumption // Some cases (e.g. in overview mode), require overriding the assumption
// that focus is an ancestor of a selection target. // that focus is an ancestor of a selection target.
......
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