123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684 |
- // Package target provides the Chrome DevTools Protocol
- // commands, types, and events for the Target domain.
- //
- // Supports additional targets discovery and allows to attach to them.
- //
- // Generated by the cdproto-gen command.
- package target
- // Code generated by cdproto-gen. DO NOT EDIT.
- import (
- "context"
- "github.com/chromedp/cdproto/cdp"
- )
- // ActivateTargetParams activates (focuses) the target.
- type ActivateTargetParams struct {
- TargetID ID `json:"targetId"`
- }
- // ActivateTarget activates (focuses) the target.
- //
- // See: https://chromedevtools.github.io/devtools-protocol/tot/Target#method-activateTarget
- //
- // parameters:
- //
- // targetID
- func ActivateTarget(targetID ID) *ActivateTargetParams {
- return &ActivateTargetParams{
- TargetID: targetID,
- }
- }
- // Do executes Target.activateTarget against the provided context.
- func (p *ActivateTargetParams) Do(ctx context.Context) (err error) {
- return cdp.Execute(ctx, CommandActivateTarget, p, nil)
- }
- // AttachToTargetParams attaches to the target with given id.
- type AttachToTargetParams struct {
- TargetID ID `json:"targetId"`
- Flatten bool `json:"flatten,omitempty"` // 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.
- }
- // AttachToTarget attaches to the target with given id.
- //
- // See: https://chromedevtools.github.io/devtools-protocol/tot/Target#method-attachToTarget
- //
- // parameters:
- //
- // targetID
- func AttachToTarget(targetID ID) *AttachToTargetParams {
- return &AttachToTargetParams{
- TargetID: targetID,
- }
- }
- // WithFlatten 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.
- func (p AttachToTargetParams) WithFlatten(flatten bool) *AttachToTargetParams {
- p.Flatten = flatten
- return &p
- }
- // AttachToTargetReturns return values.
- type AttachToTargetReturns struct {
- SessionID SessionID `json:"sessionId,omitempty"` // Id assigned to the session.
- }
- // Do executes Target.attachToTarget against the provided context.
- //
- // returns:
- //
- // sessionID - Id assigned to the session.
- func (p *AttachToTargetParams) Do(ctx context.Context) (sessionID SessionID, err error) {
- // execute
- var res AttachToTargetReturns
- err = cdp.Execute(ctx, CommandAttachToTarget, p, &res)
- if err != nil {
- return "", err
- }
- return res.SessionID, nil
- }
- // AttachToBrowserTargetParams attaches to the browser target, only uses flat
- // sessionId mode.
- type AttachToBrowserTargetParams struct{}
- // AttachToBrowserTarget attaches to the browser target, only uses flat
- // sessionId mode.
- //
- // See: https://chromedevtools.github.io/devtools-protocol/tot/Target#method-attachToBrowserTarget
- func AttachToBrowserTarget() *AttachToBrowserTargetParams {
- return &AttachToBrowserTargetParams{}
- }
- // AttachToBrowserTargetReturns return values.
- type AttachToBrowserTargetReturns struct {
- SessionID SessionID `json:"sessionId,omitempty"` // Id assigned to the session.
- }
- // Do executes Target.attachToBrowserTarget against the provided context.
- //
- // returns:
- //
- // sessionID - Id assigned to the session.
- func (p *AttachToBrowserTargetParams) Do(ctx context.Context) (sessionID SessionID, err error) {
- // execute
- var res AttachToBrowserTargetReturns
- err = cdp.Execute(ctx, CommandAttachToBrowserTarget, nil, &res)
- if err != nil {
- return "", err
- }
- return res.SessionID, nil
- }
- // CloseTargetParams closes the target. If the target is a page that gets
- // closed too.
- type CloseTargetParams struct {
- TargetID ID `json:"targetId"`
- }
- // CloseTarget closes the target. If the target is a page that gets closed
- // too.
- //
- // See: https://chromedevtools.github.io/devtools-protocol/tot/Target#method-closeTarget
- //
- // parameters:
- //
- // targetID
- func CloseTarget(targetID ID) *CloseTargetParams {
- return &CloseTargetParams{
- TargetID: targetID,
- }
- }
- // Do executes Target.closeTarget against the provided context.
- func (p *CloseTargetParams) Do(ctx context.Context) (err error) {
- return cdp.Execute(ctx, CommandCloseTarget, p, nil)
- }
- // ExposeDevToolsProtocolParams 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.
- type ExposeDevToolsProtocolParams struct {
- TargetID ID `json:"targetId"`
- BindingName string `json:"bindingName,omitempty"` // Binding name, 'cdp' if not specified.
- }
- // ExposeDevToolsProtocol 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.
- //
- // See: https://chromedevtools.github.io/devtools-protocol/tot/Target#method-exposeDevToolsProtocol
- //
- // parameters:
- //
- // targetID
- func ExposeDevToolsProtocol(targetID ID) *ExposeDevToolsProtocolParams {
- return &ExposeDevToolsProtocolParams{
- TargetID: targetID,
- }
- }
- // WithBindingName binding name, 'cdp' if not specified.
- func (p ExposeDevToolsProtocolParams) WithBindingName(bindingName string) *ExposeDevToolsProtocolParams {
- p.BindingName = bindingName
- return &p
- }
- // Do executes Target.exposeDevToolsProtocol against the provided context.
- func (p *ExposeDevToolsProtocolParams) Do(ctx context.Context) (err error) {
- return cdp.Execute(ctx, CommandExposeDevToolsProtocol, p, nil)
- }
- // CreateBrowserContextParams creates a new empty BrowserContext. Similar to
- // an incognito profile but you can have more than one.
- type CreateBrowserContextParams struct {
- DisposeOnDetach bool `json:"disposeOnDetach,omitempty"` // If specified, disposes this context when debugging session disconnects.
- ProxyServer string `json:"proxyServer,omitempty"` // Proxy server, similar to the one passed to --proxy-server
- ProxyBypassList string `json:"proxyBypassList,omitempty"` // Proxy bypass list, similar to the one passed to --proxy-bypass-list
- OriginsWithUniversalNetworkAccess []string `json:"originsWithUniversalNetworkAccess,omitempty"` // An optional list of origins to grant unlimited cross-origin access to. Parts of the URL other than those constituting origin are ignored.
- }
- // CreateBrowserContext creates a new empty BrowserContext. Similar to an
- // incognito profile but you can have more than one.
- //
- // See: https://chromedevtools.github.io/devtools-protocol/tot/Target#method-createBrowserContext
- //
- // parameters:
- func CreateBrowserContext() *CreateBrowserContextParams {
- return &CreateBrowserContextParams{}
- }
- // WithDisposeOnDetach if specified, disposes this context when debugging
- // session disconnects.
- func (p CreateBrowserContextParams) WithDisposeOnDetach(disposeOnDetach bool) *CreateBrowserContextParams {
- p.DisposeOnDetach = disposeOnDetach
- return &p
- }
- // WithProxyServer proxy server, similar to the one passed to --proxy-server.
- func (p CreateBrowserContextParams) WithProxyServer(proxyServer string) *CreateBrowserContextParams {
- p.ProxyServer = proxyServer
- return &p
- }
- // WithProxyBypassList proxy bypass list, similar to the one passed to
- // --proxy-bypass-list.
- func (p CreateBrowserContextParams) WithProxyBypassList(proxyBypassList string) *CreateBrowserContextParams {
- p.ProxyBypassList = proxyBypassList
- return &p
- }
- // WithOriginsWithUniversalNetworkAccess an optional list of origins to grant
- // unlimited cross-origin access to. Parts of the URL other than those
- // constituting origin are ignored.
- func (p CreateBrowserContextParams) WithOriginsWithUniversalNetworkAccess(originsWithUniversalNetworkAccess []string) *CreateBrowserContextParams {
- p.OriginsWithUniversalNetworkAccess = originsWithUniversalNetworkAccess
- return &p
- }
- // CreateBrowserContextReturns return values.
- type CreateBrowserContextReturns struct {
- BrowserContextID cdp.BrowserContextID `json:"browserContextId,omitempty"` // The id of the context created.
- }
- // Do executes Target.createBrowserContext against the provided context.
- //
- // returns:
- //
- // browserContextID - The id of the context created.
- func (p *CreateBrowserContextParams) Do(ctx context.Context) (browserContextID cdp.BrowserContextID, err error) {
- // execute
- var res CreateBrowserContextReturns
- err = cdp.Execute(ctx, CommandCreateBrowserContext, p, &res)
- if err != nil {
- return "", err
- }
- return res.BrowserContextID, nil
- }
- // GetBrowserContextsParams returns all browser contexts created with
- // Target.createBrowserContext method.
- type GetBrowserContextsParams struct{}
- // GetBrowserContexts returns all browser contexts created with
- // Target.createBrowserContext method.
- //
- // See: https://chromedevtools.github.io/devtools-protocol/tot/Target#method-getBrowserContexts
- func GetBrowserContexts() *GetBrowserContextsParams {
- return &GetBrowserContextsParams{}
- }
- // GetBrowserContextsReturns return values.
- type GetBrowserContextsReturns struct {
- BrowserContextIDs []cdp.BrowserContextID `json:"browserContextIds,omitempty"` // An array of browser context ids.
- }
- // Do executes Target.getBrowserContexts against the provided context.
- //
- // returns:
- //
- // browserContextIDs - An array of browser context ids.
- func (p *GetBrowserContextsParams) Do(ctx context.Context) (browserContextIDs []cdp.BrowserContextID, err error) {
- // execute
- var res GetBrowserContextsReturns
- err = cdp.Execute(ctx, CommandGetBrowserContexts, nil, &res)
- if err != nil {
- return nil, err
- }
- return res.BrowserContextIDs, nil
- }
- // CreateTargetParams creates a new page.
- type CreateTargetParams struct {
- URL string `json:"url"` // The initial URL the page will be navigated to. An empty string indicates about:blank.
- Width int64 `json:"width,omitempty"` // Frame width in DIP (headless chrome only).
- Height int64 `json:"height,omitempty"` // Frame height in DIP (headless chrome only).
- BrowserContextID cdp.BrowserContextID `json:"browserContextId,omitempty"` // The browser context to create the page in.
- EnableBeginFrameControl bool `json:"enableBeginFrameControl,omitempty"` // Whether BeginFrames for this target will be controlled via DevTools (headless chrome only, not supported on MacOS yet, false by default).
- NewWindow bool `json:"newWindow,omitempty"` // Whether to create a new Window or Tab (chrome-only, false by default).
- Background bool `json:"background,omitempty"` // Whether to create the target in background or foreground (chrome-only, false by default).
- ForTab bool `json:"forTab,omitempty"` // Whether to create the target of type "tab".
- }
- // CreateTarget creates a new page.
- //
- // See: https://chromedevtools.github.io/devtools-protocol/tot/Target#method-createTarget
- //
- // parameters:
- //
- // url - The initial URL the page will be navigated to. An empty string indicates about:blank.
- func CreateTarget(url string) *CreateTargetParams {
- return &CreateTargetParams{
- URL: url,
- }
- }
- // WithWidth frame width in DIP (headless chrome only).
- func (p CreateTargetParams) WithWidth(width int64) *CreateTargetParams {
- p.Width = width
- return &p
- }
- // WithHeight frame height in DIP (headless chrome only).
- func (p CreateTargetParams) WithHeight(height int64) *CreateTargetParams {
- p.Height = height
- return &p
- }
- // WithBrowserContextID the browser context to create the page in.
- func (p CreateTargetParams) WithBrowserContextID(browserContextID cdp.BrowserContextID) *CreateTargetParams {
- p.BrowserContextID = browserContextID
- return &p
- }
- // WithEnableBeginFrameControl whether BeginFrames for this target will be
- // controlled via DevTools (headless chrome only, not supported on MacOS yet,
- // false by default).
- func (p CreateTargetParams) WithEnableBeginFrameControl(enableBeginFrameControl bool) *CreateTargetParams {
- p.EnableBeginFrameControl = enableBeginFrameControl
- return &p
- }
- // WithNewWindow whether to create a new Window or Tab (chrome-only, false by
- // default).
- func (p CreateTargetParams) WithNewWindow(newWindow bool) *CreateTargetParams {
- p.NewWindow = newWindow
- return &p
- }
- // WithBackground whether to create the target in background or foreground
- // (chrome-only, false by default).
- func (p CreateTargetParams) WithBackground(background bool) *CreateTargetParams {
- p.Background = background
- return &p
- }
- // WithForTab whether to create the target of type "tab".
- func (p CreateTargetParams) WithForTab(forTab bool) *CreateTargetParams {
- p.ForTab = forTab
- return &p
- }
- // CreateTargetReturns return values.
- type CreateTargetReturns struct {
- TargetID ID `json:"targetId,omitempty"` // The id of the page opened.
- }
- // Do executes Target.createTarget against the provided context.
- //
- // returns:
- //
- // targetID - The id of the page opened.
- func (p *CreateTargetParams) Do(ctx context.Context) (targetID ID, err error) {
- // execute
- var res CreateTargetReturns
- err = cdp.Execute(ctx, CommandCreateTarget, p, &res)
- if err != nil {
- return "", err
- }
- return res.TargetID, nil
- }
- // DetachFromTargetParams detaches session with given id.
- type DetachFromTargetParams struct {
- SessionID SessionID `json:"sessionId,omitempty"` // Session to detach.
- }
- // DetachFromTarget detaches session with given id.
- //
- // See: https://chromedevtools.github.io/devtools-protocol/tot/Target#method-detachFromTarget
- //
- // parameters:
- func DetachFromTarget() *DetachFromTargetParams {
- return &DetachFromTargetParams{}
- }
- // WithSessionID session to detach.
- func (p DetachFromTargetParams) WithSessionID(sessionID SessionID) *DetachFromTargetParams {
- p.SessionID = sessionID
- return &p
- }
- // Do executes Target.detachFromTarget against the provided context.
- func (p *DetachFromTargetParams) Do(ctx context.Context) (err error) {
- return cdp.Execute(ctx, CommandDetachFromTarget, p, nil)
- }
- // DisposeBrowserContextParams deletes a BrowserContext. All the belonging
- // pages will be closed without calling their beforeunload hooks.
- type DisposeBrowserContextParams struct {
- BrowserContextID cdp.BrowserContextID `json:"browserContextId"`
- }
- // DisposeBrowserContext deletes a BrowserContext. All the belonging pages
- // will be closed without calling their beforeunload hooks.
- //
- // See: https://chromedevtools.github.io/devtools-protocol/tot/Target#method-disposeBrowserContext
- //
- // parameters:
- //
- // browserContextID
- func DisposeBrowserContext(browserContextID cdp.BrowserContextID) *DisposeBrowserContextParams {
- return &DisposeBrowserContextParams{
- BrowserContextID: browserContextID,
- }
- }
- // Do executes Target.disposeBrowserContext against the provided context.
- func (p *DisposeBrowserContextParams) Do(ctx context.Context) (err error) {
- return cdp.Execute(ctx, CommandDisposeBrowserContext, p, nil)
- }
- // GetTargetInfoParams returns information about a target.
- type GetTargetInfoParams struct {
- TargetID ID `json:"targetId,omitempty"`
- }
- // GetTargetInfo returns information about a target.
- //
- // See: https://chromedevtools.github.io/devtools-protocol/tot/Target#method-getTargetInfo
- //
- // parameters:
- func GetTargetInfo() *GetTargetInfoParams {
- return &GetTargetInfoParams{}
- }
- // WithTargetID [no description].
- func (p GetTargetInfoParams) WithTargetID(targetID ID) *GetTargetInfoParams {
- p.TargetID = targetID
- return &p
- }
- // GetTargetInfoReturns return values.
- type GetTargetInfoReturns struct {
- TargetInfo *Info `json:"targetInfo,omitempty"`
- }
- // Do executes Target.getTargetInfo against the provided context.
- //
- // returns:
- //
- // targetInfo
- func (p *GetTargetInfoParams) Do(ctx context.Context) (targetInfo *Info, err error) {
- // execute
- var res GetTargetInfoReturns
- err = cdp.Execute(ctx, CommandGetTargetInfo, p, &res)
- if err != nil {
- return nil, err
- }
- return res.TargetInfo, nil
- }
- // GetTargetsParams retrieves a list of available targets.
- type GetTargetsParams struct {
- Filter Filter `json:"filter,omitempty"` // 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.
- }
- // GetTargets retrieves a list of available targets.
- //
- // See: https://chromedevtools.github.io/devtools-protocol/tot/Target#method-getTargets
- //
- // parameters:
- func GetTargets() *GetTargetsParams {
- return &GetTargetsParams{}
- }
- // WithFilter 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.
- func (p GetTargetsParams) WithFilter(filter Filter) *GetTargetsParams {
- p.Filter = filter
- return &p
- }
- // GetTargetsReturns return values.
- type GetTargetsReturns struct {
- TargetInfos []*Info `json:"targetInfos,omitempty"` // The list of targets.
- }
- // Do executes Target.getTargets against the provided context.
- //
- // returns:
- //
- // targetInfos - The list of targets.
- func (p *GetTargetsParams) Do(ctx context.Context) (targetInfos []*Info, err error) {
- // execute
- var res GetTargetsReturns
- err = cdp.Execute(ctx, CommandGetTargets, p, &res)
- if err != nil {
- return nil, err
- }
- return res.TargetInfos, nil
- }
- // SetAutoAttachParams controls whether to automatically attach to new
- // targets which are considered to be related to this one. 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.
- type SetAutoAttachParams struct {
- AutoAttach bool `json:"autoAttach"` // Whether to auto-attach to related targets.
- WaitForDebuggerOnStart bool `json:"waitForDebuggerOnStart"` // Whether to pause new targets when attaching to them. Use Runtime.runIfWaitingForDebugger to run paused targets.
- Flatten bool `json:"flatten,omitempty"` // 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.
- Filter Filter `json:"filter,omitempty"` // Only targets matching filter will be attached.
- }
- // SetAutoAttach controls whether to automatically attach to new targets
- // which are considered to be related to this one. 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.
- //
- // See: https://chromedevtools.github.io/devtools-protocol/tot/Target#method-setAutoAttach
- //
- // parameters:
- //
- // autoAttach - Whether to auto-attach to related targets.
- // waitForDebuggerOnStart - Whether to pause new targets when attaching to them. Use Runtime.runIfWaitingForDebugger to run paused targets.
- func SetAutoAttach(autoAttach bool, waitForDebuggerOnStart bool) *SetAutoAttachParams {
- return &SetAutoAttachParams{
- AutoAttach: autoAttach,
- WaitForDebuggerOnStart: waitForDebuggerOnStart,
- }
- }
- // WithFlatten 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.
- func (p SetAutoAttachParams) WithFlatten(flatten bool) *SetAutoAttachParams {
- p.Flatten = flatten
- return &p
- }
- // WithFilter only targets matching filter will be attached.
- func (p SetAutoAttachParams) WithFilter(filter Filter) *SetAutoAttachParams {
- p.Filter = filter
- return &p
- }
- // Do executes Target.setAutoAttach against the provided context.
- func (p *SetAutoAttachParams) Do(ctx context.Context) (err error) {
- return cdp.Execute(ctx, CommandSetAutoAttach, p, nil)
- }
- // AutoAttachRelatedParams 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.
- type AutoAttachRelatedParams struct {
- TargetID ID `json:"targetId"`
- WaitForDebuggerOnStart bool `json:"waitForDebuggerOnStart"` // Whether to pause new targets when attaching to them. Use Runtime.runIfWaitingForDebugger to run paused targets.
- Filter Filter `json:"filter,omitempty"` // Only targets matching filter will be attached.
- }
- // AutoAttachRelated 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.
- //
- // See: https://chromedevtools.github.io/devtools-protocol/tot/Target#method-autoAttachRelated
- //
- // parameters:
- //
- // targetID
- // waitForDebuggerOnStart - Whether to pause new targets when attaching to them. Use Runtime.runIfWaitingForDebugger to run paused targets.
- func AutoAttachRelated(targetID ID, waitForDebuggerOnStart bool) *AutoAttachRelatedParams {
- return &AutoAttachRelatedParams{
- TargetID: targetID,
- WaitForDebuggerOnStart: waitForDebuggerOnStart,
- }
- }
- // WithFilter only targets matching filter will be attached.
- func (p AutoAttachRelatedParams) WithFilter(filter Filter) *AutoAttachRelatedParams {
- p.Filter = filter
- return &p
- }
- // Do executes Target.autoAttachRelated against the provided context.
- func (p *AutoAttachRelatedParams) Do(ctx context.Context) (err error) {
- return cdp.Execute(ctx, CommandAutoAttachRelated, p, nil)
- }
- // SetDiscoverTargetsParams controls whether to discover available targets
- // and notify via targetCreated/targetInfoChanged/targetDestroyed events.
- type SetDiscoverTargetsParams struct {
- Discover bool `json:"discover"` // Whether to discover available targets.
- Filter Filter `json:"filter,omitempty"` // Only targets matching filter will be attached. If discover is false, filter must be omitted or empty.
- }
- // SetDiscoverTargets controls whether to discover available targets and
- // notify via targetCreated/targetInfoChanged/targetDestroyed events.
- //
- // See: https://chromedevtools.github.io/devtools-protocol/tot/Target#method-setDiscoverTargets
- //
- // parameters:
- //
- // discover - Whether to discover available targets.
- func SetDiscoverTargets(discover bool) *SetDiscoverTargetsParams {
- return &SetDiscoverTargetsParams{
- Discover: discover,
- }
- }
- // WithFilter only targets matching filter will be attached. If discover is
- // false, filter must be omitted or empty.
- func (p SetDiscoverTargetsParams) WithFilter(filter Filter) *SetDiscoverTargetsParams {
- p.Filter = filter
- return &p
- }
- // Do executes Target.setDiscoverTargets against the provided context.
- func (p *SetDiscoverTargetsParams) Do(ctx context.Context) (err error) {
- return cdp.Execute(ctx, CommandSetDiscoverTargets, p, nil)
- }
- // SetRemoteLocationsParams enables target discovery for the specified
- // locations, when setDiscoverTargets was set to true.
- type SetRemoteLocationsParams struct {
- Locations []*RemoteLocation `json:"locations"` // List of remote locations.
- }
- // SetRemoteLocations enables target discovery for the specified locations,
- // when setDiscoverTargets was set to true.
- //
- // See: https://chromedevtools.github.io/devtools-protocol/tot/Target#method-setRemoteLocations
- //
- // parameters:
- //
- // locations - List of remote locations.
- func SetRemoteLocations(locations []*RemoteLocation) *SetRemoteLocationsParams {
- return &SetRemoteLocationsParams{
- Locations: locations,
- }
- }
- // Do executes Target.setRemoteLocations against the provided context.
- func (p *SetRemoteLocationsParams) Do(ctx context.Context) (err error) {
- return cdp.Execute(ctx, CommandSetRemoteLocations, p, nil)
- }
- // Command names.
- const (
- CommandActivateTarget = "Target.activateTarget"
- CommandAttachToTarget = "Target.attachToTarget"
- CommandAttachToBrowserTarget = "Target.attachToBrowserTarget"
- CommandCloseTarget = "Target.closeTarget"
- CommandExposeDevToolsProtocol = "Target.exposeDevToolsProtocol"
- CommandCreateBrowserContext = "Target.createBrowserContext"
- CommandGetBrowserContexts = "Target.getBrowserContexts"
- CommandCreateTarget = "Target.createTarget"
- CommandDetachFromTarget = "Target.detachFromTarget"
- CommandDisposeBrowserContext = "Target.disposeBrowserContext"
- CommandGetTargetInfo = "Target.getTargetInfo"
- CommandGetTargets = "Target.getTargets"
- CommandSetAutoAttach = "Target.setAutoAttach"
- CommandAutoAttachRelated = "Target.autoAttachRelated"
- CommandSetDiscoverTargets = "Target.setDiscoverTargets"
- CommandSetRemoteLocations = "Target.setRemoteLocations"
- )
|