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
3 // found in the LICENSE file.
5 // The <code>chrome.automation</code> API allows developers to access the
6 // automation (accessibility) tree for the browser. The tree resembles the DOM
7 // tree, but only exposes the <em>semantic</em> structure of a page. It can be
8 // used to programmatically interact with a page by examining names, roles, and
9 // states, listening for events, and performing actions on nodes.
10 [nocompile
] namespace automation
{
11 // Keep the following enums in sync with 'ui/accessibility/ax_enums.idl'.
12 // They are kept here purely for extension docs generation.
14 // Possible events fired on an $(ref:automation.AutomationNode).
16 activedescendantchanged
,
19 autocorrectionOccured
,
40 scrollPositionChanged
,
42 selectedChildrenChanged
,
52 // Describes the purpose of an $(ref:automation.AutomationNode).
77 descriptionListDetail
,
166 tableHeaderContainer
,
185 // Describes characteristics of an $(ref:automation.AutomationNode).
191 disabled
, // ui/views only
192 editable
, // ui/views only
193 enabled
, // content only
221 // An event in the Automation tree.
222 [nocompile
, noinline_doc
] dictionary AutomationEvent
{
223 // The $(ref:automation.AutomationNode) to which the event was targeted.
224 AutomationNode target
;
226 // The type of the event.
229 // Stops this event from further processing except for any remaining
230 // listeners on $(ref:AutomationEvent.target).
231 static
void stopPropagation
();
234 // A listener for events on an <code>AutomationNode</code>.
235 callback AutomationListener
= void(AutomationEvent event
);
237 // A single node in an Automation tree.
238 [nocompile
, noinline_doc
] dictionary AutomationNode
{
239 // The root node of the tree containing this AutomationNode.
240 AutomationRootNode root
;
242 // Whether this AutomationNode is an AutomationRootNode.
245 // Unique ID to identify this node.
248 // The role of this node.
249 automation.RoleType role
;
251 // The $(ref:automation.StateType)s describing this node.
254 // The rendered location (as a bounding box) of this node within the frame.
255 automation.Rect location
;
257 // A collection of this node's other attributes.
260 // The index of this node in its parent node's list of children. If this is
261 // the root node, this will be undefined.
264 static AutomationNode
[] children
();
265 static AutomationNode parent
();
266 static AutomationNode firstChild
();
267 static AutomationNode lastChild
();
268 static AutomationNode previousSibling
();
269 static AutomationNode nextSibling
();
271 // Does the default action based on this node's role. This is generally
272 // the same action that would result from clicking the node such as
273 // expanding a treeitem, toggling a checkbox, selecting a radiobutton,
274 // or activating a button.
275 static
void doDefault
();
277 // Places focus on this node.
280 // Scrolls this node to make it visible.
281 static
void makeVisible
();
283 // Sets selection within a text field.
284 static
void setSelection
(long startIndex
, long endIndex
);
286 // Adds a listener for the given event type and event phase.
287 static
void addEventListener
(
288 EventType eventType
, AutomationListener listener
, boolean capture
);
290 // Removes a listener for the given event type and event phase.
291 static
void removeEventListener
(
292 EventType eventType
, AutomationListener listener
, boolean capture
);
295 // Called when the <code>AutomationRootNode</code> for the page is available.
296 callback RootCallback
= void(AutomationRootNode rootNode
);
298 // The root node of the automation tree for a single frame or desktop.
302 // <li> The top frame of a page
303 // <li> A frame or iframe within a page
305 // Thus, an <code>AutomationRootNode</code> may be a descendant of one or
306 // more <code>AutomationRootNode</code>s, and in turn have one or more
307 // <code>AutomationRootNode</code>s in its descendants. Thus, the
308 // <code>root</code> property of the <code>AutomationRootNode</code> will be
309 // the immediate parent <code>AutomationRootNode</code>, or <code>null</code>
310 // if this is the top-level <code>AutomationRootNode</code>.
312 // Extends $(ref:automation.AutomationNode).
313 [nocompile
, noinline_doc
] dictionary AutomationRootNode
{
314 // TODO(aboxhall/dtseng): implement loading. Kept separate to not include
315 // in generated docs.
317 // Whether this AutomationRootNode is loaded or not. If false, call load()
318 // to get the contents.
321 // Load the accessibility tree for this AutomationRootNode.
322 static
void load
(RootCallback
callback);
325 interface Functions
{
326 // Get the automation tree for the tab with the given tabId, or the current
327 // tab if no tabID is given, enabling automation if necessary. Returns a
328 // tree with a placeholder root node; listen for the "loadComplete" event to
329 // get a notification that the tree has fully loaded (the previous root node
330 // reference will stop working at or before this point).
331 [nocompile
] static
void getTree
(optional long tabId
, RootCallback
callback);
333 // Get the automation tree for the whole desktop which consists of all on
334 // screen views. Note this API is currently only supported on Chrome OS.
335 [nocompile
] static
void getDesktop
(RootCallback
callback);