Updating to latest protocol.json

This commit is contained in:
Kenneth Shaw 2017-10-24 09:06:01 +07:00
parent 60dbb97d45
commit 89723e0ce3
12 changed files with 642 additions and 545 deletions

View File

@ -188,7 +188,7 @@ const (
CommandNetworkSetBypassServiceWorker MethodType = "Network.setBypassServiceWorker" CommandNetworkSetBypassServiceWorker MethodType = "Network.setBypassServiceWorker"
CommandNetworkSetDataSizeLimitsForTest MethodType = "Network.setDataSizeLimitsForTest" CommandNetworkSetDataSizeLimitsForTest MethodType = "Network.setDataSizeLimitsForTest"
CommandNetworkGetCertificate MethodType = "Network.getCertificate" CommandNetworkGetCertificate MethodType = "Network.getCertificate"
CommandNetworkSetRequestInterceptionEnabled MethodType = "Network.setRequestInterceptionEnabled" CommandNetworkSetRequestInterception MethodType = "Network.setRequestInterception"
CommandNetworkContinueInterceptedRequest MethodType = "Network.continueInterceptedRequest" CommandNetworkContinueInterceptedRequest MethodType = "Network.continueInterceptedRequest"
EventDatabaseAddDatabase MethodType = "Database.addDatabase" EventDatabaseAddDatabase MethodType = "Database.addDatabase"
CommandDatabaseEnable MethodType = "Database.enable" CommandDatabaseEnable MethodType = "Database.enable"
@ -797,8 +797,8 @@ func (t *MethodType) UnmarshalEasyJSON(in *jlexer.Lexer) {
*t = CommandNetworkSetDataSizeLimitsForTest *t = CommandNetworkSetDataSizeLimitsForTest
case CommandNetworkGetCertificate: case CommandNetworkGetCertificate:
*t = CommandNetworkGetCertificate *t = CommandNetworkGetCertificate
case CommandNetworkSetRequestInterceptionEnabled: case CommandNetworkSetRequestInterception:
*t = CommandNetworkSetRequestInterceptionEnabled *t = CommandNetworkSetRequestInterception
case CommandNetworkContinueInterceptedRequest: case CommandNetworkContinueInterceptedRequest:
*t = CommandNetworkContinueInterceptedRequest *t = CommandNetworkContinueInterceptedRequest
case EventDatabaseAddDatabase: case EventDatabaseAddDatabase:

View File

@ -422,7 +422,7 @@ func UnmarshalMessage(msg *cdp.Message) (interface{}, error) {
case cdp.CommandNetworkGetCertificate: case cdp.CommandNetworkGetCertificate:
v = new(network.GetCertificateReturns) v = new(network.GetCertificateReturns)
case cdp.CommandNetworkSetRequestInterceptionEnabled: case cdp.CommandNetworkSetRequestInterception:
return emptyVal, nil return emptyVal, nil
case cdp.CommandNetworkContinueInterceptedRequest: case cdp.CommandNetworkContinueInterceptedRequest:

View File

@ -42,6 +42,8 @@ func easyjsonC5a4559bDecodeGithubComKnqChromedpCdpEmulation(in *jlexer.Lexer, ou
(out.Policy).UnmarshalEasyJSON(in) (out.Policy).UnmarshalEasyJSON(in)
case "budget": case "budget":
out.Budget = int64(in.Int64()) out.Budget = int64(in.Int64())
case "maxVirtualTimeTaskStarvationCount":
out.MaxVirtualTimeTaskStarvationCount = int64(in.Int64())
default: default:
in.SkipRecursive() in.SkipRecursive()
} }
@ -70,6 +72,14 @@ func easyjsonC5a4559bEncodeGithubComKnqChromedpCdpEmulation(out *jwriter.Writer,
out.RawString("\"budget\":") out.RawString("\"budget\":")
out.Int64(int64(in.Budget)) out.Int64(int64(in.Budget))
} }
if in.MaxVirtualTimeTaskStarvationCount != 0 {
if !first {
out.RawByte(',')
}
first = false
out.RawString("\"maxVirtualTimeTaskStarvationCount\":")
out.Int64(int64(in.MaxVirtualTimeTaskStarvationCount))
}
out.RawByte('}') out.RawByte('}')
} }

View File

