Updating to latest protocol.json

This commit is contained in:
Kenneth Shaw 2017-10-15 12:47:06 +07:00
parent e46fa029e1
commit 49117a03d8
23 changed files with 1675 additions and 365 deletions

View File

@ -15,6 +15,20 @@ import (
"github.com/knq/chromedp/cdp/target" "github.com/knq/chromedp/cdp/target"
) )
// CloseParams close browser gracefully.
type CloseParams struct{}
// Close close browser gracefully.
func Close() *CloseParams {
return &CloseParams{}
}
// Do executes Browser.close against the provided context and
// target handler.
func (p *CloseParams) Do(ctxt context.Context, h cdp.Handler) (err error) {
return h.Execute(ctxt, cdp.CommandBrowserClose, nil, nil)
}
// GetWindowForTargetParams get the browser window that contains the devtools // GetWindowForTargetParams get the browser window that contains the devtools
// target. // target.
type GetWindowForTargetParams struct { type GetWindowForTargetParams struct {

View File

@ -579,7 +579,66 @@ func (v *GetVersionParams) UnmarshalJSON(data []byte) error {
func (v *GetVersionParams) UnmarshalEasyJSON(l *jlexer.Lexer) { func (v *GetVersionParams) UnmarshalEasyJSON(l *jlexer.Lexer) {
easyjsonC5a4559bDecodeGithubComKnqChromedpCdpBrowser6(l, v) easyjsonC5a4559bDecodeGithubComKnqChromedpCdpBrowser6(l, v)
} }
func easyjsonC5a4559bDecodeGithubComKnqChromedpCdpBrowser7(in *jlexer.Lexer, out *Bounds) { func easyjsonC5a4559bDecodeGithubComKnqChromedpCdpBrowser7(in *jlexer.Lexer, out *CloseParams) {
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 {
default:
in.SkipRecursive()
}
in.WantComma()
}
in.Delim('}')
if isTopLevel {
in.Consumed()
}
}
func easyjsonC5a4559bEncodeGithubComKnqChromedpCdpBrowser7(out *jwriter.Writer, in CloseParams) {
out.RawByte('{')
first := true
_ = first
out.RawByte('}')
}
// MarshalJSON supports json.Marshaler interface
func (v CloseParams) MarshalJSON() ([]byte, error) {
w := jwriter.Writer{}
easyjsonC5a4559bEncodeGithubComKnqChromedpCdpBrowser7(&w, v)
return w.Buffer.BuildBytes(), w.Error
}
// MarshalEasyJSON supports easyjson.Marshaler interface
func (v CloseParams) MarshalEasyJSON(w *jwriter.Writer) {
easyjsonC5a4559bEncodeGithubComKnqChromedpCdpBrowser7(w, v)
}
// UnmarshalJSON supports json.Unmarshaler interface
func (v *CloseParams) UnmarshalJSON(data []byte) error {
r := jlexer.Lexer{Data: data}
easyjsonC5a4559bDecodeGithubComKnqChromedpCdpBrowser7(&r, v)
return r.Error()
}
// UnmarshalEasyJSON supports easyjson.Unmarshaler interface
func (v *CloseParams) UnmarshalEasyJSON(l *jlexer.Lexer) {
easyjsonC5a4559bDecodeGithubComKnqChromedpCdpBrowser7(l, v)
}
func easyjsonC5a4559bDecodeGithubComKnqChromedpCdpBrowser8(in *jlexer.Lexer, out *Bounds) {
isTopLevel := in.IsStart() isTopLevel := in.IsStart()
if in.IsNull() { if in.IsNull() {
if isTopLevel { if isTopLevel {
@ -618,7 +677,7 @@ func easyjsonC5a4559bDecodeGithubComKnqChromedpCdpBrowser7(in *jlexer.Lexer, out
in.Consumed() in.Consumed()
} }
} }
func easyjsonC5a4559bEncodeGithubComKnqChromedpCdpBrowser7(out *jwriter.Writer, in Bounds) { func easyjsonC5a4559bEncodeGithubComKnqChromedpCdpBrowser8(out *jwriter.Writer, in Bounds) {
out.RawByte('{') out.RawByte('{')
first := true first := true
_ = first _ = first
@ -668,23 +727,23 @@ func easyjsonC5a4559bEncodeGithubComKnqChromedpCdpBrowser7(out *jwriter.Writer,
// MarshalJSON supports json.Marshaler interface // MarshalJSON supports json.Marshaler interface
func (v Bounds) MarshalJSON() ([]byte, error) { func (v Bounds) MarshalJSON() ([]byte, error) {
w := jwriter.Writer{} w := jwriter.Writer{}
easyjsonC5a4559bEncodeGithubComKnqChromedpCdpBrowser7(&w, v) easyjsonC5a4559bEncodeGithubComKnqChromedpCdpBrowser8(&w, v)
return w.Buffer.BuildBytes(), w.Error return w.Buffer.BuildBytes(), w.Error
} }
// MarshalEasyJSON supports easyjson.Marshaler interface // MarshalEasyJSON supports easyjson.Marshaler interface
func (v Bounds) MarshalEasyJSON(w *jwriter.Writer) { func (v Bounds) MarshalEasyJSON(w *jwriter.Writer) {
easyjsonC5a4559bEncodeGithubComKnqChromedpCdpBrowser7(w, v) easyjsonC5a4559bEncodeGithubComKnqChromedpCdpBrowser8(w, v)
} }
// UnmarshalJSON supports json.Unmarshaler interface // UnmarshalJSON supports json.Unmarshaler interface
func (v *Bounds) UnmarshalJSON(data []byte) error { func (v *Bounds) UnmarshalJSON(data []byte) error {
r := jlexer.Lexer{Data: data} r := jlexer.Lexer{Data: data}
easyjsonC5a4559bDecodeGithubComKnqChromedpCdpBrowser7(&r, v) easyjsonC5a4559bDecodeGithubComKnqChromedpCdpBrowser8(&r, v)
return r.Error() return r.Error()
} }
// UnmarshalEasyJSON supports easyjson.Unmarshaler interface // UnmarshalEasyJSON supports easyjson.Unmarshaler interface
func (v *Bounds) UnmarshalEasyJSON(l *jlexer.Lexer) { func (v *Bounds) UnmarshalEasyJSON(l *jlexer.Lexer) {
easyjsonC5a4559bDecodeGithubComKnqChromedpCdpBrowser7(l, v) easyjsonC5a4559bDecodeGithubComKnqChromedpCdpBrowser8(l, v)
} }

View File

@ -78,6 +78,7 @@ const (
EventPageScreencastVisibilityChanged MethodType = "Page.screencastVisibilityChanged" EventPageScreencastVisibilityChanged MethodType = "Page.screencastVisibilityChanged"
EventPageInterstitialShown MethodType = "Page.interstitialShown" EventPageInterstitialShown MethodType = "Page.interstitialShown"
EventPageInterstitialHidden MethodType = "Page.interstitialHidden" EventPageInterstitialHidden MethodType = "Page.interstitialHidden"
EventPageWindowOpen MethodType = "Page.windowOpen"
CommandPageEnable MethodType = "Page.enable" CommandPageEnable MethodType = "Page.enable"
CommandPageDisable MethodType = "Page.disable" CommandPageDisable MethodType = "Page.disable"
CommandPageAddScriptToEvaluateOnNewDocument MethodType = "Page.addScriptToEvaluateOnNewDocument" CommandPageAddScriptToEvaluateOnNewDocument MethodType = "Page.addScriptToEvaluateOnNewDocument"
@ -332,6 +333,11 @@ const (
CommandTargetDisposeBrowserContext MethodType = "Target.disposeBrowserContext" CommandTargetDisposeBrowserContext MethodType = "Target.disposeBrowserContext"
CommandTargetCreateTarget MethodType = "Target.createTarget" CommandTargetCreateTarget MethodType = "Target.createTarget"
CommandTargetGetTargets MethodType = "Target.getTargets" CommandTargetGetTargets MethodType = "Target.getTargets"
EventHeadlessExperimentalNeedsBeginFramesChanged MethodType = "HeadlessExperimental.needsBeginFramesChanged"
EventHeadlessExperimentalMainFrameReadyForScreenshots MethodType = "HeadlessExperimental.mainFrameReadyForScreenshots"
CommandHeadlessExperimentalEnable MethodType = "HeadlessExperimental.enable"
CommandHeadlessExperimentalDisable MethodType = "HeadlessExperimental.disable"
CommandHeadlessExperimentalBeginFrame MethodType = "HeadlessExperimental.beginFrame"
EventServiceWorkerWorkerRegistrationUpdated MethodType = "ServiceWorker.workerRegistrationUpdated" EventServiceWorkerWorkerRegistrationUpdated MethodType = "ServiceWorker.workerRegistrationUpdated"
EventServiceWorkerWorkerVersionUpdated MethodType = "ServiceWorker.workerVersionUpdated" EventServiceWorkerWorkerVersionUpdated MethodType = "ServiceWorker.workerVersionUpdated"
EventServiceWorkerWorkerErrorReported MethodType = "ServiceWorker.workerErrorReported" EventServiceWorkerWorkerErrorReported MethodType = "ServiceWorker.workerErrorReported"
@ -410,6 +416,7 @@ 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"
CommandBrowserClose MethodType = "Browser.close"
CommandBrowserGetWindowForTarget MethodType = "Browser.getWindowForTarget" CommandBrowserGetWindowForTarget MethodType = "Browser.getWindowForTarget"
CommandBrowserGetVersion MethodType = "Browser.getVersion" CommandBrowserGetVersion MethodType = "Browser.getVersion"
CommandBrowserSetWindowBounds MethodType = "Browser.setWindowBounds" CommandBrowserSetWindowBounds MethodType = "Browser.setWindowBounds"
@ -569,6 +576,8 @@ func (t *MethodType) UnmarshalEasyJSON(in *jlexer.Lexer) {
*t = EventPageInterstitialShown *t = EventPageInterstitialShown
case EventPageInterstitialHidden: case EventPageInterstitialHidden:
*t = EventPageInterstitialHidden *t = EventPageInterstitialHidden
case EventPageWindowOpen:
*t = EventPageWindowOpen
case CommandPageEnable: case CommandPageEnable:
*t = CommandPageEnable *t = CommandPageEnable
case CommandPageDisable: case CommandPageDisable:
@ -1077,6 +1086,16 @@ func (t *MethodType) UnmarshalEasyJSON(in *jlexer.Lexer) {
*t = CommandTargetCreateTarget *t = CommandTargetCreateTarget
case CommandTargetGetTargets: case CommandTargetGetTargets:
*t = CommandTargetGetTargets *t = CommandTargetGetTargets
case EventHeadlessExperimentalNeedsBeginFramesChanged:
*t = EventHeadlessExperimentalNeedsBeginFramesChanged
case EventHeadlessExperimentalMainFrameReadyForScreenshots:
*t = EventHeadlessExperimentalMainFrameReadyForScreenshots
case CommandHeadlessExperimentalEnable:
*t = CommandHeadlessExperimentalEnable
case CommandHeadlessExperimentalDisable:
*t = CommandHeadlessExperimentalDisable
case CommandHeadlessExperimentalBeginFrame:
*t = CommandHeadlessExperimentalBeginFrame
case EventServiceWorkerWorkerRegistrationUpdated: case EventServiceWorkerWorkerRegistrationUpdated:
*t = EventServiceWorkerWorkerRegistrationUpdated *t = EventServiceWorkerWorkerRegistrationUpdated
case EventServiceWorkerWorkerVersionUpdated: case EventServiceWorkerWorkerVersionUpdated:
@ -1233,6 +1252,8 @@ func (t *MethodType) UnmarshalEasyJSON(in *jlexer.Lexer) {
*t = CommandTetheringBind *t = CommandTetheringBind
case CommandTetheringUnbind: case CommandTetheringUnbind:
*t = CommandTetheringUnbind *t = CommandTetheringUnbind
case CommandBrowserClose:
*t = CommandBrowserClose
case CommandBrowserGetWindowForTarget: case CommandBrowserGetWindowForTarget:
*t = CommandBrowserGetWindowForTarget *t = CommandBrowserGetWindowForTarget
case CommandBrowserGetVersion: case CommandBrowserGetVersion:

View File

@ -20,6 +20,7 @@ import (
"github.com/knq/chromedp/cdp/domsnapshot" "github.com/knq/chromedp/cdp/domsnapshot"
"github.com/knq/chromedp/cdp/domstorage" "github.com/knq/chromedp/cdp/domstorage"
"github.com/knq/chromedp/cdp/emulation" "github.com/knq/chromedp/cdp/emulation"
"github.com/knq/chromedp/cdp/headlessexperimental"
"github.com/knq/chromedp/cdp/heapprofiler" "github.com/knq/chromedp/cdp/heapprofiler"
"github.com/knq/chromedp/cdp/indexeddb" "github.com/knq/chromedp/cdp/indexeddb"
"github.com/knq/chromedp/cdp/inspector" "github.com/knq/chromedp/cdp/inspector"
@ -220,6 +221,9 @@ func UnmarshalMessage(msg *cdp.Message) (interface{}, error) {
case cdp.EventPageInterstitialHidden: case cdp.EventPageInterstitialHidden:
v = new(page.EventInterstitialHidden) v = new(page.EventInterstitialHidden)
case cdp.EventPageWindowOpen:
v = new(page.EventWindowOpen)
case cdp.CommandOverlayEnable: case cdp.CommandOverlayEnable:
return emptyVal, nil return emptyVal, nil
@ -901,6 +905,21 @@ func UnmarshalMessage(msg *cdp.Message) (interface{}, error) {
case cdp.EventTargetReceivedMessageFromTarget: case cdp.EventTargetReceivedMessageFromTarget:
v = new(target.EventReceivedMessageFromTarget) v = new(target.EventReceivedMessageFromTarget)
case cdp.CommandHeadlessExperimentalEnable:
return emptyVal, nil
case cdp.CommandHeadlessExperimentalDisable:
return emptyVal, nil
case cdp.CommandHeadlessExperimentalBeginFrame:
v = new(headlessexperimental.BeginFrameReturns)
case cdp.EventHeadlessExperimentalNeedsBeginFramesChanged:
v = new(headlessexperimental.EventNeedsBeginFramesChanged)
case cdp.EventHeadlessExperimentalMainFrameReadyForScreenshots:
v = new(headlessexperimental.EventMainFrameReadyForScreenshots)
case cdp.CommandServiceWorkerEnable: case cdp.CommandServiceWorkerEnable:
return emptyVal, nil return emptyVal, nil
@ -1135,6 +1154,9 @@ func UnmarshalMessage(msg *cdp.Message) (interface{}, error) {
case cdp.EventTetheringAccepted: case cdp.EventTetheringAccepted:
v = new(tethering.EventAccepted) v = new(tethering.EventAccepted)
case cdp.CommandBrowserClose:
return emptyVal, nil
case cdp.CommandBrowserGetWindowForTarget: case cdp.CommandBrowserGetWindowForTarget:
v = new(browser.GetWindowForTargetReturns) v = new(browser.GetWindowForTargetReturns)

View File

@ -103,6 +103,7 @@ type SetBreakpointByURLParams struct {
LineNumber int64 `json:"lineNumber"` // Line number to set breakpoint at. LineNumber int64 `json:"lineNumber"` // Line number to set breakpoint at.
URL string `json:"url,omitempty"` // URL of the resources to set breakpoint on. URL string `json:"url,omitempty"` // URL of the resources to set breakpoint on.
URLRegex string `json:"urlRegex,omitempty"` // Regex pattern for the URLs of the resources to set breakpoints on. Either url or urlRegex must be specified. URLRegex string `json:"urlRegex,omitempty"` // Regex pattern for the URLs of the resources to set breakpoints on. Either url or urlRegex must be specified.
ScriptHash string `json:"scriptHash,omitempty"` // Script hash of the resources to set breakpoint on.
ColumnNumber int64 `json:"columnNumber,omitempty"` // Offset in the line to set breakpoint at. ColumnNumber int64 `json:"columnNumber,omitempty"` // Offset in the line to set breakpoint at.
Condition string `json:"condition,omitempty"` // Expression to use as a breakpoint condition. When specified, debugger will only stop on the breakpoint if this expression evaluates to true. Condition string `json:"condition,omitempty"` // Expression to use as a breakpoint condition. When specified, debugger will only stop on the breakpoint if this expression evaluates to true.
} }
@ -134,6 +135,12 @@ func (p SetBreakpointByURLParams) WithURLRegex(urlRegex string) *SetBreakpointBy
return &p return &p
} }
// WithScriptHash script hash of the resources to set breakpoint on.
func (p SetBreakpointByURLParams) WithScriptHash(scriptHash string) *SetBreakpointByURLParams {
p.ScriptHash = scriptHash
return &p
}
// WithColumnNumber offset in the line to set breakpoint at. // WithColumnNumber offset in the line to set breakpoint at.
func (p SetBreakpointByURLParams) WithColumnNumber(columnNumber int64) *SetBreakpointByURLParams { func (p SetBreakpointByURLParams) WithColumnNumber(columnNumber int64) *SetBreakpointByURLParams {
p.ColumnNumber = columnNumber p.ColumnNumber = columnNumber

View File

@ -1079,6 +1079,8 @@ func easyjsonC5a4559bDecodeGithubComKnqChromedpCdpDebugger12(in *jlexer.Lexer, o
out.URL = string(in.String()) out.URL = string(in.String())
case "urlRegex": case "urlRegex":
out.URLRegex = string(in.String()) out.URLRegex = string(in.String())
case "scriptHash":
out.ScriptHash = string(in.String())
case "columnNumber": case "columnNumber":
out.ColumnNumber = int64(in.Int64()) out.ColumnNumber = int64(in.Int64())
case "condition": case "condition":
@ -1119,6 +1121,14 @@ func easyjsonC5a4559bEncodeGithubComKnqChromedpCdpDebugger12(out *jwriter.Writer
out.RawString("\"urlRegex\":") out.RawString("\"urlRegex\":")
out.String(string(in.URLRegex)) out.String(string(in.URLRegex))
} }
if in.ScriptHash != "" {
if !first {
out.RawByte(',')
}
first = false
out.RawString("\"scriptHash\":")
out.String(string(in.ScriptHash))
}
if in.ColumnNumber != 0 { if in.ColumnNumber != 0 {
if !first { if !first {
out.RawByte(',') out.RawByte(',')

View File

@ -5,6 +5,7 @@ package emulation
import ( import (
json "encoding/json" json "encoding/json"
cdp "github.com/knq/chromedp/cdp" cdp "github.com/knq/chromedp/cdp"
page "github.com/knq/chromedp/cdp/page"
easyjson "github.com/mailru/easyjson" easyjson "github.com/mailru/easyjson"
jlexer "github.com/mailru/easyjson/jlexer" jlexer "github.com/mailru/easyjson/jlexer"
jwriter "github.com/mailru/easyjson/jwriter" jwriter "github.com/mailru/easyjson/jwriter"
@ -655,6 +656,16 @@ func easyjsonC5a4559bDecodeGithubComKnqChromedpCdpEmulation8(in *jlexer.Lexer, o
} }
(*out.ScreenOrientation).UnmarshalEasyJSON(in) (*out.ScreenOrientation).UnmarshalEasyJSON(in)
} }
case "viewport":
if in.IsNull() {
in.Skip()
out.Viewport = nil
} else {
if out.Viewport == nil {
out.Viewport = new(page.Viewport)
}
(*out.Viewport).UnmarshalEasyJSON(in)
}
default: default:
in.SkipRecursive() in.SkipRecursive()
} }
@ -753,6 +764,18 @@ func easyjsonC5a4559bEncodeGithubComKnqChromedpCdpEmulation8(out *jwriter.Writer
(*in.ScreenOrientation).MarshalEasyJSON(out) (*in.ScreenOrientation).MarshalEasyJSON(out)
} }
} }
if in.Viewport != nil {
if !first {
out.RawByte(',')
}
first = false
out.RawString("\"viewport\":")
if in.Viewport == nil {
out.RawString("null")
} else {
(*in.Viewport).MarshalEasyJSON(out)
}
}
out.RawByte('}') out.RawByte('}')
} }

View File

@ -12,6 +12,7 @@ import (
"context" "context"
cdp "github.com/knq/chromedp/cdp" cdp "github.com/knq/chromedp/cdp"
"github.com/knq/chromedp/cdp/page"
) )
// SetDeviceMetricsOverrideParams overrides the values of device screen // SetDeviceMetricsOverrideParams overrides the values of device screen
@ -30,6 +31,7 @@ type SetDeviceMetricsOverrideParams struct {
PositionY int64 `json:"positionY,omitempty"` // Overriding view Y position on screen in pixels (minimum 0, maximum 10000000). PositionY int64 `json:"positionY,omitempty"` // Overriding view Y position on screen in pixels (minimum 0, maximum 10000000).
DontSetVisibleSize bool `json:"dontSetVisibleSize,omitempty"` // Do not set visible view size, rely upon explicit setVisibleSize call. DontSetVisibleSize bool `json:"dontSetVisibleSize,omitempty"` // Do not set visible view size, rely upon explicit setVisibleSize call.
ScreenOrientation *ScreenOrientation `json:"screenOrientation,omitempty"` // Screen orientation override. ScreenOrientation *ScreenOrientation `json:"screenOrientation,omitempty"` // Screen orientation override.
Viewport *page.Viewport `json:"viewport,omitempty"` // If set, the visible area of the page will be overridden to this viewport. This viewport change is not observed by the page, e.g. viewport-relative elements do not change positions.
} }
// SetDeviceMetricsOverride overrides the values of device screen dimensions // SetDeviceMetricsOverride overrides the values of device screen dimensions
@ -98,6 +100,14 @@ func (p SetDeviceMetricsOverrideParams) WithScreenOrientation(screenOrientation
return &p return &p
} }
// WithViewport if set, the visible area of the page will be overridden to
// this viewport. This viewport change is not observed by the page, e.g.
// viewport-relative elements do not change positions.
func (p SetDeviceMetricsOverrideParams) WithViewport(viewport *page.Viewport) *SetDeviceMetricsOverrideParams {
p.Viewport = viewport
return &p
}
// Do executes Emulation.setDeviceMetricsOverride against the provided context and // Do executes Emulation.setDeviceMetricsOverride against the provided context and
// target handler. // target handler.
func (p *SetDeviceMetricsOverrideParams) Do(ctxt context.Context, h cdp.Handler) (err error) { func (p *SetDeviceMetricsOverrideParams) Do(ctxt context.Context, h cdp.Handler) (err error) {

View File

@ -0,0 +1,557 @@
// Code generated by easyjson for marshaling/unmarshaling. DO NOT EDIT.
package headlessexperimental
import (
json "encoding/json"
runtime "github.com/knq/chromedp/cdp/runtime"
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 easyjsonC5a4559bDecodeGithubComKnqChromedpCdpHeadlessexperimental(in *jlexer.Lexer, out *ScreenshotParams) {
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 "format":
(out.Format).UnmarshalEasyJSON(in)
case "quality":
out.Quality = int64(in.Int64())
default:
in.SkipRecursive()
}
in.WantComma()
}
in.Delim('}')
if isTopLevel {
in.Consumed()
}
}
func easyjsonC5a4559bEncodeGithubComKnqChromedpCdpHeadlessexperimental(out *jwriter.Writer, in ScreenshotParams) {
out.RawByte('{')
first := true
_ = first
if in.Format != "" {
if !first {
out.RawByte(',')
}
first = false
out.RawString("\"format\":")
(in.Format).MarshalEasyJSON(out)
}
if in.Quality != 0 {
if !first {
out.RawByte(',')
}
first = false
out.RawString("\"quality\":")
out.Int64(int64(in.Quality))
}
out.RawByte('}')
}
// MarshalJSON supports json.Marshaler interface
func (v ScreenshotParams) MarshalJSON() ([]byte, error) {
w := jwriter.Writer{}
easyjsonC5a4559bEncodeGithubComKnqChromedpCdpHeadlessexperimental(&w, v)
return w.Buffer.BuildBytes(), w.Error
}
// MarshalEasyJSON supports easyjson.Marshaler interface
func (v ScreenshotParams) MarshalEasyJSON(w *jwriter.Writer) {
easyjsonC5a4559bEncodeGithubComKnqChromedpCdpHeadlessexperimental(w, v)
}
// UnmarshalJSON supports json.Unmarshaler interface
func (v *ScreenshotParams) UnmarshalJSON(data []byte) error {
r := jlexer.Lexer{Data: data}
easyjsonC5a4559bDecodeGithubComKnqChromedpCdpHeadlessexperimental(&r, v)
return r.Error()
}
// UnmarshalEasyJSON supports easyjson.Unmarshaler interface
func (v *ScreenshotParams) UnmarshalEasyJSON(l *jlexer.Lexer) {
easyjsonC5a4559bDecodeGithubComKnqChromedpCdpHeadlessexperimental(l, v)
}
func easyjsonC5a4559bDecodeGithubComKnqChromedpCdpHeadlessexperimental1(in *jlexer.Lexer, out *EventNeedsBeginFramesChanged) {
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 "needsBeginFrames":
out.NeedsBeginFrames = bool(in.Bool())
default:
in.SkipRecursive()
}
in.WantComma()
}
in.Delim('}')
if isTopLevel {
in.Consumed()
}
}
func easyjsonC5a4559bEncodeGithubComKnqChromedpCdpHeadlessexperimental1(out *jwriter.Writer, in EventNeedsBeginFramesChanged) {
out.RawByte('{')
first := true
_ = first
if !first {
out.RawByte(',')
}
first = false
out.RawString("\"needsBeginFrames\":")
out.Bool(bool(in.NeedsBeginFrames))
out.RawByte('}')
}
// MarshalJSON supports json.Marshaler interface
func (v EventNeedsBeginFramesChanged) MarshalJSON() ([]byte, error) {
w := jwriter.Writer{}
easyjsonC5a4559bEncodeGithubComKnqChromedpCdpHeadlessexperimental1(&w, v)
return w.Buffer.BuildBytes(), w.Error
}
// MarshalEasyJSON supports easyjson.Marshaler interface
func (v EventNeedsBeginFramesChanged) MarshalEasyJSON(w *jwriter.Writer) {
easyjsonC5a4559bEncodeGithubComKnqChromedpCdpHeadlessexperimental1(w, v)
}
// UnmarshalJSON supports json.Unmarshaler interface
func (v *EventNeedsBeginFramesChanged) UnmarshalJSON(data []byte) error {
r := jlexer.Lexer{Data: data}
easyjsonC5a4559bDecodeGithubComKnqChromedpCdpHeadlessexperimental1(&r, v)
return r.Error()
}
// UnmarshalEasyJSON supports easyjson.Unmarshaler interface
func (v *EventNeedsBeginFramesChanged) UnmarshalEasyJSON(l *jlexer.Lexer) {
easyjsonC5a4559bDecodeGithubComKnqChromedpCdpHeadlessexperimental1(l, v)
}
func easyjsonC5a4559bDecodeGithubComKnqChromedpCdpHeadlessexperimental2(in *jlexer.Lexer, out *EventMainFrameReadyForScreenshots) {
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 {
default:
in.SkipRecursive()
}
in.WantComma()
}
in.Delim('}')
if isTopLevel {
in.Consumed()
}
}
func easyjsonC5a4559bEncodeGithubComKnqChromedpCdpHeadlessexperimental2(out *jwriter.Writer, in EventMainFrameReadyForScreenshots) {
out.RawByte('{')
first := true
_ = first
out.RawByte('}')
}
// MarshalJSON supports json.Marshaler interface
func (v EventMainFrameReadyForScreenshots) MarshalJSON() ([]byte, error) {
w := jwriter.Writer{}
easyjsonC5a4559bEncodeGithubComKnqChromedpCdpHeadlessexperimental2(&w, v)
return w.Buffer.BuildBytes(), w.Error
}
// MarshalEasyJSON supports easyjson.Marshaler interface
func (v EventMainFrameReadyForScreenshots) MarshalEasyJSON(w *jwriter.Writer) {
easyjsonC5a4559bEncodeGithubComKnqChromedpCdpHeadlessexperimental2(w, v)
}
// UnmarshalJSON supports json.Unmarshaler interface
func (v *EventMainFrameReadyForScreenshots) UnmarshalJSON(data []byte) error {
r := jlexer.Lexer{Data: data}
easyjsonC5a4559bDecodeGithubComKnqChromedpCdpHeadlessexperimental2(&r, v)
return r.Error()
}
// UnmarshalEasyJSON supports easyjson.Unmarshaler interface
func (v *EventMainFrameReadyForScreenshots) UnmarshalEasyJSON(l *jlexer.Lexer) {
easyjsonC5a4559bDecodeGithubComKnqChromedpCdpHeadlessexperimental2(l, v)
}
func easyjsonC5a4559bDecodeGithubComKnqChromedpCdpHeadlessexperimental3(in *jlexer.Lexer, out *EnableParams) {
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 {
default:
in.SkipRecursive()
}
in.WantComma()
}
in.Delim('}')
if isTopLevel {
in.Consumed()
}
}
func easyjsonC5a4559bEncodeGithubComKnqChromedpCdpHeadlessexperimental3(out *jwriter.Writer, in EnableParams) {
out.RawByte('{')
first := true
_ = first
out.RawByte('}')
}
// MarshalJSON supports json.Marshaler interface
func (v EnableParams) MarshalJSON() ([]byte, error) {
w := jwriter.Writer{}
easyjsonC5a4559bEncodeGithubComKnqChromedpCdpHeadlessexperimental3(&w, v)
return w.Buffer.BuildBytes(), w.Error
}
// MarshalEasyJSON supports easyjson.Marshaler interface
func (v EnableParams) MarshalEasyJSON(w *jwriter.Writer) {
easyjsonC5a4559bEncodeGithubComKnqChromedpCdpHeadlessexperimental3(w, v)
}
// UnmarshalJSON supports json.Unmarshaler interface
func (v *EnableParams) UnmarshalJSON(data []byte) error {
r := jlexer.Lexer{Data: data}
easyjsonC5a4559bDecodeGithubComKnqChromedpCdpHeadlessexperimental3(&r, v)
return r.Error()
}
// UnmarshalEasyJSON supports easyjson.Unmarshaler interface
func (v *EnableParams) UnmarshalEasyJSON(l *jlexer.Lexer) {
easyjsonC5a4559bDecodeGithubComKnqChromedpCdpHeadlessexperimental3(l, v)
}
func easyjsonC5a4559bDecodeGithubComKnqChromedpCdpHeadlessexperimental4(in *jlexer.Lexer, out *DisableParams) {
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 {
default:
in.SkipRecursive()
}
in.WantComma()
}
in.Delim('}')
if isTopLevel {
in.Consumed()
}
}
func easyjsonC5a4559bEncodeGithubComKnqChromedpCdpHeadlessexperimental4(out *jwriter.Writer, in DisableParams) {
out.RawByte('{')
first := true
_ = first
out.RawByte('}')
}
// MarshalJSON supports json.Marshaler interface
func (v DisableParams) MarshalJSON() ([]byte, error) {
w := jwriter.Writer{}
easyjsonC5a4559bEncodeGithubComKnqChromedpCdpHeadlessexperimental4(&w, v)
return w.Buffer.BuildBytes(), w.Error
}
// MarshalEasyJSON supports easyjson.Marshaler interface
func (v DisableParams) MarshalEasyJSON(w *jwriter.Writer) {
easyjsonC5a4559bEncodeGithubComKnqChromedpCdpHeadlessexperimental4(w, v)
}
// UnmarshalJSON supports json.Unmarshaler interface
func (v *DisableParams) UnmarshalJSON(data []byte) error {
r := jlexer.Lexer{Data: data}
easyjsonC5a4559bDecodeGithubComKnqChromedpCdpHeadlessexperimental4(&r, v)
return r.Error()
}
// UnmarshalEasyJSON supports easyjson.Unmarshaler interface
func (v *DisableParams) UnmarshalEasyJSON(l *jlexer.Lexer) {
easyjsonC5a4559bDecodeGithubComKnqChromedpCdpHeadlessexperimental4(l, v)
}
func easyjsonC5a4559bDecodeGithubComKnqChromedpCdpHeadlessexperimental5(in *jlexer.Lexer, out *BeginFrameReturns) {
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 "hasDamage":
out.HasDamage = bool(in.Bool())
case "screenshotData":
out.ScreenshotData = string(in.String())
default:
in.SkipRecursive()
}
in.WantComma()
}
in.Delim('}')
if isTopLevel {
in.Consumed()
}
}
func easyjsonC5a4559bEncodeGithubComKnqChromedpCdpHeadlessexperimental5(out *jwriter.Writer, in BeginFrameReturns) {
out.RawByte('{')
first := true
_ = first
if in.HasDamage {
if !first {
out.RawByte(',')
}
first = false
out.RawString("\"hasDamage\":")
out.Bool(bool(in.HasDamage))
}
if in.ScreenshotData != "" {
if !first {
out.RawByte(',')
}
first = false
out.RawString("\"screenshotData\":")
out.String(string(in.ScreenshotData))
}
out.RawByte('}')
}
// MarshalJSON supports json.Marshaler interface
func (v BeginFrameReturns) MarshalJSON() ([]byte, error) {
w := jwriter.Writer{}
easyjsonC5a4559bEncodeGithubComKnqChromedpCdpHeadlessexperimental5(&w, v)
return w.Buffer.BuildBytes(), w.Error
}
// MarshalEasyJSON supports easyjson.Marshaler interface
func (v BeginFrameReturns) MarshalEasyJSON(w *jwriter.Writer) {
easyjsonC5a4559bEncodeGithubComKnqChromedpCdpHeadlessexperimental5(w, v)
}
// UnmarshalJSON supports json.Unmarshaler interface
func (v *BeginFrameReturns) UnmarshalJSON(data []byte) error {
r := jlexer.Lexer{Data: data}
easyjsonC5a4559bDecodeGithubComKnqChromedpCdpHeadlessexperimental5(&r, v)
return r.Error()
}
// UnmarshalEasyJSON supports easyjson.Unmarshaler interface
func (v *BeginFrameReturns) UnmarshalEasyJSON(l *jlexer.Lexer) {
easyjsonC5a4559bDecodeGithubComKnqChromedpCdpHeadlessexperimental5(l, v)
}
func easyjsonC5a4559bDecodeGithubComKnqChromedpCdpHeadlessexperimental6(in *jlexer.Lexer, out *BeginFrameParams) {
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 "frameTime":
if in.IsNull() {
in.Skip()
out.FrameTime = nil
} else {
if out.FrameTime == nil {
out.FrameTime = new(runtime.Timestamp)
}
(*out.FrameTime).UnmarshalEasyJSON(in)
}
case "deadline":
if in.IsNull() {
in.Skip()
out.Deadline = nil
} else {
if out.Deadline == nil {
out.Deadline = new(runtime.Timestamp)
}
(*out.Deadline).UnmarshalEasyJSON(in)
}
case "interval":
out.Interval = float64(in.Float64())
case "screenshot":
if in.IsNull() {
in.Skip()
out.Screenshot = nil
} else {
if out.Screenshot == nil {
out.Screenshot = new(ScreenshotParams)
}
(*out.Screenshot).UnmarshalEasyJSON(in)
}
default:
in.SkipRecursive()
}
in.WantComma()
}
in.Delim('}')
if isTopLevel {
in.Consumed()
}
}
func easyjsonC5a4559bEncodeGithubComKnqChromedpCdpHeadlessexperimental6(out *jwriter.Writer, in BeginFrameParams) {
out.RawByte('{')
first := true
_ = first
if in.FrameTime != nil {
if !first {
out.RawByte(',')
}
first = false
out.RawString("\"frameTime\":")
if in.FrameTime == nil {
out.RawString("null")
} else {
(*in.FrameTime).MarshalEasyJSON(out)
}
}
if in.Deadline != nil {
if !first {
out.RawByte(',')
}
first = false
out.RawString("\"deadline\":")
if in.Deadline == nil {
out.RawString("null")
} else {
(*in.Deadline).MarshalEasyJSON(out)
}
}
if in.Interval != 0 {
if !first {
out.RawByte(',')
}
first = false
out.RawString("\"interval\":")
out.Float64(float64(in.Interval))
}
if in.Screenshot != nil {
if !first {
out.RawByte(',')
}
first = false
out.RawString("\"screenshot\":")
if in.Screenshot == nil {
out.RawString("null")
} else {
(*in.Screenshot).MarshalEasyJSON(out)
}
}
out.RawByte('}')
}
// MarshalJSON supports json.Marshaler interface
func (v BeginFrameParams) MarshalJSON() ([]byte, error) {
w := jwriter.Writer{}
easyjsonC5a4559bEncodeGithubComKnqChromedpCdpHeadlessexperimental6(&w, v)
return w.Buffer.BuildBytes(), w.Error
}
// MarshalEasyJSON supports easyjson.Marshaler interface
func (v BeginFrameParams) MarshalEasyJSON(w *jwriter.Writer) {
easyjsonC5a4559bEncodeGithubComKnqChromedpCdpHeadlessexperimental6(w, v)
}
// UnmarshalJSON supports json.Unmarshaler interface
func (v *BeginFrameParams) UnmarshalJSON(data []byte) error {
r := jlexer.Lexer{Data: data}
easyjsonC5a4559bDecodeGithubComKnqChromedpCdpHeadlessexperimental6(&r, v)
return r.Error()
}
// UnmarshalEasyJSON supports easyjson.Unmarshaler interface
func (v *BeginFrameParams) UnmarshalEasyJSON(l *jlexer.Lexer) {
easyjsonC5a4559bDecodeGithubComKnqChromedpCdpHeadlessexperimental6(l, v)
}

View File

@ -0,0 +1,24 @@
package headlessexperimental
// Code generated by chromedp-gen. DO NOT EDIT.
import (
cdp "github.com/knq/chromedp/cdp"
)
// EventNeedsBeginFramesChanged issued when the target starts or stops
// needing BeginFrames.
type EventNeedsBeginFramesChanged struct {
NeedsBeginFrames bool `json:"needsBeginFrames"` // True if BeginFrames are needed, false otherwise.
}
// EventMainFrameReadyForScreenshots issued when the main frame has first
// submitted a frame to the browser. May only be fired while a BeginFrame is in
// flight. Before this event, screenshotting requests may fail.
type EventMainFrameReadyForScreenshots struct{}
// EventTypes all event types in the domain.
var EventTypes = []cdp.MethodType{
cdp.EventHeadlessExperimentalNeedsBeginFramesChanged,
cdp.EventHeadlessExperimentalMainFrameReadyForScreenshots,
}

View File

@ -0,0 +1,123 @@
// Package headlessexperimental provides the Chrome Debugging Protocol
// commands, types, and events for the HeadlessExperimental domain.
//
// This domain provides experimental commands only supported in headless
// mode.
//
// Generated by the chromedp-gen command.
package headlessexperimental
// Code generated by chromedp-gen. DO NOT EDIT.
import (
"context"
"encoding/base64"
cdp "github.com/knq/chromedp/cdp"
"github.com/knq/chromedp/cdp/runtime"
)
// EnableParams enables headless events for the target.
type EnableParams struct{}
// Enable enables headless events for the target.
func Enable() *EnableParams {
return &EnableParams{}
}
// Do executes HeadlessExperimental.enable against the provided context and
// target handler.
func (p *EnableParams) Do(ctxt context.Context, h cdp.Handler) (err error) {
return h.Execute(ctxt, cdp.CommandHeadlessExperimentalEnable, nil, nil)
}
// DisableParams disables headless events for the target.
type DisableParams struct{}
// Disable disables headless events for the target.
func Disable() *DisableParams {
return &DisableParams{}
}
// Do executes HeadlessExperimental.disable against the provided context and
// target handler.
func (p *DisableParams) Do(ctxt context.Context, h cdp.Handler) (err error) {
return h.Execute(ctxt, cdp.CommandHeadlessExperimentalDisable, nil, nil)
}
// BeginFrameParams sends a BeginFrame to the target and returns when the
// frame was completed. Optionally captures a screenshot from the resulting
// frame. Requires that the target was created with enabled BeginFrameControl.
type BeginFrameParams struct {
FrameTime *runtime.Timestamp `json:"frameTime,omitempty"` // Timestamp of this BeginFrame (milliseconds since epoch). If not set, the current time will be used.
Deadline *runtime.Timestamp `json:"deadline,omitempty"` // Deadline of this BeginFrame (milliseconds since epoch). If not set, the deadline will be calculated from the frameTime and interval.
Interval float64 `json:"interval,omitempty"` // The interval between BeginFrames that is reported to the compositor, in milliseconds. Defaults to a 60 frames/second interval, i.e. about 16.666 milliseconds.
Screenshot *ScreenshotParams `json:"screenshot,omitempty"` // If set, a screenshot of the frame will be captured and returned in the response. Otherwise, no screenshot will be captured.
}
// BeginFrame sends a BeginFrame to the target and returns when the frame was
// completed. Optionally captures a screenshot from the resulting frame.
// Requires that the target was created with enabled BeginFrameControl.
//
// parameters:
func BeginFrame() *BeginFrameParams {
return &BeginFrameParams{}
}
// WithFrameTime timestamp of this BeginFrame (milliseconds since epoch). If
// not set, the current time will be used.
func (p BeginFrameParams) WithFrameTime(frameTime *runtime.Timestamp) *BeginFrameParams {
p.FrameTime = frameTime
return &p
}
// WithDeadline deadline of this BeginFrame (milliseconds since epoch). If
// not set, the deadline will be calculated from the frameTime and interval.
func (p BeginFrameParams) WithDeadline(deadline *runtime.Timestamp) *BeginFrameParams {
p.Deadline = deadline
return &p
}
// WithInterval the interval between BeginFrames that is reported to the
// compositor, in milliseconds. Defaults to a 60 frames/second interval, i.e.
// about 16.666 milliseconds.
func (p BeginFrameParams) WithInterval(interval float64) *BeginFrameParams {
p.Interval = interval
return &p
}
// WithScreenshot if set, a screenshot of the frame will be captured and
// returned in the response. Otherwise, no screenshot will be captured.
func (p BeginFrameParams) WithScreenshot(screenshot *ScreenshotParams) *BeginFrameParams {
p.Screenshot = screenshot
return &p
}
// BeginFrameReturns return values.
type BeginFrameReturns struct {
HasDamage bool `json:"hasDamage,omitempty"` // Whether the BeginFrame resulted in damage and, thus, a new frame was committed to the display.
ScreenshotData string `json:"screenshotData,omitempty"` // Base64-encoded image data of the screenshot, if one was requested and successfully taken.
}
// Do executes HeadlessExperimental.beginFrame against the provided context and
// target handler.
//
// returns:
// hasDamage - Whether the BeginFrame resulted in damage and, thus, a new frame was committed to the display.
// screenshotData - Base64-encoded image data of the screenshot, if one was requested and successfully taken.
func (p *BeginFrameParams) Do(ctxt context.Context, h cdp.Handler) (hasDamage bool, screenshotData []byte, err error) {
// execute
var res BeginFrameReturns
err = h.Execute(ctxt, cdp.CommandHeadlessExperimentalBeginFrame, p, &res)
if err != nil {
return false, nil, err
}
// decode
var dec []byte
dec, err = base64.StdEncoding.DecodeString(res.ScreenshotData)
if err != nil {
return false, nil, err
}
return res.HasDamage, dec, nil
}

View File

@ -0,0 +1,59 @@
package headlessexperimental
import (
"errors"
"github.com/mailru/easyjson"
"github.com/mailru/easyjson/jlexer"
"github.com/mailru/easyjson/jwriter"
)
// Code generated by chromedp-gen. DO NOT EDIT.
// ScreenshotParams encoding options for a screenshot.
type ScreenshotParams struct {
Format ScreenshotParamsFormat `json:"format,omitempty"` // Image compression format (defaults to png).
Quality int64 `json:"quality,omitempty"` // Compression quality from range [0..100] (jpeg only).
}
// ScreenshotParamsFormat image compression format (defaults to png).
type ScreenshotParamsFormat string
// String returns the ScreenshotParamsFormat as string value.
func (t ScreenshotParamsFormat) String() string {
return string(t)
}
// ScreenshotParamsFormat values.
const (
ScreenshotParamsFormatJpeg ScreenshotParamsFormat = "jpeg"
ScreenshotParamsFormatPng ScreenshotParamsFormat = "png"
)
// MarshalEasyJSON satisfies easyjson.Marshaler.
func (t ScreenshotParamsFormat) MarshalEasyJSON(out *jwriter.Writer) {
out.String(string(t))
}
// MarshalJSON satisfies json.Marshaler.
func (t ScreenshotParamsFormat) MarshalJSON() ([]byte, error) {
return easyjson.Marshal(t)
}
// UnmarshalEasyJSON satisfies easyjson.Unmarshaler.
func (t *ScreenshotParamsFormat) UnmarshalEasyJSON(in *jlexer.Lexer) {
switch ScreenshotParamsFormat(in.String()) {
case ScreenshotParamsFormatJpeg:
*t = ScreenshotParamsFormatJpeg
case ScreenshotParamsFormatPng:
*t = ScreenshotParamsFormatPng
default:
in.AddError(errors.New("unknown ScreenshotParamsFormat value"))
}
}
// UnmarshalJSON satisfies json.Unmarshaler.
func (t *ScreenshotParamsFormat) UnmarshalJSON(buf []byte) error {
return easyjson.Unmarshal(buf, t)
}

View File

@ -5,6 +5,7 @@ package network
import ( import (
json "encoding/json" json "encoding/json"
cdp "github.com/knq/chromedp/cdp" cdp "github.com/knq/chromedp/cdp"
page "github.com/knq/chromedp/cdp/page"
runtime "github.com/knq/chromedp/cdp/runtime" runtime "github.com/knq/chromedp/cdp/runtime"
security "github.com/knq/chromedp/cdp/security" security "github.com/knq/chromedp/cdp/security"
easyjson "github.com/mailru/easyjson" easyjson "github.com/mailru/easyjson"
@ -664,6 +665,29 @@ func easyjsonC5a4559bDecodeGithubComKnqChromedpCdpNetwork5(in *jlexer.Lexer, out
} }
in.Delim(']') in.Delim(']')
} }
case "resourceTypes":
if in.IsNull() {
in.Skip()
out.ResourceTypes = nil
} else {
in.Delim('[')
if out.ResourceTypes == nil {
if !in.IsDelim(']') {
out.ResourceTypes = make([]page.ResourceType, 0, 4)
} else {
out.ResourceTypes = []page.ResourceType{}
}
} else {
out.ResourceTypes = (out.ResourceTypes)[:0]
}
for !in.IsDelim(']') {
var v8 page.ResourceType
(v8).UnmarshalEasyJSON(in)
out.ResourceTypes = append(out.ResourceTypes, v8)
in.WantComma()
}
in.Delim(']')
}
default: default:
in.SkipRecursive() in.SkipRecursive()
} }
@ -694,11 +718,30 @@ func easyjsonC5a4559bEncodeGithubComKnqChromedpCdpNetwork5(out *jwriter.Writer,
out.RawString("null") out.RawString("null")
} else { } else {
out.RawByte('[') out.RawByte('[')
for v8, v9 := range in.Patterns { for v9, v10 := range in.Patterns {
if v8 > 0 { if v9 > 0 {
out.RawByte(',') out.RawByte(',')
} }
out.String(string(v9)) out.String(string(v10))
}
out.RawByte(']')
}
}
if len(in.ResourceTypes) != 0 {
if !first {
out.RawByte(',')
}
first = false
out.RawString("\"resourceTypes\":")
if in.ResourceTypes == nil && (out.Flags&jwriter.NilSliceAsEmpty) == 0 {
out.RawString("null")
} else {
out.RawByte('[')
for v11, v12 := range in.ResourceTypes {
if v11 > 0 {
out.RawByte(',')
}
(v12).MarshalEasyJSON(out)
} }
out.RawByte(']') out.RawByte(']')
} }
@ -761,15 +804,15 @@ func easyjsonC5a4559bDecodeGithubComKnqChromedpCdpNetwork6(in *jlexer.Lexer, out
for !in.IsDelim('}') { for !in.IsDelim('}') {
key := string(in.String()) key := string(in.String())
in.WantColon() in.WantColon()
var v10 interface{} var v13 interface{}
if m, ok := v10.(easyjson.Unmarshaler); ok { if m, ok := v13.(easyjson.Unmarshaler); ok {
m.UnmarshalEasyJSON(in) m.UnmarshalEasyJSON(in)
} else if m, ok := v10.(json.Unmarshaler); ok { } else if m, ok := v13.(json.Unmarshaler); ok {
_ = m.UnmarshalJSON(in.Raw()) _ = m.UnmarshalJSON(in.Raw())
} else { } else {
v10 = in.Interface() v13 = in.Interface()
} }
(out.Headers)[key] = v10 (out.Headers)[key] = v13
in.WantComma() in.WantComma()
} }
in.Delim('}') in.Delim('}')
@ -797,20 +840,20 @@ func easyjsonC5a4559bEncodeGithubComKnqChromedpCdpNetwork6(out *jwriter.Writer,
out.RawString(`null`) out.RawString(`null`)
} else { } else {
out.RawByte('{') out.RawByte('{')
v11First := true v14First := true
for v11Name, v11Value := range in.Headers { for v14Name, v14Value := range in.Headers {
if !v11First { if !v14First {
out.RawByte(',') out.RawByte(',')
} }
v11First = false v14First = false
out.String(string(v11Name)) out.String(string(v14Name))
out.RawByte(':') out.RawByte(':')
if m, ok := v11Value.(easyjson.Marshaler); ok { if m, ok := v14Value.(easyjson.Marshaler); ok {
m.MarshalEasyJSON(out) m.MarshalEasyJSON(out)
} else if m, ok := v11Value.(json.Marshaler); ok { } else if m, ok := v14Value.(json.Marshaler); ok {
out.Raw(m.MarshalJSON()) out.Raw(m.MarshalJSON())
} else { } else {
out.Raw(json.Marshal(v11Value)) out.Raw(json.Marshal(v14Value))
} }
} }
out.RawByte('}') out.RawByte('}')
@ -951,17 +994,17 @@ func easyjsonC5a4559bDecodeGithubComKnqChromedpCdpNetwork8(in *jlexer.Lexer, out
out.Cookies = (out.Cookies)[:0] out.Cookies = (out.Cookies)[:0]
} }
for !in.IsDelim(']') { for !in.IsDelim(']') {
var v12 *CookieParam var v15 *CookieParam
if in.IsNull() { if in.IsNull() {
in.Skip() in.Skip()
v12 = nil v15 = nil
} else { } else {
if v12 == nil { if v15 == nil {
v12 = new(CookieParam) v15 = new(CookieParam)
} }
(*v12).UnmarshalEasyJSON(in) (*v15).UnmarshalEasyJSON(in)
} }
out.Cookies = append(out.Cookies, v12) out.Cookies = append(out.Cookies, v15)
in.WantComma() in.WantComma()
} }
in.Delim(']') in.Delim(']')
@ -989,14 +1032,14 @@ func easyjsonC5a4559bEncodeGithubComKnqChromedpCdpNetwork8(out *jwriter.Writer,
out.RawString("null") out.RawString("null")
} else { } else {
out.RawByte('[') out.RawByte('[')
for v13, v14 := range in.Cookies { for v16, v17 := range in.Cookies {
if v13 > 0 { if v16 > 0 {
out.RawByte(',') out.RawByte(',')
} }
if v14 == nil { if v17 == nil {
out.RawString("null") out.RawString("null")
} else { } else {
(*v14).MarshalEasyJSON(out) (*v17).MarshalEasyJSON(out)
} }
} }
out.RawByte(']') out.RawByte(']')
@ -1422,9 +1465,9 @@ func easyjsonC5a4559bDecodeGithubComKnqChromedpCdpNetwork13(in *jlexer.Lexer, ou
out.Urls = (out.Urls)[:0] out.Urls = (out.Urls)[:0]
} }
for !in.IsDelim(']') { for !in.IsDelim(']') {
var v15 string var v18 string
v15 = string(in.String()) v18 = string(in.String())
out.Urls = append(out.Urls, v15) out.Urls = append(out.Urls, v18)
in.WantComma() in.WantComma()
} }
in.Delim(']') in.Delim(']')
@ -1452,11 +1495,11 @@ func easyjsonC5a4559bEncodeGithubComKnqChromedpCdpNetwork13(out *jwriter.Writer,
out.RawString("null") out.RawString("null")
} else { } else {
out.RawByte('[') out.RawByte('[')
for v16, v17 := range in.Urls { for v19, v20 := range in.Urls {
if v16 > 0 { if v19 > 0 {
out.RawByte(',') out.RawByte(',')
} }
out.String(string(v17)) out.String(string(v20))
} }
out.RawByte(']') out.RawByte(']')
} }
@ -1535,9 +1578,9 @@ func easyjsonC5a4559bDecodeGithubComKnqChromedpCdpNetwork14(in *jlexer.Lexer, ou
out.SanList = (out.SanList)[:0] out.SanList = (out.SanList)[:0]
} }
for !in.IsDelim(']') { for !in.IsDelim(']') {
var v18 string var v21 string
v18 = string(in.String()) v21 = string(in.String())
out.SanList = append(out.SanList, v18) out.SanList = append(out.SanList, v21)
in.WantComma() in.WantComma()
} }
in.Delim(']') in.Delim(']')
@ -1580,17 +1623,17 @@ func easyjsonC5a4559bDecodeGithubComKnqChromedpCdpNetwork14(in *jlexer.Lexer, ou
out.SignedCertificateTimestampList = (out.SignedCertificateTimestampList)[:0] out.SignedCertificateTimestampList = (out.SignedCertificateTimestampList)[:0]
} }
for !in.IsDelim(']') { for !in.IsDelim(']') {
var v19 *SignedCertificateTimestamp var v22 *SignedCertificateTimestamp
if in.IsNull() { if in.IsNull() {
in.Skip() in.Skip()
v19 = nil v22 = nil
} else { } else {
if v19 == nil { if v22 == nil {
v19 = new(SignedCertificateTimestamp) v22 = new(SignedCertificateTimestamp)
} }
(*v19).UnmarshalEasyJSON(in) (*v22).UnmarshalEasyJSON(in)
} }
out.SignedCertificateTimestampList = append(out.SignedCertificateTimestampList, v19) out.SignedCertificateTimestampList = append(out.SignedCertificateTimestampList, v22)
in.WantComma() in.WantComma()
} }
in.Delim(']') in.Delim(']')
@ -1664,11 +1707,11 @@ func easyjsonC5a4559bEncodeGithubComKnqChromedpCdpNetwork14(out *jwriter.Writer,
out.RawString("null") out.RawString("null")
} else { } else {
out.RawByte('[') out.RawByte('[')
for v20, v21 := range in.SanList { for v23, v24 := range in.SanList {
if v20 > 0 { if v23 > 0 {
out.RawByte(',') out.RawByte(',')
} }
out.String(string(v21)) out.String(string(v24))
} }
out.RawByte(']') out.RawByte(']')
} }
@ -1707,14 +1750,14 @@ func easyjsonC5a4559bEncodeGithubComKnqChromedpCdpNetwork14(out *jwriter.Writer,
out.RawString("null") out.RawString("null")
} else { } else {
out.RawByte('[') out.RawByte('[')
for v22, v23 := range in.SignedCertificateTimestampList { for v25, v26 := range in.SignedCertificateTimestampList {
if v22 > 0 { if v25 > 0 {
out.RawByte(',') out.RawByte(',')
} }
if v23 == nil { if v26 == nil {
out.RawString("null") out.RawString("null")
} else { } else {
(*v23).MarshalEasyJSON(out) (*v26).MarshalEasyJSON(out)
} }
} }
out.RawByte(']') out.RawByte(']')
@ -1783,15 +1826,15 @@ func easyjsonC5a4559bDecodeGithubComKnqChromedpCdpNetwork15(in *jlexer.Lexer, ou
for !in.IsDelim('}') { for !in.IsDelim('}') {
key := string(in.String()) key := string(in.String())
in.WantColon() in.WantColon()
var v24 interface{} var v27 interface{}
if m, ok := v24.(easyjson.Unmarshaler); ok { if m, ok := v27.(easyjson.Unmarshaler); ok {
m.UnmarshalEasyJSON(in) m.UnmarshalEasyJSON(in)
} else if m, ok := v24.(json.Unmarshaler); ok { } else if m, ok := v27.(json.Unmarshaler); ok {
_ = m.UnmarshalJSON(in.Raw()) _ = m.UnmarshalJSON(in.Raw())
} else { } else {
v24 = in.Interface() v27 = in.Interface()
} }
(out.Headers)[key] = v24 (out.Headers)[key] = v27
in.WantComma() in.WantComma()
} }
in.Delim('}') in.Delim('}')
@ -1813,15 +1856,15 @@ func easyjsonC5a4559bDecodeGithubComKnqChromedpCdpNetwork15(in *jlexer.Lexer, ou
for !in.IsDelim('}') { for !in.IsDelim('}') {
key := string(in.String()) key := string(in.String())
in.WantColon() in.WantColon()
var v25 interface{} var v28 interface{}
if m, ok := v25.(easyjson.Unmarshaler); ok { if m, ok := v28.(easyjson.Unmarshaler); ok {
m.UnmarshalEasyJSON(in) m.UnmarshalEasyJSON(in)
} else if m, ok := v25.(json.Unmarshaler); ok { } else if m, ok := v28.(json.Unmarshaler); ok {
_ = m.UnmarshalJSON(in.Raw()) _ = m.UnmarshalJSON(in.Raw())
} else { } else {
v25 = in.Interface() v28 = in.Interface()
} }
(out.RequestHeaders)[key] = v25 (out.RequestHeaders)[key] = v28
in.WantComma() in.WantComma()
} }
in.Delim('}') in.Delim('}')
@ -1907,20 +1950,20 @@ func easyjsonC5a4559bEncodeGithubComKnqChromedpCdpNetwork15(out *jwriter.Writer,
out.RawString(`null`) out.RawString(`null`)
} else { } else {
out.RawByte('{') out.RawByte('{')
v26First := true v29First := true
for v26Name, v26Value := range in.Headers { for v29Name, v29Value := range in.Headers {
if !v26First { if !v29First {
out.RawByte(',') out.RawByte(',')
} }
v26First = false v29First = false
out.String(string(v26Name)) out.String(string(v29Name))
out.RawByte(':') out.RawByte(':')
if m, ok := v26Value.(easyjson.Marshaler); ok { if m, ok := v29Value.(easyjson.Marshaler); ok {
m.MarshalEasyJSON(out) m.MarshalEasyJSON(out)
} else if m, ok := v26Value.(json.Marshaler); ok { } else if m, ok := v29Value.(json.Marshaler); ok {
out.Raw(m.MarshalJSON()) out.Raw(m.MarshalJSON())
} else { } else {
out.Raw(json.Marshal(v26Value)) out.Raw(json.Marshal(v29Value))
} }
} }
out.RawByte('}') out.RawByte('}')
@ -1949,20 +1992,20 @@ func easyjsonC5a4559bEncodeGithubComKnqChromedpCdpNetwork15(out *jwriter.Writer,
out.RawString(`null`) out.RawString(`null`)
} else { } else {
out.RawByte('{') out.RawByte('{')
v27First := true v30First := true
for v27Name, v27Value := range in.RequestHeaders { for v30Name, v30Value := range in.RequestHeaders {
if !v27First { if !v30First {
out.RawByte(',') out.RawByte(',')
} }
v27First = false v30First = false
out.String(string(v27Name)) out.String(string(v30Name))
out.RawByte(':') out.RawByte(':')
if m, ok := v27Value.(easyjson.Marshaler); ok { if m, ok := v30Value.(easyjson.Marshaler); ok {
m.MarshalEasyJSON(out) m.MarshalEasyJSON(out)
} else if m, ok := v27Value.(json.Marshaler); ok { } else if m, ok := v30Value.(json.Marshaler); ok {
out.Raw(m.MarshalJSON()) out.Raw(m.MarshalJSON())
} else { } else {
out.Raw(json.Marshal(v27Value)) out.Raw(json.Marshal(v30Value))
} }
} }
out.RawByte('}') out.RawByte('}')
@ -2313,15 +2356,15 @@ func easyjsonC5a4559bDecodeGithubComKnqChromedpCdpNetwork17(in *jlexer.Lexer, ou
for !in.IsDelim('}') { for !in.IsDelim('}') {
key := string(in.String()) key := string(in.String())
in.WantColon() in.WantColon()
var v28 interface{} var v31 interface{}
if m, ok := v28.(easyjson.Unmarshaler); ok { if m, ok := v31.(easyjson.Unmarshaler); ok {
m.UnmarshalEasyJSON(in) m.UnmarshalEasyJSON(in)
} else if m, ok := v28.(json.Unmarshaler); ok { } else if m, ok := v31.(json.Unmarshaler); ok {
_ = m.UnmarshalJSON(in.Raw()) _ = m.UnmarshalJSON(in.Raw())
} else { } else {
v28 = in.Interface() v31 = in.Interface()
} }
(out.Headers)[key] = v28 (out.Headers)[key] = v31
in.WantComma() in.WantComma()
} }
in.Delim('}') in.Delim('}')
@ -2371,20 +2414,20 @@ func easyjsonC5a4559bEncodeGithubComKnqChromedpCdpNetwork17(out *jwriter.Writer,
out.RawString(`null`) out.RawString(`null`)
} else { } else {
out.RawByte('{') out.RawByte('{')
v29First := true v32First := true
for v29Name, v29Value := range in.Headers { for v32Name, v32Value := range in.Headers {
if !v29First { if !v32First {
out.RawByte(',') out.RawByte(',')
} }
v29First = false v32First = false
out.String(string(v29Name)) out.String(string(v32Name))
out.RawByte(':') out.RawByte(':')
if m, ok := v29Value.(easyjson.Marshaler); ok { if m, ok := v32Value.(easyjson.Marshaler); ok {
m.MarshalEasyJSON(out) m.MarshalEasyJSON(out)
} else if m, ok := v29Value.(json.Marshaler); ok { } else if m, ok := v32Value.(json.Marshaler); ok {
out.Raw(m.MarshalJSON()) out.Raw(m.MarshalJSON())
} else { } else {
out.Raw(json.Marshal(v29Value)) out.Raw(json.Marshal(v32Value))
} }
} }
out.RawByte('}') out.RawByte('}')
@ -2808,17 +2851,17 @@ func easyjsonC5a4559bDecodeGithubComKnqChromedpCdpNetwork22(in *jlexer.Lexer, ou
out.Cookies = (out.Cookies)[:0] out.Cookies = (out.Cookies)[:0]
} }
for !in.IsDelim(']') { for !in.IsDelim(']') {
var v30 *Cookie var v33 *Cookie
if in.IsNull() { if in.IsNull() {
in.Skip() in.Skip()
v30 = nil v33 = nil
} else { } else {
if v30 == nil { if v33 == nil {
v30 = new(Cookie) v33 = new(Cookie)
} }
(*v30).UnmarshalEasyJSON(in) (*v33).UnmarshalEasyJSON(in)
} }
out.Cookies = append(out.Cookies, v30) out.Cookies = append(out.Cookies, v33)
in.WantComma() in.WantComma()
} }
in.Delim(']') in.Delim(']')
@ -2847,14 +2890,14 @@ func easyjsonC5a4559bEncodeGithubComKnqChromedpCdpNetwork22(out *jwriter.Writer,
out.RawString("null") out.RawString("null")
} else { } else {
out.RawByte('[') out.RawByte('[')
for v31, v32 := range in.Cookies { for v34, v35 := range in.Cookies {
if v31 > 0 { if v34 > 0 {
out.RawByte(',') out.RawByte(',')
} }
if v32 == nil { if v35 == nil {
out.RawString("null") out.RawString("null")
} else { } else {
(*v32).MarshalEasyJSON(out) (*v35).MarshalEasyJSON(out)
} }
} }
out.RawByte(']') out.RawByte(']')
@ -2921,9 +2964,9 @@ func easyjsonC5a4559bDecodeGithubComKnqChromedpCdpNetwork23(in *jlexer.Lexer, ou
out.Urls = (out.Urls)[:0] out.Urls = (out.Urls)[:0]
} }
for !in.IsDelim(']') { for !in.IsDelim(']') {
var v33 string var v36 string
v33 = string(in.String()) v36 = string(in.String())
out.Urls = append(out.Urls, v33) out.Urls = append(out.Urls, v36)
in.WantComma() in.WantComma()
} }
in.Delim(']') in.Delim(']')
@ -2952,11 +2995,11 @@ func easyjsonC5a4559bEncodeGithubComKnqChromedpCdpNetwork23(out *jwriter.Writer,
out.RawString("null") out.RawString("null")
} else { } else {
out.RawByte('[') out.RawByte('[')
for v34, v35 := range in.Urls { for v37, v38 := range in.Urls {
if v34 > 0 { if v37 > 0 {
out.RawByte(',') out.RawByte(',')
} }
out.String(string(v35)) out.String(string(v38))
} }
out.RawByte(']') out.RawByte(']')
} }
@ -3022,9 +3065,9 @@ func easyjsonC5a4559bDecodeGithubComKnqChromedpCdpNetwork24(in *jlexer.Lexer, ou
out.TableNames = (out.TableNames)[:0] out.TableNames = (out.TableNames)[:0]
} }
for !in.IsDelim(']') { for !in.IsDelim(']') {
var v36 string var v39 string
v36 = string(in.String()) v39 = string(in.String())
out.TableNames = append(out.TableNames, v36) out.TableNames = append(out.TableNames, v39)
in.WantComma() in.WantComma()
} }
in.Delim(']') in.Delim(']')
@ -3053,11 +3096,11 @@ func easyjsonC5a4559bEncodeGithubComKnqChromedpCdpNetwork24(out *jwriter.Writer,
out.RawString("null") out.RawString("null")
} else { } else {
out.RawByte('[') out.RawByte('[')
for v37, v38 := range in.TableNames { for v40, v41 := range in.TableNames {
if v37 > 0 { if v40 > 0 {
out.RawByte(',') out.RawByte(',')
} }
out.String(string(v38)) out.String(string(v41))
} }
out.RawByte(']') out.RawByte(']')
} }
@ -3190,17 +3233,17 @@ func easyjsonC5a4559bDecodeGithubComKnqChromedpCdpNetwork26(in *jlexer.Lexer, ou
out.Cookies = (out.Cookies)[:0] out.Cookies = (out.Cookies)[:0]
} }
for !in.IsDelim(']') { for !in.IsDelim(']') {
var v39 *Cookie var v42 *Cookie
if in.IsNull() { if in.IsNull() {
in.Skip() in.Skip()
v39 = nil v42 = nil
} else { } else {
if v39 == nil { if v42 == nil {
v39 = new(Cookie) v42 = new(Cookie)
} }
(*v39).UnmarshalEasyJSON(in) (*v42).UnmarshalEasyJSON(in)
} }
out.Cookies = append(out.Cookies, v39) out.Cookies = append(out.Cookies, v42)
in.WantComma() in.WantComma()
} }
in.Delim(']') in.Delim(']')
@ -3229,14 +3272,14 @@ func easyjsonC5a4559bEncodeGithubComKnqChromedpCdpNetwork26(out *jwriter.Writer,
out.RawString("null") out.RawString("null")
} else { } else {
out.RawByte('[') out.RawByte('[')
for v40, v41 := range in.Cookies { for v43, v44 := range in.Cookies {
if v40 > 0 { if v43 > 0 {
out.RawByte(',') out.RawByte(',')
} }
if v41 == nil { if v44 == nil {
out.RawString("null") out.RawString("null")
} else { } else {
(*v41).MarshalEasyJSON(out) (*v44).MarshalEasyJSON(out)
} }
} }
out.RawByte(']') out.RawByte(']')
@ -4602,15 +4645,15 @@ func easyjsonC5a4559bDecodeGithubComKnqChromedpCdpNetwork39(in *jlexer.Lexer, ou
for !in.IsDelim('}') { for !in.IsDelim('}') {
key := string(in.String()) key := string(in.String())
in.WantColon() in.WantColon()
var v42 interface{} var v45 interface{}
if m, ok := v42.(easyjson.Unmarshaler); ok { if m, ok := v45.(easyjson.Unmarshaler); ok {
m.UnmarshalEasyJSON(in) m.UnmarshalEasyJSON(in)
} else if m, ok := v42.(json.Unmarshaler); ok { } else if m, ok := v45.(json.Unmarshaler); ok {
_ = m.UnmarshalJSON(in.Raw()) _ = m.UnmarshalJSON(in.Raw())
} else { } else {
v42 = in.Interface() v45 = in.Interface()
} }
(out.RedirectHeaders)[key] = v42 (out.RedirectHeaders)[key] = v45
in.WantComma() in.WantComma()
} }
in.Delim('}') in.Delim('}')
@ -4681,20 +4724,20 @@ func easyjsonC5a4559bEncodeGithubComKnqChromedpCdpNetwork39(out *jwriter.Writer,
out.RawString(`null`) out.RawString(`null`)
} else { } else {
out.RawByte('{') out.RawByte('{')
v43First := true v46First := true
for v43Name, v43Value := range in.RedirectHeaders { for v46Name, v46Value := range in.RedirectHeaders {
if !v43First { if !v46First {
out.RawByte(',') out.RawByte(',')
} }
v43First = false v46First = false
out.String(string(v43Name)) out.String(string(v46Name))
out.RawByte(':') out.RawByte(':')
if m, ok := v43Value.(easyjson.Marshaler); ok { if m, ok := v46Value.(easyjson.Marshaler); ok {
m.MarshalEasyJSON(out) m.MarshalEasyJSON(out)
} else if m, ok := v43Value.(json.Marshaler); ok { } else if m, ok := v46Value.(json.Marshaler); ok {
out.Raw(m.MarshalJSON()) out.Raw(m.MarshalJSON())
} else { } else {
out.Raw(json.Marshal(v43Value)) out.Raw(json.Marshal(v46Value))
} }
} }
out.RawByte('}') out.RawByte('}')
@ -5864,15 +5907,15 @@ func easyjsonC5a4559bDecodeGithubComKnqChromedpCdpNetwork50(in *jlexer.Lexer, ou
for !in.IsDelim('}') { for !in.IsDelim('}') {
key := string(in.String()) key := string(in.String())
in.WantColon() in.WantColon()
var v44 interface{} var v47 interface{}
if m, ok := v44.(easyjson.Unmarshaler); ok { if m, ok := v47.(easyjson.Unmarshaler); ok {
m.UnmarshalEasyJSON(in) m.UnmarshalEasyJSON(in)
} else if m, ok := v44.(json.Unmarshaler); ok { } else if m, ok := v47.(json.Unmarshaler); ok {
_ = m.UnmarshalJSON(in.Raw()) _ = m.UnmarshalJSON(in.Raw())
} else { } else {
v44 = in.Interface() v47 = in.Interface()
} }
(out.Headers)[key] = v44 (out.Headers)[key] = v47
in.WantComma() in.WantComma()
} }
in.Delim('}') in.Delim('}')
@ -5957,20 +6000,20 @@ func easyjsonC5a4559bEncodeGithubComKnqChromedpCdpNetwork50(out *jwriter.Writer,
out.RawString(`null`) out.RawString(`null`)
} else { } else {
out.RawByte('{') out.RawByte('{')
v45First := true v48First := true
for v45Name, v45Value := range in.Headers { for v48Name, v48Value := range in.Headers {
if !v45First { if !v48First {
out.RawByte(',') out.RawByte(',')
} }
v45First = false v48First = false
out.String(string(v45Name)) out.String(string(v48Name))
out.RawByte(':') out.RawByte(':')
if m, ok := v45Value.(easyjson.Marshaler); ok { if m, ok := v48Value.(easyjson.Marshaler); ok {
m.MarshalEasyJSON(out) m.MarshalEasyJSON(out)
} else if m, ok := v45Value.(json.Marshaler); ok { } else if m, ok := v48Value.(json.Marshaler); ok {
out.Raw(m.MarshalJSON()) out.Raw(m.MarshalJSON())
} else { } else {
out.Raw(json.Marshal(v45Value)) out.Raw(json.Marshal(v48Value))
} }
} }
out.RawByte('}') out.RawByte('}')

View File

@ -15,6 +15,7 @@ import (
"encoding/base64" "encoding/base64"
cdp "github.com/knq/chromedp/cdp" cdp "github.com/knq/chromedp/cdp"
"github.com/knq/chromedp/cdp/page"
) )
// EnableParams enables network tracking, network events will now be // EnableParams enables network tracking, network events will now be
@ -703,14 +704,15 @@ func (p *GetCertificateParams) Do(ctxt context.Context, h cdp.Handler) (tableNam
} }
// SetRequestInterceptionEnabledParams sets the requests to intercept that // SetRequestInterceptionEnabledParams sets the requests to intercept that
// match a the provided patterns. // match a the provided patterns and optionally resource types.
type SetRequestInterceptionEnabledParams struct { type SetRequestInterceptionEnabledParams struct {
Enabled bool `json:"enabled"` // Whether requests should be intercepted. If patterns is not set, matches all and resets any previously set patterns. Other parameters are ignored if false. Enabled bool `json:"enabled"` // Whether requests should be intercepted. If patterns is not set, matches all and resets any previously set patterns. Other parameters are ignored if false.
Patterns []string `json:"patterns,omitempty"` // URLs matching any of these patterns will be forwarded and wait for the corresponding continueInterceptedRequest call. Wildcards ('*' -> zero or more, '?' -> exactly one) are allowed. Escape character is backslash. If omitted equivalent to ['*'] (intercept all). Patterns []string `json:"patterns,omitempty"` // URLs matching any of these patterns will be forwarded and wait for the corresponding continueInterceptedRequest call. Wildcards ('*' -> zero or more, '?' -> exactly one) are allowed. Escape character is backslash. If omitted equivalent to ['*'] (intercept all).
ResourceTypes []page.ResourceType `json:"resourceTypes,omitempty"` // If set, only requests for matching resource types will be intercepted.
} }
// SetRequestInterceptionEnabled sets the requests to intercept that match a // SetRequestInterceptionEnabled sets the requests to intercept that match a
// the provided patterns. // the provided patterns and optionally resource types.
// //
// parameters: // parameters:
// enabled - Whether requests should be intercepted. If patterns is not set, matches all and resets any previously set patterns. Other parameters are ignored if false. // enabled - Whether requests should be intercepted. If patterns is not set, matches all and resets any previously set patterns. Other parameters are ignored if false.
@ -729,6 +731,13 @@ func (p SetRequestInterceptionEnabledParams) WithPatterns(patterns []string) *Se
return &p return &p
} }
// WithResourceTypes if set, only requests for matching resource types will
// be intercepted.
func (p SetRequestInterceptionEnabledParams) WithResourceTypes(resourceTypes []page.ResourceType) *SetRequestInterceptionEnabledParams {
p.ResourceTypes = resourceTypes
return &p
}
// Do executes Network.setRequestInterceptionEnabled against the provided context and // Do executes Network.setRequestInterceptionEnabled against the provided context and
// target handler. // target handler.
func (p *SetRequestInterceptionEnabledParams) Do(ctxt context.Context, h cdp.Handler) (err error) { func (p *SetRequestInterceptionEnabledParams) Do(ctxt context.Context, h cdp.Handler) (err error) {

File diff suppressed because it is too large Load Diff

View File

@ -20,6 +20,7 @@ type EventLoadEventFired struct {
// EventLifecycleEvent fired for top level page lifecycle events such as // EventLifecycleEvent fired for top level page lifecycle events such as
// navigation, load, paint, etc. // navigation, load, paint, etc.
type EventLifecycleEvent struct { type EventLifecycleEvent struct {
FrameID cdp.FrameID `json:"frameId"` // Id of the frame.
Name string `json:"name"` Name string `json:"name"`
Timestamp *cdp.MonotonicTime `json:"timestamp"` Timestamp *cdp.MonotonicTime `json:"timestamp"`
} }
@ -106,6 +107,14 @@ type EventInterstitialShown struct{}
// EventInterstitialHidden fired when interstitial page was hidden. // EventInterstitialHidden fired when interstitial page was hidden.
type EventInterstitialHidden struct{} type EventInterstitialHidden struct{}
// EventWindowOpen fired when window.open() was called.
type EventWindowOpen struct {
URL string `json:"url"` // The URL for the new window.
WindowName string `json:"windowName"` // Window name passed to window.open().
WindowFeatures string `json:"windowFeatures"` // Window features passed to window.open().
UserGesture bool `json:"userGesture"` // Whether or not window.open() was triggered by user gesture.
}
// EventTypes all event types in the domain. // EventTypes all event types in the domain.
var EventTypes = []cdp.MethodType{ var EventTypes = []cdp.MethodType{
cdp.EventPageDomContentEventFired, cdp.EventPageDomContentEventFired,
@ -125,4 +134,5 @@ var EventTypes = []cdp.MethodType{
cdp.EventPageScreencastVisibilityChanged, cdp.EventPageScreencastVisibilityChanged,
cdp.EventPageInterstitialShown, cdp.EventPageInterstitialShown,
cdp.EventPageInterstitialHidden, cdp.EventPageInterstitialHidden,
cdp.EventPageWindowOpen,
} }

View File

@ -518,6 +518,8 @@ func easyjsonC5a4559bDecodeGithubComKnqChromedpCdpTarget6(in *jlexer.Lexer, out
out.URL = string(in.String()) out.URL = string(in.String())
case "attached": case "attached":
out.Attached = bool(in.Bool()) out.Attached = bool(in.Bool())
case "openerId":
out.OpenerID = ID(in.String())
default: default:
in.SkipRecursive() in.SkipRecursive()
} }
@ -562,6 +564,14 @@ func easyjsonC5a4559bEncodeGithubComKnqChromedpCdpTarget6(out *jwriter.Writer, i
first = false first = false
out.RawString("\"attached\":") out.RawString("\"attached\":")
out.Bool(bool(in.Attached)) out.Bool(bool(in.Attached))
if in.OpenerID != "" {
if !first {
out.RawByte(',')
}
first = false
out.RawString("\"openerId\":")
out.String(string(in.OpenerID))
}
out.RawByte('}') out.RawByte('}')
} }
@ -1671,6 +1681,8 @@ func easyjsonC5a4559bDecodeGithubComKnqChromedpCdpTarget21(in *jlexer.Lexer, out
out.Height = int64(in.Int64()) out.Height = int64(in.Int64())
case "browserContextId": case "browserContextId":
out.BrowserContextID = BrowserContextID(in.String()) out.BrowserContextID = BrowserContextID(in.String())
case "enableBeginFrameControl":
out.EnableBeginFrameControl = bool(in.Bool())
default: default:
in.SkipRecursive() in.SkipRecursive()
} }
@ -1715,6 +1727,14 @@ func easyjsonC5a4559bEncodeGithubComKnqChromedpCdpTarget21(out *jwriter.Writer,
out.RawString("\"browserContextId\":") out.RawString("\"browserContextId\":")
out.String(string(in.BrowserContextID)) out.String(string(in.BrowserContextID))
} }
if in.EnableBeginFrameControl {
if !first {
out.RawByte(',')
}
first = false
out.RawString("\"enableBeginFrameControl\":")
out.Bool(bool(in.EnableBeginFrameControl))
}
out.RawByte('}') out.RawByte('}')
} }

View File

@ -366,10 +366,11 @@ func (p *DisposeBrowserContextParams) Do(ctxt context.Context, h cdp.Handler) (s
// CreateTargetParams creates a new page. // CreateTargetParams creates a new page.
type CreateTargetParams struct { type CreateTargetParams struct {
URL string `json:"url"` // The initial URL the page will be navigated to. URL string `json:"url"` // The initial URL the page will be navigated to.
Width int64 `json:"width,omitempty"` // Frame width in DIP (headless chrome only). Width int64 `json:"width,omitempty"` // Frame width in DIP (headless chrome only).
Height int64 `json:"height,omitempty"` // Frame height in DIP (headless chrome only). Height int64 `json:"height,omitempty"` // Frame height in DIP (headless chrome only).
BrowserContextID BrowserContextID `json:"browserContextId,omitempty"` // The browser context to create the page in (headless chrome only). BrowserContextID BrowserContextID `json:"browserContextId,omitempty"` // The browser context to create the page in (headless chrome only).
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).
} }
// CreateTarget creates a new page. // CreateTarget creates a new page.
@ -401,6 +402,14 @@ func (p CreateTargetParams) WithBrowserContextID(browserContextID BrowserContext
return &p 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
}
// CreateTargetReturns return values. // CreateTargetReturns return values.
type CreateTargetReturns struct { type CreateTargetReturns struct {
TargetID ID `json:"targetId,omitempty"` // The id of the page opened. TargetID ID `json:"targetId,omitempty"` // The id of the page opened.

View File

@ -32,7 +32,8 @@ type Info struct {
Type string `json:"type"` Type string `json:"type"`
Title string `json:"title"` Title string `json:"title"`
URL string `json:"url"` URL string `json:"url"`
Attached bool `json:"attached"` // Whether the target has an attached client. Attached bool `json:"attached"` // Whether the target has an attached client.
OpenerID ID `json:"openerId,omitempty"` // Opener target Id
} }
// RemoteLocation [no description]. // RemoteLocation [no description].

View File

@ -12,45 +12,46 @@ type DomainType string
// DomainType values. // DomainType values.
const ( const (
DomainAccessibility DomainType = "Accessibility" DomainAccessibility DomainType = "Accessibility"
DomainAnimation DomainType = "Animation" DomainAnimation DomainType = "Animation"
DomainApplicationCache DomainType = "ApplicationCache" DomainApplicationCache DomainType = "ApplicationCache"
DomainAudits DomainType = "Audits" DomainAudits DomainType = "Audits"
DomainBrowser DomainType = "Browser" DomainBrowser DomainType = "Browser"
DomainCSS DomainType = "CSS" DomainCSS DomainType = "CSS"
DomainCacheStorage DomainType = "CacheStorage" DomainCacheStorage DomainType = "CacheStorage"
DomainConsole DomainType = "Console" DomainConsole DomainType = "Console"
DomainDOM DomainType = "DOM" DomainDOM DomainType = "DOM"
DomainDOMDebugger DomainType = "DOMDebugger" DomainDOMDebugger DomainType = "DOMDebugger"
DomainDOMSnapshot DomainType = "DOMSnapshot" DomainDOMSnapshot DomainType = "DOMSnapshot"
DomainDOMStorage DomainType = "DOMStorage" DomainDOMStorage DomainType = "DOMStorage"
DomainDatabase DomainType = "Database" DomainDatabase DomainType = "Database"
DomainDebugger DomainType = "Debugger" DomainDebugger DomainType = "Debugger"
DomainDeviceOrientation DomainType = "DeviceOrientation" DomainDeviceOrientation DomainType = "DeviceOrientation"
DomainEmulation DomainType = "Emulation" DomainEmulation DomainType = "Emulation"
DomainHAR DomainType = "HAR" DomainHAR DomainType = "HAR"
DomainHeapProfiler DomainType = "HeapProfiler" DomainHeadlessExperimental DomainType = "HeadlessExperimental"
DomainIO DomainType = "IO" DomainHeapProfiler DomainType = "HeapProfiler"
DomainIndexedDB DomainType = "IndexedDB" DomainIO DomainType = "IO"
DomainInput DomainType = "Input" DomainIndexedDB DomainType = "IndexedDB"
DomainInspector DomainType = "Inspector" DomainInput DomainType = "Input"
DomainLayerTree DomainType = "LayerTree" DomainInspector DomainType = "Inspector"
DomainLog DomainType = "Log" DomainLayerTree DomainType = "LayerTree"
DomainMemory DomainType = "Memory" DomainLog DomainType = "Log"
DomainNetwork DomainType = "Network" DomainMemory DomainType = "Memory"
DomainOverlay DomainType = "Overlay" DomainNetwork DomainType = "Network"
DomainPage DomainType = "Page" DomainOverlay DomainType = "Overlay"
DomainPerformance DomainType = "Performance" DomainPage DomainType = "Page"
DomainProfiler DomainType = "Profiler" DomainPerformance DomainType = "Performance"
DomainRuntime DomainType = "Runtime" DomainProfiler DomainType = "Profiler"
DomainSchema DomainType = "Schema" DomainRuntime DomainType = "Runtime"
DomainSecurity DomainType = "Security" DomainSchema DomainType = "Schema"
DomainServiceWorker DomainType = "ServiceWorker" DomainSecurity DomainType = "Security"
DomainStorage DomainType = "Storage" DomainServiceWorker DomainType = "ServiceWorker"
DomainSystemInfo DomainType = "SystemInfo" DomainStorage DomainType = "Storage"
DomainTarget DomainType = "Target" DomainSystemInfo DomainType = "SystemInfo"
DomainTethering DomainType = "Tethering" DomainTarget DomainType = "Target"
DomainTracing DomainType = "Tracing" DomainTethering DomainType = "Tethering"
DomainTracing DomainType = "Tracing"
) )
// String satisfies Stringer. // String satisfies Stringer.
@ -105,6 +106,8 @@ func (dt *DomainType) UnmarshalJSON(buf []byte) error {
*dt = DomainEmulation *dt = DomainEmulation
case DomainHAR: case DomainHAR:
*dt = DomainHAR *dt = DomainHAR
case DomainHeadlessExperimental:
*dt = DomainHeadlessExperimental
case DomainHeapProfiler: case DomainHeapProfiler:
*dt = DomainHeapProfiler *dt = DomainHeapProfiler
case DomainIO: case DomainIO:

View File

@ -973,6 +973,12 @@
"$ref": "Emulation.ScreenOrientation", "$ref": "Emulation.ScreenOrientation",
"optional": true, "optional": true,
"description": "Screen orientation override." "description": "Screen orientation override."
},
{
"name": "viewport",
"$ref": "Viewport",
"optional": true,
"description": "The viewport dimensions and scale. If not set, the override is cleared."
} }
], ],
"redirect": "Emulation", "redirect": "Emulation",
@ -1402,6 +1408,11 @@
{ {
"name": "lifecycleEvent", "name": "lifecycleEvent",
"parameters": [ "parameters": [
{
"name": "frameId",
"$ref": "FrameId",
"description": "Id of the frame."
},
{ {
"name": "name", "name": "name",
"type": "string" "type": "string"
@ -1620,6 +1631,33 @@
{ {
"name": "interstitialHidden", "name": "interstitialHidden",
"description": "Fired when interstitial page was hidden" "description": "Fired when interstitial page was hidden"
},
{
"name": "windowOpen",
"description": "Fired when window.open() was called",
"parameters": [
{
"name": "url",
"type": "string",
"description": "The URL for the new window."
},
{
"name": "windowName",
"type": "string",
"description": "Window name passed to window.open()."
},
{
"name": "windowFeatures",
"type": "string",
"description": "Window features passed to window.open()."
},
{
"name": "userGesture",
"type": "boolean",
"description": "Whether or not window.open() was triggered by user gesture."
}
],
"experimental": true
} }
] ]
}, },
@ -2004,7 +2042,8 @@
"domain": "Emulation", "domain": "Emulation",
"description": "This domain emulates different environments for the page.", "description": "This domain emulates different environments for the page.",
"dependencies": [ "dependencies": [
"DOM" "DOM",
"Page"
], ],
"types": [ "types": [
{ {
@ -2113,6 +2152,13 @@
"$ref": "ScreenOrientation", "$ref": "ScreenOrientation",
"optional": true, "optional": true,
"description": "Screen orientation override." "description": "Screen orientation override."
},
{
"name": "viewport",
"$ref": "Page.Viewport",
"optional": true,
"experimental": true,
"description": "If set, the visible area of the page will be overridden to this viewport. This viewport change is not observed by the page, e.g. viewport-relative elements do not change positions."
} }
] ]
}, },
@ -3827,7 +3873,7 @@
}, },
{ {
"name": "setRequestInterceptionEnabled", "name": "setRequestInterceptionEnabled",
"description": "Sets the requests to intercept that match a the provided patterns.", "description": "Sets the requests to intercept that match a the provided patterns and optionally resource types.",
"parameters": [ "parameters": [
{ {
"name": "enabled", "name": "enabled",
@ -3842,6 +3888,15 @@
"type": "string" "type": "string"
}, },
"description": "URLs matching any of these patterns will be forwarded and wait for the corresponding continueInterceptedRequest call. Wildcards ('*' -> zero or more, '?' -> exactly one) are allowed. Escape character is backslash. If omitted equivalent to ['*'] (intercept all)." "description": "URLs matching any of these patterns will be forwarded and wait for the corresponding continueInterceptedRequest call. Wildcards ('*' -> zero or more, '?' -> exactly one) are allowed. Escape character is backslash. If omitted equivalent to ['*'] (intercept all)."
},
{
"name": "resourceTypes",
"type": "array",
"optional": true,
"items": {
"$ref": "Page.ResourceType"
},
"description": "If set, only requests for matching resource types will be intercepted."
} }
], ],
"experimental": true "experimental": true
@ -8645,6 +8700,12 @@
"name": "attached", "name": "attached",
"type": "boolean", "type": "boolean",
"description": "Whether the target has an attached client." "description": "Whether the target has an attached client."
},
{
"name": "openerId",
"optional": true,
"$ref": "TargetID",
"description": "Opener target Id"
} }
] ]
}, },
@ -8869,6 +8930,13 @@
"$ref": "BrowserContextID", "$ref": "BrowserContextID",
"description": "The browser context to create the page in (headless chrome only).", "description": "The browser context to create the page in (headless chrome only).",
"optional": true "optional": true
},
{
"name": "enableBeginFrameControl",
"type": "boolean",
"description": "Whether BeginFrames for this target will be controlled via DevTools (headless chrome only, not supported on MacOS yet, false by default).",
"optional": true,
"experimental": true
} }
], ],
"returns": [ "returns": [
@ -8986,6 +9054,110 @@
} }
] ]
}, },
{
"domain": "HeadlessExperimental",
"experimental": true,
"description": "This domain provides experimental commands only supported in headless mode.",
"dependencies": [
"Page",
"Runtime"
],
"types": [
{
"id": "ScreenshotParams",
"type": "object",
"properties": [
{
"name": "format",
"type": "string",
"optional": true,
"enum": [
"jpeg",
"png"
],
"description": "Image compression format (defaults to png)."
},
{
"name": "quality",
"type": "integer",
"optional": true,
"description": "Compression quality from range [0..100] (jpeg only)."
}
],
"description": "Encoding options for a screenshot."
}
],
"commands": [
{
"name": "enable",
"description": "Enables headless events for the target."
},
{
"name": "disable",
"description": "Disables headless events for the target."
},
{
"name": "beginFrame",
"parameters": [
{
"name": "frameTime",
"$ref": "Runtime.Timestamp",
"optional": true,
"description": "Timestamp of this BeginFrame (milliseconds since epoch). If not set, the current time will be used."
},
{
"name": "deadline",
"$ref": "Runtime.Timestamp",
"optional": true,
"description": "Deadline of this BeginFrame (milliseconds since epoch). If not set, the deadline will be calculated from the frameTime and interval."
},
{
"name": "interval",
"type": "number",
"optional": true,
"description": "The interval between BeginFrames that is reported to the compositor, in milliseconds. Defaults to a 60 frames/second interval, i.e. about 16.666 milliseconds."
},
{
"name": "screenshot",
"$ref": "ScreenshotParams",
"optional": true,
"description": "If set, a screenshot of the frame will be captured and returned in the response. Otherwise, no screenshot will be captured."
}
],
"returns": [
{
"name": "hasDamage",
"type": "boolean",
"description": "Whether the BeginFrame resulted in damage and, thus, a new frame was committed to the display."
},
{
"name": "screenshotData",
"type": "string",
"optional": true,
"description": "Base64-encoded image data of the screenshot, if one was requested and successfully taken."
}
],
"description": "Sends a BeginFrame to the target and returns when the frame was completed. Optionally captures a screenshot from the resulting frame. Requires that the target was created with enabled BeginFrameControl."
}
],
"events": [
{
"name": "needsBeginFramesChanged",
"description": "Issued when the target starts or stops needing BeginFrames.",
"parameters": [
{
"name": "needsBeginFrames",
"type": "boolean",
"description": "True if BeginFrames are needed, false otherwise."
}
]
},
{
"name": "mainFrameReadyForScreenshots",
"description": "Issued when the main frame has first submitted a frame to the browser. May only be fired while a BeginFrame is in flight. Before this event, screenshotting requests may fail."
}
]
},
{ {
"domain": "ServiceWorker", "domain": "ServiceWorker",
"experimental": true, "experimental": true,
@ -11712,6 +11884,10 @@
} }
], ],
"commands": [ "commands": [
{
"name": "close",
"description": "Close browser gracefully."
},
{ {
"name": "getWindowForTarget", "name": "getWindowForTarget",
"description": "Get the browser window that contains the devtools target.", "description": "Get the browser window that contains the devtools target.",
@ -13219,6 +13395,13 @@
"optional": true, "optional": true,
"description": "Regex pattern for the URLs of the resources to set breakpoints on. Either <code>url</code> or <code>urlRegex</code> must be specified." "description": "Regex pattern for the URLs of the resources to set breakpoints on. Either <code>url</code> or <code>urlRegex</code> must be specified."
}, },
{
"name": "scriptHash",
"type": "string",
"optional": true,
"experimental": true,
"description": "Script hash of the resources to set breakpoint on."
},
{ {
"name": "columnNumber", "name": "columnNumber",
"type": "integer", "type": "integer",

View File

@ -127,7 +127,7 @@ func (p *{%s= typ %}) Do(ctxt context.Context, h cdp.Handler) ({%s= retTypeList
if res.Base64encoded {{% endif %} if res.Base64encoded {{% endif %}
dec, err = base64.StdEncoding.DecodeString(res.{%s= b64ret.GoName(false) %}) dec, err = base64.StdEncoding.DecodeString(res.{%s= b64ret.GoName(false) %})
if err != nil { if err != nil {
return nil, err return {%s= emptyRet %}err
}{% if b64cond %} }{% if b64cond %}
} else { } else {
dec = []byte(res.{%s= b64ret.GoName(false) %}) dec = []byte(res.{%s= b64ret.GoName(false) %})

View File

@ -549,7 +549,11 @@ func (p *`)
//line templates/domain.qtpl:128 //line templates/domain.qtpl:128
qw422016.N().S(`) qw422016.N().S(`)
if err != nil { if err != nil {
return nil, err return `)
//line templates/domain.qtpl:130
qw422016.N().S(emptyRet)
//line templates/domain.qtpl:130
qw422016.N().S(`err
}`) }`)
//line templates/domain.qtpl:131 //line templates/domain.qtpl:131
if b64cond { if b64cond {