browser-protocol 0.1.0

Generated Rust types and commands for the Chrome DevTools Protocol (browser-protocol)
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
use serde::{Serialize, Deserialize};
use serde_json::Value as JsonValue;

/// Unique accessibility node identifier.

pub type AXNodeId = String;

/// Enum of possible property types.

#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Default)]
pub enum AXValueType {
    #[default]
    Boolean,
    Tristate,
    BooleanOrUndefined,
    Idref,
    IdrefList,
    Integer,
    Node,
    NodeList,
    Number,
    String,
    ComputedString,
    Token,
    TokenList,
    DomRelation,
    Role,
    InternalRole,
    ValueUndefined,
}

/// Enum of possible property sources.

#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Default)]
pub enum AXValueSourceType {
    #[default]
    Attribute,
    Implicit,
    Style,
    Contents,
    Placeholder,
    RelatedElement,
}

/// Enum of possible native property sources (as a subtype of a particular AXValueSourceType).

#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Default)]
pub enum AXValueNativeSourceType {
    #[default]
    Description,
    Figcaption,
    Label,
    Labelfor,
    Labelwrapped,
    Legend,
    Rubyannotation,
    Tablecaption,
    Title,
    Other,
}

/// A single source for a computed AX property.

#[derive(Debug, Clone, Serialize, Deserialize, Default)]
#[serde(rename_all = "camelCase")]
pub struct AXValueSource {
    /// What type of source this is.

    #[serde(rename = "type")]
    pub type_: AXValueSourceType,
    /// The value of this property source.

    #[serde(skip_serializing_if = "Option::is_none")]
    pub value: Option<AXValue>,
    /// The name of the relevant attribute, if any.

    #[serde(skip_serializing_if = "Option::is_none")]
    pub attribute: Option<String>,
    /// The value of the relevant attribute, if any.

    #[serde(skip_serializing_if = "Option::is_none")]
    pub attributeValue: Option<AXValue>,
    /// Whether this source is superseded by a higher priority source.

    #[serde(skip_serializing_if = "Option::is_none")]
    pub superseded: Option<bool>,
    /// The native markup source for this value, e.g. a '\<label\>' element.

    #[serde(skip_serializing_if = "Option::is_none")]
    pub nativeSource: Option<AXValueNativeSourceType>,
    /// The value, such as a node or node list, of the native source.

    #[serde(skip_serializing_if = "Option::is_none")]
    pub nativeSourceValue: Option<AXValue>,
    /// Whether the value for this property is invalid.

    #[serde(skip_serializing_if = "Option::is_none")]
    pub invalid: Option<bool>,
    /// Reason for the value being invalid, if it is.

    #[serde(skip_serializing_if = "Option::is_none")]
    pub invalidReason: Option<String>,
}


#[derive(Debug, Clone, Serialize, Deserialize, Default)]
#[serde(rename_all = "camelCase")]
pub struct AXRelatedNode {
    /// The BackendNodeId of the related DOM node.

    pub backendDOMNodeId: crate::dom::BackendNodeId,
    /// The IDRef value provided, if any.

    #[serde(skip_serializing_if = "Option::is_none")]
    pub idref: Option<String>,
    /// The text alternative of this node in the current context.

    #[serde(skip_serializing_if = "Option::is_none")]
    pub text: Option<String>,
}


#[derive(Debug, Clone, Serialize, Deserialize, Default)]
#[serde(rename_all = "camelCase")]
pub struct AXProperty {
    /// The name of this property.

    pub name: AXPropertyName,
    /// The value of this property.

    pub value: AXValue,
}

/// A single computed AX property.

#[derive(Debug, Clone, Serialize, Deserialize, Default)]
#[serde(rename_all = "camelCase")]
pub struct AXValue {
    /// The type of this value.

    #[serde(rename = "type")]
    pub type_: AXValueType,
    /// The computed value of this property.

    #[serde(skip_serializing_if = "Option::is_none")]
    pub value: Option<JsonValue>,
    /// One or more related nodes, if applicable.

    #[serde(skip_serializing_if = "Option::is_none")]
    pub relatedNodes: Option<Vec<AXRelatedNode>>,
    /// The sources which contributed to the computation of this property.

    #[serde(skip_serializing_if = "Option::is_none")]
    pub sources: Option<Vec<AXValueSource>>,
}

/// Values of AXProperty name:
/// - from 'busy' to 'roledescription': states which apply to every AX node
/// - from 'live' to 'root': attributes which apply to nodes in live regions
/// - from 'autocomplete' to 'valuetext': attributes which apply to widgets
/// - from 'checked' to 'selected': states which apply to widgets
/// - from 'activedescendant' to 'owns': relationships between elements other than parent/child/sibling
/// - from 'activeFullscreenElement' to 'uninteresting': reasons why this noode is hidden

