target

package
v0.157.7 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 5, 2026 License: MIT Imports: 2 Imported by: 177

Documentation

Overview

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 pdlgen command.

Index

Constants

View Source
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"
	CommandGetDevToolsTarget      = "Target.getDevToolsTarget"
	CommandOpenDevTools           = "Target.openDevTools"
)

Command names.

Variables

ActivateTarget activates (focuses) the target.

See: https://chromedevtools.github.io/devtools-protocol/tot/Target#method-activateTarget

AttachToBrowserTarget attaches to the browser target, only uses flat sessionId mode.

See: https://chromedevtools.github.io/devtools-protocol/tot/Target#method-attachToBrowserTarget

AttachToTarget attaches to the target with given id.

See: https://chromedevtools.github.io/devtools-protocol/tot/Target#method-attachToTarget

View Source
var AttachedToTarget = cdp.Event[EventAttachedToTarget]{Method: "Target.attachedToTarget"}

AttachedToTarget issued when attached to target because of auto-attach or attachToTarget command.

See: https://chromedevtools.github.io/devtools-protocol/tot/Target#event-attachedToTarget

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

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

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

CreateTarget creates a new page.

See: https://chromedevtools.github.io/devtools-protocol/tot/Target#method-createTarget

DetachFromTarget detaches session with given id.

See: https://chromedevtools.github.io/devtools-protocol/tot/Target#method-detachFromTarget

View Source
var DetachedFromTarget = cdp.Event[EventDetachedFromTarget]{Method: "Target.detachedFromTarget"}

DetachedFromTarget issued when detached from target for any reason (including detachFromTarget command). Can be issued multiple times per target if multiple sessions have been attached to it.

See: https://chromedevtools.github.io/devtools-protocol/tot/Target#event-detachedFromTarget

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

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

GetBrowserContexts returns all browser contexts created with Target.createBrowserContext method.

See: https://chromedevtools.github.io/devtools-protocol/tot/Target#method-getBrowserContexts

GetDevToolsTarget gets the targetId of the DevTools page target opened for the given target (if any).

See: https://chromedevtools.github.io/devtools-protocol/tot/Target#method-getDevToolsTarget

GetTargetInfo returns information about a target.

See: https://chromedevtools.github.io/devtools-protocol/tot/Target#method-getTargetInfo

GetTargets retrieves a list of available targets.

See: https://chromedevtools.github.io/devtools-protocol/tot/Target#method-getTargets

OpenDevTools opens a DevTools window for the target.

See: https://chromedevtools.github.io/devtools-protocol/tot/Target#method-openDevTools

View Source
var ReceivedMessageFromTarget = cdp.Event[EventReceivedMessageFromTarget]{Method: "Target.receivedMessageFromTarget"}

ReceivedMessageFromTarget notifies about a new protocol message received from the session (as reported in attachedToTarget event).

See: https://chromedevtools.github.io/devtools-protocol/tot/Target#event-receivedMessageFromTarget

SetAutoAttach 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.

See: https://chromedevtools.github.io/devtools-protocol/tot/Target#method-setAutoAttach

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

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

View Source
var TargetCrashed = cdp.Event[EventTargetCrashed]{Method: "Target.targetCrashed"}

TargetCrashed issued when a target has crashed.

See: https://chromedevtools.github.io/devtools-protocol/tot/Target#event-targetCrashed

View Source
var TargetCreated = cdp.Event[EventTargetCreated]{Method: "Target.targetCreated"}

TargetCreated issued when a possible inspection target is created.

See: https://chromedevtools.github.io/devtools-protocol/tot/Target#event-targetCreated

View Source
var TargetDestroyed = cdp.Event[EventTargetDestroyed]{Method: "Target.targetDestroyed"}

TargetDestroyed issued when a target is destroyed.

See: https://chromedevtools.github.io/devtools-protocol/tot/Target#event-targetDestroyed