@ -376,8 +376,9 @@ func (p *CanEmulateParams) Do(ctxt context.Context, h cdp.Handler) (result bool,
// real-time with a synthetic time source) and sets the current virtual time // real-time with a synthetic time source) and sets the current virtual time
// policy. Note this supersedes any previous time budget. // policy. Note this supersedes any previous time budget.
type SetVirtualTimePolicyParams struct { type SetVirtualTimePolicyParams struct {
Policy VirtualTimePolicy `json:"policy"` Policy VirtualTimePolicy `json:"policy"`
Budget int64 `json:"budget,omitempty"` // If set, after this many virtual milliseconds have elapsed virtual time will be paused and a virtualTimeBudgetExpired event is sent. Budget int64 `json:"budget,omitempty"` // If set, after this many virtual milliseconds have elapsed virtual time will be paused and a virtualTimeBudgetExpired event is sent.
MaxVirtualTimeTaskStarvationCount int64 `json:"maxVirtualTimeTaskStarvationCount,omitempty"` // If set this specifies the maximum number of tasks that can be run before virtual is forced forwards to prevent deadlock.
} }
// SetVirtualTimePolicy turns on virtual time for all frames (replacing // SetVirtualTimePolicy turns on virtual time for all frames (replacing
@ -399,6 +400,14 @@ func (p SetVirtualTimePolicyParams) WithBudget(budget int64) *SetVirtualTimePoli
return &p return &p
} }
// WithMaxVirtualTimeTaskStarvationCount if set this specifies the maximum
// number of tasks that can be run before virtual is forced forwards to prevent
// deadlock.
func (p SetVirtualTimePolicyParams) WithMaxVirtualTimeTaskStarvationCount(maxVirtualTimeTaskStarvationCount int64) *SetVirtualTimePolicyParams {
p.MaxVirtualTimeTaskStarvationCount = maxVirtualTimeTaskStarvationCount
return &p
}
// Do executes Emulation.setVirtualTimePolicy against the provided context and // Do executes Emulation.setVirtualTimePolicy against the provided context and
// target handler. // target handler.
func (p *SetVirtualTimePolicyParams) Do(ctxt context.Context, h cdp.Handler) (err error) { func (p *SetVirtualTimePolicyParams) Do(ctxt context.Context, h cdp.Handler) (err error) {

View File

@ -362,6 +362,8 @@ func easyjsonC5a4559bDecodeGithubComKnqChromedpCdpHeadlessexperimental5(in *jlex
switch key { switch key {
case "hasDamage": case "hasDamage":
out.HasDamage = bool(in.Bool()) out.HasDamage = bool(in.Bool())
case "mainFrameContentUpdated":
out.MainFrameContentUpdated = bool(in.Bool())
case "screenshotData": case "screenshotData":
out.ScreenshotData = string(in.String()) out.ScreenshotData = string(in.String())
default: default:
@ -386,6 +388,14 @@ func easyjsonC5a4559bEncodeGithubComKnqChromedpCdpHeadlessexperimental5(out *jwr
out.RawString("\"hasDamage\":") out.RawString("\"hasDamage\":")
out.Bool(bool(in.HasDamage)) out.Bool(bool(in.HasDamage))
} }
if in.MainFrameContentUpdated {
if !first {
out.RawByte(',')
}
first = false
out.RawString("\"mainFrameContentUpdated\":")
out.Bool(bool(in.MainFrameContentUpdated))
}
if in.ScreenshotData != "" { if in.ScreenshotData != "" {
if !first { if !first {
out.RawByte(',') out.RawByte(',')

View File

@ -95,8 +95,9 @@ func (p BeginFrameParams) WithScreenshot(screenshot *ScreenshotParams) *BeginFra
// BeginFrameReturns return values. // BeginFrameReturns return values.
type BeginFrameReturns struct { type BeginFrameReturns struct {
HasDamage bool `json:"hasDamage,omitempty"` // Whether the BeginFrame resulted in damage and, thus, a new frame was committed to the display. 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. MainFrameContentUpdated bool `json:"mainFrameContentUpdated,omitempty"` // Whether the main frame submitted a new display frame in response to this BeginFrame.
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 // Do executes HeadlessExperimental.beginFrame against the provided context and
@ -104,20 +105,21 @@ type BeginFrameReturns struct {
// //
// returns: // returns:
// hasDamage - Whether the BeginFrame resulted in damage and, thus, a new frame was committed to the display. // hasDamage - Whether the BeginFrame resulted in damage and, thus, a new frame was committed to the display.
// mainFrameContentUpdated - Whether the main frame submitted a new display frame in response to this BeginFrame.
// screenshotData - Base64-encoded image data of the screenshot, if one was requested and successfully taken. // 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) { func (p *BeginFrameParams) Do(ctxt context.Context, h cdp.Handler) (hasDamage bool, mainFrameContentUpdated bool, screenshotData []byte, err error) {
// execute // execute
var res BeginFrameReturns var res BeginFrameReturns
err = h.Execute(ctxt, cdp.CommandHeadlessExperimentalBeginFrame, p, &res) err = h.Execute(ctxt, cdp.CommandHeadlessExperimentalBeginFrame, p, &res)
if err != nil { if err != nil {
return false, nil, err return false, false, nil, err
} }
// decode // decode
var dec []byte var dec []byte
dec, err = base64.StdEncoding.DecodeString(res.ScreenshotData) dec, err = base64.StdEncoding.DecodeString(res.ScreenshotData)
if err != nil { if err != nil {
return false, nil, err return false, false, nil, err
} }
return res.HasDamage, dec, nil return res.HasDamage, res.MainFrameContentUpdated, dec, nil
} }

View File

@ -1102,6 +1102,8 @@ func easyjsonC5a4559bDecodeGithubComKnqChromedpCdpInput8(in *jlexer.Lexer, out *
out.IsKeypad = bool(in.Bool()) out.IsKeypad = bool(in.Bool())
case "isSystemKey": case "isSystemKey":
out.IsSystemKey = bool(in.Bool()) out.IsSystemKey = bool(in.Bool())
case "location":
out.Location = int64(in.Int64())
default: default:
in.SkipRecursive() in.SkipRecursive()
} }
@ -1222,6 +1224,14 @@ func easyjsonC5a4559bEncodeGithubComKnqChromedpCdpInput8(out *jwriter.Writer, in
out.RawString("\"isSystemKey\":") out.RawString("\"isSystemKey\":")
out.Bool(bool(in.IsSystemKey)) out.Bool(bool(in.IsSystemKey))
} }
if in.Location != 0 {
if !first {
out.RawByte(',')
}
first = false
out.RawString("\"location\":")
out.Int64(int64(in.Location))
}
out.RawByte('}') out.RawByte('}')
} }

View File

@ -49,6 +49,7 @@ type DispatchKeyEventParams struct {
AutoRepeat bool `json:"autoRepeat,omitempty"` // Whether the event was generated from auto repeat (default: false). AutoRepeat bool `json:"autoRepeat,omitempty"` // Whether the event was generated from auto repeat (default: false).
IsKeypad bool `json:"isKeypad,omitempty"` // Whether the event was generated from the keypad (default: false). IsKeypad bool `json:"isKeypad,omitempty"` // Whether the event was generated from the keypad (default: false).
IsSystemKey bool `json:"isSystemKey,omitempty"` // Whether the event was a system key event (default: false). IsSystemKey bool `json:"isSystemKey,omitempty"` // Whether the event was a system key event (default: false).
Location int64 `json:"location,omitempty"` // Whether the event was from the left or right side of the keyboard. 1=Left, 2=Right (default: 0).
} }
// DispatchKeyEvent dispatches a key event to the page. // DispatchKeyEvent dispatches a key event to the page.
@ -143,6 +144,13 @@ func (p DispatchKeyEventParams) WithIsSystemKey(isSystemKey bool) *DispatchKeyEv
return &p return &p
} }
// WithLocation whether the event was from the left or right side of the
// keyboard. 1=Left, 2=Right (default: 0).
func (p DispatchKeyEventParams) WithLocation(location int64) *DispatchKeyEventParams {
p.Location = location
return &p
}
// Do executes Input.dispatchKeyEvent against the provided context and // Do executes Input.dispatchKeyEvent against the provided context and
// target handler. // target handler.
func (p *DispatchKeyEventParams) Do(ctxt context.Context, h cdp.Handler) (err error) { func (p *DispatchKeyEventParams) Do(ctxt context.Context, h cdp.Handler) (err error) {

File diff suppressed because it is too large Load Diff

View File

@ -15,7 +15,6 @@ 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,45 +702,27 @@ func (p *GetCertificateParams) Do(ctxt context.Context, h cdp.Handler) (tableNam
return res.TableNames, nil return res.TableNames, nil
} }
// SetRequestInterceptionEnabledParams sets the requests to intercept that // SetRequestInterceptionParams sets the requests to intercept that match a
// match a the provided patterns and optionally resource types. // the provided patterns and optionally resource types.
type SetRequestInterceptionEnabledParams struct { type SetRequestInterceptionParams 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. Patterns []*RequestPattern `json:"patterns"` // Requests matching any of these patterns will be forwarded and wait for the corresponding continueInterceptedRequest call.
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 // SetRequestInterception sets the requests to intercept that match a the
// the provided patterns and optionally resource types. // 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. // patterns - Requests matching any of these patterns will be forwarded and wait for the corresponding continueInterceptedRequest call.
func SetRequestInterceptionEnabled(enabled bool) *SetRequestInterceptionEnabledParams { func SetRequestInterception(patterns []*RequestPattern) *SetRequestInterceptionParams {
return &SetRequestInterceptionEnabledParams{ return &SetRequestInterceptionParams{
Enabled: enabled, Patterns: patterns,
} }
} }
// WithPatterns uRLs matching any of these patterns will be forwarded and // Do executes Network.setRequestInterception against the provided context 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).
func (p SetRequestInterceptionEnabledParams) WithPatterns(patterns []string) *SetRequestInterceptionEnabledParams {
p.Patterns = patterns
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
// target handler. // target handler.
func (p *SetRequestInterceptionEnabledParams) Do(ctxt context.Context, h cdp.Handler) (err error) { func (p *SetRequestInterceptionParams) Do(ctxt context.Context, h cdp.Handler) (err error) {
return h.Execute(ctxt, cdp.CommandNetworkSetRequestInterceptionEnabled, p, nil) return h.Execute(ctxt, cdp.CommandNetworkSetRequestInterception, p, nil)
} }
// ContinueInterceptedRequestParams response to Network.requestIntercepted // ContinueInterceptedRequestParams response to Network.requestIntercepted

View File

@ -481,6 +481,12 @@ type AuthChallengeResponse struct {
Password string `json:"password,omitempty"` // The password to provide, possibly empty. Should only be set if response is ProvideCredentials. Password string `json:"password,omitempty"` // The password to provide, possibly empty. Should only be set if response is ProvideCredentials.
} }
// RequestPattern request pattern for interception.
type RequestPattern struct {
URLPattern string `json:"urlPattern,omitempty"` // Wildcards ('*' -> zero or more, '?' -> exactly one) are allowed. Escape character is backslash. Omitting is equivalent to "*".
ResourceType page.ResourceType `json:"resourceType,omitempty"` // If set, only requests for matching resource types will be intercepted.
}
// ReferrerPolicy the referrer policy of the request, as defined in // ReferrerPolicy the referrer policy of the request, as defined in
// https://www.w3.org/TR/referrer-policy/. // https://www.w3.org/TR/referrer-policy/.
type ReferrerPolicy string type ReferrerPolicy string

View File

@ -2329,6 +2329,12 @@
"type": "integer", "type": "integer",
"optional": true, "optional": true,
"description": "If set, after this many virtual milliseconds have elapsed virtual time will be paused and a virtualTimeBudgetExpired event is sent." "description": "If set, after this many virtual milliseconds have elapsed virtual time will be paused and a virtualTimeBudgetExpired event is sent."
},
{
"name": "maxVirtualTimeTaskStarvationCount",
"type": "integer",
"optional": true,
"description": "If set this specifies the maximum number of tasks that can be run before virtual is forced forwards to prevent deadlock."
} }
], ],
"experimental": true "experimental": true
@ -3485,6 +3491,26 @@
} }
], ],
"experimental": true "experimental": true
},
{
"id": "RequestPattern",
"type": "object",
"description": "Request pattern for interception.",
"properties": [
{
"name": "urlPattern",
"type": "string",
"optional": true,
"description": "Wildcards ('*' -> zero or more, '?' -> exactly one) are allowed. Escape character is backslash. Omitting is equivalent to \"*\"."
},
{
"name": "resourceType",
"$ref": "Page.ResourceType",
"optional": true,
"description": "If set, only requests for matching resource types will be intercepted."
}
],
"experimental": true
} }
], ],
"commands": [ "commands": [
@ -3872,31 +3898,16 @@
"experimental": true "experimental": true
}, },
{ {
"name": "setRequestInterceptionEnabled", "name": "setRequestInterception",
"description": "Sets the requests to intercept that match a the provided patterns and optionally resource types.", "description": "Sets the requests to intercept that match a the provided patterns and optionally resource types.",
"parameters": [ "parameters": [
{
"name": "enabled",
"type": "boolean",
"description": "Whether requests should be intercepted. If patterns is not set, matches all and resets any previously set patterns. Other parameters are ignored if false."
},
{ {
"name": "patterns", "name": "patterns",
"type": "array", "type": "array",
"optional": true,
"items": { "items": {
"type": "string" "$ref": "RequestPattern"
}, },
"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": "Requests matching any of these patterns will be forwarded and wait for the corresponding continueInterceptedRequest call."
},
{
"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
@ -9130,6 +9141,11 @@
"type": "boolean", "type": "boolean",
"description": "Whether the BeginFrame resulted in damage and, thus, a new frame was committed to the display." "description": "Whether the BeginFrame resulted in damage and, thus, a new frame was committed to the display."
}, },
{
"name": "mainFrameContentUpdated",
"type": "boolean",
"description": "Whether the main frame submitted a new display frame in response to this BeginFrame."
},
{ {
"name": "screenshotData", "name": "screenshotData",
"type": "string", "type": "string",
@ -9598,6 +9614,13 @@
"type": "boolean", "type": "boolean",
"optional": true, "optional": true,
"description": "Whether the event was a system key event (default: false)." "description": "Whether the event was a system key event (default: false)."
},
{
"name": "location",
"type": "integer",
"optional": true,
"experimental": true,
"description": "Whether the event was from the left or right side of the keyboard. 1=Left, 2=Right (default: 0)."
} }
], ],
"description": "Dispatches a key event to the page." "description": "Dispatches a key event to the page."