browser-protocol 0.1.1

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
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
//! Supports additional targets discovery and allows to attach to them.

use serde::{Serialize, Deserialize};


pub type TargetID = String;

/// Unique identifier of attached debugging session.

pub type SessionID = String;


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

    pub targetId: TargetID,
    /// List of types: <https://source.chromium.org/chromium/chromium/src/+/main:content/browser/devtools/devtools_agent_host_impl.cc?ss=chromium&q=f:devtools%20-f:out%20%22::kTypeTab%5B%5D%22>

    #[serde(rename = "type")]
    pub type_: String,

    pub title: String,

    pub url: String,
    /// Whether the target has an attached client.

    pub attached: bool,
    /// Opener target Id

    #[serde(skip_serializing_if = "Option::is_none")]
    pub openerId: Option<TargetID>,
    /// Whether the target has access to the originating window.

    pub canAccessOpener: bool,
    /// Frame id of originating window (is only set if target has an opener).

    #[serde(skip_serializing_if = "Option::is_none")]
    pub openerFrameId: Option<crate::page::FrameId>,
    /// Id of the parent frame, present for "iframe" and "worker" targets. For nested workers,
    /// this is the "ancestor" frame that created the first worker in the nested chain.

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

    #[serde(skip_serializing_if = "Option::is_none")]
    pub browserContextId: Option<crate::browser::BrowserContextID>,
    /// Provides additional details for specific target types. For example, for
    /// the type of "page", this may be set to "prerender".

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

/// A filter used by target query/discovery/auto-attach operations.

#[derive(Debug, Clone, Serialize, Deserialize, Default)]
#[serde(rename_all = "camelCase")]
pub struct FilterEntry {
    /// If set, causes exclusion of matching targets from the list.

    #[serde(skip_serializing_if = "Option::is_none")]
    pub exclude: Option<bool>,
    /// If not present, matches any type.

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

/// The entries in TargetFilter are matched sequentially against targets and
/// the first entry that matches determines if the target is included or not,
/// depending on the value of 'exclude' field in the entry.
/// If filter is not specified, the one assumed is
/// \[{type: "browser", exclude: true}, {type: "tab", exclude: true}, {}\]
/// (i.e. include everything but 'browser' and 'tab').

pub type TargetFilter = Vec<FilterEntry>;


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

    pub host: String,

    pub port: i64,
}

/// The state of the target window.

#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Default)]
pub enum WindowState {
    #[default]
    Normal,
    Minimized,
    Maximized,
    Fullscreen,
}

/// Activates (focuses) the target.

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

    pub targetId: TargetID,
}

/// Attaches to the target with given id.

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

    pub targetId: TargetID,
    /// Enables "flat" access to the session via specifying sessionId attribute in the commands.
    /// We plan to make this the default, deprecate non-flattened mode,
    /// and eventually retire it. See crbug.com/991325.

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

/// Attaches to the target with given id.

#[derive(Debug, Clone, Serialize, Deserialize, Default)]
#[serde(rename_all = "camelCase")]
pub struct AttachToTargetReturns {
    /// Id assigned to the session.

    pub sessionId: SessionID,
}

/// Attaches to the browser target, only uses flat sessionId mode.

#[derive(Debug, Clone, Serialize, Deserialize, Default)]
#[serde(rename_all = "camelCase")]
pub struct AttachToBrowserTargetReturns {
    /// Id assigned to the session.

    pub sessionId: SessionID,
}

/// Closes the target. If the target is a page that gets closed too.

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

    pub targetId: TargetID,
}

/// Closes the target. If the target is a page that gets closed too.

#[derive(Debug, Clone, Serialize, Deserialize, Default)]
#[serde(rename_all = "camelCase")]
pub struct CloseTargetReturns {
    /// Always set to true. If an error occurs, the response indicates protocol error.

    pub success: bool,
}

/// Inject object to the target's main frame that provides a communication
/// channel with browser target.
/// 
/// Injected object will be available as 'window\[bindingName\]'.
/// 
/// The object has the following API:
/// - 'binding.send(json)' - a method to send messages over the remote debugging protocol
/// - 'binding.onmessage = json =\> handleMessage(json)' - a callback that will be called for the protocol notifications and command responses.

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

    pub targetId: TargetID,
    /// Binding name, 'cdp' if not specified.

    #[serde(skip_serializing_if = "Option::is_none")]
    pub bindingName: Option<String>,
    /// If true, inherits the current root session's permissions (default: false).

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

/// Creates a new empty BrowserContext. Similar to an incognito profile but you can have more than
/// one.

#[derive(Debug, Clone, Serialize, Deserialize, Default)]
#[serde(rename_all = "camelCase")]
pub struct CreateBrowserContextParams {
    /// If specified, disposes this context when debugging session disconnects.

    #[serde(skip_serializing_if = "Option::is_none")]
    pub disposeOnDetach: Option<bool>,
    /// Proxy server, similar to the one passed to --proxy-server

