| 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 3c875816498f55874e92a6a531616c8913526b60..f36a2b948f4d271047b7d0dd3e0d2f238f53ced9 100644
|
| --- a/chrome/renderer/resources/extensions/automation/automation_node.js
|
| +++ b/chrome/renderer/resources/extensions/automation/automation_node.js
|
| @@ -199,15 +199,13 @@ var utils = require('utils');
|
| */
|
| function AutomationNodeImpl(root) {
|
| this.rootImpl = root;
|
| - // Public attributes. No actual data gets set on this object.
|
| - this.listeners = {};
|
| + this.listeners = {__proto__: null};
|
| }
|
|
|
| AutomationNodeImpl.prototype = {
|
| + __proto__: null,
|
| treeID: -1,
|
| id: -1,
|
| - role: '',
|
| - state: { busy: true },
|
| isRootNode: false,
|
|
|
| get root() {
|
| @@ -275,7 +273,7 @@ AutomationNodeImpl.prototype = {
|
| for (var i = 0; i < count; ++i) {
|
| var childID = GetChildIDAtIndex(this.treeID, this.id, i);
|
| var child = this.rootImpl.get(childID);
|
| - children.push(child);
|
| + $Array.push(children, child);
|
| }
|
| return children;
|
| },
|
| @@ -326,7 +324,7 @@ AutomationNodeImpl.prototype = {
|
| { treeID: this.rootImpl.treeID,
|
| automationNodeID: this.id,
|
| selector: selector },
|
| - this.domQuerySelectorCallback_.bind(this, callback));
|
| + $Function.bind(this.domQuerySelectorCallback_, this, callback));
|
| },
|
|
|
| find: function(params) {
|
| @@ -345,7 +343,11 @@ AutomationNodeImpl.prototype = {
|
| this.removeEventListener(eventType, callback);
|
| if (!this.listeners[eventType])
|
| this.listeners[eventType] = [];
|
| - this.listeners[eventType].push({callback: callback, capture: !!capture});
|
| + $Array.push(this.listeners[eventType], {
|
| + __proto__: null,
|
| + callback: callback,
|
| + capture: !!capture,
|
| + });
|
| },
|
|
|
| // TODO(dtseng/aboxhall): Check this impl against spec.
|
| @@ -354,7 +356,7 @@ AutomationNodeImpl.prototype = {
|
| var listeners = this.listeners[eventType];
|
| for (var i = 0; i < listeners.length; i++) {
|
| if (callback === listeners[i].callback)
|
| - listeners.splice(i, 1);
|
| + $Array.splice(listeners, i, 1);
|
| }
|
| }
|
| },
|
| @@ -370,7 +372,7 @@ AutomationNodeImpl.prototype = {
|
| var path = [];
|
| var parent = this.parent;
|
| while (parent) {
|
| - path.push(parent);
|
| + $Array.push(path, parent);
|
| parent = parent.parent;
|
| }
|
| var event = new AutomationEvent(eventType, this.wrapper);
|
| @@ -394,7 +396,7 @@ AutomationNodeImpl.prototype = {
|
| var childIDs = [];
|
| for (var i = 0; i < count; ++i) {
|
| var childID = GetChildIDAtIndex(this.treeID, this.id, i);
|
| - childIDs.push(childID);
|
| + $Array.push(childIDs, childID);
|
| }
|
|
|
| var result = 'node id=' + this.id +
|
| @@ -500,7 +502,7 @@ AutomationNodeImpl.prototype = {
|
| this.forAllDescendants_(function(node) {
|
| if (privates(node).impl.matchInternal_(params)) {
|
| if (opt_results)
|
| - opt_results.push(node);
|
| + $Array.push(opt_results, node);
|
| else
|
| result = node;
|
| return !opt_results;
|
| @@ -518,20 +520,20 @@ AutomationNodeImpl.prototype = {
|
| * for each node. Return true to early-out the traversal.
|
| */
|
| forAllDescendants_: function(closure) {
|
| - var stack = this.wrapper.children.reverse();
|
| + var stack = $Array.reverse(this.wrapper.children);
|
| while (stack.length > 0) {
|
| - var node = stack.pop();
|
| + var node = $Array.pop(stack);
|
| if (closure(node))
|
| return;
|
|
|
| var children = node.children;
|
| for (var i = children.length - 1; i >= 0; i--)
|
| - stack.push(children[i]);
|
| + $Array.push(stack, children[i]);
|
| }
|
| },
|
|
|
| matchInternal_: function(params) {
|
| - if (Object.keys(params).length == 0)
|
| + if ($Object.keys(params).length === 0)
|
| return false;
|
|
|
| if ('role' in params && this.role != params.role)
|
| @@ -549,7 +551,7 @@ AutomationNodeImpl.prototype = {
|
| if (typeof attrValue != 'object') {
|
| if (this[attribute] !== attrValue)
|
| return false;
|
| - } else if (attrValue instanceof RegExp) {
|
| + } else if (attrValue instanceof $RegExp.self) {
|
| if (typeof this[attribute] != 'string')
|
| return false;
|
| if (!attrValue.test(this[attribute]))
|
| @@ -660,38 +662,42 @@ var htmlAttributes = [
|
|
|
| var publicAttributes = [];
|
|
|
| -stringAttributes.forEach(function (attributeName) {
|
| - publicAttributes.push(attributeName);
|
| - Object.defineProperty(AutomationNodeImpl.prototype, attributeName, {
|
| +$Array.forEach(stringAttributes, function(attributeName) {
|
| + $Array.push(publicAttributes, attributeName);
|
| + $Object.defineProperty(AutomationNodeImpl.prototype, attributeName, {
|
| + __proto__: null,
|
| get: function() {
|
| return GetStringAttribute(this.treeID, this.id, attributeName);
|
| }
|
| });
|
| });
|
|
|
| -boolAttributes.forEach(function (attributeName) {
|
| - publicAttributes.push(attributeName);
|
| - Object.defineProperty(AutomationNodeImpl.prototype, attributeName, {
|
| +$Array.forEach(boolAttributes, function(attributeName) {
|
| + $Array.push(publicAttributes, attributeName);
|
| + $Object.defineProperty(AutomationNodeImpl.prototype, attributeName, {
|
| + __proto__: null,
|
| get: function() {
|
| return GetBoolAttribute(this.treeID, this.id, attributeName);
|
| }
|
| });
|
| });
|
|
|
| -intAttributes.forEach(function (attributeName) {
|
| - publicAttributes.push(attributeName);
|
| - Object.defineProperty(AutomationNodeImpl.prototype, attributeName, {
|
| +$Array.forEach(intAttributes, function(attributeName) {
|
| + $Array.push(publicAttributes, attributeName);
|
| + $Object.defineProperty(AutomationNodeImpl.prototype, attributeName, {
|
| + __proto__: null,
|
| get: function() {
|
| return GetIntAttribute(this.treeID, this.id, attributeName);
|
| }
|
| });
|
| });
|
|
|
| -nodeRefAttributes.forEach(function (params) {
|
| +$Array.forEach(nodeRefAttributes, function(params) {
|
| var srcAttributeName = params[0];
|
| var dstAttributeName = params[1];
|
| - publicAttributes.push(dstAttributeName);
|
| - Object.defineProperty(AutomationNodeImpl.prototype, dstAttributeName, {
|
| + $Array.push(publicAttributes, dstAttributeName);
|
| + $Object.defineProperty(AutomationNodeImpl.prototype, dstAttributeName, {
|
| + __proto__: null,
|
| get: function() {
|
| var id = GetIntAttribute(this.treeID, this.id, srcAttributeName);
|
| if (id)
|
| @@ -702,20 +708,22 @@ nodeRefAttributes.forEach(function (params) {
|
| });
|
| });
|
|
|
| -intListAttributes.forEach(function (attributeName) {
|
| - publicAttributes.push(attributeName);
|
| - Object.defineProperty(AutomationNodeImpl.prototype, attributeName, {
|
| +$Array.forEach(intListAttributes, function(attributeName) {
|
| + $Array.push(publicAttributes, attributeName);
|
| + $Object.defineProperty(AutomationNodeImpl.prototype, attributeName, {
|
| + __proto__: null,
|
| get: function() {
|
| return GetIntListAttribute(this.treeID, this.id, attributeName);
|
| }
|
| });
|
| });
|
|
|
| -nodeRefListAttributes.forEach(function (params) {
|
| +$Array.forEach(nodeRefListAttributes, function(params) {
|
| var srcAttributeName = params[0];
|
| var dstAttributeName = params[1];
|
| - publicAttributes.push(dstAttributeName);
|
| - Object.defineProperty(AutomationNodeImpl.prototype, dstAttributeName, {
|
| + $Array.push(publicAttributes, dstAttributeName);
|
| + $Object.defineProperty(AutomationNodeImpl.prototype, dstAttributeName, {
|
| + __proto__: null,
|
| get: function() {
|
| var ids = GetIntListAttribute(this.treeID, this.id, srcAttributeName);
|
| if (!ids)
|
| @@ -724,27 +732,29 @@ nodeRefListAttributes.forEach(function (params) {
|
| for (var i = 0; i < ids.length; ++i) {
|
| var node = this.rootImpl.get(ids[i]);
|
| if (node)
|
| - result.push(node);
|
| + $Array.push(result, node);
|
| }
|
| return result;
|
| }
|
| });
|
| });
|
|
|
| -floatAttributes.forEach(function (attributeName) {
|
| - publicAttributes.push(attributeName);
|
| - Object.defineProperty(AutomationNodeImpl.prototype, attributeName, {
|
| +$Array.forEach(floatAttributes, function(attributeName) {
|
| + $Array.push(publicAttributes, attributeName);
|
| + $Object.defineProperty(AutomationNodeImpl.prototype, attributeName, {
|
| + __proto__: null,
|
| get: function() {
|
| return GetFloatAttribute(this.treeID, this.id, attributeName);
|
| }
|
| });
|
| });
|
|
|
| -htmlAttributes.forEach(function (params) {
|
| +$Array.forEach(htmlAttributes, function(params) {
|
| var srcAttributeName = params[0];
|
| var dstAttributeName = params[1];
|
| - publicAttributes.push(dstAttributeName);
|
| - Object.defineProperty(AutomationNodeImpl.prototype, dstAttributeName, {
|
| + $Array.push(publicAttributes, dstAttributeName);
|
| + $Object.defineProperty(AutomationNodeImpl.prototype, dstAttributeName, {
|
| + __proto__: null,
|
| get: function() {
|
| return GetHtmlAttribute(this.treeID, this.id, srcAttributeName);
|
| }
|
| @@ -769,29 +779,30 @@ htmlAttributes.forEach(function (params) {
|
| * @constructor
|
| */
|
| function AutomationRootNodeImpl(treeID) {
|
| - AutomationNodeImpl.call(this, this);
|
| + $Function.call(AutomationNodeImpl, this, this);
|
| this.treeID = treeID;
|
| - this.axNodeDataCache_ = {};
|
| + this.axNodeDataCache_ = {__proto__: null};
|
| }
|
|
|
| -AutomationRootNodeImpl.idToAutomationRootNode_ = {};
|
| +utils.defineProperty(AutomationRootNodeImpl, 'idToAutomationRootNode_',
|
| + {__proto__: null});
|
|
|
| -AutomationRootNodeImpl.get = function(treeID) {
|
| +utils.defineProperty(AutomationRootNodeImpl, 'get', function(treeID) {
|
| var result = AutomationRootNodeImpl.idToAutomationRootNode_[treeID];
|
| return result || undefined;
|
| -}
|
| +});
|
|
|
| -AutomationRootNodeImpl.getOrCreate = function(treeID) {
|
| +utils.defineProperty(AutomationRootNodeImpl, 'getOrCreate', function(treeID) {
|
| if (AutomationRootNodeImpl.idToAutomationRootNode_[treeID])
|
| return AutomationRootNodeImpl.idToAutomationRootNode_[treeID];
|
| var result = new AutomationRootNode(treeID);
|
| AutomationRootNodeImpl.idToAutomationRootNode_[treeID] = result;
|
| return result;
|
| -}
|
| +});
|
|
|
| -AutomationRootNodeImpl.destroy = function(treeID) {
|
| +utils.defineProperty(AutomationRootNodeImpl, 'destroy', function(treeID) {
|
| delete AutomationRootNodeImpl.idToAutomationRootNode_[treeID];
|
| -}
|
| +});
|
|
|
| AutomationRootNodeImpl.prototype = {
|
| __proto__: AutomationNodeImpl.prototype,
|
| @@ -927,8 +938,7 @@ AutomationRootNodeImpl.prototype = {
|
| if (nodeImpl.isRootNode)
|
| output += indent + 'tree id=' + nodeImpl.treeID + '\n';
|
| output += indent +
|
| - AutomationNodeImpl.prototype.toString.call(nodeImpl) +
|
| - '\n';
|
| + $Function.call(AutomationNodeImpl.prototype.toString, nodeImpl) + '\n';
|
| indent += ' ';
|
| var children = nodeImpl.children;
|
| for (var i = 0; i < children.length; ++i)
|
| @@ -991,17 +1001,17 @@ utils.expose(AutomationRootNode, AutomationRootNodeImpl, {
|
| ],
|
| });
|
|
|
| -AutomationRootNode.get = function(treeID) {
|
| +utils.defineProperty(AutomationRootNode, 'get', function(treeID) {
|
| return AutomationRootNodeImpl.get(treeID);
|
| -}
|
| +});
|
|
|
| -AutomationRootNode.getOrCreate = function(treeID) {
|
| +utils.defineProperty(AutomationRootNode, 'getOrCreate', function(treeID) {
|
| return AutomationRootNodeImpl.getOrCreate(treeID);
|
| -}
|
| +});
|
|
|
| -AutomationRootNode.destroy = function(treeID) {
|
| +utils.defineProperty(AutomationRootNode, 'destroy', function(treeID) {
|
| AutomationRootNodeImpl.destroy(treeID);
|
| -}
|
| +});
|
|
|
| exports.$set('AutomationNode', AutomationNode);
|
| exports.$set('AutomationRootNode', AutomationRootNode);
|
|
|