View Source
var TargetInfoChanged = cdp.Event[EventTargetInfoChanged]{Method: "Target.targetInfoChanged"}

TargetInfoChanged issued when some information about a target has changed. This only happens between targetCreated and targetDestroyed.

See: https://chromedevtools.github.io/devtools-protocol/tot/Target#event-targetInfoChanged

Functions

This section is empty.

Types

type ActivateTargetParams

type ActivateTargetParams struct {
	TargetID ID `json:"targetId"`
}

ActivateTargetParams are the parameters of the command Target.activateTarget.

type AttachToBrowserTargetResult added in v0.157.3

type AttachToBrowserTargetResult struct {
	SessionID SessionID `json:"sessionId,omitempty,omitzero"` // Id assigned to the session.
}

AttachToBrowserTargetResult is the result of the command Target.attachToBrowserTarget.

type AttachToTargetParams

type AttachToTargetParams struct {
	TargetID ID    `json:"targetId"`
	Flatten  *bool `json:"flatten,omitempty,omitzero"` // 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.
}

AttachToTargetParams are the parameters of the command Target.attachToTarget.

type AttachToTargetResult added in v0.157.3

type AttachToTargetResult struct {
	SessionID SessionID `json:"sessionId,omitempty,omitzero"` // Id assigned to the session.
}

AttachToTargetResult is the result of the command Target.attachToTarget.

type AutoAttachRelatedParams

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,omitzero"` // Only targets matching filter will be attached.
}

AutoAttachRelatedParams are the parameters of the command Target.autoAttachRelated.

type CloseTargetParams

type CloseTargetParams struct {
	TargetID ID `json:"targetId"`
}

CloseTargetParams are the parameters of the command Target.closeTarget.

type CreateBrowserContextParams

type CreateBrowserContextParams struct {
	DisposeOnDetach                   *bool    `json:"disposeOnDetach,omitempty,omitzero"`                   // If specified, disposes this context when debugging session disconnects.
	ProxyServer                       string   `json:"proxyServer,omitempty,omitzero"`                       // Proxy server, similar to the one passed to --proxy-server
	ProxyBypassList                   string   `json:"proxyBypassList,omitempty,omitzero"`                   // Proxy bypass list, similar to the one passed to --proxy-bypass-list
	OriginsWithUniversalNetworkAccess []string `json:"originsWithUniversalNetworkAccess,omitempty,omitzero"` // An optional list of origins to grant unlimited cross-origin access to. Parts of the URL other than those constituting origin are ignored.
}

CreateBrowserContextParams are the parameters of the command Target.createBrowserContext.

type CreateBrowserContextResult added in v0.157.3

type CreateBrowserContextResult struct {
	BrowserContextID cdp.BrowserContextID `json:"browserContextId,omitempty,omitzero"` // The id of the context created.
}

CreateBrowserContextResult is the result of the command Target.createBrowserContext.

type CreateTargetParams