#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Default)]
pub enum AXPropertyName {
    #[default]
    Actions,
    Busy,
    Disabled,
    Editable,
    Focusable,
    Focused,
    Hidden,
    HiddenRoot,
    Invalid,
    Keyshortcuts,
    Settable,
    Roledescription,
    Live,
    Atomic,
    Relevant,
    Root,
    Autocomplete,
    HasPopup,
    Level,
    Multiselectable,
    Orientation,
    Multiline,
    Readonly,
    Required,
    Valuemin,
    Valuemax,
    Valuetext,
    Checked,
    Expanded,
    Modal,
    Pressed,
    Selected,
    Activedescendant,
    Controls,
    Describedby,
    Details,
    Errormessage,
    Flowto,
    Labelledby,
    Owns,
    Url,
    ActiveFullscreenElement,
    ActiveModalDialog,
    ActiveAriaModalDialog,
    AriaHiddenElement,
    AriaHiddenSubtree,
    EmptyAlt,
    EmptyText,
    InertElement,
    InertSubtree,
    LabelContainer,
    LabelFor,
    NotRendered,
    NotVisible,
    PresentationalRole,
    ProbablyPresentational,
    InactiveCarouselTabContent,
    Uninteresting,
}

/// A node in the accessibility tree.

#[derive(Debug, Clone, Serialize, Deserialize, Default)]
#[serde(rename_all = "camelCase")]
pub struct AXNode {
    /// Unique identifier for this node.

    pub nodeId: AXNodeId,
    /// Whether this node is ignored for accessibility

    pub ignored: bool,
    /// Collection of reasons why this node is hidden.

    #[serde(skip_serializing_if = "Option::is_none")]
    pub ignoredReasons: Option<Vec<AXProperty>>,
    /// This 'Node''s role, whether explicit or implicit.

    #[serde(skip_serializing_if = "Option::is_none")]
    pub role: Option<AXValue>,
    /// This 'Node''s Chrome raw role.

    #[serde(skip_serializing_if = "Option::is_none")]
    pub chromeRole: Option<AXValue>,
    /// The accessible name for this 'Node'.

    #[serde(skip_serializing_if = "Option::is_none")]
    pub name: Option<AXValue>,
    /// The accessible description for this 'Node'.

    #[serde(skip_serializing_if = "Option::is_none")]
    pub description: Option<AXValue>,
    /// The value for this 'Node'.

    #[serde(skip_serializing_if = "Option::is_none")]
    pub value: Option<AXValue>,
    /// All other properties

    #[serde(skip_serializing_if = "Option::is_none")]
    pub properties: Option<Vec<AXProperty>>,
    /// ID for this node's parent.

    #[serde(skip_serializing_if = "Option::is_none")]
    pub parentId: Option<AXNodeId>,
    /// IDs for each of this node's child nodes.

    #[serde(skip_serializing_if = "Option::is_none")]
    pub childIds: Option<Vec<AXNodeId>>,
    /// The backend ID for the associated DOM node, if any.

    #[serde(skip_serializing_if = "Option::is_none")]
    pub backendDOMNodeId: Option<crate::dom::BackendNodeId>,
    /// The frame ID for the frame associated with this nodes document.

    #[serde(skip_serializing_if = "Option::is_none")]
    pub frameId: Option<crate::page::FrameId>,
}

/// Fetches the accessibility node and partial accessibility tree for this DOM node, if it exists.

#[derive(Debug, Clone, Serialize, Deserialize, Default)]
#[serde(rename_all = "camelCase")]
pub struct GetPartialAXTreeParams {
    /// Identifier of the node to get the partial accessibility tree for.

    #[serde(skip_serializing_if = "Option::is_none")]
    pub nodeId: Option<crate::dom::NodeId>,
    /// Identifier of the backend node to get the partial accessibility tree for.

    #[serde(skip_serializing_if = "Option::is_none")]
    pub backendNodeId: Option<crate::dom::BackendNodeId>,
    /// JavaScript object id of the node wrapper to get the partial accessibility tree for.

    #[serde(skip_serializing_if = "Option::is_none")]
    pub objectId: Option<crate::runtime::RemoteObjectId>,
    /// Whether to fetch this node's ancestors, siblings and children. Defaults to true.

    #[serde(skip_serializing_if = "Option::is_none")]
    pub fetchRelatives: Option<bool>,
}

/// Fetches the accessibility node and partial accessibility tree for this DOM node, if it exists.

#[derive(Debug, Clone, Serialize, Deserialize, Default)]
#[serde(rename_all = "camelCase")]
pub struct GetPartialAXTreeReturns {
    /// The 'Accessibility.AXNode' for this DOM node, if it exists, plus its ancestors, siblings and
    /// children, if requested.

    pub nodes: Vec<AXNode>,
}

/// Fetches the entire accessibility tree for the root Document

#[derive(Debug, Clone, Serialize, Deserialize, Default)]
#[serde(rename_all = "camelCase")]
pub struct GetFullAXTreeParams {
    /// The maximum depth at which descendants of the root node should be retrieved.
    /// If omitted, the full tree is returned.

    #[serde(skip_serializing_if = "Option::is_none")]
    pub depth: Option<i64>,
    /// The frame for whose document the AX tree should be retrieved.
    /// If omitted, the root frame is used.

