Updating to latest protocol.json and addition of Browser domain

This commit is contained in:
Kenneth Shaw 2017-04-17 07:32:07 +07:00
parent 09d39c646b
commit 4bb2c55697
11 changed files with 1165 additions and 418 deletions

116
cdp/browser/browser.go Normal file
View File

@ -0,0 +1,116 @@
// Package browser provides the Chrome Debugging Protocol
// commands, types, and events for the Browser domain.
//
// The Browser domain defines methods and events for browser managing.
//
// Generated by the chromedp-gen command.
package browser
// AUTOGENERATED. DO NOT EDIT.
import (
"context"
cdp "github.com/knq/chromedp/cdp"
"github.com/knq/chromedp/cdp/target"
)
// GetWindowForTargetParams get the browser window that contains the devtools
// target.
type GetWindowForTargetParams struct {
TargetID target.ID `json:"targetId"` // Devtools agent host id.
}
// GetWindowForTarget get the browser window that contains the devtools
// target.
//
// parameters:
// targetID - Devtools agent host id.
func GetWindowForTarget(targetID target.ID) *GetWindowForTargetParams {
return &GetWindowForTargetParams{
TargetID: targetID,
}
}
// GetWindowForTargetReturns return values.
type GetWindowForTargetReturns struct {
WindowID WindowID `json:"windowId,omitempty"` // Browser window id.
Bounds *Bounds `json:"bounds,omitempty"` // Bounds information of the window. When window state is 'minimized', the restored window position and size are returned.
}
// Do executes Browser.getWindowForTarget against the provided context and
// target handler.
//
// returns:
// windowID - Browser window id.
// bounds - Bounds information of the window. When window state is 'minimized', the restored window position and size are returned.
func (p *GetWindowForTargetParams) Do(ctxt context.Context, h cdp.Handler) (windowID WindowID, bounds *Bounds, err error) {
// execute
var res GetWindowForTargetReturns
err = h.Execute(ctxt, cdp.CommandBrowserGetWindowForTarget, p, &res)
if err != nil {
return 0, nil, err
}
return res.WindowID, res.Bounds, nil
}
// SetWindowBoundsParams set position and/or size of the browser window.
type SetWindowBoundsParams struct {
WindowID WindowID `json:"windowId"` // Browser window id.
Bounds *Bounds `json:"bounds"` // New window bounds. The 'minimized', 'maximized' and 'fullscreen' states cannot be combined with 'left', 'top', 'width' or 'height'. Leaves unspecified fields unchanged.
}
// SetWindowBounds set position and/or size of the browser window.
//
// parameters:
// windowID - Browser window id.
// bounds - New window bounds. The 'minimized', 'maximized' and 'fullscreen' states cannot be combined with 'left', 'top', 'width' or 'height'. Leaves unspecified fields unchanged.
func SetWindowBounds(windowID WindowID, bounds *Bounds) *SetWindowBoundsParams {
return &SetWindowBoundsParams{
WindowID: windowID,
Bounds: bounds,
}
}
// Do executes Browser.setWindowBounds against the provided context and
// target handler.
func (p *SetWindowBoundsParams) Do(ctxt context.Context, h cdp.Handler) (err error) {
return h.Execute(ctxt, cdp.CommandBrowserSetWindowBounds, p, nil)
}
// GetWindowBoundsParams get position and size of the browser window.
type GetWindowBoundsParams struct {
WindowID WindowID `json:"windowId"` // Browser window id.
}
// GetWindowBounds get position and size of the browser window.
//
// parameters:
// windowID - Browser window id.
func GetWindowBounds(windowID WindowID) *GetWindowBoundsParams {
return &GetWindowBoundsParams{
WindowID: windowID,
}
}
// GetWindowBoundsReturns return values.
type GetWindowBoundsReturns struct {
Bounds *Bounds `json:"bounds,omitempty"` // Bounds information of the window. When window state is 'minimized', the restored window position and size are returned.
}
// Do executes Browser.getWindowBounds against the provided context and
// target handler.
//
// returns:
// bounds - Bounds information of the window. When window state is 'minimized', the restored window position and size are returned.
func (p *GetWindowBoundsParams) Do(ctxt context.Context, h cdp.Handler) (bounds *Bounds, err error) {
// execute
var res GetWindowBoundsReturns
err = h.Execute(ctxt, cdp.CommandBrowserGetWindowBounds, p, &res)
if err != nil {
return nil, err
}
return res.Bounds, nil
}

522
cdp/browser/easyjson.go Normal file
View File