    #[serde(skip_serializing_if = "Option::is_none")]
    pub proxyServer: Option<String>,
    /// Proxy bypass list, similar to the one passed to --proxy-bypass-list

    #[serde(skip_serializing_if = "Option::is_none")]
    pub proxyBypassList: Option<String>,
    /// An optional list of origins to grant unlimited cross-origin access to.
    /// Parts of the URL other than those constituting origin are ignored.

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

/// Creates a new empty BrowserContext. Similar to an incognito profile but you can have more than
/// one.

#[derive(Debug, Clone, Serialize, Deserialize, Default)]
#[serde(rename_all = "camelCase")]
pub struct CreateBrowserContextReturns {
    /// The id of the context created.

    pub browserContextId: crate::browser::BrowserContextID,
}

/// Returns all browser contexts created with 'Target.createBrowserContext' method.

#[derive(Debug, Clone, Serialize, Deserialize, Default)]
#[serde(rename_all = "camelCase")]
pub struct GetBrowserContextsReturns {
    /// An array of browser context ids.

    pub browserContextIds: Vec<crate::browser::BrowserContextID>,
    /// The id of the default browser context if available.

    #[serde(skip_serializing_if = "Option::is_none")]
    pub defaultBrowserContextId: Option<crate::browser::BrowserContextID>,
}

/// Creates a new page.

#[derive(Debug, Clone, Serialize, Deserialize, Default)]
#[serde(rename_all = "camelCase")]
pub struct CreateTargetParams {
    /// The initial URL the page will be navigated to. An empty string indicates about:blank.

    pub url: String,
    /// Frame left origin in DIP (requires newWindow to be true or headless shell).

    #[serde(skip_serializing_if = "Option::is_none")]
    pub left: Option<i64>,
    /// Frame top origin in DIP (requires newWindow to be true or headless shell).

    #[serde(skip_serializing_if = "Option::is_none")]
    pub top: Option<i64>,
    /// Frame width in DIP (requires newWindow to be true or headless shell).

    #[serde(skip_serializing_if = "Option::is_none")]
    pub width: Option<u64>,
    /// Frame height in DIP (requires newWindow to be true or headless shell).

    #[serde(skip_serializing_if = "Option::is_none")]
    pub height: Option<i64>,
    /// Frame window state (requires newWindow to be true or headless shell).
    /// Default is normal.

    #[serde(skip_serializing_if = "Option::is_none")]
    pub windowState: Option<WindowState>,
    /// The browser context to create the page in.

    #[serde(skip_serializing_if = "Option::is_none")]
    pub browserContextId: Option<crate::browser::BrowserContextID>,
    /// Whether BeginFrames for this target will be controlled via DevTools (headless shell only,
    /// not supported on MacOS yet, false by default).

    #[serde(skip_serializing_if = "Option::is_none")]
    pub enableBeginFrameControl: Option<bool>,
    /// Whether to create a new Window or Tab (false by default, not supported by headless shell).

    #[serde(skip_serializing_if = "Option::is_none")]
    pub newWindow: Option<bool>,
    /// Whether to create the target in background or foreground (false by default, not supported
    /// by headless shell).

    #[serde(skip_serializing_if = "Option::is_none")]
    pub background: Option<bool>,
    /// Whether to create the target of type "tab".

    #[serde(skip_serializing_if = "Option::is_none")]
    pub forTab: Option<bool>,
    /// Whether to create a hidden target. The hidden target is observable via protocol, but not
    /// present in the tab UI strip. Cannot be created with 'forTab: true', 'newWindow: true' or
    /// 'background: false'. The life-time of the tab is limited to the life-time of the session.

    #[serde(skip_serializing_if = "Option::is_none")]
    pub hidden: Option<bool>,
    /// If specified, the option is used to determine if the new target should
    /// be focused or not. By default, the focus behavior depends on the
    /// value of the background field. For example, background=false and focus=false
    /// will result in the target tab being opened but the browser window remain
    /// unchanged (if it was in the background, it will remain in the background)
    /// and background=false with focus=undefined will result in the window being focused.
    /// Using background: true and focus: true is not supported and will result in an error.

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

/// Creates a new page.

#[derive(Debug, Clone, Serialize, Deserialize, Default)]
#[serde(rename_all = "camelCase")]
pub struct CreateTargetReturns {
    /// The id of the page opened.

    pub targetId: TargetID,
}

/// Detaches session with given id.

#[derive(Debug, Clone, Serialize, Deserialize, Default)]
#[serde(rename_all = "camelCase")]
pub struct DetachFromTargetParams {
    /// Session to detach.

    #[serde(skip_serializing_if = "Option::is_none")]
    pub sessionId: Option<SessionID>,
    /// Deprecated.

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

/// Deletes a BrowserContext. All the belonging pages will be closed without calling their
/// beforeunload hooks.

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

    pub browserContextId: crate::browser::BrowserContextID,
}

/// Returns information about a target.

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

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

/// Returns information about a target.

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

    pub targetInfo: TargetInfo,
}

/// Retrieves a list of available targets.

#[derive(Debug, Clone, Serialize, Deserialize, Default)]
#[serde(rename_all = "camelCase")]
pub struct GetTargetsParams {
    /// Only targets matching filter will be reported. If filter is not specified
    /// and target discovery is currently enabled, a filter used for target discovery
    /// is used for consistency.

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

/// Retrieves a list of available targets.

#[derive(Debug, Clone, Serialize, Deserialize, Default)]
#[serde(rename_all = "camelCase")]
pub struct GetTargetsReturns {
    /// The list of targets.

    pub targetInfos: Vec<TargetInfo>,
}

/// Sends protocol message over session with given id.
/// Consider using flat mode instead; see commands attachToTarget, setAutoAttach,
/// and crbug.com/991325.

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

    pub message: String,
    /// Identifier of the session.

    #[serde(skip_serializing_if = "Option::is_none")]
    pub sessionId: Option<SessionID>,
    /// Deprecated.

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

/// Controls whether to automatically attach to new targets which are considered
/// to be directly related to this one (for example, iframes or workers).
/// When turned on, attaches to all existing related targets as well. When turned off,
/// automatically detaches from all currently attached targets.
/// This also clears all targets added by 'autoAttachRelated' from the list of targets to watch
/// for creation of related targets.
/// You might want to call this recursively for auto-attached targets to attach
/// to all available targets.

#[derive(Debug, Clone, Serialize, Deserialize, Default)]
#[serde(rename_all = "camelCase")]
pub struct SetAutoAttachParams {
    /// Whether to auto-attach to related targets.

    pub autoAttach: bool,
    /// Whether to pause new targets when attaching to them. Use 'Runtime.runIfWaitingForDebugger'
    /// to run paused targets.

    pub waitForDebuggerOnStart: bool,
    /// Enables "flat" access to the session via specifying sessionId attribute in the commands.
    /// We plan to make this the default, deprecate non-flattened mode,
    /// and eventually retire it. See crbug.com/991325.

    #[serde(skip_serializing_if = "Option::is_none")]
    pub flatten: Option<bool>,
    /// Only targets matching filter will be attached.

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

/// Adds the specified target to the list of targets that will be monitored for any related target
/// creation (such as child frames, child workers and new versions of service worker) and reported
/// through 'attachedToTarget'. The specified target is also auto-attached.
/// This cancels the effect of any previous 'setAutoAttach' and is also cancelled by subsequent
/// 'setAutoAttach'. Only available at the Browser target.

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

    pub targetId: TargetID,
    /// Whether to pause new targets when attaching to them. Use 'Runtime.runIfWaitingForDebugger'
    /// to run paused targets.

    pub waitForDebuggerOnStart: bool,
    /// Only targets matching filter will be attached.

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

/// Controls whether to discover available targets and notify via
/// 'targetCreated/targetInfoChanged/targetDestroyed' events.

#[derive(Debug, Clone, Serialize, Deserialize, Default)]
#[serde(rename_all = "camelCase")]
pub struct SetDiscoverTargetsParams {
    /// Whether to discover available targets.

    pub discover: bool,
    /// Only targets matching filter will be attached. If 'discover' is false,
    /// 'filter' must be omitted or empty.

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

/// Enables target discovery for the specified locations, when 'setDiscoverTargets' was set to
/// 'true'.

#[derive(Debug, Clone, Serialize, Deserialize, Default)]
#[serde(rename_all = "camelCase")]
pub struct SetRemoteLocationsParams {
    /// List of remote locations.

    pub locations: Vec<RemoteLocation>,
}

/// Gets the targetId of the DevTools page target opened for the given target
/// (if any).

#[derive(Debug, Clone, Serialize, Deserialize, Default)]
#[serde(rename_all = "camelCase")]
pub struct GetDevToolsTargetParams {
    /// Page or tab target ID.

    pub targetId: TargetID,
}

/// Gets the targetId of the DevTools page target opened for the given target
/// (if any).

#[derive(Debug, Clone, Serialize, Deserialize, Default)]
#[serde(rename_all = "camelCase")]
pub struct GetDevToolsTargetReturns {
    /// The targetId of DevTools page target if exists.

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

/// Opens a DevTools window for the target.

#[derive(Debug, Clone, Serialize, Deserialize, Default)]
#[serde(rename_all = "camelCase")]
pub struct OpenDevToolsParams {
    /// This can be the page or tab target ID.

    pub targetId: TargetID,
    /// The id of the panel we want DevTools to open initially. Currently
    /// supported panels are elements, console, network, sources, resources
    /// and performance.

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

/// Opens a DevTools window for the target.

#[derive(Debug, Clone, Serialize, Deserialize, Default)]
#[serde(rename_all = "camelCase")]
pub struct OpenDevToolsReturns {
    /// The targetId of DevTools page target.

    pub targetId: TargetID,
}