| 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 19e4cb815f870e475db45e672f9f85481b2944dc..7ff36ced0dfd37ccd87f0241b6f7b609b0ab3745 100644
|
| --- a/chrome/renderer/resources/extensions/automation/automation_node.js
|
| +++ b/chrome/renderer/resources/extensions/automation/automation_node.js
|
| @@ -2,6 +2,8 @@
|
| // Use of this source code is governed by a BSD-style license that can be
|
| // found in the LICENSE file.
|
|
|
| +var automationInternal =
|
| + require('binding').Binding.create('automationInternal').generate();
|
| var utils = require('utils');
|
|
|
| /**
|
| @@ -11,49 +13,105 @@ var utils = require('utils');
|
| */
|
| var AutomationNodeImpl = function(owner) {
|
| this.owner = owner;
|
| - this.child_ids = [];
|
| -
|
| + this.childIDs = [];
|
| this.attributes = {};
|
| + this.listeners = {};
|
| };
|
|
|
| AutomationNodeImpl.prototype = {
|
| parent: function() {
|
| - return this.owner.get(this.parent_id);
|
| + return this.owner.get(this.parentID);
|
| },
|
|
|
| firstChild: function() {
|
| - var node = this.owner.get(this.child_ids[0]);
|
| + var node = this.owner.get(this.childIDs[0]);
|
| return node;
|
| },
|
|
|
| lastChild: function() {
|
| - var child_ids = this.child_ids;
|
| - var node = this.owner.get(child_ids[child_ids.length - 1]);
|
| + var childIDs = this.childIDs;
|
| + var node = this.owner.get(childIDs[childIDs.length - 1]);
|
| return node;
|
| },
|
|
|
| children: function() {
|
| var children = [];
|
| - for (var i = 0, child_id; child_id = this.child_ids[i]; i++)
|
| - children.push(this.owner.get(child_id));
|
| + for (var i = 0, childID; childID = this.childIDs[i]; i++)
|
| + children.push(this.owner.get(childID));
|
| return children;
|
| },
|
|
|
| previousSibling: function() {
|
| var parent = this.parent();
|
| - if (parent && this.index_in_parent > 0)
|
| - return parent.children()[this.index_in_parent - 1];
|
| + if (parent && this.indexInParent > 0)
|
| + return parent.children()[this.indexInParent - 1];
|
| return undefined;
|
| },
|
|
|
| nextSibling: function() {
|
| var parent = this.parent();
|
| - if (parent && this.index_in_parent < parent.children().length)
|
| - return parent.children()[this.index_in_parent + 1];
|
| + if (parent && this.indexInParent < parent.children().length)
|
| + return parent.children()[this.indexInParent + 1];
|
| return undefined;
|
| },
|
| -};
|
|
|
| + doDefault: function() {
|
| + this.performAction_('doDefault');
|
| + },
|
| +
|
| + focus: function() {
|
| + this.performAction_('focus');
|
| + },
|
| +
|
| + makeVisible: function() {
|
| + this.performAction_('makeVisible');
|
| + },
|
| +
|
| + setSelection: function(startIndex, endIndex) {
|
| + this.performAction_('setSelection',
|
| + {startIndex: startIndex, endIndex: endIndex});
|
| + },
|
| +
|
| + addEventListener: function(eventType, callback, capture) {
|
| + this.removeEventListener(eventType, callback);
|
| + if (!this.listeners[eventType])
|
| + this.listeners[eventType] = [];
|
| + this.listeners[eventType].push([callback, capture]);
|
| + },
|
| +
|
| + // TODO(dtseng/aboxhall): Check this impl against spec.
|
| + removeEventListener: function(eventType, callback) {
|
| + if (this.listeners[eventType]) {
|
| + var listeners = this.listeners[eventType];
|
| + for (var i = 0; i < listeners.length; i++) {
|
| + if (callback === listeners[i][0])
|
| + listeners.splice(i, 1);
|
| + }
|
| + }
|
| + },
|
| +
|
| + notifyEventListeners: function(eventType) {
|
| + var listeners = this.listeners[eventType];
|
| + if (!listeners)
|
| + return;
|
| + // TODO(dtseng/aboxhall): Implement capture/bubble.
|
| + for (var i = 0; i < listeners.length; i++)
|
| + listeners[i][0]();
|
| + },
|
| +
|
| + performAction_: function(actionType, opt_args) {
|
| + // Not yet initialized.
|
| + if (!this.owner.processID ||
|
| + !this.owner.routingID ||
|
| + !this.wrapper.id)
|
| + return;
|
| + automationInternal.performAction({processID: this.owner.processID,
|
| + routingID: this.owner.routingID,
|
| + automationNodeID: this.wrapper.id,
|
| + actionType: actionType},
|
| + opt_args || {});
|
| + },
|
| +};
|
|
|
| var AutomationNode = utils.expose('AutomationNode',
|
| AutomationNodeImpl,
|
| @@ -62,5 +120,11 @@ var AutomationNode = utils.expose('AutomationNode',
|
| 'lastChild',
|
| 'children',
|
| 'previousSibling',
|
| - 'nextSibling']);
|
| + 'nextSibling',
|
| + 'doDefault',
|
| + 'focus',
|
| + 'makeVisible',
|
| + 'setSelection',
|
| + 'addEventListener',
|
| + 'removeEventListener']);
|
| exports.AutomationNode = AutomationNode;
|
|
|