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

Side by Side Diff: chrome/renderer/resources/extensions/automation_custom_bindings.js

Issue 485843002: Add logspam to help diagnose flaky tests (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 4 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 // Custom bindings for the automation API. 5 // Custom bindings for the automation API.
6 var AutomationNode = require('automationNode').AutomationNode; 6 var AutomationNode = require('automationNode').AutomationNode;
7 var AutomationRootNode = require('automationNode').AutomationRootNode; 7 var AutomationRootNode = require('automationNode').AutomationRootNode;
8 var automation = require('binding').Binding.create('automation'); 8 var automation = require('binding').Binding.create('automation');
9 var automationInternal = 9 var automationInternal =
10 require('binding').Binding.create('automationInternal').generate(); 10 require('binding').Binding.create('automationInternal').generate();
(...skipping 15 matching lines...) Expand all
26 */ 26 */
27 var createAutomationRootNodeID = function(pid, rid) { 27 var createAutomationRootNodeID = function(pid, rid) {
28 return pid + '_' + rid; 28 return pid + '_' + rid;
29 }; 29 };
30 30
31 var DESKTOP_TREE_ID = createAutomationRootNodeID(0, 0); 31 var DESKTOP_TREE_ID = createAutomationRootNodeID(0, 0);
32 32
33 automation.registerCustomHook(function(bindingsAPI) { 33 automation.registerCustomHook(function(bindingsAPI) {
34 var apiFunctions = bindingsAPI.apiFunctions; 34 var apiFunctions = bindingsAPI.apiFunctions;
35 35
36 // TODO(aboxhall, dtseng): Make this return the speced AutomationRootNode obj.
37 apiFunctions.setHandleRequest('getTree', function getTree(tabId, callback) { 36 apiFunctions.setHandleRequest('getTree', function getTree(tabId, callback) {
38 // enableTab() ensures the renderer for the active or specified tab has 37 // enableTab() ensures the renderer for the active or specified tab has
39 // accessibility enabled, and fetches its process and routing ids to use as 38 // accessibility enabled, and fetches its process and routing ids to use as
40 // a key in the idToAutomationRootNode map. The callback to enableTab is is 39 // a key in the idToAutomationRootNode map. The callback to enableTab is is
41 // bound to the callback passed in to getTree(), so that once the tree is 40 // bound to the callback passed in to getTree(), so that once the tree is
42 // available (either due to having been cached earlier, or after an 41 // available (either due to having been cached earlier, or after an
43 // accessibility event occurs which causes the tree to be populated), the 42 // accessibility event occurs which causes the tree to be populated), the
44 // callback can be called. 43 // callback can be called.
45 automationInternal.enableTab(tabId, function onEnable(pid, rid) { 44 automationInternal.enableTab(tabId, function onEnable(pid, rid) {
46 if (lastError.hasError(chrome)) { 45 if (lastError.hasError(chrome)) {
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
85 } 84 }
86 }); 85 });
87 }); 86 });
88 87
89 // Listen to the automationInternal.onAccessibilityEvent event, which is 88 // Listen to the automationInternal.onAccessibilityEvent event, which is
90 // essentially a proxy for the AccessibilityHostMsg_Events IPC from the 89 // essentially a proxy for the AccessibilityHostMsg_Events IPC from the
91 // renderer. 90 // renderer.
92 automationInternal.onAccessibilityEvent.addListener(function(data) { 91 automationInternal.onAccessibilityEvent.addListener(function(data) {
93 var pid = data.processID; 92 var pid = data.processID;
94 var rid = data.routingID; 93 var rid = data.routingID;
94 console.log('onAccessibilityEvent { processID: ' + pid + ', routingID: ' +
95 rid + ', eventType: ' + data.eventType + ' }');
95 var id = createAutomationRootNodeID(pid, rid); 96 var id = createAutomationRootNodeID(pid, rid);
96 var targetTree = idToAutomationRootNode[id]; 97 var targetTree = idToAutomationRootNode[id];
97 if (!targetTree) { 98 if (!targetTree) {
98 // If this is the first time we've gotten data for this tree, it will 99 // If this is the first time we've gotten data for this tree, it will
99 // contain all of the tree's data, so create a new tree which will be 100 // contain all of the tree's data, so create a new tree which will be
100 // bootstrapped from |data|. 101 // bootstrapped from |data|.
101 targetTree = new AutomationRootNode(pid, rid); 102 targetTree = new AutomationRootNode(pid, rid);
102 idToAutomationRootNode[id] = targetTree; 103 idToAutomationRootNode[id] = targetTree;
103 } 104 }
105
104 if (!privates(targetTree).impl.onAccessibilityEvent(data)) 106 if (!privates(targetTree).impl.onAccessibilityEvent(data))
105 return; 107 return;
David Tseng 2014/08/18 22:55:45 Also put logging in performAction?
106 108
107 // If we're not waiting on a callback to getTree(), we can early out here. 109 // If we're not waiting on a callback to getTree(), we can early out here.
108 if (!(id in idToCallback)) 110 if (!(id in idToCallback))
109 return; 111 return;
110 112
111 // We usually get a 'placeholder' tree first, which doesn't have any url 113 // We usually get a 'placeholder' tree first, which doesn't have any url
112 // attribute or child nodes. If we've got that, wait for the full tree before 114 // attribute or child nodes. If we've got that, wait for the full tree before
113 // calling the callback. 115 // calling the callback.
114 // TODO(dmazzoni): Don't send down placeholder (crbug.com/397553) 116 // TODO(dmazzoni): Don't send down placeholder (crbug.com/397553)
115 if (id != DESKTOP_TREE_ID && !targetTree.attributes.url && 117 if (id != DESKTOP_TREE_ID && !targetTree.attributes.url &&
(...skipping 25 matching lines...) Expand all
141 }); 143 });
142 144
143 exports.binding = automation.generate(); 145 exports.binding = automation.generate();
144 146
145 // Add additional accessibility bindings not specified in the automation IDL. 147 // Add additional accessibility bindings not specified in the automation IDL.
146 // Accessibility and automation share some APIs (see 148 // Accessibility and automation share some APIs (see
147 // ui/accessibility/ax_enums.idl). 149 // ui/accessibility/ax_enums.idl).
148 forEach(schema, function(k, v) { 150 forEach(schema, function(k, v) {
149 exports.binding[k] = v; 151 exports.binding[k] = v;
150 }); 152 });
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698