client

package
v0.0.0-...-b47709e Latest Latest
Warning

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

Go to latest
Published: Apr 5, 2018 License: MIT Imports: 15 Imported by: 0

Documentation

Overview

Package client provides the low level Chrome Debugging Protocol JSON types and related funcs.

Index

Constants

View Source
const (
	// DefaultURL is the default Chrome URL to connect to.
	DefaultURL = "http://localhost:9222/json"

	// DefaultWatchInterval is the default check duration.
	DefaultWatchInterval = 100 * time.Millisecond

	// DefaultWatchTimeout is the default watch timeout.
	DefaultWatchTimeout = 5 * time.Second
)
View Source
const (
	// DefaultReadBufferSize is the default maximum read buffer size.
	DefaultReadBufferSize = 25 * 1024 * 1024

	// DefaultWriteBufferSize is the default maximum write buffer size.
	DefaultWriteBufferSize = 10 * 1024 * 1024
)

Variables

View Source
var (
	// ErrUnsupportedProtocolType is the unsupported protocol type error.
	ErrUnsupportedProtocolType = errors.New("unsupported protocol type")

	// ErrUnsupportedProtocolVersion is the unsupported protocol version error.
	ErrUnsupportedProtocolVersion = errors.New("unsupported protocol version")
)

Functions

This section is empty.

Types

type Chrome

type Chrome struct {
	Description  string     `json:"description,omitempty"`
	DevtoolsURL  string     `json:"devtoolsFrontendUrl,omitempty"`
	ID           string     `json:"id,omitempty"`
	Title        string     `json:"title,omitempty"`
	Type         TargetType `json:"type,omitempty"`
	URL          string     `json:"url,omitempty"`
	WebsocketURL string     `json:"webSocketDebuggerUrl,omitempty"`
	FaviconURL   string     `json:"faviconURL,omitempty"`
}

Chrome holds connection information for a Chrome, Edge, or Safari target.

func (*Chrome) GetID

func (c *Chrome) GetID() string

GetID returns the target ID.

func (*Chrome) GetType

func (c *Chrome) GetType() TargetType

GetType returns the target type.

func (*Chrome) GetWebsocketURL

func (c *Chrome) GetWebsocketURL() string

GetWebsocketURL provides the websocket URL for the target, satisfying the domains.Target interface.

func (Chrome) MarshalEasyJSON

func (v Chrome) MarshalEasyJSON(w *jwriter.Writer)

MarshalEasyJSON supports easyjson.Marshaler interface

func (Chrome) MarshalJSON

func (v Chrome) MarshalJSON() ([]byte, error)

MarshalJSON supports json.Marshaler interface

func (Chrome) String

func (c Chrome) String() string

String satisfies the stringer interface.

func (*Chrome) UnmarshalEasyJSON

func (v *Chrome) UnmarshalEasyJSON(l *jlexer.Lexer)

UnmarshalEasyJSON supports easyjson.Unmarshaler interface

func (*Chrome) UnmarshalJSON

func (v *Chrome) UnmarshalJSON(data []byte) error

UnmarshalJSON supports json.Unmarshaler interface

type Client

type Client struct {
	// contains filtered or unexported fields
}

Client is a Chrome Debugging Protocol client.

func New

func New(opts ...Option) *Client

New creates a new Chrome Debugging Protocol client.

func (*Client) ActivateTarget

func (c *Client) ActivateTarget(ctxt context.Context, t Target) error

ActivateTarget activates a target.

func (*Client) CloseTarget

func (c *Client) CloseTarget(ctxt context.Context, t Target) error

CloseTarget activates a target.

func (*Client) ListPageTargets

func (c *Client) ListPageTargets(ctxt context.Context) ([]Target, error)

ListPageTargets lists the available Page targets.

func (*Client) ListTargets

func (c *Client) ListTargets(ctxt context.Context) ([]Target, error)

ListTargets returns a list of all targets.

func (*Client) ListTargetsWithType

func (c *Client) ListTargetsWithType(ctxt context.Context, typ TargetType) ([]Target, error)

ListTargetsWithType returns a list of Targets with the specified target type.

func (*Client) NewPageTarget

func (c *Client) NewPageTarget(ctxt context.Context) (Target, error)

NewPageTarget creates a new page target.

func (*Client) NewPageTargetWithURL

func (c *Client) NewPageTargetWithURL(ctxt context.Context, urlstr string) (Target, error)

NewPageTargetWithURL creates a new page target with the specified url.

func (*Client) VersionInfo

func (c *Client) VersionInfo(ctxt context.Context) (map[string]string, error)

VersionInfo returns information about the remote debugging protocol.

func (*Client) WatchPageTargets

func (c *Client) WatchPageTargets(ctxt context.Context) <-chan Target

WatchPageTargets watches for new page targets.

type Conn

type Conn struct {
	*websocket.Conn
}

Conn wraps a gorilla/websocket.Conn connection.

func (*Conn) Read

func (c *Conn) Read() ([]byte, error)

Read reads the next websocket message.

func (*Conn) Write

func (c *Conn) Write(buf []byte) error

Write writes a websocket message.

type DialOption

type DialOption func(*websocket.Dialer)

DialOption is a dial option.

type Option

type Option func(*Client)

Option is a Chrome Debugging Protocol client option.

func URL

func URL(url string) Option

URL is a client option to specify the remote Chrome instance to connect to.

func WatchInterval

func WatchInterval(check time.Duration) Option

WatchInterval is a client option that specifies the check interval duration.

func WatchTimeout

func WatchTimeout(timeout time.Duration) Option

WatchTimeout is a client option that specifies the watch timeout duration.

type Target

type Target interface {
	String() string
	GetID() string
	GetType() TargetType
	GetWebsocketURL() string
}

Target is the common interface for a Chrome Debugging Protocol target.

type TargetType

type TargetType string

TargetType are the types of targets available in Chrome.

const (
	BackgroundPage TargetType = "background_page"
	Other          TargetType = "other"
	Page           TargetType = "page"
	ServiceWorker  TargetType = "service_worker"
	Node           TargetType = "node"
)

TargetType values.

func (TargetType) MarshalEasyJSON

func (tt TargetType) MarshalEasyJSON(out *jwriter.Writer)

MarshalEasyJSON satisfies easyjson.Marshaler.

func (TargetType) MarshalJSON

func (tt TargetType) MarshalJSON() ([]byte, error)

MarshalJSON satisfies json.Marshaler.

func (TargetType) String

func (tt TargetType) String() string

String satisfies stringer.

func (*TargetType) UnmarshalEasyJSON

func (tt *TargetType) UnmarshalEasyJSON(in *jlexer.Lexer)

UnmarshalEasyJSON satisfies easyjson.Unmarshaler.

func (*TargetType) UnmarshalJSON

func (tt *TargetType) UnmarshalJSON(buf []byte) error

UnmarshalJSON satisfies json.Unmarshaler.

type Transport

type Transport interface {
	Read() ([]byte, error)
	Write([]byte) error
	io.Closer
}

Transport is the common interface to send/receive messages.

func Dial

func Dial(t Target, opts ...DialOption) (Transport, error)

Dial dials the specified target's websocket URL.

Note: uses gorilla/websocket.

Jump to

Keyboard shortcuts

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