Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(614)

Unified Diff: chrome/renderer/resources/extensions/automation/automation_node.js

Issue 655273005: Implement AutomationNode.querySelector(). (Closed) Base URL: https://chromium.googlesource.com/chromium/src@master
Patch Set: Address review comments and flesh out error and edge case handling Created 6 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: chrome/renderer/resources/extensions/automation/automation_node.js
diff --git a/chrome/renderer/resources/extensions/automation/automation_node.js b/chrome/renderer/resources/extensions/automation/automation_node.js
index fb851690585913880b3ba70de3c1a2f1ea4dbd09..dc76e77de271e30931d485cef5c89dd5c4cbe5d1 100644
--- a/chrome/renderer/resources/extensions/automation/automation_node.js
+++ b/chrome/renderer/resources/extensions/automation/automation_node.js
@@ -95,6 +95,15 @@ AutomationNodeImpl.prototype = {
endIndex: endIndex });
},
+ querySelector: function(selector, callback) {
+ automationInternal.querySelector(
+ { processID: this.rootImpl.processID,
+ routingID: this.rootImpl.routingID,
+ automationNodeID: this.id,
+ selector: selector },
+ this.querySelectorCallback_.bind(this, callback));
+ },
+
addEventListener: function(eventType, callback, capture) {
this.removeEventListener(eventType, callback);
if (!this.listeners[eventType])
@@ -136,11 +145,14 @@ AutomationNodeImpl.prototype = {
},
toString: function() {
- return 'node id=' + this.id +
+ var impl = privates(this).impl;
+ if (!impl)
+ impl = this;
+ return 'node id=' + impl.id +
' role=' + this.role +
' state=' + $JSON.stringify(this.state) +
- ' parentID=' + this.parentID +
- ' childIds=' + $JSON.stringify(this.childIds) +
+ ' parentID=' + impl.parentID +
+ ' childIds=' + $JSON.stringify(impl.childIds) +
' attributes=' + $JSON.stringify(this.attributes);
},
@@ -211,6 +223,19 @@ AutomationNodeImpl.prototype = {
automationNodeID: this.id,
actionType: actionType },
opt_args || {});
+ },
+
+ querySelectorCallback_: function(userCallback, resultAutomationNodeID) {
+ if (resultAutomationNodeID == 0) {
+ userCallback(null);
+ return;
+ }
+ var resultNode = this.rootImpl.get(resultAutomationNodeID);
+ if (!resultNode) {
dmazzoni 2014/10/30 23:32:42 Do you want to return here? It looks like you're c
aboxhall 2014/10/31 20:32:22 I think that's WAI - they need to know that they d
+ logging.WARNING('Query selector result not in tree: ' +
+ resultAutomationNodeID)
+ }
+ userCallback(resultNode);
}
};
@@ -599,7 +624,9 @@ var AutomationNode = utils.expose('AutomationNode',
'makeVisible',
'setSelection',
'addEventListener',
- 'removeEventListener'],
+ 'removeEventListener',
+ 'querySelector',
+ 'toString'],
readonly: ['isRootNode',
'role',
'state',
@@ -610,7 +637,8 @@ var AutomationNode = utils.expose('AutomationNode',
var AutomationRootNode = utils.expose('AutomationRootNode',
AutomationRootNodeImpl,
{ superclass: AutomationNode,
- functions: ['load'],
+ functions: ['load',
+ 'toString'],
readonly: ['loaded'] });
exports.AutomationNode = AutomationNode;

Powered by Google App Engine
This is Rietveld 408576698