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).
78 descriptionListDetail
,
166 tableHeaderContainer
,
186 // Describes characteristics of an $(ref:automation.AutomationNode).
192 disabled
, // ui/views only
193 editable
, // ui/views only
194 enabled
, // content only
222 // Arguments for the find() and findAll() methods.
223 [nocompile
, noinline_doc
] dictionary FindParams
{
224 automation.RoleType? role
;
226 // A map of $(ref:automation.StateType) to boolean, indicating for each
227 // state whether it should be set or not. For example:
228 // <code>{ StateType.enabled: false }</code> would only match if
229 // <code>StateType.enabled</code> was <em>not</em> present in the node's
230 // <code>state</code> object.
233 // A map of attribute name to expected value, for example
234 // <code>{ name: 'Root directory', button_mixed: true }</code>.
235 // String attribute values may be specified as a regex, for example
236 // <code>{ name: /stralia$/</code> }</code>.
237 // Unless specifying a regex, the expected value must be an exact match
238 // in type and value for the actual value. Thus, the type of expected value
249 // Called when the result for a <code>query</code> is available.
250 callback QueryCallback
= void(AutomationNode node
);
252 // An event in the Automation tree.
253 [nocompile
, noinline_doc
] dictionary AutomationEvent
{
254 // The $(ref:automation.AutomationNode) to which the event was targeted.
255 AutomationNode target
;
257 // The type of the event.
260 // Stops this event from further processing except for any remaining
261 // listeners on $(ref:AutomationEvent.target).
262 static
void stopPropagation
();
265 // A listener for events on an <code>AutomationNode</code>.
266 callback AutomationListener
= void(AutomationEvent event
);
268 // A single node in an Automation tree.
269 [nocompile
, noinline_doc
] dictionary AutomationNode
{
270 // The root node of the tree containing this AutomationNode.
273 // Whether this AutomationNode is root node.
276 // The role of this node.
277 automation.RoleType role
;
279 // The $(ref:automation.StateType)s describing this node.
282 // The rendered location (as a bounding box) of this node within the frame.
283 automation.Rect location
;
285 // A collection of this node's other attributes.
288 // The index of this node in its parent node's list of children. If this is
289 // the root node, this will be undefined.
292 static AutomationNode
[] children
();
293 static AutomationNode parent
();
294 static AutomationNode firstChild
();
295 static AutomationNode lastChild
();
296 static AutomationNode previousSibling
();
297 static AutomationNode nextSibling
();
299 // Does the default action based on this node's role. This is generally
300 // the same action that would result from clicking the node such as
301 // expanding a treeitem, toggling a checkbox, selecting a radiobutton,
302 // or activating a button.
303 static
void doDefault
();
305 // Places focus on this node.
308 // Scrolls this node to make it visible.
309 static
void makeVisible
();
311 // Sets selection within a text field.
312 static
void setSelection
(long startIndex
, long endIndex
);
314 // Adds a listener for the given event type and event phase.
315 static
void addEventListener
(
316 EventType eventType
, AutomationListener listener
, boolean capture
);
318 // Removes a listener for the given event type and event phase.
319 static
void removeEventListener
(
320 EventType eventType
, AutomationListener listener
, boolean capture
);
322 // Gets the first node in this node's subtree which matches the given CSS
323 // selector and is within the same DOM context.
325 // If this node doesn't correspond directly with an HTML node in the DOM,
326 // querySelector will be run on this node's nearest HTML node ancestor. Note
327 // that this may result in the query returning a node which is not a
328 // descendant of this node.
330 // If the selector matches a node which doesn't directly correspond to an
331 // automation node (for example an element within an ARIA widget, where the
332 // ARIA widget forms one node of the automation tree, or an element which
333 // is hidden from accessibility via hiding it using CSS or using
334 // aria-hidden), this will return the nearest ancestor which does correspond
335 // to an automation node.
336 static
void domQuerySelector
(DOMString selector
, QueryCallback
callback);
338 // Finds the first AutomationNode in this node's subtree which matches the
339 // given search parameters.
340 static AutomationNode find
(FindParams params
);
342 // Finds all the AutomationNodes in this node's subtree which matches the
343 // given search parameters.
344 static AutomationNode
[] findAll
(FindParams params
);
346 // Returns whether this node matches the given $(ref:automation.FindParams).
347 static
boolean matches
(FindParams params
);
350 // Called when the <code>AutomationNode</code> for the page is available.
351 callback RootCallback
= void(AutomationNode rootNode
);
353 interface Functions
{
354 // Get the automation tree for the tab with the given tabId, or the current
355 // tab if no tabID is given, enabling automation if necessary. Returns a
356 // tree with a placeholder root node; listen for the "loadComplete" event to
357 // get a notification that the tree has fully loaded (the previous root node
358 // reference will stop working at or before this point).
359 [nocompile
] static
void getTree
(optional long tabId
, RootCallback
callback);
361 // Get the automation tree for the whole desktop which consists of all on
362 // screen views. Note this API is currently only supported on Chrome OS.
363 [nocompile
] static
void getDesktop
(RootCallback
callback);