type CreateTargetParams struct {
	URL                     string               `json:"url"`                                        // The initial URL the page will be navigated to. An empty string indicates about:blank.
	Left                    *int64               `json:"left,omitempty,omitzero"`                    // Frame left origin in DIP (requires newWindow to be true or headless shell).
	Top                     *int64               `json:"top,omitempty,omitzero"`                     // Frame top origin in DIP (requires newWindow to be true or headless shell).
	Width                   int64                `json:"width,omitempty,omitzero"`                   // Frame width in DIP (requires newWindow to be true or headless shell).
	Height                  int64                `json:"height,omitempty,omitzero"`                  // Frame height in DIP (requires newWindow to be true or headless shell).
	WindowState             WindowState          `json:"windowState,omitempty,omitzero"`             // Frame window state (requires newWindow to be true or headless shell). Default is normal.
	BrowserContextID        cdp.BrowserContextID `json:"browserContextId,omitempty,omitzero"`        // The browser context to create the page in.
	EnableBeginFrameControl *bool                `json:"enableBeginFrameControl,omitempty,omitzero"` // Whether BeginFrames for this target will be controlled via DevTools (headless shell only, not supported on MacOS yet, false by default).
	NewWindow               *bool                `json:"newWindow,omitempty,omitzero"`               // Whether to create a new Window or Tab (false by default, not supported by headless shell).
	Background              *bool                `json:"background,omitempty,omitzero"`              // Whether to create the target in background or foreground (false by default, not supported by headless shell).
	ForTab                  *bool                `json:"forTab,omitempty,omitzero"`                  // Whether to create the target of type "tab".
	Hidden                  *bool                `json:"hidden,omitempty,omitzero"`                  // 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.
	Focus                   *bool                `json:"focus,omitempty,omitzero"`                   // If specified, determines whether the new target should be focused. By default, the focus behavior depends on the background parameter: - If background is false (default) and focus is omitted, the new target is focused and the browser window is brought to the foreground. - If background is false and focus is false, the target is opened but the browser window's focus remains unchanged (e.g., if the window was in the background, it stays there). - If background is true, setting focus to true is not supported and will result in an error.
}

CreateTargetParams are the parameters of the command Target.createTarget.

type CreateTargetResult added in v0.157.3

type CreateTargetResult struct {
	TargetID ID `json:"targetId,omitempty,omitzero"` // The id of the page opened.
}

CreateTargetResult is the result of the command Target.createTarget.

type DetachFromTargetParams

type DetachFromTargetParams struct {
	SessionID SessionID `json:"sessionId,omitempty,omitzero"` // Session to detach.
}

DetachFromTargetParams are the parameters of the command Target.detachFromTarget.

type DisposeBrowserContextParams

type DisposeBrowserContextParams struct {
	BrowserContextID cdp.BrowserContextID `json:"browserContextId"`
}

DisposeBrowserContextParams are the parameters of the command Target.disposeBrowserContext.

type EventAttachedToTarget

type EventAttachedToTarget struct {
	SessionID          SessionID `json:"sessionId"` // Identifier assigned to the session used to send/receive messages.
	TargetInfo         *Info     `json:"targetInfo"`
	WaitingForDebugger bool      `json:"waitingForDebugger"`
}

EventAttachedToTarget issued when attached to target because of auto-attach or attachToTarget command.

See: https://chromedevtools.github.io/devtools-protocol/tot/Target#event-attachedToTarget

type EventDetachedFromTarget

type EventDetachedFromTarget struct {
	SessionID SessionID `json:"sessionId"` // Detached session identifier.
}

EventDetachedFromTarget issued when detached from target for any reason (including detachFromTarget command). Can be issued multiple times per target if multiple sessions have been attached to it.

See: https://chromedevtools.github.io/devtools-protocol/tot/Target#event-detachedFromTarget

type EventReceivedMessageFromTarget

type EventReceivedMessageFromTarget struct {
	SessionID SessionID `json:"sessionId"` // Identifier of a session which sends a message.
	Message   string    `json:"message"`
}

EventReceivedMessageFromTarget notifies about a new protocol message received from the session (as reported in attachedToTarget event).

See: https://chromedevtools.github.io/devtools-protocol/tot/Target#event-receivedMessageFromTarget

type EventTargetCrashed

type EventTargetCrashed struct {
	TargetID  ID     `json:"targetId"`
	Status    string `json:"status"`    // Termination status type.
	ErrorCode int64  `json:"errorCode"` // Termination error code.
}

EventTargetCrashed issued when a target has crashed.

See: https://chromedevtools.github.io/devtools-protocol/tot/Target#event-targetCrashed

type EventTargetCreated

type EventTargetCreated struct {
	TargetInfo *Info `json:"targetInfo"`
}

EventTargetCreated issued when a possible inspection target is created.

See: https://chromedevtools.github.io/devtools-protocol/tot/Target#event-targetCreated