@ -0,0 +1,522 @@
// AUTOGENERATED FILE: easyjson marshaler/unmarshalers.
package browser
import (
json "encoding/json"
target "github.com/knq/chromedp/cdp/target"
easyjson "github.com/mailru/easyjson"
jlexer "github.com/mailru/easyjson/jlexer"
jwriter "github.com/mailru/easyjson/jwriter"
)
// suppress unused package warning
var (
_ *json.RawMessage
_ *jlexer.Lexer
_ *jwriter.Writer
_ easyjson.Marshaler
)
func easyjsonC5a4559bDecodeGithubComKnqChromedpCdpBrowser(in *jlexer.Lexer, out *SetWindowBoundsParams) {
isTopLevel := in.IsStart()
if in.IsNull() {
if isTopLevel {
in.Consumed()
}
in.Skip()
return
}
in.Delim('{')
for !in.IsDelim('}') {
key := in.UnsafeString()
in.WantColon()
if in.IsNull() {
in.Skip()
in.WantComma()
continue
}
switch key {
case "windowId":
out.WindowID = WindowID(in.Int64())
case "bounds":
if in.IsNull() {
in.Skip()
out.Bounds = nil
} else {
if out.Bounds == nil {
out.Bounds = new(Bounds)
}
(*out.Bounds).UnmarshalEasyJSON(in)
}
default:
in.SkipRecursive()
}
in.WantComma()
}
in.Delim('}')
if isTopLevel {
in.Consumed()
}
}
func easyjsonC5a4559bEncodeGithubComKnqChromedpCdpBrowser(out *jwriter.Writer, in SetWindowBoundsParams) {
out.RawByte('{')
first := true
_ = first
if !first {
out.RawByte(',')
}
first = false
out.RawString("\"windowId\":")
out.Int64(int64(in.WindowID))
if !first {
out.RawByte(',')
}
first = false
out.RawString("\"bounds\":")
if in.Bounds == nil {
out.RawString("null")
} else {
(*in.Bounds).MarshalEasyJSON(out)
}
out.RawByte('}')
}
// MarshalJSON supports json.Marshaler interface
func (v SetWindowBoundsParams) MarshalJSON() ([]byte, error) {
w := jwriter.Writer{}
easyjsonC5a4559bEncodeGithubComKnqChromedpCdpBrowser(&w, v)
return w.Buffer.BuildBytes(), w.Error
}
// MarshalEasyJSON supports easyjson.Marshaler interface
func (v SetWindowBoundsParams) MarshalEasyJSON(w *jwriter.Writer) {
easyjsonC5a4559bEncodeGithubComKnqChromedpCdpBrowser(w, v)
}
// UnmarshalJSON supports json.Unmarshaler interface
func (v *SetWindowBoundsParams) UnmarshalJSON(data []byte) error {
r := jlexer.Lexer{Data: data}
easyjsonC5a4559bDecodeGithubComKnqChromedpCdpBrowser(&r, v)
return r.Error()
}
// UnmarshalEasyJSON supports easyjson.Unmarshaler interface
func (v *SetWindowBoundsParams) UnmarshalEasyJSON(l *jlexer.Lexer) {
easyjsonC5a4559bDecodeGithubComKnqChromedpCdpBrowser(l, v)
}
func easyjsonC5a4559bDecodeGithubComKnqChromedpCdpBrowser1(in *jlexer.Lexer, out *GetWindowForTargetReturns) {
isTopLevel := in.IsStart()
if in.IsNull() {
if isTopLevel {
in.Consumed()
}
in.Skip()
return
}
in.Delim('{')
for !in.IsDelim('}') {
key := in.UnsafeString()
in.WantColon()
if in.IsNull() {
in.Skip()
in.WantComma()
continue
}
switch key {
case "windowId":
out.WindowID = WindowID(in.Int64())
case "bounds":
if in.IsNull() {
in.Skip()
out.Bounds = nil
} else {
if out.Bounds == nil {
out.Bounds = new(Bounds)
}
(*out.Bounds).UnmarshalEasyJSON(in)
}
default:
in.SkipRecursive()
}
in.WantComma()
}
in.Delim('}')
if isTopLevel {
in.Consumed()
}
}
func easyjsonC5a4559bEncodeGithubComKnqChromedpCdpBrowser1(out *jwriter.Writer, in GetWindowForTargetReturns) {
out.RawByte('{')
first := true
_ = first
if in.WindowID != 0 {
if !first {
out.RawByte(',')
}
first = false
out.RawString("\"windowId\":")
out.Int64(int64(in.WindowID))
}
if in.Bounds != nil {
if !first {
out.RawByte(',')
}
first = false
out.RawString("\"bounds\":")
if in.Bounds == nil {
out.RawString("null")
} else {
(*in.Bounds).MarshalEasyJSON(out)
}
}
out.RawByte('}')
}
// MarshalJSON supports json.Marshaler interface
func (v GetWindowForTargetReturns) MarshalJSON() ([]byte, error) {
w := jwriter.Writer{}
easyjsonC5a4559bEncodeGithubComKnqChromedpCdpBrowser1(&w, v)
return w.Buffer.BuildBytes(), w.Error
}
// MarshalEasyJSON supports easyjson.Marshaler interface
func (v GetWindowForTargetReturns) MarshalEasyJSON(w *jwriter.Writer) {
easyjsonC5a4559bEncodeGithubComKnqChromedpCdpBrowser1(w, v)
}
// UnmarshalJSON supports json.Unmarshaler interface
func (v *GetWindowForTargetReturns) UnmarshalJSON(data []byte) error {
r := jlexer.Lexer{Data: data}
easyjsonC5a4559bDecodeGithubComKnqChromedpCdpBrowser1(&r, v)
return r.Error()
}
// UnmarshalEasyJSON supports easyjson.Unmarshaler interface
func (v *GetWindowForTargetReturns) UnmarshalEasyJSON(l *jlexer.Lexer) {
easyjsonC5a4559bDecodeGithubComKnqChromedpCdpBrowser1(l, v)
}
func easyjsonC5a4559bDecodeGithubComKnqChromedpCdpBrowser2(in *jlexer.Lexer, out *GetWindowForTargetParams) {
isTopLevel := in.IsStart()
if in.IsNull() {
if isTopLevel {
in.Consumed()
}
in.Skip()
return
}
in.Delim('{')
for !in.IsDelim('}') {
key := in.UnsafeString()
in.WantColon()
if in.IsNull() {
in.Skip()
in.WantComma()
continue
}
switch key {
case "targetId":
out.TargetID = target.ID(in.String())
default:
in.SkipRecursive()
}
in.WantComma()
}
in.Delim('}')
if isTopLevel {
in.Consumed()
}
}
func easyjsonC5a4559bEncodeGithubComKnqChromedpCdpBrowser2(out *jwriter.Writer, in GetWindowForTargetParams) {
out.RawByte('{')
first := true
_ = first
if !first {
out.RawByte(',')
}
first = false
out.RawString("\"targetId\":")
out.String(string(in.TargetID))
out.RawByte('}')
}
// MarshalJSON supports json.Marshaler interface
func (v GetWindowForTargetParams) MarshalJSON() ([]byte, error) {
w := jwriter.Writer{}
easyjsonC5a4559bEncodeGithubComKnqChromedpCdpBrowser2(&w, v)
return w.Buffer.BuildBytes(), w.Error
}
// MarshalEasyJSON supports easyjson.Marshaler interface
func (v GetWindowForTargetParams) MarshalEasyJSON(w *jwriter.Writer) {
easyjsonC5a4559bEncodeGithubComKnqChromedpCdpBrowser2(w, v)
}
// UnmarshalJSON supports json.Unmarshaler interface
func (v *GetWindowForTargetParams) UnmarshalJSON(data []byte) error {
r := jlexer.Lexer{Data: data}
easyjsonC5a4559bDecodeGithubComKnqChromedpCdpBrowser2(&r, v)
return r.Error()
}
// UnmarshalEasyJSON supports easyjson.Unmarshaler interface
func (v *GetWindowForTargetParams) UnmarshalEasyJSON(l *jlexer.Lexer) {
easyjsonC5a4559bDecodeGithubComKnqChromedpCdpBrowser2(l, v)
}
func easyjsonC5a4559bDecodeGithubComKnqChromedpCdpBrowser3(in *jlexer.Lexer, out *GetWindowBoundsReturns) {
isTopLevel := in.IsStart()
if in.IsNull() {
if isTopLevel {
in.Consumed()
}
in.Skip()
return
}
in.Delim('{')
for !in.IsDelim('}') {
key := in.UnsafeString()
in.WantColon()
if in.IsNull() {
in.Skip()
in.WantComma()
continue
}
switch key {
case "bounds":
if in.IsNull() {
in.Skip()
out.Bounds = nil
} else {
if out.Bounds == nil {
out.Bounds = new(Bounds)
}
(*out.Bounds).UnmarshalEasyJSON(in)
}
default:
in.SkipRecursive()
}
in.WantComma()
}
in.Delim('}')
if isTopLevel {
in.Consumed()
}
}
func easyjsonC5a4559bEncodeGithubComKnqChromedpCdpBrowser3(out *jwriter.Writer, in GetWindowBoundsReturns) {
out.RawByte('{')
first := true
_ = first
if in.Bounds != nil {
if !first {
out.RawByte(',')
}
first = false
out.RawString("\"bounds\":")
if in.Bounds == nil {
out.RawString("null")
} else {
(*in.Bounds).MarshalEasyJSON(out)
}
}
out.RawByte('}')
}
// MarshalJSON supports json.Marshaler interface
func (v GetWindowBoundsReturns) MarshalJSON() ([]byte, error) {
w := jwriter.Writer{}
easyjsonC5a4559bEncodeGithubComKnqChromedpCdpBrowser3(&w, v)
return w.Buffer.BuildBytes(), w.Error
}
// MarshalEasyJSON supports easyjson.Marshaler interface
func (v GetWindowBoundsReturns) MarshalEasyJSON(w *jwriter.Writer) {
easyjsonC5a4559bEncodeGithubComKnqChromedpCdpBrowser3(w, v)
}
// UnmarshalJSON supports json.Unmarshaler interface
func (v *GetWindowBoundsReturns) UnmarshalJSON(data []byte) error {
r := jlexer.Lexer{Data: data}
easyjsonC5a4559bDecodeGithubComKnqChromedpCdpBrowser3(&r, v)
return r.Error()
}
// UnmarshalEasyJSON supports easyjson.Unmarshaler interface
func (v *GetWindowBoundsReturns) UnmarshalEasyJSON(l *jlexer.Lexer) {
easyjsonC5a4559bDecodeGithubComKnqChromedpCdpBrowser3(l, v)
}
func easyjsonC5a4559bDecodeGithubComKnqChromedpCdpBrowser4(in *jlexer.Lexer, out *GetWindowBoundsParams) {
isTopLevel := in.IsStart()
if in.IsNull() {
if isTopLevel {
in.Consumed()
}
in.Skip()
return
}
in.Delim('{')
for !in.IsDelim('}') {
key := in.UnsafeString()
in.WantColon()
if in.IsNull() {
in.Skip()
in.WantComma()
continue
}
switch key {
case "windowId":
out.WindowID = WindowID(in.Int64())
default:
in.SkipRecursive()
}
in.WantComma()
}
in.Delim('}')
if isTopLevel {
in.Consumed()
}
}
func easyjsonC5a4559bEncodeGithubComKnqChromedpCdpBrowser4(out *jwriter.Writer, in GetWindowBoundsParams) {
out.RawByte('{')
first := true
_ = first
if !first {
out.RawByte(',')
}
first = false
out.RawString("\"windowId\":")
out.Int64(int64(in.WindowID))
out.RawByte('}')
}
// MarshalJSON supports json.Marshaler interface
func (v GetWindowBoundsParams) MarshalJSON() ([]byte, error) {
w := jwriter.Writer{}
easyjsonC5a4559bEncodeGithubComKnqChromedpCdpBrowser4(&w, v)
return w.Buffer.BuildBytes(), w.Error
}
// MarshalEasyJSON supports easyjson.Marshaler interface
func (v GetWindowBoundsParams) MarshalEasyJSON(w *jwriter.Writer) {
easyjsonC5a4559bEncodeGithubComKnqChromedpCdpBrowser4(w, v)
}
// UnmarshalJSON supports json.Unmarshaler interface
func (v *GetWindowBoundsParams) UnmarshalJSON(data []byte) error {
r := jlexer.Lexer{Data: data}
easyjsonC5a4559bDecodeGithubComKnqChromedpCdpBrowser4(&r, v)
return r.Error()
}
// UnmarshalEasyJSON supports easyjson.Unmarshaler interface
func (v *GetWindowBoundsParams) UnmarshalEasyJSON(l *jlexer.Lexer) {
easyjsonC5a4559bDecodeGithubComKnqChromedpCdpBrowser4(l, v)
}
func easyjsonC5a4559bDecodeGithubComKnqChromedpCdpBrowser5(in *jlexer.Lexer, out *Bounds) {
isTopLevel := in.IsStart()
if in.IsNull() {
if isTopLevel {
in.Consumed()
}
in.Skip()
return
}
in.Delim('{')
for !in.IsDelim('}') {
key := in.UnsafeString()
in.WantColon()
if in.IsNull() {
in.Skip()
in.WantComma()
continue
}
switch key {
case "left":
out.Left = int64(in.Int64())
case "top":
out.Top = int64(in.Int64())
case "width":
out.Width = int64(in.Int64())
case "height":
out.Height = int64(in.Int64())
case "windowState":
(out.WindowState).UnmarshalEasyJSON(in)
default:
in.SkipRecursive()
}
in.WantComma()
}
in.Delim('}')
if isTopLevel {
in.Consumed()
}
}
func easyjsonC5a4559bEncodeGithubComKnqChromedpCdpBrowser5(out *jwriter.Writer, in Bounds) {
out.RawByte('{')
first := true
_ = first
if in.Left != 0 {
if !first {
out.RawByte(',')
}
first = false
out.RawString("\"left\":")
out.Int64(int64(in.Left))
}
if in.Top != 0 {
if !first {
out.RawByte(',')
}
first = false
out.RawString("\"top\":")
out.Int64(int64(in.Top))
}
if in.Width != 0 {
if !first {
out.RawByte(',')
}
first = false
out.RawString("\"width\":")
out.Int64(int64(in.Width))
}
if in.Height != 0 {
if !first {
out.RawByte(',')
}
first = false
out.RawString("\"height\":")
out.Int64(int64(in.Height))
}
if in.WindowState != "" {
if !first {
out.RawByte(',')
}
first = false
out.RawString("\"windowState\":")
(in.WindowState).MarshalEasyJSON(out)
}
out.RawByte('}')
}
// MarshalJSON supports json.Marshaler interface
func (v Bounds) MarshalJSON() ([]byte, error) {
w := jwriter.Writer{}
easyjsonC5a4559bEncodeGithubComKnqChromedpCdpBrowser5(&w, v)
return w.Buffer.BuildBytes(), w.Error
}
// MarshalEasyJSON supports easyjson.Marshaler interface
func (v Bounds) MarshalEasyJSON(w *jwriter.Writer) {
easyjsonC5a4559bEncodeGithubComKnqChromedpCdpBrowser5(w, v)
}
// UnmarshalJSON supports json.Unmarshaler interface
func (v *Bounds) UnmarshalJSON(data []byte) error {
r := jlexer.Lexer{Data: data}
easyjsonC5a4559bDecodeGithubComKnqChromedpCdpBrowser5(&r, v)
return r.Error()
}
// UnmarshalEasyJSON supports easyjson.Unmarshaler interface
func (v *Bounds) UnmarshalEasyJSON(l *jlexer.Lexer) {
easyjsonC5a4559bDecodeGithubComKnqChromedpCdpBrowser5(l, v)
}

