Index: chrome/renderer/resources/extensions/automation_custom_bindings.js |
diff --git a/chrome/renderer/resources/extensions/automation_custom_bindings.js b/chrome/renderer/resources/extensions/automation_custom_bindings.js |
index 350f2179df2d8a1e1e814ffdaa5f60cb9d8b18ec..10fd29d0609708f8dee99df03c2d0a9fd36de032 100644 |
--- a/chrome/renderer/resources/extensions/automation_custom_bindings.js |
+++ b/chrome/renderer/resources/extensions/automation_custom_bindings.js |
@@ -278,10 +278,22 @@ automationInternal.onAccessibilityEvent.addListener(function(eventParams) { |
var id = eventParams.treeID; |
var targetTree = AutomationRootNode.getOrCreate(id); |
+ // 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. |
+ var isFocusEvent = false; |
+ if (eventParams.eventType == schema.EventType.focus) { |
+ isFocusEvent = true; |
+ } else if (eventParams.eventType == schema.EventType.blur) { |
+ var node = privates(targetTree).impl.get(eventParams.targetID); |
+ if (node == node.root) |
+ isFocusEvent = true; |
+ } |
+ |
// 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 (eventParams.eventType == schema.EventType.focus) { |
+ if (isFocusEvent) { |
var previousFocusedNode = automationUtil.focusedNode; |
automationUtil.updateFocusedNode(); |
if (automationUtil.focusedNode && |