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,
55 // Describes the purpose of an $(ref:automation.AutomationNode).
78 descriptionListDetail,
160 tableHeaderContainer,
178 // Describes characteristics of an $(ref:automation.AutomationNode).
184 disabled, // ui/views only
185 editable, // ui/views only
186 enabled, // content only
214 // An event in the Automation tree.
215 [nocompile, noinline_doc] dictionary AutomationEvent {
216 // The $(ref:automation.AutomationNode) to which the event was targeted.
217 AutomationNode target;
219 // The type of the event.
222 // Stops this event from further processing except for any remaining
223 // listeners on $(ref:AutomationEvent.target).
224 static void stopPropagation();
227 // A listener for events on an <code>AutomationNode</code>.
228 callback AutomationListener = void(AutomationEvent event);
230 // A single node in an Automation tree.
231 [nocompile, noinline_doc] dictionary AutomationNode {
232 // The root node of the tree containing this AutomationNode.
233 AutomationRootNode root;
235 // Whether this AutomationNode is an AutomationRootNode.
238 // Unique ID to identify this node.
241 // The role of this node.
242 automation.RoleType role;
244 // The $(ref:automation.StateType)s describing this node.
247 // The rendered location (as a bounding box) of this node within the frame.
248 automation.Rect location;
250 // A collection of this node's other attributes.
253 // The index of this node in its parent node's list of children. If this is
254 // the root node, this will be undefined.
257 static AutomationNode[] children();
258 static AutomationNode parent();
259 static AutomationNode firstChild();
260 static AutomationNode lastChild();
261 static AutomationNode previousSibling();
262 static AutomationNode nextSibling();
264 // Does the default action based on this node's role. This is generally
265 // the same action that would result from clicking the node such as
266 // expanding a treeitem, toggling a checkbox, selecting a radiobutton,
267 // or activating a button.
268 static void doDefault();
270 // Places focus on this node.
273 // Scrolls this node to make it visible.
274 static void makeVisible();
276 // Sets selection within a text field.
277 static void setSelection(long startIndex, long endIndex);
279 // Adds a listener for the given event type and event phase.
280 static void addEventListener(
281 EventType eventType, AutomationListener listener, boolean capture);
283 // Removes a listener for the given event type and event phase.
284 static void removeEventListener(
285 EventType eventType, AutomationListener listener, boolean capture);
288 // Called when the <code>AutomationRootNode</code> for the page is available.
289 callback RootCallback = void(AutomationRootNode rootNode);
291 // The root node of the automation tree for a single frame or desktop.
295 // <li> The top frame of a page
296 // <li> A frame or iframe within a page
298 // Thus, an <code>AutomationRootNode</code> may be a descendant of one or
299 // more <code>AutomationRootNode</code>s, and in turn have one or more
300 // <code>AutomationRootNode</code>s in its descendants. Thus, the
301 // <code>root</code> property of the <code>AutomationRootNode</code> will be
302 // the immediate parent <code>AutomationRootNode</code>, or <code>null</code>
303 // if this is the top-level <code>AutomationRootNode</code>.
305 // Extends $(ref:automation.AutomationNode).
306 [nocompile, noinline_doc] dictionary AutomationRootNode {
307 // TODO(aboxhall/dtseng): implement loading. Kept separate to not include
308 // in generated docs.
310 // Whether this AutomationRootNode is loaded or not. If false, call load()
311 // to get the contents.
314 // Load the accessibility tree for this AutomationRootNode.
315 static void load(RootCallback callback);
318 interface Functions {
319 // Get the automation tree for the tab with the given tabId, or the current
320 // tab if no tabID is given, enabling automation if necessary. Returns a
321 // tree with a placeholder root node; listen for the "loadComplete" event to
322 // get a notification that the tree has fully loaded (the previous root node
323 // reference will stop working at or before this point).
324 [nocompile] static void getTree(optional long tabId, RootCallback callback);
326 // Get the automation tree for the whole desktop which consists of all on
327 // screen views. Note this API is currently only supported on Chrome OS.
328 [nocompile] static void getDesktop(RootCallback callback);