76
cdp/browser/types.go Normal file
View File

@ -0,0 +1,76 @@
package browser
import (
"errors"
"github.com/mailru/easyjson"
"github.com/mailru/easyjson/jlexer"
"github.com/mailru/easyjson/jwriter"
)
// AUTOGENERATED. DO NOT EDIT.
// WindowID [no description].
type WindowID int64
// Int64 returns the WindowID as int64 value.
func (t WindowID) Int64() int64 {
return int64(t)
}
// WindowState the state of the browser window.
type WindowState string
// String returns the WindowState as string value.
func (t WindowState) String() string {
return string(t)
}
// WindowState values.
const (
WindowStateNormal WindowState = "normal"
WindowStateMinimized WindowState = "minimized"
WindowStateMaximized WindowState = "maximized"
WindowStateFullscreen WindowState = "fullscreen"
)
// MarshalEasyJSON satisfies easyjson.Marshaler.
func (t WindowState) MarshalEasyJSON(out *jwriter.Writer) {
out.String(string(t))
}
// MarshalJSON satisfies json.Marshaler.
func (t WindowState) MarshalJSON() ([]byte, error) {
return easyjson.Marshal(t)
}
// UnmarshalEasyJSON satisfies easyjson.Unmarshaler.
func (t *WindowState) UnmarshalEasyJSON(in *jlexer.Lexer) {
switch WindowState(in.String()) {
case WindowStateNormal:
*t = WindowStateNormal
case WindowStateMinimized:
*t = WindowStateMinimized
case WindowStateMaximized:
*t = WindowStateMaximized
case WindowStateFullscreen:
*t = WindowStateFullscreen
default:
in.AddError(errors.New("unknown WindowState value"))
}
}
// UnmarshalJSON satisfies json.Unmarshaler.
func (t *WindowState) UnmarshalJSON(buf []byte) error {
return easyjson.Unmarshal(buf, t)
}
// Bounds browser window bounds information.
type Bounds struct {
Left int64 `json:"left,omitempty"` // The offset from the left edge of the screen to the window in pixels.
Top int64 `json:"top,omitempty"` // The offset from the top edge of the screen to the window in pixels.
Width int64 `json:"width,omitempty"` // The window width in pixels.
Height int64 `json:"height,omitempty"` // The window height in pixels.
WindowState WindowState `json:"windowState,omitempty"` // The window state. Default to normal.
}

