Commit b356f98c authored by Dominic Mazzoni's avatar Dominic Mazzoni Committed by Commit Bot

Fix hitTestWithReply by making the action map global.

The problem was that if you call hitTestWithReply on a node in one tree
(like the desktop, typically the most logical place to call it), it was
storing the callback in a map specific to that try. But then when the hit
test result came back via an event on the correct target node, that node
might be in a different tree - and that tree had its own map from action IDs
to callbacks.

Tested by manually calling desktop.hitTestWithReply with coordinates in
the middle of the feedback link on the www.chromevox.com homepage.

Bug: 818108
Change-Id: I5b995f381f6e260ddcb0f7a1f58a64d0682af949
Reviewed-on: https://chromium-review.googlesource.com/1074490
Commit-Queue: Dominic Mazzoni <dmazzoni@chromium.org>
Reviewed-by: default avatarDavid Tseng <dtseng@chromium.org>
Cr-Commit-Position: refs/heads/master@{#562578}
parent 07e6f86f
......@@ -1160,7 +1160,6 @@ function AutomationRootNodeImpl(treeID) {
$Function.call(AutomationNodeImpl, this, this);
this.treeID = treeID;
this.axNodeDataCache_ = {__proto__: null};
this.actionRequestIDToCallback_ = {__proto__: null};
}
utils.defineProperty(AutomationRootNodeImpl, 'idToAutomationRootNode_',
......@@ -1190,6 +1189,18 @@ utils.defineProperty(AutomationRootNodeImpl, 'destroy', function(treeID) {
delete AutomationRootNodeImpl.idToAutomationRootNode_[treeID];
});
/**
* A counter keeping track of IDs to use for mapping action requests to
* their callback function.
*/
AutomationRootNodeImpl.actionRequestCounter = 0;
/**
* A map from a request ID to the corresponding callback function to call
* when the action response event is received.
*/
AutomationRootNodeImpl.actionRequestIDToCallback = {};
AutomationRootNodeImpl.prototype = {
__proto__: AutomationNodeImpl.prototype,
......@@ -1210,10 +1221,6 @@ AutomationRootNodeImpl.prototype = {
*/
axNodeDataCache_: null,
actionRequestCounter_: 0,
actionRequestIDToCallback_: null,
get id() {
var result = GetRootID(this.treeID);
......@@ -1341,14 +1348,15 @@ AutomationRootNodeImpl.prototype = {
},
addActionResultCallback: function(callback) {
this.actionRequestIDToCallback_[++this.actionRequestCounter_] = callback;
return this.actionRequestCounter_;
AutomationRootNodeImpl.actionRequestIDToCallback[
++AutomationRootNodeImpl.actionRequestCounter] = callback;
return AutomationRootNodeImpl.actionRequestCounter;
},
onActionResult: function(requestID, result) {
if (requestID in this.actionRequestIDToCallback_) {
this.actionRequestIDToCallback_[requestID](result);
delete this.actionRequestIDToCallback_[requestID];
if (requestID in AutomationRootNodeImpl.actionRequestIDToCallback) {
AutomationRootNodeImpl.actionRequestIDToCallback[requestID](result);
delete AutomationRootNodeImpl.actionRequestIDToCallback[requestID];
}
},
......
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