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 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
71 var parent = this.parent(); | 71 var parent = this.parent(); |
72 if (parent && this.indexInParent < parent.children().length) | 72 if (parent && this.indexInParent < parent.children().length) |
73 return parent.children()[this.indexInParent + 1]; | 73 return parent.children()[this.indexInParent + 1]; |
74 return undefined; | 74 return undefined; |
75 }, | 75 }, |
76 | 76 |
77 doDefault: function() { | 77 doDefault: function() { |
78 this.performAction_('doDefault'); | 78 this.performAction_('doDefault'); |
79 }, | 79 }, |
80 | 80 |
81 focus: function(opt_callback) { | 81 focus: function() { |
82 this.performAction_('focus'); | 82 this.performAction_('focus'); |
83 }, | 83 }, |
84 | 84 |
85 makeVisible: function(opt_callback) { | 85 makeVisible: function() { |
86 this.performAction_('makeVisible'); | 86 this.performAction_('makeVisible'); |
87 }, | 87 }, |
88 | 88 |
89 setSelection: function(startIndex, endIndex, opt_callback) { | 89 setSelection: function(startIndex, endIndex) { |
90 this.performAction_('setSelection', | 90 this.performAction_('setSelection', |
91 { startIndex: startIndex, | 91 { startIndex: startIndex, |
92 endIndex: endIndex }); | 92 endIndex: endIndex }); |
93 }, | 93 }, |
94 | 94 |
95 addEventListener: function(eventType, callback, capture) { | 95 addEventListener: function(eventType, callback, capture) { |
96 this.removeEventListener(eventType, callback); | 96 this.removeEventListener(eventType, callback); |
97 if (!this.listeners[eventType]) | 97 if (!this.listeners[eventType]) |
98 this.listeners[eventType] = []; | 98 this.listeners[eventType] = []; |
99 this.listeners[eventType].push({callback: callback, capture: !!capture}); | 99 this.listeners[eventType].push({callback: callback, capture: !!capture}); |
(...skipping 271 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
371 var id = node.id; | 371 var id = node.id; |
372 for (var key in AutomationAttributeDefaults) { | 372 for (var key in AutomationAttributeDefaults) { |
373 nodeImpl[key] = AutomationAttributeDefaults[key]; | 373 nodeImpl[key] = AutomationAttributeDefaults[key]; |
374 } | 374 } |
375 nodeImpl.childIds = []; | 375 nodeImpl.childIds = []; |
376 nodeImpl.loaded = false; | 376 nodeImpl.loaded = false; |
377 nodeImpl.id = id; | 377 nodeImpl.id = id; |
378 delete this.axNodeDataCache_[id]; | 378 delete this.axNodeDataCache_[id]; |
379 }, | 379 }, |
380 | 380 |
| 381 load: function(callback) { |
| 382 // TODO(dtseng/aboxhall): Implement. |
| 383 if (!this.loaded) |
| 384 throw 'Unsupported state: root node is not loaded.'; |
| 385 |
| 386 setTimeout(callback, 0); |
| 387 }, |
| 388 |
381 deleteOldChildren_: function(node, newChildIds) { | 389 deleteOldChildren_: function(node, newChildIds) { |
382 // Create a set of child ids in |src| for fast lookup, and return false | 390 // Create a set of child ids in |src| for fast lookup, and return false |
383 // if a duplicate is found; | 391 // if a duplicate is found; |
384 var newChildIdSet = {}; | 392 var newChildIdSet = {}; |
385 for (var i = 0; i < newChildIds.length; i++) { | 393 for (var i = 0; i < newChildIds.length; i++) { |
386 var childId = newChildIds[i]; | 394 var childId = newChildIds[i]; |
387 if (newChildIdSet[childId]) { | 395 if (newChildIdSet[childId]) { |
388 logging.WARNING('Node ' + node.id + ' has duplicate child id ' + | 396 logging.WARNING('Node ' + node.id + ' has duplicate child id ' + |
389 childId); | 397 childId); |
390 lastError.set('automation', | 398 lastError.set('automation', |
(...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
536 'toString'] }); | 544 'toString'] }); |
537 | 545 |
538 var AutomationRootNode = utils.expose('AutomationRootNode', | 546 var AutomationRootNode = utils.expose('AutomationRootNode', |
539 AutomationRootNodeImpl, | 547 AutomationRootNodeImpl, |
540 { superclass: AutomationNode, | 548 { superclass: AutomationNode, |
541 functions: ['load'], | 549 functions: ['load'], |
542 readonly: ['loaded'] }); | 550 readonly: ['loaded'] }); |
543 | 551 |
544 exports.AutomationNode = AutomationNode; | 552 exports.AutomationNode = AutomationNode; |
545 exports.AutomationRootNode = AutomationRootNode; | 553 exports.AutomationRootNode = AutomationRootNode; |
OLD | NEW |