Merge Chromium + Blink git repositories
[chromium-blink-merge.git] / chrome / common / extensions / api / automation.idl
blobb49c3a5e179c58bd70ee76efc89f179bfb0eda68
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).
15 enum EventType {
16 activedescendantchanged,
17 alert,
18 ariaAttributeChanged,
19 autocorrectionOccured,
20 blur,
21 checkedStateChanged,
22 childrenChanged,
23 focus,
24 hide,
25 hover,
26 invalidStatusChanged,
27 layoutComplete,
28 liveRegionChanged,
29 loadComplete,
30 locationChanged,
31 menuEnd,
32 menuListItemSelected,
33 menuListValueChanged,
34 menuPopupEnd,
35 menuPopupStart,
36 menuStart,
37 rowCollapsed,
38 rowCountChanged,
39 rowExpanded,
40 scrollPositionChanged,
41 scrolledToAnchor,
42 selectedChildrenChanged,
43 selection,
44 selectionAdd,
45 selectionRemove,
46 show,
47 textChanged,
48 textSelectionChanged,
49 treeChanged,
50 valueChanged
53 // Describes the purpose of an $(ref:automation.AutomationNode).
54 enum RoleType {
55 alertDialog,
56 alert,
57 annotation,
58 application,
59 article,
60 banner,
61 blockquote,
62 busyIndicator,
63 button,
64 buttonDropDown,
65 canvas,
66 caption,
67 cell,
68 checkBox,
69 client,
70 colorWell,
71 columnHeader,
72 column,
73 comboBox,
74 complementary,
75 contentInfo,
76 date,
77 dateTime,
78 definition,
79 descriptionListDetail,
80 descriptionList,
81 descriptionListTerm,
82 desktop,
83 details,
84 dialog,
85 directory,
86 disclosureTriangle,
87 div,
88 document,
89 embeddedObject,
90 figcaption,
91 figure,
92 footer,
93 form,
94 grid,
95 group,
96 heading,
97 iframe,
98 iframePresentational,
99 ignored,
100 imageMapLink,
101 imageMap,
102 image,
103 inlineTextBox,
104 inputTime,
105 labelText,
106 legend,
107 lineBreak,
108 link,
109 listBoxOption,
110 listBox,
111 listItem,
112 listMarker,
113 list,
114 locationBar,
115 log,
116 main,
117 mark,
118 marquee,
119 math,
120 menuBar,
121 menuButton,
122 menuItem,
123 menuItemCheckBox,
124 menuItemRadio,
125 menuListOption,
126 menuListPopup,
127 menu,
128 meter,
129 navigation,
130 note,
131 outline,
132 pane,
133 paragraph,
134 popUpButton,
135 pre,
136 presentational,
137 progressIndicator,
138 radioButton,
139 radioGroup,
140 region,
141 rootWebArea,
142 rowHeader,
143 row,
144 ruby,
145 ruler,
146 svgRoot,
147 scrollArea,
148 scrollBar,
149 seamlessWebArea,
150 search,
151 searchBox,
152 slider,
153 sliderThumb,
154 spinButtonPart,
155 spinButton,
156 splitter,
157 staticText,
158 status,
159 switch,
160 tabGroup,
161 tabList,
162 tabPanel,
163 tab,
164 tableHeaderContainer,
165 table,
166 textField,
167 time,
168 timer,
169 titleBar,
170 toggleButton,
171 toolbar,
172 treeGrid,
173 treeItem,
174 tree,
175 unknown,
176 tooltip,
177 webArea,
178 webView,
179 window
182 // Describes characteristics of an $(ref:automation.AutomationNode).
183 enum StateType {
184 busy,
185 checked,
186 collapsed,
187 default,
188 disabled, // ui/views only
189 editable, // ui/views only
190 enabled, // content only
191 expanded,
192 focusable,
193 focused,
194 haspopup,
195 horizontal,
196 hovered,
197 indeterminate,
198 invisible,
199 linked,
200 multiline,
201 multiselectable,
202 offscreen,
203 pressed,
204 protected,
205 readOnly,
206 required,
207 selectable,
208 selected,
209 vertical,
210 visited
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.
225 nodeCreated,
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.
232 subtreeCreated,
235 * This node changed.
237 nodeChanged,
240 * This node was removed.
242 nodeRemoved
245 dictionary Rect {
246 long left;
247 long top;
248 long width;
249 long height;
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.
261 object? state;
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
269 // must be one of:
270 // <ul>
271 // <li>string</li>
272 // <li>integer</li>
273 // <li>float</li>
274 // <li>boolean</li>
275 // </ul>
276 object? attributes;
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.
288 EventType type;
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.
304 TreeChangeType type;
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.
313 AutomationNode root;
315 // Whether this AutomationNode is root node.
316 boolean isRootNode;
318 // The role of this node.
319 automation.RoleType role;
321 // The $(ref:automation.StateType)s describing this node.
322 object state;
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.
331 DOMString help;
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.
336 DOMString name;
338 // The value for this node: for example the <code>value</code> attribute of
339 // an <code>&lt;input&gt; element.
340 DOMString value;
342 // The HTML tag for this element, if this node is an HTML element.
343 DOMString htmlTag;
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.
349 long[] wordStarts;
350 long[] wordEnds;
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
361 // one. See
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
372 // applicable
373 AutomationNode activedescendant;
376 // Link attributes.
379 // The URL that this link will navigate to.
380 DOMString url;
383 // Document attributes.
386 // The URL of this document.
387 DOMString docUrl;
389 // The title of this document.
390 DOMString docTitle;
392 // Whether this document has finished loading.
393 boolean docLoaded;
395 // The proportion (out of 1.0) that this doc has completed loading.
396 double docLoadingProgress;
399 // Scrollable container attributes.
402 long scrollX;
403 long scrollXMin;
404 long scrollXMax;
405 long scrollY;
406 long scrollYMin;
407 long scrollYMax;
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.
415 long textSelStart;
417 // The character index of the end of the selection within this editable
418 // text element; -1 if no selection.
419 long textSelEnd;
421 // The input type, like email or number.
422 DOMString textInputType;
425 // Range attributes.
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;
438 // Table attributes.
441 // The number of rows in this table.
442 long tableRowCount;
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;
464 // Walking the tree.
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.
476 long? indexInParent;
479 // Actions.
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.
489 static void focus();
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);