View File

@ -152,7 +152,6 @@ const (
CommandNetworkGetResponseBody MethodType = "Network.getResponseBody" CommandNetworkGetResponseBody MethodType = "Network.getResponseBody"
CommandNetworkSetBlockedURLS MethodType = "Network.setBlockedURLs" CommandNetworkSetBlockedURLS MethodType = "Network.setBlockedURLs"
CommandNetworkReplayXHR MethodType = "Network.replayXHR" CommandNetworkReplayXHR MethodType = "Network.replayXHR"
CommandNetworkSetMonitoringXHREnabled MethodType = "Network.setMonitoringXHREnabled"
CommandNetworkCanClearBrowserCache MethodType = "Network.canClearBrowserCache" CommandNetworkCanClearBrowserCache MethodType = "Network.canClearBrowserCache"
CommandNetworkClearBrowserCache MethodType = "Network.clearBrowserCache" CommandNetworkClearBrowserCache MethodType = "Network.clearBrowserCache"
CommandNetworkCanClearBrowserCookies MethodType = "Network.canClearBrowserCookies" CommandNetworkCanClearBrowserCookies MethodType = "Network.canClearBrowserCookies"
@ -382,6 +381,9 @@ const (
EventTetheringAccepted MethodType = "Tethering.accepted" EventTetheringAccepted MethodType = "Tethering.accepted"
CommandTetheringBind MethodType = "Tethering.bind" CommandTetheringBind MethodType = "Tethering.bind"
CommandTetheringUnbind MethodType = "Tethering.unbind" CommandTetheringUnbind MethodType = "Tethering.unbind"
CommandBrowserGetWindowForTarget MethodType = "Browser.getWindowForTarget"
CommandBrowserSetWindowBounds MethodType = "Browser.setWindowBounds"
CommandBrowserGetWindowBounds MethodType = "Browser.getWindowBounds"
CommandSchemaGetDomains MethodType = "Schema.getDomains" CommandSchemaGetDomains MethodType = "Schema.getDomains"
EventRuntimeExecutionContextCreated MethodType = "Runtime.executionContextCreated" EventRuntimeExecutionContextCreated MethodType = "Runtime.executionContextCreated"
EventRuntimeExecutionContextDestroyed MethodType = "Runtime.executionContextDestroyed" EventRuntimeExecutionContextDestroyed MethodType = "Runtime.executionContextDestroyed"
@ -681,8 +683,6 @@ func (t *MethodType) UnmarshalEasyJSON(in *jlexer.Lexer) {
*t = CommandNetworkSetBlockedURLS *t = CommandNetworkSetBlockedURLS
case CommandNetworkReplayXHR: case CommandNetworkReplayXHR:
*t = CommandNetworkReplayXHR *t = CommandNetworkReplayXHR
case CommandNetworkSetMonitoringXHREnabled:
*t = CommandNetworkSetMonitoringXHREnabled
case CommandNetworkCanClearBrowserCache: case CommandNetworkCanClearBrowserCache:
*t = CommandNetworkCanClearBrowserCache *t = CommandNetworkCanClearBrowserCache
case CommandNetworkClearBrowserCache: case CommandNetworkClearBrowserCache:
@ -1141,6 +1141,12 @@ func (t *MethodType) UnmarshalEasyJSON(in *jlexer.Lexer) {
*t = CommandTetheringBind *t = CommandTetheringBind
case CommandTetheringUnbind: case CommandTetheringUnbind:
*t = CommandTetheringUnbind *t = CommandTetheringUnbind
case CommandBrowserGetWindowForTarget:
*t = CommandBrowserGetWindowForTarget
case CommandBrowserSetWindowBounds:
*t = CommandBrowserSetWindowBounds
case CommandBrowserGetWindowBounds:
*t = CommandBrowserGetWindowBounds
case CommandSchemaGetDomains: case CommandSchemaGetDomains:
*t = CommandSchemaGetDomains *t = CommandSchemaGetDomains
case EventRuntimeExecutionContextCreated: case EventRuntimeExecutionContextCreated:

View File

@ -9,6 +9,7 @@ import (
"github.com/knq/chromedp/cdp/accessibility" "github.com/knq/chromedp/cdp/accessibility"
"github.com/knq/chromedp/cdp/animation" "github.com/knq/chromedp/cdp/animation"
"github.com/knq/chromedp/cdp/applicationcache" "github.com/knq/chromedp/cdp/applicationcache"
"github.com/knq/chromedp/cdp/browser"
"github.com/knq/chromedp/cdp/cachestorage" "github.com/knq/chromedp/cdp/cachestorage"
"github.com/knq/chromedp/cdp/css" "github.com/knq/chromedp/cdp/css"
"github.com/knq/chromedp/cdp/database" "github.com/knq/chromedp/cdp/database"
@ -310,9 +311,6 @@ func UnmarshalMessage(msg *cdp.Message) (interface{}, error) {
case cdp.CommandNetworkReplayXHR: case cdp.CommandNetworkReplayXHR:
return emptyVal, nil return emptyVal, nil
case cdp.CommandNetworkSetMonitoringXHREnabled:
return emptyVal, nil
case cdp.CommandNetworkCanClearBrowserCache: case cdp.CommandNetworkCanClearBrowserCache:
v = new(network.CanClearBrowserCacheReturns) v = new(network.CanClearBrowserCacheReturns)
@ -1045,6 +1043,15 @@ func UnmarshalMessage(msg *cdp.Message) (interface{}, error) {
case cdp.EventTetheringAccepted: case cdp.EventTetheringAccepted:
v = new(tethering.EventAccepted) v = new(tethering.EventAccepted)
case cdp.CommandBrowserGetWindowForTarget:
v = new(browser.GetWindowForTargetReturns)
case cdp.CommandBrowserSetWindowBounds:
return emptyVal, nil
case cdp.CommandBrowserGetWindowBounds:
v = new(browser.GetWindowBoundsReturns)
case cdp.CommandSchemaGetDomains: case cdp.CommandSchemaGetDomains:
v = new(schema.GetDomainsReturns) v = new(schema.GetDomainsReturns)

File diff suppressed because it is too large Load Diff

View File

@ -208,29 +208,6 @@ func (p *ReplayXHRParams) Do(ctxt context.Context, h cdp.Handler) (err error) {
return h.Execute(ctxt, cdp.CommandNetworkReplayXHR, p, nil) return h.Execute(ctxt, cdp.CommandNetworkReplayXHR, p, nil)
} }
// SetMonitoringXHREnabledParams toggles monitoring of XMLHttpRequest. If
// true, console will receive messages upon each XHR issued.
type SetMonitoringXHREnabledParams struct {
Enabled bool `json:"enabled"` // Monitoring enabled state.
}
// SetMonitoringXHREnabled toggles monitoring of XMLHttpRequest. If true,
// console will receive messages upon each XHR issued.
//
// parameters:
// enabled - Monitoring enabled state.
func SetMonitoringXHREnabled(enabled bool) *SetMonitoringXHREnabledParams {
return &SetMonitoringXHREnabledParams{
Enabled: enabled,
}
}
// Do executes Network.setMonitoringXHREnabled against the provided context and
// target handler.
func (p *SetMonitoringXHREnabledParams) Do(ctxt context.Context, h cdp.Handler) (err error) {
return h.Execute(ctxt, cdp.CommandNetworkSetMonitoringXHREnabled, p, nil)
}
// CanClearBrowserCacheParams tells whether clearing browser cache is // CanClearBrowserCacheParams tells whether clearing browser cache is
// supported. // supported.
type CanClearBrowserCacheParams struct{} type CanClearBrowserCacheParams struct{}

View File

@ -357,7 +357,7 @@ func easyjsonC5a4559bDecodeGithubComKnqChromedpCdpTarget4(in *jlexer.Lexer, out
} }
switch key { switch key {
case "targetId": case "targetId":
out.TargetID = string(in.String()) out.TargetID = ID(in.String())
case "message": case "message":
out.Message = string(in.String()) out.Message = string(in.String())
default: default:

View File

@ -114,7 +114,7 @@ func (p *SetRemoteLocationsParams) Do(ctxt context.Context, h cdp.Handler) (err
// SendMessageToTargetParams sends protocol message to the target with given // SendMessageToTargetParams sends protocol message to the target with given
// id. // id.
type SendMessageToTargetParams struct { type SendMessageToTargetParams struct {
TargetID string `json:"targetId"` TargetID ID `json:"targetId"`
Message string `json:"message"` Message string `json:"message"`
} }
@ -123,7 +123,7 @@ type SendMessageToTargetParams struct {
// parameters: // parameters:
// targetID // targetID
// message // message
func SendMessageToTarget(targetID string, message string) *SendMessageToTargetParams { func SendMessageToTarget(targetID ID, message string) *SendMessageToTargetParams {
return &SendMessageToTargetParams{ return &SendMessageToTargetParams{
TargetID: targetID, TargetID: targetID,
Message: message, Message: message,

View File

@ -12,6 +12,7 @@ type DomainType string
Accessibility Accessibility
Animation Animation
ApplicationCache ApplicationCache
Browser
CacheStorage CacheStorage
Console Console
CSS CSS
@ -51,6 +52,7 @@ const (
DomainAccessibility DomainType = "Accessibility" DomainAccessibility DomainType = "Accessibility"
DomainAnimation DomainType = "Animation" DomainAnimation DomainType = "Animation"
DomainApplicationCache DomainType = "ApplicationCache" DomainApplicationCache DomainType = "ApplicationCache"
DomainBrowser DomainType = "Browser"
DomainCacheStorage DomainType = "CacheStorage" DomainCacheStorage DomainType = "CacheStorage"
DomainConsole DomainType = "Console" DomainConsole DomainType = "Console"
DomainCSS DomainType = "CSS" DomainCSS DomainType = "CSS"
@ -111,6 +113,8 @@ func (dt *DomainType) UnmarshalJSON(buf []byte) error {
*dt = DomainAnimation *dt = DomainAnimation
case DomainApplicationCache: case DomainApplicationCache:
*dt = DomainApplicationCache *dt = DomainApplicationCache
case DomainBrowser:
*dt = DomainBrowser
case DomainCacheStorage: case DomainCacheStorage:
*dt = DomainCacheStorage *dt = DomainCacheStorage
case DomainConsole: case DomainConsole:

View File

@ -2709,18 +2709,6 @@
], ],
"experimental": true "experimental": true
}, },
{
"name": "setMonitoringXHREnabled",
"parameters": [
{
"name": "enabled",
"type": "boolean",
"description": "Monitoring enabled state."
}
],
"description": "Toggles monitoring of XMLHttpRequest. If <code>true</code>, console will receive messages upon each XHR issued.",
"experimental": true
},
{ {
"name": "canClearBrowserCache", "name": "canClearBrowserCache",
"description": "Tells whether clearing browser cache is supported.", "description": "Tells whether clearing browser cache is supported.",
@ -7573,7 +7561,7 @@
"parameters": [ "parameters": [
{ {
"name": "targetId", "name": "targetId",
"type": "string" "$ref": "TargetID"
}, },
{ {
"name": "message", "name": "message",
@ -10229,6 +10217,124 @@
} }
] ]
}, },
{
"domain": "Browser",
"description": "The Browser domain defines methods and events for browser managing.",
"experimental": true,
"types": [
{
"id": "WindowID",
"type": "integer"
},
{
"id": "WindowState",
"type": "string",
"enum": [
"normal",
"minimized",
"maximized",
"fullscreen"
],
"description": "The state of the browser window."
},
{
"id": "Bounds",
"type": "object",
"description": "Browser window bounds information",
"properties": [
{
"name": "left",
"type": "integer",
"optional": true,
"description": "The offset from the left edge of the screen to the window in pixels."
},
{
"name": "top",
"type": "integer",
"optional": true,
"description": "The offset from the top edge of the screen to the window in pixels."
},
{
"name": "width",
"type": "integer",
"optional": true,
"description": "The window width in pixels."
},
{
"name": "height",
"type": "integer",
"optional": true,
"description": "The window height in pixels."
},
{
"name": "windowState",
"$ref": "WindowState",
"optional": true,
"description": "The window state. Default to normal."
}
]
}
],
"commands": [
{
"name": "getWindowForTarget",
"description": "Get the browser window that contains the devtools target.",
"parameters": [
{
"name": "targetId",
"$ref": "Target.TargetID",
"description": "Devtools agent host id."
}
],
"returns": [
{
"name": "windowId",
"$ref": "WindowID",
"description": "Browser window id."
},
{
"name": "bounds",
"$ref": "Bounds",
"description": "Bounds information of the window. When window state is 'minimized', the restored window position and size are returned."
}
]
},
{
"name": "setWindowBounds",
"description": "Set position and/or size of the browser window.",
"parameters": [
{
"name": "windowId",
"$ref": "WindowID",
"description": "Browser window id."
},
{
"name": "bounds",
"$ref": "Bounds",
"description": "New window bounds. The 'minimized', 'maximized' and 'fullscreen' states cannot be combined with 'left', 'top', 'width' or 'height'. Leaves unspecified fields unchanged."
}
]
},
{
"name": "getWindowBounds",
"description": "Get position and size of the browser window.",
"parameters": [
{
"name": "windowId",
"$ref": "WindowID",
"description": "Browser window id."
}
],
"returns": [
{
"name": "bounds",
"$ref": "Bounds",
"description": "Bounds information of the window. When window state is 'minimized', the restored window position and size are returned."
}
]
}
]
},
{ {
"domain": "Schema", "domain": "Schema",
"description": "Provides information about the protocol schema.", "description": "Provides information about the protocol schema.",