type EventTargetDestroyed

type EventTargetDestroyed struct {
	TargetID ID `json:"targetId"`
}

EventTargetDestroyed issued when a target is destroyed.

See: https://chromedevtools.github.io/devtools-protocol/tot/Target#event-targetDestroyed

type EventTargetInfoChanged

type EventTargetInfoChanged struct {
	TargetInfo *Info `json:"targetInfo"`
}

EventTargetInfoChanged issued when some information about a target has changed. This only happens between targetCreated and targetDestroyed.

See: https://chromedevtools.github.io/devtools-protocol/tot/Target#event-targetInfoChanged

type ExposeDevToolsProtocolParams

type ExposeDevToolsProtocolParams struct {
	TargetID           ID     `json:"targetId"`
	BindingName        string `json:"bindingName,omitempty,omitzero"`        // Binding name, 'cdp' if not specified.
	InheritPermissions *bool  `json:"inheritPermissions,omitempty,omitzero"` // If true, inherits the current root session's permissions (default: false).
}

ExposeDevToolsProtocolParams are the parameters of the command Target.exposeDevToolsProtocol.

type Filter

type Filter []struct {
	Exclude bool   `json:"exclude"`                 // If set, causes exclusion of matching targets from the list.
	Type    string `json:"type,omitempty,omitzero"` // If not present, matches any type.
}

Filter 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).

See: https://chromedevtools.github.io/devtools-protocol/tot/Target#type-TargetFilter

type FilterEntry

type FilterEntry struct {
	Exclude bool   `json:"exclude"`                 // If set, causes exclusion of matching targets from the list.
	Type    string `json:"type,omitempty,omitzero"` // If not present, matches any type.
}

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

See: https://chromedevtools.github.io/devtools-protocol/tot/Target#type-FilterEntry

type GetBrowserContextsResult added in v0.157.3

type GetBrowserContextsResult struct {
	BrowserContextIDs       []cdp.BrowserContextID `json:"browserContextIds,omitempty,omitzero"`       // An array of browser context ids.
	DefaultBrowserContextID cdp.BrowserContextID   `json:"defaultBrowserContextId,omitempty,omitzero"` // The id of the default browser context if available.
}

GetBrowserContextsResult is the result of the command Target.getBrowserContexts.

type GetDevToolsTargetParams

type GetDevToolsTargetParams struct {
	TargetID ID `json:"targetId"` // Page or tab target ID.
}

GetDevToolsTargetParams are the parameters of the command Target.getDevToolsTarget.

type GetDevToolsTargetResult added in v0.157.3

type GetDevToolsTargetResult struct {
	TargetID ID `json:"targetId,omitempty,omitzero"` // The targetId of DevTools page target if exists.
}

GetDevToolsTargetResult is the result of the command Target.getDevToolsTarget.

type GetTargetInfoParams

type GetTargetInfoParams struct {
	TargetID ID `json:"targetId,omitempty,omitzero"`
}

GetTargetInfoParams are the parameters of the command Target.getTargetInfo.

type GetTargetInfoResult added in v0.157.3

type GetTargetInfoResult struct {
	TargetInfo *Info `json:"targetInfo,omitempty,omitzero"`
}

GetTargetInfoResult is the result of the command Target.getTargetInfo.

type GetTargetsParams

type GetTargetsParams struct {
	Filter Filter `json:"filter,omitempty,omitzero"` // 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.
}

GetTargetsParams are the parameters of the command Target.getTargets.

type GetTargetsResult added in v0.157.3

type GetTargetsResult struct {
	TargetInfos []*Info `json:"targetInfos,omitempty,omitzero"` // The list of targets.
}

GetTargetsResult is the result of the command Target.getTargets.

type ID

type ID string

ID [no description].

See: https://chromedevtools.github.io/devtools-protocol/tot/Target#type-TargetID

func (ID) String

func (t ID) String() string

String returns the ID as string value.

type Info

