vendor/github.com/go-rod/rod/lib/proto/target.go
585 lines · 20827 bytes
1// This file is generated by "./lib/proto/generate"
2
3package proto
4
5/*
6
7Target
8
9Supports additional targets discovery and allows to attach to them.
10
11*/
12
13// TargetTargetID ...
14type TargetTargetID string
15
16// TargetSessionID Unique identifier of attached debugging session.
17type TargetSessionID string
18
19// TargetTargetInfoType enum.
20type TargetTargetInfoType string
21
22const (
23 // TargetTargetInfoTypePage enum const.
24 TargetTargetInfoTypePage TargetTargetInfoType = "page"
25
26 // TargetTargetInfoTypeBackgroundPage enum const.
27 TargetTargetInfoTypeBackgroundPage TargetTargetInfoType = "background_page"
28
29 // TargetTargetInfoTypeServiceWorker enum const.
30 TargetTargetInfoTypeServiceWorker TargetTargetInfoType = "service_worker"
31
32 // TargetTargetInfoTypeSharedWorker enum const.
33 TargetTargetInfoTypeSharedWorker TargetTargetInfoType = "shared_worker"
34
35 // TargetTargetInfoTypeBrowser enum const.
36 TargetTargetInfoTypeBrowser TargetTargetInfoType = "browser"
37
38 // TargetTargetInfoTypeOther enum const.
39 TargetTargetInfoTypeOther TargetTargetInfoType = "other"
40)
41
42// TargetTargetInfo ...
43type TargetTargetInfo struct {
44 // TargetID ...
45 TargetID TargetTargetID `json:"targetId"`
46
47 // Type 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
48 Type TargetTargetInfoType `json:"type"`
49
50 // Title ...
51 Title string `json:"title"`
52
53 // URL ...
54 URL string `json:"url"`
55
56 // Attached Whether the target has an attached client.
57 Attached bool `json:"attached"`
58
59 // OpenerID (optional) Opener target Id
60 OpenerID TargetTargetID `json:"openerId,omitempty"`
61
62 // CanAccessOpener (experimental) Whether the target has access to the originating window.
63 CanAccessOpener bool `json:"canAccessOpener"`
64
65 // OpenerFrameID (experimental) (optional) Frame id of originating window (is only set if target has an opener).
66 OpenerFrameID PageFrameID `json:"openerFrameId,omitempty"`
67
68 // BrowserContextID (experimental) (optional) ...
69 BrowserContextID BrowserBrowserContextID `json:"browserContextId,omitempty"`
70
71 // Subtype (experimental) (optional) Provides additional details for specific target types. For example, for
72 // the type of "page", this may be set to "portal" or "prerender".
73 Subtype string `json:"subtype,omitempty"`
74}
75
76// TargetFilterEntry (experimental) A filter used by target query/discovery/auto-attach operations.
77type TargetFilterEntry struct {
78 // Exclude (optional) If set, causes exclusion of matching targets from the list.
79 Exclude bool `json:"exclude,omitempty"`
80
81 // Type (optional) If not present, matches any type.
82 Type string `json:"type,omitempty"`
83}
84
85// TargetTargetFilter (experimental) The entries in TargetFilter are matched sequentially against targets and
86// the first entry that matches determines if the target is included or not,
87// depending on the value of `exclude` field in the entry.
88// If filter is not specified, the one assumed is
89// [{type: "browser", exclude: true}, {type: "tab", exclude: true}, {}]
90// (i.e. include everything but `browser` and `tab`).
91type TargetTargetFilter []*TargetFilterEntry
92
93// TargetRemoteLocation (experimental) ...
94type TargetRemoteLocation struct {
95 // Host ...
96 Host string `json:"host"`
97
98 // Port ...
99 Port int `json:"port"`
100}
101
102// TargetActivateTarget Activates (focuses) the target.
103type TargetActivateTarget struct {
104 // TargetID ...
105 TargetID TargetTargetID `json:"targetId"`
106}
107
108// ProtoReq name.
109func (m TargetActivateTarget) ProtoReq() string { return "Target.activateTarget" }
110
111// Call sends the request.
112func (m TargetActivateTarget) Call(c Client) error {
113 return call(m.ProtoReq(), m, nil, c)
114}
115
116// TargetAttachToTarget Attaches to the target with given id.
117type TargetAttachToTarget struct {
118 // TargetID ...
119 TargetID TargetTargetID `json:"targetId"`
120
121 // Flatten (optional) Enables "flat" access to the session via specifying sessionId attribute in the commands.
122 // We plan to make this the default, deprecate non-flattened mode,
123 // and eventually retire it. See crbug.com/991325.
124 Flatten bool `json:"flatten,omitempty"`
125}
126
127// ProtoReq name.
128func (m TargetAttachToTarget) ProtoReq() string { return "Target.attachToTarget" }
129
130// Call the request.
131func (m TargetAttachToTarget) Call(c Client) (*TargetAttachToTargetResult, error) {
132 var res TargetAttachToTargetResult
133 return &res, call(m.ProtoReq(), m, &res, c)
134}
135
136// TargetAttachToTargetResult ...
137type TargetAttachToTargetResult struct {
138 // SessionID Id assigned to the session.
139 SessionID TargetSessionID `json:"sessionId"`
140}
141
142// TargetAttachToBrowserTarget (experimental) Attaches to the browser target, only uses flat sessionId mode.
143type TargetAttachToBrowserTarget struct{}
144
145// ProtoReq name.
146func (m TargetAttachToBrowserTarget) ProtoReq() string { return "Target.attachToBrowserTarget" }
147
148// Call the request.
149func (m TargetAttachToBrowserTarget) Call(c Client) (*TargetAttachToBrowserTargetResult, error) {
150 var res TargetAttachToBrowserTargetResult
151 return &res, call(m.ProtoReq(), m, &res, c)
152}
153
154// TargetAttachToBrowserTargetResult (experimental) ...
155type TargetAttachToBrowserTargetResult struct {
156 // SessionID Id assigned to the session.
157 SessionID TargetSessionID `json:"sessionId"`
158}
159
160// TargetCloseTarget Closes the target. If the target is a page that gets closed too.
161type TargetCloseTarget struct {
162 // TargetID ...
163 TargetID TargetTargetID `json:"targetId"`
164}
165
166// ProtoReq name.
167func (m TargetCloseTarget) ProtoReq() string { return "Target.closeTarget" }
168
169// Call the request.
170func (m TargetCloseTarget) Call(c Client) (*TargetCloseTargetResult, error) {
171 var res TargetCloseTargetResult
172 return &res, call(m.ProtoReq(), m, &res, c)
173}
174
175// TargetCloseTargetResult ...
176type TargetCloseTargetResult struct {
177 // Success (deprecated) Always set to true. If an error occurs, the response indicates protocol error.
178 Success bool `json:"success"`
179}
180
181// TargetExposeDevToolsProtocol (experimental) Inject object to the target's main frame that provides a communication
182// channel with browser target.
183//
184// Injected object will be available as `window[bindingName]`.
185//
186// The object has the following API:
187// - `binding.send(json)` - a method to send messages over the remote debugging protocol
188// - `binding.onmessage = json => handleMessage(json)` - a callback that will be called for the protocol notifications and command responses.
189type TargetExposeDevToolsProtocol struct {
190 // TargetID ...
191 TargetID TargetTargetID `json:"targetId"`
192
193 // BindingName (optional) Binding name, 'cdp' if not specified.
194 BindingName string `json:"bindingName,omitempty"`
195}
196
197// ProtoReq name.
198func (m TargetExposeDevToolsProtocol) ProtoReq() string { return "Target.exposeDevToolsProtocol" }
199
200// Call sends the request.
201func (m TargetExposeDevToolsProtocol) Call(c Client) error {
202 return call(m.ProtoReq(), m, nil, c)
203}
204
205// TargetCreateBrowserContext Creates a new empty BrowserContext. Similar to an incognito profile but you can have more than
206// one.
207type TargetCreateBrowserContext struct {
208 // DisposeOnDetach (experimental) (optional) If specified, disposes this context when debugging session disconnects.
209 DisposeOnDetach bool `json:"disposeOnDetach,omitempty"`
210
211 // ProxyServer (experimental) (optional) Proxy server, similar to the one passed to --proxy-server
212 ProxyServer string `json:"proxyServer,omitempty"`
213
214 // ProxyBypassList (experimental) (optional) Proxy bypass list, similar to the one passed to --proxy-bypass-list
215 ProxyBypassList string `json:"proxyBypassList,omitempty"`
216
217 // OriginsWithUniversalNetworkAccess (experimental) (optional) An optional list of origins to grant unlimited cross-origin access to.
218 // Parts of the URL other than those constituting origin are ignored.
219 OriginsWithUniversalNetworkAccess []string `json:"originsWithUniversalNetworkAccess,omitempty"`
220}
221
222// ProtoReq name.
223func (m TargetCreateBrowserContext) ProtoReq() string { return "Target.createBrowserContext" }
224
225// Call the request.
226func (m TargetCreateBrowserContext) Call(c Client) (*TargetCreateBrowserContextResult, error) {
227 var res TargetCreateBrowserContextResult
228 return &res, call(m.ProtoReq(), m, &res, c)
229}
230
231// TargetCreateBrowserContextResult ...
232type TargetCreateBrowserContextResult struct {
233 // BrowserContextID The id of the context created.
234 BrowserContextID BrowserBrowserContextID `json:"browserContextId"`
235}
236
237// TargetGetBrowserContexts Returns all browser contexts created with `Target.createBrowserContext` method.
238type TargetGetBrowserContexts struct{}
239
240// ProtoReq name.
241func (m TargetGetBrowserContexts) ProtoReq() string { return "Target.getBrowserContexts" }
242
243// Call the request.
244func (m TargetGetBrowserContexts) Call(c Client) (*TargetGetBrowserContextsResult, error) {
245 var res TargetGetBrowserContextsResult
246 return &res, call(m.ProtoReq(), m, &res, c)
247}
248
249// TargetGetBrowserContextsResult ...
250type TargetGetBrowserContextsResult struct {
251 // BrowserContextIDs An array of browser context ids.
252 BrowserContextIDs []BrowserBrowserContextID `json:"browserContextIds"`
253}
254
255// TargetCreateTarget Creates a new page.
256type TargetCreateTarget struct {
257 // URL The initial URL the page will be navigated to. An empty string indicates about:blank.
258 URL string `json:"url"`
259
260 // Width (optional) Frame width in DIP (headless chrome only).
261 Width *int `json:"width,omitempty"`
262
263 // Height (optional) Frame height in DIP (headless chrome only).
264 Height *int `json:"height,omitempty"`
265
266 // BrowserContextID (experimental) (optional) The browser context to create the page in.
267 BrowserContextID BrowserBrowserContextID `json:"browserContextId,omitempty"`
268
269 // EnableBeginFrameControl (experimental) (optional) Whether BeginFrames for this target will be controlled via DevTools (headless chrome only,
270 // not supported on MacOS yet, false by default).
271 EnableBeginFrameControl bool `json:"enableBeginFrameControl,omitempty"`
272
273 // NewWindow (optional) Whether to create a new Window or Tab (chrome-only, false by default).
274 NewWindow bool `json:"newWindow,omitempty"`
275
276 // Background (optional) Whether to create the target in background or foreground (chrome-only,
277 // false by default).
278 Background bool `json:"background,omitempty"`
279
280 // ForTab (experimental) (optional) Whether to create the target of type "tab".
281 ForTab bool `json:"forTab,omitempty"`
282}
283
284// ProtoReq name.
285func (m TargetCreateTarget) ProtoReq() string { return "Target.createTarget" }
286
287// Call the request.
288func (m TargetCreateTarget) Call(c Client) (*TargetCreateTargetResult, error) {
289 var res TargetCreateTargetResult
290 return &res, call(m.ProtoReq(), m, &res, c)
291}
292
293// TargetCreateTargetResult ...
294type TargetCreateTargetResult struct {
295 // TargetID The id of the page opened.
296 TargetID TargetTargetID `json:"targetId"`
297}
298
299// TargetDetachFromTarget Detaches session with given id.
300type TargetDetachFromTarget struct {
301 // SessionID (optional) Session to detach.
302 SessionID TargetSessionID `json:"sessionId,omitempty"`
303
304 // TargetID (deprecated) (optional) Deprecated.
305 TargetID TargetTargetID `json:"targetId,omitempty"`
306}
307
308// ProtoReq name.
309func (m TargetDetachFromTarget) ProtoReq() string { return "Target.detachFromTarget" }
310
311// Call sends the request.
312func (m TargetDetachFromTarget) Call(c Client) error {
313 return call(m.ProtoReq(), m, nil, c)
314}
315
316// TargetDisposeBrowserContext Deletes a BrowserContext. All the belonging pages will be closed without calling their
317// beforeunload hooks.
318type TargetDisposeBrowserContext struct {
319 // BrowserContextID ...
320 BrowserContextID BrowserBrowserContextID `json:"browserContextId"`
321}
322
323// ProtoReq name.
324func (m TargetDisposeBrowserContext) ProtoReq() string { return "Target.disposeBrowserContext" }
325
326// Call sends the request.
327func (m TargetDisposeBrowserContext) Call(c Client) error {
328 return call(m.ProtoReq(), m, nil, c)
329}
330
331// TargetGetTargetInfo (experimental) Returns information about a target.
332type TargetGetTargetInfo struct {
333 // TargetID (optional) ...
334 TargetID TargetTargetID `json:"targetId,omitempty"`
335}
336
337// ProtoReq name.
338func (m TargetGetTargetInfo) ProtoReq() string { return "Target.getTargetInfo" }
339
340// Call the request.
341func (m TargetGetTargetInfo) Call(c Client) (*TargetGetTargetInfoResult, error) {
342 var res TargetGetTargetInfoResult
343 return &res, call(m.ProtoReq(), m, &res, c)
344}
345
346// TargetGetTargetInfoResult (experimental) ...
347type TargetGetTargetInfoResult struct {
348 // TargetInfo ...
349 TargetInfo *TargetTargetInfo `json:"targetInfo"`
350}
351
352// TargetGetTargets Retrieves a list of available targets.
353type TargetGetTargets struct {
354 // Filter (experimental) (optional) Only targets matching filter will be reported. If filter is not specified
355 // and target discovery is currently enabled, a filter used for target discovery
356 // is used for consistency.
357 Filter TargetTargetFilter `json:"filter,omitempty"`
358}
359
360// ProtoReq name.
361func (m TargetGetTargets) ProtoReq() string { return "Target.getTargets" }
362
363// Call the request.
364func (m TargetGetTargets) Call(c Client) (*TargetGetTargetsResult, error) {
365 var res TargetGetTargetsResult
366 return &res, call(m.ProtoReq(), m, &res, c)
367}
368
369// TargetGetTargetsResult ...
370type TargetGetTargetsResult struct {
371 // TargetInfos The list of targets.
372 TargetInfos []*TargetTargetInfo `json:"targetInfos"`
373}
374
375// TargetSendMessageToTarget (deprecated) Sends protocol message over session with given id.
376// Consider using flat mode instead; see commands attachToTarget, setAutoAttach,
377// and crbug.com/991325.
378type TargetSendMessageToTarget struct {
379 // Message ...
380 Message string `json:"message"`
381
382 // SessionID (optional) Identifier of the session.
383 SessionID TargetSessionID `json:"sessionId,omitempty"`
384
385 // TargetID (deprecated) (optional) Deprecated.
386 TargetID TargetTargetID `json:"targetId,omitempty"`
387}
388
389// ProtoReq name.
390func (m TargetSendMessageToTarget) ProtoReq() string { return "Target.sendMessageToTarget" }
391
392// Call sends the request.
393func (m TargetSendMessageToTarget) Call(c Client) error {
394 return call(m.ProtoReq(), m, nil, c)
395}
396
397// TargetSetAutoAttach Controls whether to automatically attach to new targets which are considered to be related to
398// this one. When turned on, attaches to all existing related targets as well. When turned off,
399// automatically detaches from all currently attached targets.
400// This also clears all targets added by `autoAttachRelated` from the list of targets to watch
401// for creation of related targets.
402type TargetSetAutoAttach struct {
403 // AutoAttach Whether to auto-attach to related targets.
404 AutoAttach bool `json:"autoAttach"`
405
406 // WaitForDebuggerOnStart Whether to pause new targets when attaching to them. Use `Runtime.runIfWaitingForDebugger`
407 // to run paused targets.
408 WaitForDebuggerOnStart bool `json:"waitForDebuggerOnStart"`
409
410 // Flatten (experimental) (optional) Enables "flat" access to the session via specifying sessionId attribute in the commands.
411 // We plan to make this the default, deprecate non-flattened mode,
412 // and eventually retire it. See crbug.com/991325.
413 Flatten bool `json:"flatten,omitempty"`
414
415 // Filter (experimental) (optional) Only targets matching filter will be attached.
416 Filter TargetTargetFilter `json:"filter,omitempty"`
417}
418
419// ProtoReq name.
420func (m TargetSetAutoAttach) ProtoReq() string { return "Target.setAutoAttach" }
421
422// Call sends the request.
423func (m TargetSetAutoAttach) Call(c Client) error {
424 return call(m.ProtoReq(), m, nil, c)
425}
426
427// TargetAutoAttachRelated (experimental) Adds the specified target to the list of targets that will be monitored for any related target
428// creation (such as child frames, child workers and new versions of service worker) and reported
429// through `attachedToTarget`. The specified target is also auto-attached.
430// This cancels the effect of any previous `setAutoAttach` and is also cancelled by subsequent
431// `setAutoAttach`. Only available at the Browser target.
432type TargetAutoAttachRelated struct {
433 // TargetID ...
434 TargetID TargetTargetID `json:"targetId"`
435
436 // WaitForDebuggerOnStart Whether to pause new targets when attaching to them. Use `Runtime.runIfWaitingForDebugger`
437 // to run paused targets.
438 WaitForDebuggerOnStart bool `json:"waitForDebuggerOnStart"`
439
440 // Filter (experimental) (optional) Only targets matching filter will be attached.
441 Filter TargetTargetFilter `json:"filter,omitempty"`
442}
443
444// ProtoReq name.
445func (m TargetAutoAttachRelated) ProtoReq() string { return "Target.autoAttachRelated" }
446
447// Call sends the request.
448func (m TargetAutoAttachRelated) Call(c Client) error {
449 return call(m.ProtoReq(), m, nil, c)
450}
451
452// TargetSetDiscoverTargets Controls whether to discover available targets and notify via
453// `targetCreated/targetInfoChanged/targetDestroyed` events.
454type TargetSetDiscoverTargets struct {
455 // Discover Whether to discover available targets.
456 Discover bool `json:"discover"`
457
458 // Filter (experimental) (optional) Only targets matching filter will be attached. If `discover` is false,
459 // `filter` must be omitted or empty.
460 Filter TargetTargetFilter `json:"filter,omitempty"`
461}
462
463// ProtoReq name.
464func (m TargetSetDiscoverTargets) ProtoReq() string { return "Target.setDiscoverTargets" }
465
466// Call sends the request.
467func (m TargetSetDiscoverTargets) Call(c Client) error {
468 return call(m.ProtoReq(), m, nil, c)
469}
470
471// TargetSetRemoteLocations (experimental) Enables target discovery for the specified locations, when `setDiscoverTargets` was set to
472// `true`.
473type TargetSetRemoteLocations struct {
474 // Locations List of remote locations.
475 Locations []*TargetRemoteLocation `json:"locations"`
476}
477
478// ProtoReq name.
479func (m TargetSetRemoteLocations) ProtoReq() string { return "Target.setRemoteLocations" }
480
481// Call sends the request.
482func (m TargetSetRemoteLocations) Call(c Client) error {
483 return call(m.ProtoReq(), m, nil, c)
484}
485
486// TargetAttachedToTarget (experimental) Issued when attached to target because of auto-attach or `attachToTarget` command.
487type TargetAttachedToTarget struct {
488 // SessionID Identifier assigned to the session used to send/receive messages.
489 SessionID TargetSessionID `json:"sessionId"`
490
491 // TargetInfo ...
492 TargetInfo *TargetTargetInfo `json:"targetInfo"`
493
494 // WaitingForDebugger ...
495 WaitingForDebugger bool `json:"waitingForDebugger"`
496}
497
498// ProtoEvent name.
499func (evt TargetAttachedToTarget) ProtoEvent() string {
500 return "Target.attachedToTarget"
501}
502
503// TargetDetachedFromTarget (experimental) Issued when detached from target for any reason (including `detachFromTarget` command). Can be
504// issued multiple times per target if multiple sessions have been attached to it.
505type TargetDetachedFromTarget struct {
506 // SessionID Detached session identifier.
507 SessionID TargetSessionID `json:"sessionId"`
508
509 // TargetID (deprecated) (optional) Deprecated.
510 TargetID TargetTargetID `json:"targetId,omitempty"`
511}
512
513// ProtoEvent name.
514func (evt TargetDetachedFromTarget) ProtoEvent() string {
515 return "Target.detachedFromTarget"
516}
517
518// TargetReceivedMessageFromTarget Notifies about a new protocol message received from the session (as reported in
519// `attachedToTarget` event).
520type TargetReceivedMessageFromTarget struct {
521 // SessionID Identifier of a session which sends a message.
522 SessionID TargetSessionID `json:"sessionId"`
523
524 // Message ...
525 Message string `json:"message"`
526
527 // TargetID (deprecated) (optional) Deprecated.
528 TargetID TargetTargetID `json:"targetId,omitempty"`
529}
530
531// ProtoEvent name.
532func (evt TargetReceivedMessageFromTarget) ProtoEvent() string {
533 return "Target.receivedMessageFromTarget"
534}
535
536// TargetTargetCreated Issued when a possible inspection target is created.
537type TargetTargetCreated struct {
538 // TargetInfo ...
539 TargetInfo *TargetTargetInfo `json:"targetInfo"`
540}
541
542// ProtoEvent name.
543func (evt TargetTargetCreated) ProtoEvent() string {
544 return "Target.targetCreated"
545}
546
547// TargetTargetDestroyed Issued when a target is destroyed.
548type TargetTargetDestroyed struct {
549 // TargetID ...
550 TargetID TargetTargetID `json:"targetId"`
551}
552
553// ProtoEvent name.
554func (evt TargetTargetDestroyed) ProtoEvent() string {
555 return "Target.targetDestroyed"
556}
557
558// TargetTargetCrashed Issued when a target has crashed.
559type TargetTargetCrashed struct {
560 // TargetID ...
561 TargetID TargetTargetID `json:"targetId"`
562
563 // Status Termination status type.
564 Status string `json:"status"`
565
566 // ErrorCode Termination error code.
567 ErrorCode int `json:"errorCode"`
568}
569
570// ProtoEvent name.
571func (evt TargetTargetCrashed) ProtoEvent() string {
572 return "Target.targetCrashed"
573}
574
575// TargetTargetInfoChanged Issued when some information about a target has changed. This only happens between
576// `targetCreated` and `targetDestroyed`.
577type TargetTargetInfoChanged struct {
578 // TargetInfo ...
579 TargetInfo *TargetTargetInfo `json:"targetInfo"`
580}
581
582// ProtoEvent name.
583func (evt TargetTargetInfoChanged) ProtoEvent() string {
584 return "Target.targetInfoChanged"
585}