Updating to latest protocol.json

This commit is contained in:
Kenneth Shaw 2017-02-25 07:21:58 +07:00
parent 3a264ed3ff
commit 826072d0bf
3 changed files with 59 additions and 4 deletions

View File

@ -6,6 +6,7 @@ import (
json "encoding/json" json "encoding/json"
cdp "github.com/knq/chromedp/cdp" cdp "github.com/knq/chromedp/cdp"
debugger "github.com/knq/chromedp/cdp/debugger" debugger "github.com/knq/chromedp/cdp/debugger"
dom "github.com/knq/chromedp/cdp/dom"
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"
@ -1717,6 +1718,8 @@ func easyjsonC5a4559bDecodeGithubComKnqChromedpCdpPage21(in *jlexer.Lexer, out *
switch key { switch key {
case "url": case "url":
out.URL = string(in.String()) out.URL = string(in.String())
case "referrer":
out.Referrer = string(in.String())
default: default:
in.SkipRecursive() in.SkipRecursive()
} }
@ -1737,6 +1740,14 @@ func easyjsonC5a4559bEncodeGithubComKnqChromedpCdpPage21(out *jwriter.Writer, in
first = false first = false
out.RawString("\"url\":") out.RawString("\"url\":")
out.String(string(in.URL)) out.String(string(in.URL))
if in.Referrer != "" {
if !first {
out.RawByte(',')
}
first = false
out.RawString("\"referrer\":")
out.String(string(in.Referrer))
}
out.RawByte('}') out.RawByte('}')
} }
@ -2454,6 +2465,16 @@ func easyjsonC5a4559bDecodeGithubComKnqChromedpCdpPage30(in *jlexer.Lexer, out *
} }
(*out.VisualViewport).UnmarshalEasyJSON(in) (*out.VisualViewport).UnmarshalEasyJSON(in)
} }
case "contentSize":
if in.IsNull() {
in.Skip()
out.ContentSize = nil
} else {
if out.ContentSize == nil {
out.ContentSize = new(dom.Rect)
}
(*out.ContentSize).UnmarshalEasyJSON(in)
}
default: default:
in.SkipRecursive() in.SkipRecursive()
} }
@ -2492,6 +2513,18 @@ func easyjsonC5a4559bEncodeGithubComKnqChromedpCdpPage30(out *jwriter.Writer, in
(*in.VisualViewport).MarshalEasyJSON(out) (*in.VisualViewport).MarshalEasyJSON(out)
} }
} }
if in.ContentSize != nil {
if !first {
out.RawByte(',')
}
first = false
out.RawString("\"contentSize\":")
if in.ContentSize == nil {
out.RawString("null")
} else {
(*in.ContentSize).MarshalEasyJSON(out)
}
}
out.RawByte('}') out.RawByte('}')
} }

View File

@ -15,6 +15,7 @@ import (
cdp "github.com/knq/chromedp/cdp" cdp "github.com/knq/chromedp/cdp"
"github.com/knq/chromedp/cdp/debugger" "github.com/knq/chromedp/cdp/debugger"
"github.com/knq/chromedp/cdp/dom"
) )
// EnableParams enables page domain notifications. // EnableParams enables page domain notifications.
@ -160,7 +161,8 @@ func (p *ReloadParams) Do(ctxt context.Context, h cdp.Handler) (err error) {
// NavigateParams navigates current page to the given URL. // NavigateParams navigates current page to the given URL.
type NavigateParams struct { type NavigateParams struct {
URL string `json:"url"` // URL to navigate the page to. URL string `json:"url"` // URL to navigate the page to.
Referrer string `json:"referrer,omitempty"` // Referrer URL.
} }
// Navigate navigates current page to the given URL. // Navigate navigates current page to the given URL.
@ -173,6 +175,12 @@ func Navigate(url string) *NavigateParams {
} }
} }
// WithReferrer referrer URL.
func (p NavigateParams) WithReferrer(referrer string) *NavigateParams {
p.Referrer = referrer
return &p
}
// NavigateReturns return values. // NavigateReturns return values.
type NavigateReturns struct { type NavigateReturns struct {
FrameID cdp.FrameID `json:"frameId,omitempty"` // Frame id that will be navigated. FrameID cdp.FrameID `json:"frameId,omitempty"` // Frame id that will be navigated.
@ -795,6 +803,7 @@ func GetLayoutMetrics() *GetLayoutMetricsParams {
type GetLayoutMetricsReturns struct { type GetLayoutMetricsReturns struct {
LayoutViewport *LayoutViewport `json:"layoutViewport,omitempty"` // Metrics relating to the layout viewport. LayoutViewport *LayoutViewport `json:"layoutViewport,omitempty"` // Metrics relating to the layout viewport.
VisualViewport *VisualViewport `json:"visualViewport,omitempty"` // Metrics relating to the visual viewport. VisualViewport *VisualViewport `json:"visualViewport,omitempty"` // Metrics relating to the visual viewport.
ContentSize *dom.Rect `json:"contentSize,omitempty"` // Size of scrollable area.
} }
// Do executes Page.getLayoutMetrics against the provided context and // Do executes Page.getLayoutMetrics against the provided context and
@ -803,13 +812,14 @@ type GetLayoutMetricsReturns struct {
// returns: // returns:
// layoutViewport - Metrics relating to the layout viewport. // layoutViewport - Metrics relating to the layout viewport.
// visualViewport - Metrics relating to the visual viewport. // visualViewport - Metrics relating to the visual viewport.
func (p *GetLayoutMetricsParams) Do(ctxt context.Context, h cdp.Handler) (layoutViewport *LayoutViewport, visualViewport *VisualViewport, err error) { // contentSize - Size of scrollable area.
func (p *GetLayoutMetricsParams) Do(ctxt context.Context, h cdp.Handler) (layoutViewport *LayoutViewport, visualViewport *VisualViewport, contentSize *dom.Rect, err error) {
// execute // execute
var res GetLayoutMetricsReturns var res GetLayoutMetricsReturns
err = h.Execute(ctxt, cdp.CommandPageGetLayoutMetrics, nil, &res) err = h.Execute(ctxt, cdp.CommandPageGetLayoutMetrics, nil, &res)
if err != nil { if err != nil {
return nil, nil, err return nil, nil, nil, err
} }
return res.LayoutViewport, res.VisualViewport, nil return res.LayoutViewport, res.VisualViewport, res.ContentSize, nil
} }

View File

@ -522,6 +522,13 @@
"name": "url", "name": "url",
"type": "string", "type": "string",
"description": "URL to navigate the page to." "description": "URL to navigate the page to."
},
{
"name": "referrer",
"type": "string",
"optional": true,
"experimental": true,
"description": "Referrer URL."
} }
], ],
"returns": [ "returns": [
@ -1092,6 +1099,11 @@
"name": "visualViewport", "name": "visualViewport",
"$ref": "VisualViewport", "$ref": "VisualViewport",
"description": "Metrics relating to the visual viewport." "description": "Metrics relating to the visual viewport."
},
{
"name": "contentSize",
"$ref": "DOM.Rect",
"description": "Size of scrollable area."
} }
] ]
} }