    #[serde(skip_serializing_if = "Option::is_none")]
    pub frameId: Option<crate::page::FrameId>,
}

/// Fetches the entire accessibility tree for the root Document

#[derive(Debug, Clone, Serialize, Deserialize, Default)]
#[serde(rename_all = "camelCase")]
pub struct GetFullAXTreeReturns {

    pub nodes: Vec<AXNode>,
}

/// Fetches the root node.
/// Requires 'enable()' to have been called previously.

#[derive(Debug, Clone, Serialize, Deserialize, Default)]
#[serde(rename_all = "camelCase")]
pub struct GetRootAXNodeParams {
    /// The frame in whose document the node resides.
    /// If omitted, the root frame is used.

    #[serde(skip_serializing_if = "Option::is_none")]
    pub frameId: Option<crate::page::FrameId>,
}

/// Fetches the root node.
/// Requires 'enable()' to have been called previously.

#[derive(Debug, Clone, Serialize, Deserialize, Default)]
#[serde(rename_all = "camelCase")]
pub struct GetRootAXNodeReturns {

    pub node: AXNode,
}

/// Fetches a node and all ancestors up to and including the root.
/// Requires 'enable()' to have been called previously.

#[derive(Debug, Clone, Serialize, Deserialize, Default)]
#[serde(rename_all = "camelCase")]
pub struct GetAXNodeAndAncestorsParams {
    /// Identifier of the node to get.

    #[serde(skip_serializing_if = "Option::is_none")]
    pub nodeId: Option<crate::dom::NodeId>,
    /// Identifier of the backend node to get.

    #[serde(skip_serializing_if = "Option::is_none")]
    pub backendNodeId: Option<crate::dom::BackendNodeId>,
    /// JavaScript object id of the node wrapper to get.

    #[serde(skip_serializing_if = "Option::is_none")]
    pub objectId: Option<crate::runtime::RemoteObjectId>,
}

/// Fetches a node and all ancestors up to and including the root.
/// Requires 'enable()' to have been called previously.

#[derive(Debug, Clone, Serialize, Deserialize, Default)]
#[serde(rename_all = "camelCase")]
pub struct GetAXNodeAndAncestorsReturns {

    pub nodes: Vec<AXNode>,
}

/// Fetches a particular accessibility node by AXNodeId.
/// Requires 'enable()' to have been called previously.

#[derive(Debug, Clone, Serialize, Deserialize, Default)]
#[serde(rename_all = "camelCase")]
pub struct GetChildAXNodesParams {

    pub id: AXNodeId,
    /// The frame in whose document the node resides.
    /// If omitted, the root frame is used.

    #[serde(skip_serializing_if = "Option::is_none")]
    pub frameId: Option<crate::page::FrameId>,
}

/// Fetches a particular accessibility node by AXNodeId.
/// Requires 'enable()' to have been called previously.

#[derive(Debug, Clone, Serialize, Deserialize, Default)]
#[serde(rename_all = "camelCase")]
pub struct GetChildAXNodesReturns {

    pub nodes: Vec<AXNode>,
}

/// Query a DOM node's accessibility subtree for accessible name and role.
/// This command computes the name and role for all nodes in the subtree, including those that are
/// ignored for accessibility, and returns those that match the specified name and role. If no DOM
/// node is specified, or the DOM node does not exist, the command returns an error. If neither
/// 'accessibleName' or 'role' is specified, it returns all the accessibility nodes in the subtree.

#[derive(Debug, Clone, Serialize, Deserialize, Default)]
#[serde(rename_all = "camelCase")]
pub struct QueryAXTreeParams {
    /// Identifier of the node for the root to query.

    #[serde(skip_serializing_if = "Option::is_none")]
    pub nodeId: Option<crate::dom::NodeId>,
    /// Identifier of the backend node for the root to query.

    #[serde(skip_serializing_if = "Option::is_none")]
    pub backendNodeId: Option<crate::dom::BackendNodeId>,
    /// JavaScript object id of the node wrapper for the root to query.

    #[serde(skip_serializing_if = "Option::is_none")]
    pub objectId: Option<crate::runtime::RemoteObjectId>,
    /// Find nodes with this computed name.

    #[serde(skip_serializing_if = "Option::is_none")]
    pub accessibleName: Option<String>,
    /// Find nodes with this computed role.

    #[serde(skip_serializing_if = "Option::is_none")]
    pub role: Option<String>,
}

/// Query a DOM node's accessibility subtree for accessible name and role.
/// This command computes the name and role for all nodes in the subtree, including those that are
/// ignored for accessibility, and returns those that match the specified name and role. If no DOM
/// node is specified, or the DOM node does not exist, the command returns an error. If neither
/// 'accessibleName' or 'role' is specified, it returns all the accessibility nodes in the subtree.

#[derive(Debug, Clone, Serialize, Deserialize, Default)]
#[serde(rename_all = "camelCase")]
pub struct QueryAXTreeReturns {
    /// A list of 'Accessibility.AXNode' matching the specified attributes,
    /// including nodes that are ignored for accessibility.

    pub nodes: Vec<AXNode>,
}