OLD | NEW |
---|---|
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 var AutomationEvent = require('automationEvent').AutomationEvent; | 5 var AutomationEvent = require('automationEvent').AutomationEvent; |
6 var automationInternal = | 6 var automationInternal = |
7 require('binding').Binding.create('automationInternal').generate(); | 7 require('binding').Binding.create('automationInternal').generate(); |
8 var IsInteractPermitted = | 8 var IsInteractPermitted = |
9 requireNative('automationInternal').IsInteractPermitted; | 9 requireNative('automationInternal').IsInteractPermitted; |
10 | 10 |
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
107 if (this.listeners[eventType]) { | 107 if (this.listeners[eventType]) { |
108 var listeners = this.listeners[eventType]; | 108 var listeners = this.listeners[eventType]; |
109 for (var i = 0; i < listeners.length; i++) { | 109 for (var i = 0; i < listeners.length; i++) { |
110 if (callback === listeners[i].callback) | 110 if (callback === listeners[i].callback) |
111 listeners.splice(i, 1); | 111 listeners.splice(i, 1); |
112 } | 112 } |
113 } | 113 } |
114 }, | 114 }, |
115 | 115 |
116 dispatchEvent: function(eventType) { | 116 dispatchEvent: function(eventType) { |
117 console.log('dispatching ' + eventType + ' on ' + this.id); | |
not at google - send to devlin
2014/08/19 14:47:48
Safer to use logging.Log(...) from:
https://code.
aboxhall
2014/08/19 15:04:23
Done.
| |
117 var path = []; | 118 var path = []; |
118 var parent = this.parent(); | 119 var parent = this.parent(); |
119 while (parent) { | 120 while (parent) { |
120 path.push(parent); | 121 path.push(parent); |
121 // TODO(aboxhall/dtseng): handle unloaded parent node | 122 // TODO(aboxhall/dtseng): handle unloaded parent node |
122 parent = parent.parent(); | 123 parent = parent.parent(); |
123 } | 124 } |
124 var event = new AutomationEvent(eventType, this.wrapper); | 125 var event = new AutomationEvent(eventType, this.wrapper); |
125 | 126 |
126 // Dispatch the event through the propagation path in three phases: | 127 // Dispatch the event through the propagation path in three phases: |
(...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
275 * unique ids per node and we use these ids to build a hash to the actual | 276 * unique ids per node and we use these ids to build a hash to the actual |
276 * AutomationNode object. | 277 * AutomationNode object. |
277 * Thus, tree traversals amount to a lookup in our hash. | 278 * Thus, tree traversals amount to a lookup in our hash. |
278 * | 279 * |
279 * The tree itself is identified by the process id and routing id of the | 280 * The tree itself is identified by the process id and routing id of the |
280 * renderer widget host. | 281 * renderer widget host. |
281 * @constructor | 282 * @constructor |
282 */ | 283 */ |
283 function AutomationRootNodeImpl(processID, routingID) { | 284 function AutomationRootNodeImpl(processID, routingID) { |
284 AutomationNodeImpl.call(this, this); | 285 AutomationNodeImpl.call(this, this); |
286 console.log('AutomationRootNodeImpl constructor: processID=' + processID + | |
287 '; routingID=' + routingID + '; this.id=' + this.id); | |
285 this.processID = processID; | 288 this.processID = processID; |
286 this.routingID = routingID; | 289 this.routingID = routingID; |
287 this.axNodeDataCache_ = {}; | 290 this.axNodeDataCache_ = {}; |
288 } | 291 } |
289 | 292 |
290 AutomationRootNodeImpl.prototype = { | 293 AutomationRootNodeImpl.prototype = { |
291 __proto__: AutomationNodeImpl.prototype, | 294 __proto__: AutomationNodeImpl.prototype, |
292 | 295 |
293 isRootNode: true, | 296 isRootNode: true, |
294 | 297 |
295 get: function(id) { | 298 get: function(id) { |
296 if (id == undefined) | 299 if (id == undefined) |
297 return undefined; | 300 return undefined; |
298 | 301 |
299 return this.axNodeDataCache_[id]; | 302 return this.axNodeDataCache_[id]; |
300 }, | 303 }, |
301 | 304 |
302 unserialize: function(update) { | 305 unserialize: function(update) { |
303 var updateState = { pendingNodes: {}, newNodes: {} }; | 306 var updateState = { pendingNodes: {}, newNodes: {} }; |
304 var oldRootId = this.id; | |
305 | 307 |
306 if (update.nodeIdToClear < 0) { | 308 if (update.nodeIdToClear < 0) { |
307 logging.WARNING('Bad nodeIdToClear: ' + update.nodeIdToClear); | 309 logging.WARNING('Bad nodeIdToClear: ' + update.nodeIdToClear); |
308 lastError.set('automation', | 310 lastError.set('automation', |
309 'Bad update received on automation tree', | 311 'Bad update received on automation tree', |
310 null, | 312 null, |
311 chrome); | 313 chrome); |
312 return false; | 314 return false; |
313 } else if (update.nodeIdToClear > 0) { | 315 } else if (update.nodeIdToClear > 0) { |
314 var nodeToClear = this.axNodeDataCache_[update.nodeIdToClear]; | 316 var nodeToClear = this.axNodeDataCache_[update.nodeIdToClear]; |
(...skipping 170 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
485 privates(childNode).impl.indexInParent = i; | 487 privates(childNode).impl.indexInParent = i; |
486 privates(childNode).impl.parentID = node.id; | 488 privates(childNode).impl.parentID = node.id; |
487 } | 489 } |
488 | 490 |
489 return success; | 491 return success; |
490 }, | 492 }, |
491 | 493 |
492 setData_: function(node, nodeData) { | 494 setData_: function(node, nodeData) { |
493 var nodeImpl = privates(node).impl; | 495 var nodeImpl = privates(node).impl; |
494 for (var key in AutomationAttributeDefaults) { | 496 for (var key in AutomationAttributeDefaults) { |
495 if (key in nodeData) | 497 if (key in nodeData) { |
498 if (key == 'id' && nodeImpl[key] != nodeData[key]) { | |
499 console.log('Changing ID of node from ' + nodeImpl[key] + ' to ' + | |
500 nodeData[key]); | |
501 } | |
496 nodeImpl[key] = nodeData[key]; | 502 nodeImpl[key] = nodeData[key]; |
497 else | 503 } else { |
498 nodeImpl[key] = AutomationAttributeDefaults[key]; | 504 nodeImpl[key] = AutomationAttributeDefaults[key]; |
505 } | |
499 } | 506 } |
500 for (var i = 0; i < AutomationAttributeTypes.length; i++) { | 507 for (var i = 0; i < AutomationAttributeTypes.length; i++) { |
501 var attributeType = AutomationAttributeTypes[i]; | 508 var attributeType = AutomationAttributeTypes[i]; |
502 for (var attributeName in nodeData[attributeType]) { | 509 for (var attributeName in nodeData[attributeType]) { |
503 nodeImpl.attributesInternal[attributeName] = | 510 nodeImpl.attributesInternal[attributeName] = |
504 nodeData[attributeType][attributeName]; | 511 nodeData[attributeType][attributeName]; |
505 if (ATTRIBUTE_BLACKLIST.hasOwnProperty(attributeName) || | 512 if (ATTRIBUTE_BLACKLIST.hasOwnProperty(attributeName) || |
506 nodeImpl.attributes.hasOwnProperty(attributeName)) { | 513 nodeImpl.attributes.hasOwnProperty(attributeName)) { |
507 continue; | 514 continue; |
508 } else if ( | 515 } else if ( |
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
607 'toString'] }); | 614 'toString'] }); |
608 | 615 |
609 var AutomationRootNode = utils.expose('AutomationRootNode', | 616 var AutomationRootNode = utils.expose('AutomationRootNode', |
610 AutomationRootNodeImpl, | 617 AutomationRootNodeImpl, |
611 { superclass: AutomationNode, | 618 { superclass: AutomationNode, |
612 functions: ['load'], | 619 functions: ['load'], |
613 readonly: ['loaded'] }); | 620 readonly: ['loaded'] }); |
614 | 621 |
615 exports.AutomationNode = AutomationNode; | 622 exports.AutomationNode = AutomationNode; |
616 exports.AutomationRootNode = AutomationRootNode; | 623 exports.AutomationRootNode = AutomationRootNode; |
OLD | NEW |