type Info struct {
	TargetID         ID                   `json:"targetId"`
	Type             string               `json:"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
	Title            string               `json:"title"`
	URL              string               `json:"url"`
	Attached         bool                 `json:"attached"`                         // Whether the target has an attached client.
	ParentID         ID                   `json:"parentId,omitempty,omitzero"`      // Id of the parent target, if any. For example, "iframe" target may have a "page" parent.
	OpenerID         ID                   `json:"openerId,omitempty,omitzero"`      // Opener target Id
	CanAccessOpener  bool                 `json:"canAccessOpener"`                  // Whether the target has access to the originating window.
	OpenerFrameID    cdp.FrameID          `json:"openerFrameId,omitempty,omitzero"` // Frame id of originating window (is only set if target has an opener).
	ParentFrameID    cdp.FrameID          `json:"parentFrameId,omitempty,omitzero"` // 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.
	BrowserContextID cdp.BrowserContextID `json:"browserContextId,omitempty,omitzero"`
	Subtype          string               `json:"subtype,omitempty,omitzero"` // Provides additional details for specific target types. For example, for the type of "page", this may be set to "prerender".
	EmbedderData     jsontext.Value       `json:"embedderData,omitempty,omitzero"`
}

Info [no description].

See: https://chromedevtools.github.io/devtools-protocol/tot/Target#type-TargetInfo

type OpenDevToolsParams

type OpenDevToolsParams struct {
	TargetID ID     `json:"targetId"`                   // This can be the page or tab target ID.
	PanelID  string `json:"panelId,omitempty,omitzero"` // The id of the panel we want DevTools to open initially. Currently supported panels are elements, console, network, sources, resources, timeline, chrome-recorder, heap-profiler, lighthouse, and security.
}

OpenDevToolsParams are the parameters of the command Target.openDevTools.

type OpenDevToolsResult added in v0.157.3

type OpenDevToolsResult struct {
	TargetID ID `json:"targetId,omitempty,omitzero"` // The targetId of DevTools page target.
}

OpenDevToolsResult is the result of the command Target.openDevTools.

type RemoteLocation

type RemoteLocation struct {
	Host string `json:"host"`
	Port int64  `json:"port"`
}

RemoteLocation [no description].

See: https://chromedevtools.github.io/devtools-protocol/tot/Target#type-RemoteLocation

type SessionID

type SessionID string

SessionID unique identifier of attached debugging session.

See: https://chromedevtools.github.io/devtools-protocol/tot/Target#type-SessionID

func (SessionID) String

func (t SessionID) String() string

String returns the SessionID as string value.

type SetAutoAttachParams

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,omitzero"` // 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,omitzero"`  // Only targets matching filter will be attached.
}

SetAutoAttachParams are the parameters of the command Target.setAutoAttach.

type SetDiscoverTargetsParams

type SetDiscoverTargetsParams struct {
	Discover bool   `json:"discover"`                  // Whether to discover available targets.
	Filter   Filter `json:"filter,omitempty,omitzero"` // Only targets matching filter will be attached. If discover is false, filter must be omitted or empty.
}

SetDiscoverTargetsParams are the parameters of the command Target.setDiscoverTargets.

type SetRemoteLocationsParams

type SetRemoteLocationsParams struct {
	Locations []*RemoteLocation `json:"locations"` // List of remote locations.
}

SetRemoteLocationsParams are the parameters of the command Target.setRemoteLocations.

type WindowState

type WindowState string

WindowState the state of the target window.

See: https://chromedevtools.github.io/devtools-protocol/tot/Target#type-WindowState

const (
	WindowStateNormal     WindowState = "normal"
	WindowStateMinimized  WindowState = "minimized"
	WindowStateMaximized  WindowState = "maximized"
	WindowStateFullscreen WindowState = "fullscreen"
)

WindowState values.

func (WindowState) String

func (t WindowState) String() string

String returns the WindowState as string value.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL