Documentation
¶
Overview ¶
Package chrome aims to be a complete Chrome DevTools Protocol Viewer implementation.
This version implements the Tip-of-Tree API. See https://chromedevtools.github.io/devtools-protocol/tot/ for details.
Index ¶
- type Chrome
- func (chrome *Chrome) Address() string
- func (chrome *Chrome) Binary() string
- func (chrome *Chrome) Close() error
- func (chrome *Chrome) DebuggingAddress() string
- func (chrome *Chrome) DebuggingPort() int
- func (chrome *Chrome) Flags() ChromiumFlags
- func (chrome *Chrome) GetTab(tabID string) (Tabber, error)
- func (chrome *Chrome) Launch() error
- func (chrome *Chrome) NewTab(uri string) (*Tab, error)
- func (chrome *Chrome) Port() int
- func (chrome *Chrome) Query(path string, params url.Values, msg interface{}) (interface{}, error)
- func (chrome *Chrome) RemoveTab(tab *Tab)
- func (chrome *Chrome) STDERR() string
- func (chrome *Chrome) STDOUT() string
- func (chrome *Chrome) Tabs() []*Tab
- func (chrome *Chrome) Version() (*Version, error)
- func (chrome *Chrome) Workdir() string
- type Chromium
- type ChromiumFlags
- type Flags
- type Socketer
- type Tab
- func (tab *Tab) Accessibility() *socket.AccessibilityProtocol
- func (tab *Tab) AddEventHandler(handler socket.EventHandler)
- func (tab *Tab) Animation() *socket.AnimationProtocol
- func (tab *Tab) ApplicationCache() *socket.ApplicationCacheProtocol
- func (tab *Tab) Audits() *socket.AuditsProtocol
- func (tab *Tab) Browser() *socket.BrowserProtocol
- func (tab *Tab) CSS() *socket.CSSProtocol
- func (tab *Tab) CacheStorage() *socket.CacheStorageProtocol
- func (tab *Tab) Chromium() Chromium
- func (tab *Tab) Close() (interface{}, error)
- func (tab *Tab) Console() *socket.ConsoleProtocol
- func (tab *Tab) DOM() *socket.DOMProtocol
- func (tab *Tab) DOMDebugger() *socket.DOMDebuggerProtocol
- func (tab *Tab) DOMSnapshot() *socket.DOMSnapshotProtocol
- func (tab *Tab) DOMStorage() *socket.DOMStorageProtocol
- func (tab *Tab) Data() *TabData
- func (tab *Tab) Database() *socket.DatabaseProtocol
- func (tab *Tab) Debugger() *socket.DebuggerProtocol
- func (tab *Tab) DeviceOrientation() *socket.DeviceOrientationProtocol
- func (tab *Tab) Emulation() *socket.EmulationProtocol
- func (tab *Tab) HeadlessExperimental() *socket.HeadlessExperimentalProtocol
- func (tab *Tab) HeapProfiler() *socket.HeapProfilerProtocol
- func (tab *Tab) IO() *socket.IOProtocol
- func (tab *Tab) IndexedDB() *socket.IndexedDBProtocol
- func (tab *Tab) Input() *socket.InputProtocol
- func (tab *Tab) LayerTree() *socket.LayerTreeProtocol
- func (tab *Tab) Log() *socket.LogProtocol
- func (tab *Tab) Memory() *socket.MemoryProtocol
- func (tab *Tab) Network() *socket.NetworkProtocol
- func (tab *Tab) Overlay() *socket.OverlayProtocol
- func (tab *Tab) Page() *socket.PageProtocol
- func (tab *Tab) Performance() *socket.PerformanceProtocol
- func (tab *Tab) Profiler() *socket.ProfilerProtocol
- func (tab *Tab) Protocol() socket.Protocoller
- func (tab *Tab) RemoveEventHandler(handler socket.EventHandler)
- func (tab *Tab) Runtime() *socket.RuntimeProtocol
- func (tab *Tab) Schema() *socket.SchemaProtocol
- func (tab *Tab) Security() *socket.SecurityProtocol
- func (tab *Tab) SendCommand(command socket.Commander) chan *socket.Response
- func (tab *Tab) ServiceWorker() *socket.ServiceWorkerProtocol
- func (tab *Tab) Socket() socket.Socketer
- func (tab *Tab) Storage() *socket.StorageProtocol
- func (tab *Tab) SystemInfo() *socket.SystemInfoProtocol
- func (tab *Tab) Target() *socket.TargetProtocol
- func (tab *Tab) Tethering() *socket.TetheringProtocol
- func (tab *Tab) Tracing() *socket.TracingProtocol
- func (tab *Tab) URL() *url.URL
- type TabData
- type Tabber
- type Version
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Chrome ¶
type Chrome struct {
// contains filtered or unexported fields
}
Chrome implements Chromium.
func New ¶
func New( flags ChromiumFlags, binary string, workdir string, stdout string, stderr string, ) *Chrome
New returns a pointer to a Chromium instance.
func (*Chrome) Binary ¶
Binary implements Chromium.
Default value is '/usr/bin/google-chrome' for use with the mkenney/chromium-headless Docker image.
func (*Chrome) DebuggingPort ¶
DebuggingPort implements Chromium.
func (*Chrome) Launch ¶
Launch implements Chromium.
This implementation makes it's best effort to set a few sane default values if they aren't included in the Flags definition:
addr = "localhost" remote-debugging-address = "0.0.0.0" remote-debugging-port = 9222 port = 9222 user-data-dir = os.TempDir() + chrome.Workdir() chrome.workdir = "headless-chrome" chrome.output = "/dev/stdout"
func (*Chrome) Query ¶
func (chrome *Chrome) Query( path string, params url.Values, msg interface{}, ) (interface{}, error)
Query implements Chromium.
type Chromium ¶
type Chromium interface {
// Address returns the domain to use for accessing Chrome sockets (e.g.
// 'localhost'). Should return a sane default value such as 'localhost'.
Address() string
// Binary returns the path to the Chromium binary. Should return a sane
// default value such as '/usr/bin/google-chrome'.
Binary() string
// Close ends the Chromium process and cleans up.
Close() error
// GetTab returns an open Tabber instance, or an error if the requested tab
// does not exist.
GetTab(tabID string) (tab Tabber, err error)
// RemoveTab removes tab reference from chrome tabs list.
RemoveTab(tab *Tab)
// DebuggingAddress returns the address that the remote debugging protocol
// is available on. Should return a sane default value such as '0.0.0.0'.
DebuggingAddress() string
// DebuggingPort is the port number that the remote debugging protocol is
// available on. Should return a sane default value such as 9222.
DebuggingPort() int
// Args returns a ChromiumFlags interface used to define and manage CLI
// arguments to the Chromium binary. Only used when starting the chromium
// system process.
Flags() ChromiumFlags
// Launch launches the Chromium process and returns the connected Chromium
// struct.
Launch() error
// NewTab spawns a new tab and returns a reference to it.
NewTab(url string) (*Tab, error)
// Port returns the port number the developer tools endpoints will listen
// on. Should return a sane default value such as 9222.
Port() int
// Query queries the developer tools endpoints and returns JSON data in the
// provided struct.
Query(path string, params url.Values, msg interface{}) (interface{}, error)
// STDERR returns a string defining the location to write STDERR output.
STDERR() string
// STDOUT returns a string defining the location to write STDOUT output.
STDOUT() string
// Tabs returns the list of the currently open tabs.
Tabs() []*Tab
// Version returns Chromium version data.
Version() (*Version, error)
// Workdir returns the path of the Chromium working directory. Should return
// a sane default value such as '/tmp/headless-chrome'.
Workdir() string
}
Chromium defines an interface for interacting with Chromium based web browsers
type ChromiumFlags ¶
type ChromiumFlags interface {
// Get returns the specified flag values
Get(flag string) (interface{}, error)
// Has checks to see if an flag is present.
Has(flag string) bool
// List returns an array of each flag for use in os.StartProcess
List() []string
// Set sets a flag's values.
Set(flag string, values interface{}) error
// String implments Stringer. It returns the set parameters formatted to be
// passed to the command line.
String() string
}
ChromiumFlags provides an interface for managing CLI arguments to the Chromium binary.
type Flags ¶
type Flags map[string]interface{}
Flags contains CLI arguments to the Chromium executable.
type Socketer ¶
type Socketer interface {
// AddEventHandler adds an event handler to the stack of listeners for an
// event.
AddEventHandler(handler socket.EventHandler)
// RemoveEventHandler removes a handler from the stack of listeners for an
// event.
RemoveEventHandler(handler socket.EventHandler)
// SendCommand delivers a command payload to the websocket connection.
SendCommand(command socket.Commander) *socket.Payload
}
Socketer defins a simple socket interface for the tab struct to implement
type Tab ¶
type Tab struct {
// contains filtered or unexported fields
}
Tab is a struct representing an individual Chrome tab
func (*Tab) Accessibility ¶
func (tab *Tab) Accessibility() *socket.AccessibilityProtocol
Accessibility implements socket.Protocoller
func (*Tab) AddEventHandler ¶
func (tab *Tab) AddEventHandler(handler socket.EventHandler)
AddEventHandler implements Socketer
func (*Tab) Animation ¶
func (tab *Tab) Animation() *socket.AnimationProtocol
Animation implements socket.Protocoller
func (*Tab) ApplicationCache ¶
func (tab *Tab) ApplicationCache() *socket.ApplicationCacheProtocol
ApplicationCache implements socket.Protocoller
func (*Tab) Audits ¶
func (tab *Tab) Audits() *socket.AuditsProtocol
Audits implements socket.Protocoller
func (*Tab) Browser ¶
func (tab *Tab) Browser() *socket.BrowserProtocol
Browser implements socket.Protocoller
func (*Tab) CacheStorage ¶
func (tab *Tab) CacheStorage() *socket.CacheStorageProtocol
CacheStorage implements socket.Protocoller
func (*Tab) Console ¶
func (tab *Tab) Console() *socket.ConsoleProtocol
Console implements socket.Protocoller
func (*Tab) DOMDebugger ¶
func (tab *Tab) DOMDebugger() *socket.DOMDebuggerProtocol
DOMDebugger implements socket.Protocoller
func (*Tab) DOMSnapshot ¶
func (tab *Tab) DOMSnapshot() *socket.DOMSnapshotProtocol
DOMSnapshot implements socket.Protocoller
func (*Tab) DOMStorage ¶
func (tab *Tab) DOMStorage() *socket.DOMStorageProtocol
DOMStorage implements socket.Protocoller
func (*Tab) Database ¶
func (tab *Tab) Database() *socket.DatabaseProtocol
Database implements socket.Protocoller
func (*Tab) Debugger ¶
func (tab *Tab) Debugger() *socket.DebuggerProtocol
Debugger implements socket.Protocoller
func (*Tab) DeviceOrientation ¶
func (tab *Tab) DeviceOrientation() *socket.DeviceOrientationProtocol
DeviceOrientation implements socket.Protocoller
func (*Tab) Emulation ¶
func (tab *Tab) Emulation() *socket.EmulationProtocol
Emulation implements socket.Protocoller
func (*Tab) HeadlessExperimental ¶
func (tab *Tab) HeadlessExperimental() *socket.HeadlessExperimentalProtocol
HeadlessExperimental implements socket.Protocoller
func (*Tab) HeapProfiler ¶
func (tab *Tab) HeapProfiler() *socket.HeapProfilerProtocol
HeapProfiler implements socket.Protocoller
func (*Tab) IndexedDB ¶
func (tab *Tab) IndexedDB() *socket.IndexedDBProtocol
IndexedDB implements socket.Protocoller
func (*Tab) Input ¶
func (tab *Tab) Input() *socket.InputProtocol
Input implements socket.Protocoller
func (*Tab) LayerTree ¶
func (tab *Tab) LayerTree() *socket.LayerTreeProtocol
LayerTree implements socket.Protocoller
func (*Tab) Memory ¶
func (tab *Tab) Memory() *socket.MemoryProtocol
Memory implements socket.Protocoller
func (*Tab) Network ¶
func (tab *Tab) Network() *socket.NetworkProtocol
Network implements socket.Protocoller
func (*Tab) Overlay ¶
func (tab *Tab) Overlay() *socket.OverlayProtocol
Overlay implements socket.Protocoller
func (*Tab) Performance ¶
func (tab *Tab) Performance() *socket.PerformanceProtocol
Performance implements socket.Protocoller
func (*Tab) Profiler ¶
func (tab *Tab) Profiler() *socket.ProfilerProtocol
Profiler implements socket.Protocoller
func (*Tab) RemoveEventHandler ¶
func (tab *Tab) RemoveEventHandler(handler socket.EventHandler)
RemoveEventHandler implements Socketer
func (*Tab) Runtime ¶
func (tab *Tab) Runtime() *socket.RuntimeProtocol
Runtime implements socket.Protocoller
func (*Tab) Schema ¶
func (tab *Tab) Schema() *socket.SchemaProtocol
Schema implements socket.Protocoller
func (*Tab) Security ¶
func (tab *Tab) Security() *socket.SecurityProtocol
Security implements socket.Protocoller
func (*Tab) SendCommand ¶
SendCommand implements Socketer
func (*Tab) ServiceWorker ¶
func (tab *Tab) ServiceWorker() *socket.ServiceWorkerProtocol
ServiceWorker implements socket.Protocoller
func (*Tab) Storage ¶
func (tab *Tab) Storage() *socket.StorageProtocol
Storage implements socket.Protocoller
func (*Tab) SystemInfo ¶
func (tab *Tab) SystemInfo() *socket.SystemInfoProtocol
SystemInfo implements socket.Protocoller
func (*Tab) Target ¶
func (tab *Tab) Target() *socket.TargetProtocol
Target implements socket.Protocoller
func (*Tab) Tethering ¶
func (tab *Tab) Tethering() *socket.TetheringProtocol
Tethering implements socket.Protocoller
func (*Tab) Tracing ¶
func (tab *Tab) Tracing() *socket.TracingProtocol
Tracing implements socket.Protocoller
type TabData ¶
type TabData struct {
Description string `json:"description"`
DevtoolsFrontendURL string `json:"devtoolsFrontendURL"`
ID string `json:"id"`
Title string `json:"title"`
Type string `json:"type"`
URL string `json:"url"`
WebSocketDebuggerURL string `json:"webSocketDebuggerURL"`
}
TabData holds metadata about a browser tab
type Tabber ¶
type Tabber interface {
// Browser returns the Chromium instance this tab is in
Chromium() Chromium
// Close closes this chromium tab
Close() (interface{}, error)
// Data returns the tab metadata
Data() *TabData
// Protocol returns the socket.Protocoller interface for this tab
Protocol() socket.Protocoller
// Socket returns the socket.Socketer interface for this tab
Socket() socket.Socketer
// URL returns the URL of the websocket connection
URL() *url.URL
}
Tabber provides an interface for managing a Chromium tab
type Version ¶
type Version struct {
Browser string `json:"browser"`
ProtocolVersion string `json:"protocol-version"`
UserAgent string `json:"user-agent"`
V8Version string `json:"v8-version"`
WebKitVersion string `json:"webkit-version"`
WebSocketDebuggerURL string `json:"webSocketDebuggerUrl"`
}
Version is a struct representing the Chromium version information.
Source Files
¶
Directories
¶
| Path | Synopsis |
|---|---|
|
Package accessibility provides type definitions for use with the Chrome Accessibility protocol
|
Package accessibility provides type definitions for use with the Chrome Accessibility protocol |
|
Package animation provides type definitions for use with the Chrome Animation protocol
|
Package animation provides type definitions for use with the Chrome Animation protocol |
|
application
|
|
|
cache
Package cache provides type definitions for use with the Chrome ApplicationCache protocol
|
Package cache provides type definitions for use with the Chrome ApplicationCache protocol |
|
Package audits provides type definitions for use with the Chrome Audits protocol
|
Package audits provides type definitions for use with the Chrome Audits protocol |
|
Package browser provides type definitions for use with the Chrome Browser protocol
|
Package browser provides type definitions for use with the Chrome Browser protocol |
|
cache
|
|
|
storage
Package storage provides type definitions for use with the Chrome CacheStorage protocol
|
Package storage provides type definitions for use with the Chrome CacheStorage protocol |
|
Package console provides type definitions for use with the Chrome Console protocol
|
Package console provides type definitions for use with the Chrome Console protocol |
|
Package css provides type definitions for use with the Chrome CSS protocol
|
Package css provides type definitions for use with the Chrome CSS protocol |
|
Package database provides type definitions for use with the Chrome Database protocol
|
Package database provides type definitions for use with the Chrome Database protocol |
|
Package debugger provides type definitions for use with the Chrome Debugger protocol
|
Package debugger provides type definitions for use with the Chrome Debugger protocol |
|
device
|
|
|
orientation
Package orientation provides type definitions for use with the Chrome DeviceOrientation protocol
|
Package orientation provides type definitions for use with the Chrome DeviceOrientation protocol |
|
Package dom provides type definitions for use with the Chrome DOM protocol
|
Package dom provides type definitions for use with the Chrome DOM protocol |
|
debugger
Package debugger provides type definitions for use with the Chrome DOMDebugger protocol
|
Package debugger provides type definitions for use with the Chrome DOMDebugger protocol |
|
snapshot
Package snapshot provides type definitions for use with the Chrome DOMSnapshot protocol
|
Package snapshot provides type definitions for use with the Chrome DOMSnapshot protocol |
|
storage
Package storage provides type definitions for use with the Chrome DOMStorage protocol
|
Package storage provides type definitions for use with the Chrome DOMStorage protocol |
|
Package emulation provides type definitions for use with the Chrome Emulation protocol
|
Package emulation provides type definitions for use with the Chrome Emulation protocol |
|
headless
|
|
|
experimental
Package experimental provides type definitions for use with the Chrome HeadlessExperimental protocol
|
Package experimental provides type definitions for use with the Chrome HeadlessExperimental protocol |
|
heap
|
|
|
profiler
Package profiler provides type definitions for use with the Chrome HeapProfiler protocol
|
Package profiler provides type definitions for use with the Chrome HeapProfiler protocol |
|
indexed
|
|
|
db
Package db provides type definitions for use with the Chrome IndexedDB protocol
|
Package db provides type definitions for use with the Chrome IndexedDB protocol |
|
Package input provides type definitions for use with the Chrome Input protocol
|
Package input provides type definitions for use with the Chrome Input protocol |
|
Package io provides type definitions for use with the Chrome IO protocol
|
Package io provides type definitions for use with the Chrome IO protocol |
|
layer
|
|
|
tree
Package tree provides type definitions for use with the Chrome LayerTree protocol
|
Package tree provides type definitions for use with the Chrome LayerTree protocol |
|
Package log provides type definitions for use with the Chrome Log protocol
|
Package log provides type definitions for use with the Chrome Log protocol |
|
Package memory provides type definitions for use with the Chrome Memory protocol
|
Package memory provides type definitions for use with the Chrome Memory protocol |
|
Package network provides type definitions for use with the Chrome Network protocol
|
Package network provides type definitions for use with the Chrome Network protocol |
|
Package overlay provides type definitions for use with the Chrome Overlay protocol
|
Package overlay provides type definitions for use with the Chrome Overlay protocol |
|
Package page provides type definitions for use with the Chrome Page protocol
|
Package page provides type definitions for use with the Chrome Page protocol |
|
Package performance provides type definitions for use with the Chrome Performance protocol
|
Package performance provides type definitions for use with the Chrome Performance protocol |
|
Package profiler provides type definitions for use with the Chrome Profiler protocol
|
Package profiler provides type definitions for use with the Chrome Profiler protocol |
|
Package runtime provides type definitions for use with the Chrome Runtime protocol
|
Package runtime provides type definitions for use with the Chrome Runtime protocol |
|
Package schema provides type definitions for use with the Chrome Schema protocol
|
Package schema provides type definitions for use with the Chrome Schema protocol |
|
Package security provides type definitions for use with the Chrome Security protocol
|
Package security provides type definitions for use with the Chrome Security protocol |
|
service
|
|
|
worker
Package worker provides type definitions for use with the Chrome ServiceWorker protocol
|
Package worker provides type definitions for use with the Chrome ServiceWorker protocol |
|
Package socket allows for tools to instrument, inspect, debug and profile Chromium, Chrome and other Blink-based browsers.
|
Package socket allows for tools to instrument, inspect, debug and profile Chromium, Chrome and other Blink-based browsers. |
|
Package storage provides type definitions for use with the Chrome Storage protocol
|
Package storage provides type definitions for use with the Chrome Storage protocol |
|
system
|
|
|
info
Package info provides type definitions for use with the Chrome SystemInfo protocol
|
Package info provides type definitions for use with the Chrome SystemInfo protocol |
|
Package target provides type definitions for use with the Chrome Target protocol
|
Package target provides type definitions for use with the Chrome Target protocol |
|
Package tethering provides type definitions for use with the Chrome Tethering protocol
|
Package tethering provides type definitions for use with the Chrome Tethering protocol |
|
Package tracing provides type definitions for use with the Chrome Tracing protocol
|
Package tracing provides type definitions for use with the Chrome Tracing protocol |