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,
53 // Describes the purpose of an $(ref:automation.AutomationNode).
79 descriptionListDetail,
168 tableHeaderContainer,
188 // Describes characteristics of an $(ref:automation.AutomationNode).
194 disabled, // ui/views only
195 editable, // ui/views only
196 enabled, // content only
224 // Called when the result for a <code>query</code> is available.
225 callback QueryCallback = void(AutomationNode node);
227 // An event in the Automation tree.
228 [nocompile, noinline_doc] dictionary AutomationEvent {
229 // The $(ref:automation.AutomationNode) to which the event was targeted.
230 AutomationNode target;
232 // The type of the event.
235 // Stops this event from further processing except for any remaining
236 // listeners on $(ref:AutomationEvent.target).
237 static void stopPropagation();
240 // A listener for events on an <code>AutomationNode</code>.
241 callback AutomationListener = void(AutomationEvent event);
243 // A single node in an Automation tree.
244 [nocompile, noinline_doc] dictionary AutomationNode {
245 // The root node of the tree containing this AutomationNode.
248 // Whether this AutomationNode is root node.
251 // The role of this node.
252 automation.RoleType role;
254 // The $(ref:automation.StateType)s describing this node.
257 // The rendered location (as a bounding box) of this node within the frame.
258 automation.Rect location;
260 // A collection of this node's other attributes.
263 // The index of this node in its parent node's list of children. If this is
264 // the root node, this will be undefined.
267 static AutomationNode[] children();
268 static AutomationNode parent();
269 static AutomationNode firstChild();
270 static AutomationNode lastChild();
271 static AutomationNode previousSibling();
272 static AutomationNode nextSibling();
274 // Does the default action based on this node's role. This is generally
275 // the same action that would result from clicking the node such as
276 // expanding a treeitem, toggling a checkbox, selecting a radiobutton,
277 // or activating a button.
278 static void doDefault();
280 // Places focus on this node.
283 // Scrolls this node to make it visible.
284 static void makeVisible();
286 // Sets selection within a text field.
287 static void setSelection(long startIndex, long endIndex);
289 // Adds a listener for the given event type and event phase.
290 static void addEventListener(
291 EventType eventType, AutomationListener listener, boolean capture);
293 // Removes a listener for the given event type and event phase.
294 static void removeEventListener(
295 EventType eventType, AutomationListener listener, boolean capture);
297 // Gets the first node in this node's subtree which matches the given CSS
298 // selector and is within the same DOM context.
300 // If this node doesn't correspond directly with an HTML node in the DOM,
301 // querySelector will be run on this node's nearest HTML node ancestor. Note
302 // that this may result in the query returning a node which is not a
303 // descendant of this node.
305 // If the selector matches a node which doesn't directly correspond to an
306 // automation node (for example an element within an ARIA widget, where the
307 // ARIA widget forms one node of the automation tree, or an element which
308 // is hidden from accessibility via hiding it using CSS or using
309 // aria-hidden), this will return the nearest ancestor which does correspond
310 // to an automation node.
311 static void querySelector(DOMString selector, QueryCallback callback);
314 // Called when the <code>AutomationNode</code> for the page is available.
315 callback RootCallback = void(AutomationNode rootNode);
317 interface Functions {
318 // Get the automation tree for the tab with the given tabId, or the current
319 // tab if no tabID is given, enabling automation if necessary. Returns a
320 // tree with a placeholder root node; listen for the "loadComplete" event to
321 // get a notification that the tree has fully loaded (the previous root node
322 // reference will stop working at or before this point).
323 [nocompile] static void getTree(optional long tabId, RootCallback callback);
325 // Get the automation tree for the whole desktop which consists of all on
326 // screen views. Note this API is currently only supported on Chrome OS.
327 [nocompile] static void getDesktop(RootCallback callback);