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
,
164 tableHeaderContainer
,
182 // Describes characteristics of an $(ref:automation.AutomationNode).
188 disabled
, // ui/views only
189 editable
, // ui/views only
190 enabled
, // content only
213 // Possible changes to the automation tree. For any given atomic change
214 // to the tree, each node that's added, removed, or changed, will appear
215 // in exactly one TreeChange, with one of these types.
218 // nodeCreated means that this node was added to the tree and its parent is
219 // new as well, so it's just one node in a new subtree that was added.
220 enum TreeChangeType
{
222 * This node was added to the tree and its parent is new as well,
223 * so it's just one node in a new subtree that was added.
228 * This node was added to the tree but its parent was already in the
229 * tree, so it's possibly the root of a new subtree - it does not mean
230 * that it necessarily has children.
240 * This node was removed.
252 // Arguments for the find() and findAll() methods.
253 [nocompile
, noinline_doc
] dictionary FindParams
{
254 automation.RoleType? role
;
256 // A map of $(ref:automation.StateType) to boolean, indicating for each
257 // state whether it should be set or not. For example:
258 // <code>{ StateType.enabled: false }</code> would only match if
259 // <code>StateType.enabled</code> was <em>not</em> present in the node's
260 // <code>state</code> object.
263 // A map of attribute name to expected value, for example
264 // <code>{ name: 'Root directory', button_mixed: true }</code>.
265 // String attribute values may be specified as a regex, for example
266 // <code>{ name: /stralia$/</code> }</code>.
267 // Unless specifying a regex, the expected value must be an exact match
268 // in type and value for the actual value. Thus, the type of expected value
279 // Called when the result for a <code>query</code> is available.
280 callback QueryCallback
= void(AutomationNode node
);
282 // An event in the Automation tree.
283 [nocompile
, noinline_doc
] dictionary AutomationEvent
{
284 // The $(ref:automation.AutomationNode) to which the event was targeted.
285 AutomationNode target
;
287 // The type of the event.
290 // Stops this event from further processing except for any remaining
291 // listeners on $(ref:AutomationEvent.target).
292 static
void stopPropagation
();
295 // A listener for events on an <code>AutomationNode</code>.
296 callback AutomationListener
= void(AutomationEvent event
);
298 // A change to the Automation tree.
299 [nocompile
, noinline_doc
] dictionary TreeChange
{
300 // The $(ref:automation.AutomationNode) that changed.
301 AutomationNode target
;
303 // The type of change.
307 // A listener for changes on the <code>AutomationNode</code> tree.
308 callback TreeChangeObserver
= void(TreeChange treeChange
);
310 // A single node in an Automation tree.
311 [nocompile
, noinline_doc
] dictionary AutomationNode
{
312 // The root node of the tree containing this AutomationNode.
315 // Whether this AutomationNode is root node.
318 // The role of this node.
319 automation.RoleType role
;
321 // The $(ref:automation.StateType)s describing this node.
324 // The rendered location (as a bounding box) of this node within the frame.
325 automation.Rect location
;
327 // The purpose of the node, other than the role, if any.
328 DOMString description
;
330 // The help text for the node, if any.
333 // The accessible name for this node, via the
334 // <a href="http://www.w3.org/TR/wai-aria/roles#namecalculation">
335 // Accessible Name Calculation</a> process.
338 // The value for this node: for example the <code>value</code> attribute of
339 // an <code><input> element.
342 // The HTML tag for this element, if this node is an HTML element.
345 // The level of a heading or tree item.
346 long hierarchicalLevel
;
348 // The start and end index of each word in an inline text box.
352 // The nodes, if any, which this node is specified to control via
353 // <a href="http://www.w3.org/TR/wai-aria/states_and_properties#aria-controls">
354 // <code>aria-controls</code></a>.
355 AutomationNode
[] controls
;
357 // The nodes, if any, which form a description for this node.
358 AutomationNode
[] describedBy
;
360 // The nodes, if any, which may optionally be navigated to after this
362 // <a href="http://www.w3.org/TR/wai-aria/states_and_properties#aria-flowto">
363 // <code>aria-flowto</code></a>.
364 AutomationNode
[] flowTo
;
366 // The nodes, if any, which form a label for this element. Generally, the
367 // text from these elements will also be exposed as the element's accessible
368 // name, via the $(ref:automation.AutomationNode.name) attribute.
369 AutomationNode
[] labelledBy
;
371 // The node referred to by <code>aria-activedescendant</code>, where
373 AutomationNode activedescendant
;
379 // The URL that this link will navigate to.
383 // Document attributes.
386 // The URL of this document.
389 // The title of this document.
392 // Whether this document has finished loading.
395 // The proportion (out of 1.0) that this doc has completed loading.
396 double docLoadingProgress
;
399 // Scrollable container attributes.
410 // Editable text field attributes.
413 // The character index of the start of the selection within this editable
414 // text element; -1 if no selection.
417 // The character index of the end of the selection within this editable
418 // text element; -1 if no selection.
421 // The input type, like email or number.
422 DOMString textInputType
;
428 // The current value for this range.
429 double valueForRange
;
431 // The minimum possible value for this range.
432 double minValueForRange
;
434 // The maximum possible value for this range.
435 double maxValueForRange
;
441 // The number of rows in this table.
444 // The number of columns in this table.
445 long tableColumnCount
;
448 // Table cell attributes.
451 // The zero-based index of the column that this cell is in.
452 long tableCellColumnIndex
;
454 // The number of columns that this cell spans (default is 1).
455 long tableCellColumnSpan
;
457 // The zero-based index of the row that this cell is in.
458 long tableCellRowIndex
;
460 // The number of rows that this cell spans (default is 1).
461 long tableCellRowSpan
;
467 AutomationNode
[] children
;
468 AutomationNode parent
;
469 AutomationNode firstChild
;
470 AutomationNode lastChild
;
471 AutomationNode previousSibling
;
472 AutomationNode nextSibling
;
474 // The index of this node in its parent node's list of children. If this is
475 // the root node, this will be undefined.
482 // Does the default action based on this node's role. This is generally
483 // the same action that would result from clicking the node such as
484 // expanding a treeitem, toggling a checkbox, selecting a radiobutton,
485 // or activating a button.
486 static
void doDefault
();
488 // Places focus on this node.
491 // Scrolls this node to make it visible.
492 static
void makeVisible
();
494 // Sets selection within a text field.
495 static
void setSelection
(long startIndex
, long endIndex
);
497 // Adds a listener for the given event type and event phase.
498 static
void addEventListener
(
499 EventType eventType
, AutomationListener listener
, boolean capture
);
501 // Removes a listener for the given event type and event phase.
502 static
void removeEventListener
(
503 EventType eventType
, AutomationListener listener
, boolean capture
);
505 // Gets the first node in this node's subtree which matches the given CSS
506 // selector and is within the same DOM context.
508 // If this node doesn't correspond directly with an HTML node in the DOM,
509 // querySelector will be run on this node's nearest HTML node ancestor. Note
510 // that this may result in the query returning a node which is not a
511 // descendant of this node.
513 // If the selector matches a node which doesn't directly correspond to an
514 // automation node (for example an element within an ARIA widget, where the
515 // ARIA widget forms one node of the automation tree, or an element which
516 // is hidden from accessibility via hiding it using CSS or using
517 // aria-hidden), this will return the nearest ancestor which does correspond
518 // to an automation node.
519 static
void domQuerySelector
(DOMString selector
, QueryCallback
callback);
521 // Finds the first AutomationNode in this node's subtree which matches the
522 // given search parameters.
523 static AutomationNode find
(FindParams params
);
525 // Finds all the AutomationNodes in this node's subtree which matches the
526 // given search parameters.
527 static AutomationNode
[] findAll
(FindParams params
);
529 // Returns whether this node matches the given $(ref:automation.FindParams).
530 static
boolean matches
(FindParams params
);
533 // Called when the <code>AutomationNode</code> for the page is available.
534 callback RootCallback
= void(AutomationNode rootNode
);
536 interface Functions
{
537 // Get the automation tree for the tab with the given tabId, or the current
538 // tab if no tabID is given, enabling automation if necessary. Returns a
539 // tree with a placeholder root node; listen for the "loadComplete" event to
540 // get a notification that the tree has fully loaded (the previous root node
541 // reference will stop working at or before this point).
542 [nocompile
] static
void getTree
(optional long tabId
, RootCallback
callback);
544 // Get the automation tree for the whole desktop which consists of all on
545 // screen views. Note this API is currently only supported on Chrome OS.
546 [nocompile
] static
void getDesktop
(RootCallback
callback);
548 // Add a tree change observer. Tree change observers are static/global, they
549 // listen to changes across all trees.
550 [nocompile
] static
void addTreeChangeObserver
(
551 TreeChangeObserver observer
);
553 // Remove a tree change observer.
554 [nocompile
] static
void removeTreeChangeObserver
(
555 TreeChangeObserver observer
);