Commit ac7d91f7 authored by David Tseng's avatar David Tseng

Revert "Revert "Reland2: Fire focus if needed in automation api""

This reverts commit 9cb0482f.

Reason for revert: <INSERT REASONING HERE>
A subsequent change stops the failing test from being run on asan but went through after this revert. Seee bug 776308

Original change's description:
> Revert "Reland2: Fire focus if needed in automation api"
>
> This reverts commit 66698953.
>
> Reason for revert: So sorry to do this! But that same test is failing consistently post this reland:
> https://uberchromegw.corp.google.com/i/chromium.memory/builders/Linux%20Chromium%20OS%20ASan%20LSan%20Tests%20%281%29/builds/24261
> https://logs.chromium.org/v/?s=chromium%2Fbb%2Fchromium.memory%2FLinux_Chromium_OS_ASan_LSan_Tests__1_%2F24261%2F%2B%2Frecipes%2Fsteps%2Finteractive_ui_tests%2F0%2Flogs%2FTestAsNormalAndGuestUser__x2f_SpokenFeedbackTest.NavigateSystemTray__x2f_0%2F0
>
> Original change's description:
> > Reland2: Fire focus if needed in automation api
> >
> > TBR=dtseng@chromium.org
> > Bug: 773866
> >
> > Original change
> >
> > Reviewed-on: https://chromium-review.googlesource.com/723606
> > Commit-Queue: David Tseng <dtseng@chromium.org>
> > Reviewed-by: Dominic Mazzoni <dmazzoni@chromium.org>
> > Cr-Original-Commit-Position: refs/heads/master@{#509911}
> > Cq-Include-Trybots: master.tryserver.chromium.linux:closure_compilation
> > Change-Id: I1a1be30f3e430f2417ab3ff4b9733de1b8004077
> > Reviewed-on: https://chromium-review.googlesource.com/728302
> > Reviewed-by: David Tseng <dtseng@chromium.org>
> > Cr-Commit-Position: refs/heads/master@{#510131}
>
> TBR=dmazzoni@chromium.org,dtseng@chromium.org
>
> Change-Id: Id0bc77906aee42b7449e72c71bc2c533ed7ddcb9
> No-Presubmit: true
> No-Tree-Checks: true
> No-Try: true
> Bug: 773866
> Cq-Include-Trybots: master.tryserver.chromium.linux:closure_compilation
> Reviewed-on: https://chromium-review.googlesource.com/729720
> Reviewed-by: Alice Boxhall <aboxhall@chromium.org>
> Commit-Queue: Alice Boxhall <aboxhall@chromium.org>
> Cr-Commit-Position: refs/heads/master@{#510305}

TBR=dmazzoni@chromium.org,dtseng@chromium.org,aboxhall@chromium.org
Bug: 776308, 773866


# Not skipping CQ checks because original CL landed > 1 day ago.


Change-Id: Ia67d7681b56c6475f4824c82f434f0c1f0a820f8
Cq-Include-Trybots: master.tryserver.chromium.linux:closure_compilation
Reviewed-on: https://chromium-review.googlesource.com/775618Reviewed-by: default avatarDavid Tseng <dtseng@chromium.org>
Cr-Commit-Position: refs/heads/master@{#517203}
parent bfaa38b8
......@@ -298,8 +298,8 @@ DesktopAutomationHandler.prototype = {
var node = evt.target;
// Discard focus events on embeddedObject.
if (node.role == RoleType.EMBEDDED_OBJECT)
// Discard focus events on embeddedObject and webView.
if (node.role == RoleType.EMBEDDED_OBJECT || node.role == RoleType.WEB_VIEW)
return;
this.createTextEditHandlerIfNeeded_(evt.target);
......
......@@ -285,11 +285,7 @@ automationInternal.onNodesRemoved.addListener(function(treeID, nodeIDs) {
automationInternal.onAccessibilityEvent.addListener(function(eventParams) {
var id = eventParams.treeID;
var targetTree = AutomationRootNode.getOrCreate(id);
var isFocusEvent = false;
if (eventParams.eventType == 'focus') {
isFocusEvent = true;
} else if (eventParams.eventType == 'blur') {
if (eventParams.eventType == 'blur') {
// Work around an issue where Chrome sends us 'blur' events on the
// root node when nothing has focus, we need to treat those as focus
// events but otherwise not handle blur events specially.
......@@ -300,27 +296,31 @@ automationInternal.onAccessibilityEvent.addListener(function(eventParams) {
eventParams.eventType == 'mediaStoppedPlaying') {
// These events are global to the tree.
eventParams.targetID = privates(targetTree).impl.id;
}
// When we get a focus event, ignore the actual event target, and instead
// check what node has focus globally. If that represents a focus change,
// fire a focus event on the correct target.
if (isFocusEvent) {
} else {
var previousFocusedNode = automationUtil.focusedNode;
automationUtil.updateFocusedNode();
if (automationUtil.focusedNode &&
automationUtil.focusedNode == previousFocusedNode) {
return;
}
if (automationUtil.focusedNode) {
targetTree = automationUtil.focusedNode.root;
eventParams.treeID = privates(targetTree).impl.treeID;
eventParams.targetID = privates(automationUtil.focusedNode).impl.id;
// Fire focus events if necessary.
if (automationUtil.focusedNode &&
automationUtil.focusedNode != previousFocusedNode) {
var eventParamsCopy = {};
for (var key in eventParams)
eventParamsCopy[key] = eventParams[key];
eventParamsCopy['eventType'] = 'focus';
eventParamsCopy['treeID'] =
privates(automationUtil.focusedNode.root).impl.treeID;
eventParamsCopy['targetID'] =
privates(automationUtil.focusedNode).impl.id;
privates(automationUtil.focusedNode.root)
.impl.onAccessibilityEvent(eventParamsCopy);
}
}
if (!privates(targetTree).impl.onAccessibilityEvent(eventParams))
// Note that focus type events have already been handled above if there was a
// focused node. All other events, even non-focus events that triggered a
// focus dispatch, still need to have their original event fired.
if ((!automationUtil.focusedNode || eventParams.eventType != 'focus') &&
!privates(targetTree).impl.onAccessibilityEvent(eventParams))
return;
// If we're not waiting on a callback to getTree(), we can early out here.
......
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