Updating to latest protocol.json (clarifying timestamp behavior)

* Disabled AddOnLoadScript/RemoveOnLoadScript
* Updated chromedp-gen fixups for latest timestamp declarations
* Updated to latest protocol.json definitions
This commit is contained in:
Kenneth Shaw 2017-07-09 08:40:29 +07:00
parent 57826bddb1
commit 1e295eddfb
24 changed files with 1054 additions and 929 deletions

View File

@ -9,6 +9,7 @@ import (
"sync" "sync"
"time" "time"
"github.com/knq/sysutil"
"github.com/mailru/easyjson" "github.com/mailru/easyjson"
"github.com/mailru/easyjson/jlexer" "github.com/mailru/easyjson/jlexer"
"github.com/mailru/easyjson/jwriter" "github.com/mailru/easyjson/jwriter"
@ -74,8 +75,8 @@ const (
EventPageNavigationRequested MethodType = "Page.navigationRequested" EventPageNavigationRequested MethodType = "Page.navigationRequested"
CommandPageEnable MethodType = "Page.enable" CommandPageEnable MethodType = "Page.enable"
CommandPageDisable MethodType = "Page.disable" CommandPageDisable MethodType = "Page.disable"
CommandPageAddScriptToEvaluateOnLoad MethodType = "Page.addScriptToEvaluateOnLoad" CommandPageAddScriptToEvaluateOnNewDocument MethodType = "Page.addScriptToEvaluateOnNewDocument"
CommandPageRemoveScriptToEvaluateOnLoad MethodType = "Page.removeScriptToEvaluateOnLoad" CommandPageRemoveScriptToEvaluateOnNewDocument MethodType = "Page.removeScriptToEvaluateOnNewDocument"
CommandPageSetAutoAttachToCreatedPages MethodType = "Page.setAutoAttachToCreatedPages" CommandPageSetAutoAttachToCreatedPages MethodType = "Page.setAutoAttachToCreatedPages"
CommandPageReload MethodType = "Page.reload" CommandPageReload MethodType = "Page.reload"
CommandPageNavigate MethodType = "Page.navigate" CommandPageNavigate MethodType = "Page.navigate"
@ -177,7 +178,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"
CommandNetworkEnableRequestInterception MethodType = "Network.enableRequestInterception" CommandNetworkSetRequestInterceptionEnabled MethodType = "Network.setRequestInterceptionEnabled"
CommandNetworkContinueInterceptedRequest MethodType = "Network.continueInterceptedRequest" CommandNetworkContinueInterceptedRequest MethodType = "Network.continueInterceptedRequest"
EventDatabaseAddDatabase MethodType = "Database.addDatabase" EventDatabaseAddDatabase MethodType = "Database.addDatabase"
CommandDatabaseEnable MethodType = "Database.enable" CommandDatabaseEnable MethodType = "Database.enable"
@ -536,10 +537,10 @@ func (t *MethodType) UnmarshalEasyJSON(in *jlexer.Lexer) {
*t = CommandPageEnable *t = CommandPageEnable
case CommandPageDisable: case CommandPageDisable:
*t = CommandPageDisable *t = CommandPageDisable
case CommandPageAddScriptToEvaluateOnLoad: case CommandPageAddScriptToEvaluateOnNewDocument:
*t = CommandPageAddScriptToEvaluateOnLoad *t = CommandPageAddScriptToEvaluateOnNewDocument
case CommandPageRemoveScriptToEvaluateOnLoad: case CommandPageRemoveScriptToEvaluateOnNewDocument:
*t = CommandPageRemoveScriptToEvaluateOnLoad *t = CommandPageRemoveScriptToEvaluateOnNewDocument
case CommandPageSetAutoAttachToCreatedPages: case CommandPageSetAutoAttachToCreatedPages:
*t = CommandPageSetAutoAttachToCreatedPages *t = CommandPageSetAutoAttachToCreatedPages
case CommandPageReload: case CommandPageReload:
@ -742,8 +743,8 @@ func (t *MethodType) UnmarshalEasyJSON(in *jlexer.Lexer) {
*t = CommandNetworkSetDataSizeLimitsForTest *t = CommandNetworkSetDataSizeLimitsForTest
case CommandNetworkGetCertificate: case CommandNetworkGetCertificate:
*t = CommandNetworkGetCertificate *t = CommandNetworkGetCertificate
case CommandNetworkEnableRequestInterception: case CommandNetworkSetRequestInterceptionEnabled:
*t = CommandNetworkEnableRequestInterception *t = CommandNetworkSetRequestInterceptionEnabled
case CommandNetworkContinueInterceptedRequest: case CommandNetworkContinueInterceptedRequest:
*t = CommandNetworkContinueInterceptedRequest *t = CommandNetworkContinueInterceptedRequest
case EventDatabaseAddDatabase: case EventDatabaseAddDatabase:
@ -1501,16 +1502,16 @@ func (t LoaderID) String() string {
return string(t) return string(t)
} }
// Timestamp number of seconds since epoch. // TimeSinceEpoch uTC time in seconds, counted from January 1, 1970.
type Timestamp time.Time type TimeSinceEpoch time.Time
// Time returns the Timestamp as time.Time value. // Time returns the TimeSinceEpoch as time.Time value.
func (t Timestamp) Time() time.Time { func (t TimeSinceEpoch) Time() time.Time {
return time.Time(t) return time.Time(t)
} }
// MarshalEasyJSON satisfies easyjson.Marshaler. // MarshalEasyJSON satisfies easyjson.Marshaler.
func (t Timestamp) MarshalEasyJSON(out *jwriter.Writer) { func (t TimeSinceEpoch) MarshalEasyJSON(out *jwriter.Writer) {
v := float64(time.Time(t).UnixNano() / int64(time.Second)) v := float64(time.Time(t).UnixNano() / int64(time.Second))
out.Buffer.EnsureSpace(20) out.Buffer.EnsureSpace(20)
@ -1518,17 +1519,58 @@ func (t Timestamp) MarshalEasyJSON(out *jwriter.Writer) {
} }
// MarshalJSON satisfies json.Marshaler. // MarshalJSON satisfies json.Marshaler.
func (t Timestamp) MarshalJSON() ([]byte, error) { func (t TimeSinceEpoch) MarshalJSON() ([]byte, error) {
return easyjson.Marshal(t) return easyjson.Marshal(t)
} }
// UnmarshalEasyJSON satisfies easyjson.Unmarshaler. // UnmarshalEasyJSON satisfies easyjson.Unmarshaler.
func (t *Timestamp) UnmarshalEasyJSON(in *jlexer.Lexer) { func (t *TimeSinceEpoch) UnmarshalEasyJSON(in *jlexer.Lexer) {
*t = Timestamp(time.Unix(0, int64(in.Float64()*float64(time.Second)))) *t = TimeSinceEpoch(time.Unix(0, int64(in.Float64()*float64(time.Second))))
} }
// UnmarshalJSON satisfies json.Unmarshaler. // UnmarshalJSON satisfies json.Unmarshaler.
func (t *Timestamp) UnmarshalJSON(buf []byte) error { func (t *TimeSinceEpoch) UnmarshalJSON(buf []byte) error {
return easyjson.Unmarshal(buf, t)
}
// MonotonicTime monotonically increasing time in seconds since an arbitrary
// point in the past.
type MonotonicTime time.Time
// Time returns the MonotonicTime as time.Time value.
func (t MonotonicTime) Time() time.Time {
return time.Time(t)
}
// MonotonicTimeEpoch is the MonotonicTime time epoch.
var MonotonicTimeEpoch *time.Time
func init() {
// initialize epoch
bt := sysutil.BootTime()
MonotonicTimeEpoch = &bt
}
// MarshalEasyJSON satisfies easyjson.Marshaler.
func (t MonotonicTime) MarshalEasyJSON(out *jwriter.Writer) {
v := float64(time.Time(t).Sub(*MonotonicTimeEpoch)) / float64(time.Second)
out.Buffer.EnsureSpace(20)
out.Buffer.Buf = strconv.AppendFloat(out.Buffer.Buf, v, 'f', -1, 64)
}
// MarshalJSON satisfies json.Marshaler.
func (t MonotonicTime) MarshalJSON() ([]byte, error) {
return easyjson.Marshal(t)
}
// UnmarshalEasyJSON satisfies easyjson.Unmarshaler.
func (t *MonotonicTime) UnmarshalEasyJSON(in *jlexer.Lexer) {
*t = MonotonicTime(MonotonicTimeEpoch.Add(time.Duration(in.Float64() * float64(time.Second))))
}
// UnmarshalJSON satisfies json.Unmarshaler.
func (t *MonotonicTime) UnmarshalJSON(buf []byte) error {
return easyjson.Unmarshal(buf, t) return easyjson.Unmarshal(buf, t)
} }

View File

@ -77,10 +77,10 @@ func UnmarshalMessage(msg *cdp.Message) (interface{}, error) {
case cdp.CommandPageDisable: case cdp.CommandPageDisable:
return emptyVal, nil return emptyVal, nil
case cdp.CommandPageAddScriptToEvaluateOnLoad: case cdp.CommandPageAddScriptToEvaluateOnNewDocument:
v = new(page.AddScriptToEvaluateOnLoadReturns) v = new(page.AddScriptToEvaluateOnNewDocumentReturns)
case cdp.CommandPageRemoveScriptToEvaluateOnLoad: case cdp.CommandPageRemoveScriptToEvaluateOnNewDocument:
return emptyVal, nil return emptyVal, nil
case cdp.CommandPageSetAutoAttachToCreatedPages: case cdp.CommandPageSetAutoAttachToCreatedPages:
@ -389,7 +389,7 @@ func UnmarshalMessage(msg *cdp.Message) (interface{}, error) {
case cdp.CommandNetworkGetCertificate: case cdp.CommandNetworkGetCertificate:
v = new(network.GetCertificateReturns) v = new(network.GetCertificateReturns)
case cdp.CommandNetworkEnableRequestInterception: case cdp.CommandNetworkSetRequestInterceptionEnabled:
return emptyVal, nil return emptyVal, nil
case cdp.CommandNetworkContinueInterceptedRequest: case cdp.CommandNetworkContinueInterceptedRequest:

View File

@ -4,7 +4,6 @@ package heapprofiler
import ( import (
json "encoding/json" json "encoding/json"
cdp "github.com/knq/chromedp/cdp"
runtime "github.com/knq/chromedp/cdp/runtime" runtime "github.com/knq/chromedp/cdp/runtime"
easyjson "github.com/mailru/easyjson" easyjson "github.com/mailru/easyjson"
jlexer "github.com/mailru/easyjson/jlexer" jlexer "github.com/mailru/easyjson/jlexer"
@ -1113,15 +1112,7 @@ func easyjsonC5a4559bDecodeGithubComKnqChromedpCdpHeapprofiler14(in *jlexer.Lexe
case "lastSeenObjectId": case "lastSeenObjectId":
out.LastSeenObjectID = int64(in.Int64()) out.LastSeenObjectID = int64(in.Int64())
case "timestamp": case "timestamp":
if in.IsNull() { out.Timestamp = float64(in.Float64())
in.Skip()
out.Timestamp = nil
} else {
if out.Timestamp == nil {
out.Timestamp = new(cdp.Timestamp)
}
(*out.Timestamp).UnmarshalEasyJSON(in)
}
default: default:
in.SkipRecursive() in.SkipRecursive()
} }
@ -1147,11 +1138,7 @@ func easyjsonC5a4559bEncodeGithubComKnqChromedpCdpHeapprofiler14(out *jwriter.Wr
} }
first = false first = false
out.RawString("\"timestamp\":") out.RawString("\"timestamp\":")
if in.Timestamp == nil { out.Float64(float64(in.Timestamp))
out.RawString("null")
} else {
(*in.Timestamp).MarshalEasyJSON(out)
}
out.RawByte('}') out.RawByte('}')
} }

View File

@ -27,8 +27,8 @@ type EventReportHeapSnapshotProgress struct {
// then one or more heapStatsUpdate events will be sent before a new // then one or more heapStatsUpdate events will be sent before a new
// lastSeenObjectId event. // lastSeenObjectId event.
type EventLastSeenObjectID struct { type EventLastSeenObjectID struct {
LastSeenObjectID int64 `json:"lastSeenObjectId"` LastSeenObjectID int64 `json:"lastSeenObjectId"`
Timestamp *cdp.Timestamp `json:"timestamp"` Timestamp float64 `json:"timestamp"`
} }
// EventHeapStatsUpdate if heap objects tracking has been started then // EventHeapStatsUpdate if heap objects tracking has been started then

View File

@ -4,7 +4,6 @@ package input
import ( import (
json "encoding/json" json "encoding/json"
cdp "github.com/knq/chromedp/cdp"
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"
@ -632,7 +631,7 @@ func easyjsonC5a4559bDecodeGithubComKnqChromedpCdpInput5(in *jlexer.Lexer, out *
out.Timestamp = nil out.Timestamp = nil
} else { } else {
if out.Timestamp == nil { if out.Timestamp == nil {
out.Timestamp = new(cdp.Timestamp) out.Timestamp = new(TimeSinceEpoch)
} }
(*out.Timestamp).UnmarshalEasyJSON(in) (*out.Timestamp).UnmarshalEasyJSON(in)
} }
@ -812,7 +811,7 @@ func easyjsonC5a4559bDecodeGithubComKnqChromedpCdpInput6(in *jlexer.Lexer, out *
out.Timestamp = nil out.Timestamp = nil
} else { } else {
if out.Timestamp == nil { if out.Timestamp == nil {
out.Timestamp = new(cdp.Timestamp) out.Timestamp = new(TimeSinceEpoch)
} }
(*out.Timestamp).UnmarshalEasyJSON(in) (*out.Timestamp).UnmarshalEasyJSON(in)
} }
@ -936,7 +935,7 @@ func easyjsonC5a4559bDecodeGithubComKnqChromedpCdpInput7(in *jlexer.Lexer, out *
out.Timestamp = nil out.Timestamp = nil
} else { } else {
if out.Timestamp == nil { if out.Timestamp == nil {
out.Timestamp = new(cdp.Timestamp) out.Timestamp = new(TimeSinceEpoch)
} }
(*out.Timestamp).UnmarshalEasyJSON(in) (*out.Timestamp).UnmarshalEasyJSON(in)
} }
@ -1067,7 +1066,7 @@ func easyjsonC5a4559bDecodeGithubComKnqChromedpCdpInput8(in *jlexer.Lexer, out *
out.Timestamp = nil out.Timestamp = nil
} else { } else {
if out.Timestamp == nil { if out.Timestamp == nil {
out.Timestamp = new(cdp.Timestamp) out.Timestamp = new(TimeSinceEpoch)
} }
(*out.Timestamp).UnmarshalEasyJSON(in) (*out.Timestamp).UnmarshalEasyJSON(in)
} }

View File

@ -36,19 +36,19 @@ func (p *SetIgnoreInputEventsParams) Do(ctxt context.Context, h cdp.Handler) (er
// DispatchKeyEventParams dispatches a key event to the page. // DispatchKeyEventParams dispatches a key event to the page.
type DispatchKeyEventParams struct { type DispatchKeyEventParams struct {
Type KeyType `json:"type"` // Type of the key event. Type KeyType `json:"type"` // Type of the key event.
Modifiers Modifier `json:"modifiers,omitempty"` // Bit field representing pressed modifier keys. Alt=1, Ctrl=2, Meta/Command=4, Shift=8 (default: 0). Modifiers Modifier `json:"modifiers,omitempty"` // Bit field representing pressed modifier keys. Alt=1, Ctrl=2, Meta/Command=4, Shift=8 (default: 0).
Timestamp *cdp.Timestamp `json:"timestamp,omitempty"` // Time at which the event occurred. Measured in UTC time in seconds since January 1, 1970 (default: current time). Timestamp *TimeSinceEpoch `json:"timestamp,omitempty"` // Time at which the event occurred.
Text string `json:"text,omitempty"` // Text as generated by processing a virtual key code with a keyboard layout. Not needed for for keyUp and rawKeyDown events (default: "") Text string `json:"text,omitempty"` // Text as generated by processing a virtual key code with a keyboard layout. Not needed for for keyUp and rawKeyDown events (default: "")
UnmodifiedText string `json:"unmodifiedText,omitempty"` // Text that would have been generated by the keyboard if no modifiers were pressed (except for shift). Useful for shortcut (accelerator) key handling (default: ""). UnmodifiedText string `json:"unmodifiedText,omitempty"` // Text that would have been generated by the keyboard if no modifiers were pressed (except for shift). Useful for shortcut (accelerator) key handling (default: "").
KeyIdentifier string `json:"keyIdentifier,omitempty"` // Unique key identifier (e.g., 'U+0041') (default: ""). KeyIdentifier string `json:"keyIdentifier,omitempty"` // Unique key identifier (e.g., 'U+0041') (default: "").
Code string `json:"code,omitempty"` // Unique DOM defined string value for each physical key (e.g., 'KeyA') (default: ""). Code string `json:"code,omitempty"` // Unique DOM defined string value for each physical key (e.g., 'KeyA') (default: "").
Key string `json:"key,omitempty"` // Unique DOM defined string value describing the meaning of the key in the context of active modifiers, keyboard layout, etc (e.g., 'AltGr') (default: ""). Key string `json:"key,omitempty"` // Unique DOM defined string value describing the meaning of the key in the context of active modifiers, keyboard layout, etc (e.g., 'AltGr') (default: "").
WindowsVirtualKeyCode int64 `json:"windowsVirtualKeyCode,omitempty"` // Windows virtual key code (default: 0). WindowsVirtualKeyCode int64 `json:"windowsVirtualKeyCode,omitempty"` // Windows virtual key code (default: 0).
NativeVirtualKeyCode int64 `json:"nativeVirtualKeyCode,omitempty"` // Native virtual key code (default: 0). NativeVirtualKeyCode int64 `json:"nativeVirtualKeyCode,omitempty"` // Native virtual key code (default: 0).
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).
} }
// DispatchKeyEvent dispatches a key event to the page. // DispatchKeyEvent dispatches a key event to the page.
@ -68,9 +68,8 @@ func (p DispatchKeyEventParams) WithModifiers(modifiers Modifier) *DispatchKeyEv
return &p return &p
} }
// WithTimestamp time at which the event occurred. Measured in UTC time in // WithTimestamp time at which the event occurred.
// seconds since January 1, 1970 (default: current time). func (p DispatchKeyEventParams) WithTimestamp(timestamp *TimeSinceEpoch) *DispatchKeyEventParams {
func (p DispatchKeyEventParams) WithTimestamp(timestamp *cdp.Timestamp) *DispatchKeyEventParams {
p.Timestamp = timestamp p.Timestamp = timestamp
return &p return &p
} }
@ -152,13 +151,13 @@ func (p *DispatchKeyEventParams) Do(ctxt context.Context, h cdp.Handler) (err er
// DispatchMouseEventParams dispatches a mouse event to the page. // DispatchMouseEventParams dispatches a mouse event to the page.
type DispatchMouseEventParams struct { type DispatchMouseEventParams struct {
Type MouseType `json:"type"` // Type of the mouse event. Type MouseType `json:"type"` // Type of the mouse event.
X int64 `json:"x"` // X coordinate of the event relative to the main frame's viewport. X int64 `json:"x"` // X coordinate of the event relative to the main frame's viewport.
Y int64 `json:"y"` // Y coordinate of the event relative to the main frame's viewport. 0 refers to the top of the viewport and Y increases as it proceeds towards the bottom of the viewport. Y int64 `json:"y"` // Y coordinate of the event relative to the main frame's viewport. 0 refers to the top of the viewport and Y increases as it proceeds towards the bottom of the viewport.
Modifiers Modifier `json:"modifiers,omitempty"` // Bit field representing pressed modifier keys. Alt=1, Ctrl=2, Meta/Command=4, Shift=8 (default: 0). Modifiers Modifier `json:"modifiers,omitempty"` // Bit field representing pressed modifier keys. Alt=1, Ctrl=2, Meta/Command=4, Shift=8 (default: 0).
Timestamp *cdp.Timestamp `json:"timestamp,omitempty"` // Time at which the event occurred. Measured in UTC time in seconds since January 1, 1970 (default: current time). Timestamp *TimeSinceEpoch `json:"timestamp,omitempty"` // Time at which the event occurred.
Button ButtonType `json:"button,omitempty"` // Mouse button (default: "none"). Button ButtonType `json:"button,omitempty"` // Mouse button (default: "none").
ClickCount int64 `json:"clickCount,omitempty"` // Number of times the mouse button was clicked (default: 0). ClickCount int64 `json:"clickCount,omitempty"` // Number of times the mouse button was clicked (default: 0).
} }
// DispatchMouseEvent dispatches a mouse event to the page. // DispatchMouseEvent dispatches a mouse event to the page.
@ -182,9 +181,8 @@ func (p DispatchMouseEventParams) WithModifiers(modifiers Modifier) *DispatchMou
return &p return &p
} }
// WithTimestamp time at which the event occurred. Measured in UTC time in // WithTimestamp time at which the event occurred.
// seconds since January 1, 1970 (default: current time). func (p DispatchMouseEventParams) WithTimestamp(timestamp *TimeSinceEpoch) *DispatchMouseEventParams {
func (p DispatchMouseEventParams) WithTimestamp(timestamp *cdp.Timestamp) *DispatchMouseEventParams {
p.Timestamp = timestamp p.Timestamp = timestamp
return &p return &p
} }
@ -209,10 +207,10 @@ func (p *DispatchMouseEventParams) Do(ctxt context.Context, h cdp.Handler) (err
// DispatchTouchEventParams dispatches a touch event to the page. // DispatchTouchEventParams dispatches a touch event to the page.
type DispatchTouchEventParams struct { type DispatchTouchEventParams struct {
Type TouchType `json:"type"` // Type of the touch event. Type TouchType `json:"type"` // Type of the touch event.
TouchPoints []*TouchPoint `json:"touchPoints"` // Touch points. TouchPoints []*TouchPoint `json:"touchPoints"` // Touch points.
Modifiers Modifier `json:"modifiers,omitempty"` // Bit field representing pressed modifier keys. Alt=1, Ctrl=2, Meta/Command=4, Shift=8 (default: 0). Modifiers Modifier `json:"modifiers,omitempty"` // Bit field representing pressed modifier keys. Alt=1, Ctrl=2, Meta/Command=4, Shift=8 (default: 0).
Timestamp *cdp.Timestamp `json:"timestamp,omitempty"` // Time at which the event occurred. Measured in UTC time in seconds since January 1, 1970 (default: current time). Timestamp *TimeSinceEpoch `json:"timestamp,omitempty"` // Time at which the event occurred.
} }
// DispatchTouchEvent dispatches a touch event to the page. // DispatchTouchEvent dispatches a touch event to the page.
@ -234,9 +232,8 @@ func (p DispatchTouchEventParams) WithModifiers(modifiers Modifier) *DispatchTou
return &p return &p
} }
// WithTimestamp time at which the event occurred. Measured in UTC time in // WithTimestamp time at which the event occurred.
// seconds since January 1, 1970 (default: current time). func (p DispatchTouchEventParams) WithTimestamp(timestamp *TimeSinceEpoch) *DispatchTouchEventParams {
func (p DispatchTouchEventParams) WithTimestamp(timestamp *cdp.Timestamp) *DispatchTouchEventParams {
p.Timestamp = timestamp p.Timestamp = timestamp
return &p return &p
} }
@ -250,15 +247,15 @@ func (p *DispatchTouchEventParams) Do(ctxt context.Context, h cdp.Handler) (err
// EmulateTouchFromMouseEventParams emulates touch event from the mouse event // EmulateTouchFromMouseEventParams emulates touch event from the mouse event
// parameters. // parameters.
type EmulateTouchFromMouseEventParams struct { type EmulateTouchFromMouseEventParams struct {
Type MouseType `json:"type"` // Type of the mouse event. Type MouseType `json:"type"` // Type of the mouse event.
X int64 `json:"x"` // X coordinate of the mouse pointer in DIP. X int64 `json:"x"` // X coordinate of the mouse pointer in DIP.
Y int64 `json:"y"` // Y coordinate of the mouse pointer in DIP. Y int64 `json:"y"` // Y coordinate of the mouse pointer in DIP.
Timestamp *cdp.Timestamp `json:"timestamp"` // Time at which the event occurred. Measured in UTC time in seconds since January 1, 1970. Timestamp *TimeSinceEpoch `json:"timestamp"` // Time at which the event occurred.
Button ButtonType `json:"button"` // Mouse button. Button ButtonType `json:"button"` // Mouse button.
DeltaX float64 `json:"deltaX,omitempty"` // X delta in DIP for mouse wheel event (default: 0). DeltaX float64 `json:"deltaX,omitempty"` // X delta in DIP for mouse wheel event (default: 0).
DeltaY float64 `json:"deltaY,omitempty"` // Y delta in DIP for mouse wheel event (default: 0). DeltaY float64 `json:"deltaY,omitempty"` // Y delta in DIP for mouse wheel event (default: 0).
Modifiers Modifier `json:"modifiers,omitempty"` // Bit field representing pressed modifier keys. Alt=1, Ctrl=2, Meta/Command=4, Shift=8 (default: 0). Modifiers Modifier `json:"modifiers,omitempty"` // Bit field representing pressed modifier keys. Alt=1, Ctrl=2, Meta/Command=4, Shift=8 (default: 0).
ClickCount int64 `json:"clickCount,omitempty"` // Number of times the mouse button was clicked (default: 0). ClickCount int64 `json:"clickCount,omitempty"` // Number of times the mouse button was clicked (default: 0).
} }
// EmulateTouchFromMouseEvent emulates touch event from the mouse event // EmulateTouchFromMouseEvent emulates touch event from the mouse event
@ -268,9 +265,9 @@ type EmulateTouchFromMouseEventParams struct {
// type - Type of the mouse event. // type - Type of the mouse event.
// x - X coordinate of the mouse pointer in DIP. // x - X coordinate of the mouse pointer in DIP.
// y - Y coordinate of the mouse pointer in DIP. // y - Y coordinate of the mouse pointer in DIP.
// timestamp - Time at which the event occurred. Measured in UTC time in seconds since January 1, 1970. // timestamp - Time at which the event occurred.
// button - Mouse button. // button - Mouse button.
func EmulateTouchFromMouseEvent(typeVal MouseType, x int64, y int64, timestamp *cdp.Timestamp, button ButtonType) *EmulateTouchFromMouseEventParams { func EmulateTouchFromMouseEvent(typeVal MouseType, x int64, y int64, timestamp *TimeSinceEpoch, button ButtonType) *EmulateTouchFromMouseEventParams {
return &EmulateTouchFromMouseEventParams{ return &EmulateTouchFromMouseEventParams{
Type: typeVal, Type: typeVal,
X: x, X: x,

View File

@ -3,6 +3,8 @@ package input
import ( import (
"errors" "errors"
"fmt" "fmt"
"strconv"
"time"
"github.com/mailru/easyjson" "github.com/mailru/easyjson"
"github.com/mailru/easyjson/jlexer" "github.com/mailru/easyjson/jlexer"
@ -68,6 +70,37 @@ func (t *GestureType) UnmarshalJSON(buf []byte) error {
return easyjson.Unmarshal(buf, t) return easyjson.Unmarshal(buf, t)
} }
// TimeSinceEpoch uTC time in seconds, counted from January 1, 1970.
type TimeSinceEpoch time.Time
// Time returns the TimeSinceEpoch as time.Time value.
func (t TimeSinceEpoch) Time() time.Time {
return time.Time(t)
}
// MarshalEasyJSON satisfies easyjson.Marshaler.
func (t TimeSinceEpoch) MarshalEasyJSON(out *jwriter.Writer) {
v := float64(time.Time(t).UnixNano() / int64(time.Second))
out.Buffer.EnsureSpace(20)
out.Buffer.Buf = strconv.AppendFloat(out.Buffer.Buf, v, 'f', -1, 64)
}
// MarshalJSON satisfies json.Marshaler.
func (t TimeSinceEpoch) MarshalJSON() ([]byte, error) {
return easyjson.Marshal(t)
}
// UnmarshalEasyJSON satisfies easyjson.Unmarshaler.
func (t *TimeSinceEpoch) UnmarshalEasyJSON(in *jlexer.Lexer) {
*t = TimeSinceEpoch(time.Unix(0, int64(in.Float64()*float64(time.Second))))
}
// UnmarshalJSON satisfies json.Unmarshaler.
func (t *TimeSinceEpoch) UnmarshalJSON(buf []byte) error {
return easyjson.Unmarshal(buf, t)
}
// Modifier input key modifier type. // Modifier input key modifier type.
type Modifier int64 type Modifier int64

File diff suppressed because it is too large Load Diff

View File

@ -10,23 +10,23 @@ import (
// EventResourceChangedPriority fired when resource loading priority is // EventResourceChangedPriority fired when resource loading priority is
// changed. // changed.
type EventResourceChangedPriority struct { type EventResourceChangedPriority struct {
RequestID RequestID `json:"requestId"` // Request identifier. RequestID RequestID `json:"requestId"` // Request identifier.
NewPriority ResourcePriority `json:"newPriority"` // New priority NewPriority ResourcePriority `json:"newPriority"` // New priority
Timestamp *cdp.Timestamp `json:"timestamp"` // Timestamp. Timestamp *cdp.MonotonicTime `json:"timestamp"` // Timestamp.
} }
// EventRequestWillBeSent fired when page is about to send HTTP request. // EventRequestWillBeSent fired when page is about to send HTTP request.
type EventRequestWillBeSent struct { type EventRequestWillBeSent struct {
RequestID RequestID `json:"requestId"` // Request identifier. RequestID RequestID `json:"requestId"` // Request identifier.
LoaderID cdp.LoaderID `json:"loaderId"` // Loader identifier. Empty string if the request is fetched form worker. LoaderID cdp.LoaderID `json:"loaderId"` // Loader identifier. Empty string if the request is fetched form worker.
DocumentURL string `json:"documentURL"` // URL of the document this request is loaded for. DocumentURL string `json:"documentURL"` // URL of the document this request is loaded for.
Request *Request `json:"request"` // Request data. Request *Request `json:"request"` // Request data.
Timestamp *cdp.Timestamp `json:"timestamp"` // Timestamp. Timestamp *cdp.MonotonicTime `json:"timestamp"` // Timestamp.
WallTime *cdp.Timestamp `json:"wallTime"` // UTC Timestamp. WallTime *cdp.TimeSinceEpoch `json:"wallTime"` // Timestamp.
Initiator *Initiator `json:"initiator"` // Request initiator. Initiator *Initiator `json:"initiator"` // Request initiator.
RedirectResponse *Response `json:"redirectResponse,omitempty"` // Redirect response data. RedirectResponse *Response `json:"redirectResponse,omitempty"` // Redirect response data.
Type page.ResourceType `json:"type,omitempty"` // Type of this resource. Type page.ResourceType `json:"type,omitempty"` // Type of this resource.
FrameID cdp.FrameID `json:"frameId,omitempty"` // Frame identifier. FrameID cdp.FrameID `json:"frameId,omitempty"` // Frame identifier.
} }
// EventRequestServedFromCache fired if request ended up loading from cache. // EventRequestServedFromCache fired if request ended up loading from cache.
@ -36,53 +36,53 @@ type EventRequestServedFromCache struct {
// EventResponseReceived fired when HTTP response is available. // EventResponseReceived fired when HTTP response is available.
type EventResponseReceived struct { type EventResponseReceived struct {
RequestID RequestID `json:"requestId"` // Request identifier. RequestID RequestID `json:"requestId"` // Request identifier.
LoaderID cdp.LoaderID `json:"loaderId"` // Loader identifier. Empty string if the request is fetched form worker. LoaderID cdp.LoaderID `json:"loaderId"` // Loader identifier. Empty string if the request is fetched form worker.
Timestamp *cdp.Timestamp `json:"timestamp"` // Timestamp. Timestamp *cdp.MonotonicTime `json:"timestamp"` // Timestamp.
Type page.ResourceType `json:"type"` // Resource type. Type page.ResourceType `json:"type"` // Resource type.
Response *Response `json:"response"` // Response data. Response *Response `json:"response"` // Response data.
FrameID cdp.FrameID `json:"frameId,omitempty"` // Frame identifier. FrameID cdp.FrameID `json:"frameId,omitempty"` // Frame identifier.
} }
// EventDataReceived fired when data chunk was received over the network. // EventDataReceived fired when data chunk was received over the network.
type EventDataReceived struct { type EventDataReceived struct {
RequestID RequestID `json:"requestId"` // Request identifier. RequestID RequestID `json:"requestId"` // Request identifier.
Timestamp *cdp.Timestamp `json:"timestamp"` // Timestamp. Timestamp *cdp.MonotonicTime `json:"timestamp"` // Timestamp.
DataLength int64 `json:"dataLength"` // Data chunk length. DataLength int64 `json:"dataLength"` // Data chunk length.
EncodedDataLength int64 `json:"encodedDataLength"` // Actual bytes received (might be less than dataLength for compressed encodings). EncodedDataLength int64 `json:"encodedDataLength"` // Actual bytes received (might be less than dataLength for compressed encodings).
} }
// EventLoadingFinished fired when HTTP request has finished loading. // EventLoadingFinished fired when HTTP request has finished loading.
type EventLoadingFinished struct { type EventLoadingFinished struct {
RequestID RequestID `json:"requestId"` // Request identifier. RequestID RequestID `json:"requestId"` // Request identifier.
Timestamp *cdp.Timestamp `json:"timestamp"` // Timestamp. Timestamp *cdp.MonotonicTime `json:"timestamp"` // Timestamp.
EncodedDataLength float64 `json:"encodedDataLength"` // Total number of bytes received for this request. EncodedDataLength float64 `json:"encodedDataLength"` // Total number of bytes received for this request.
} }
// EventLoadingFailed fired when HTTP request has failed to load. // EventLoadingFailed fired when HTTP request has failed to load.
type EventLoadingFailed struct { type EventLoadingFailed struct {
RequestID RequestID `json:"requestId"` // Request identifier. RequestID RequestID `json:"requestId"` // Request identifier.
Timestamp *cdp.Timestamp `json:"timestamp"` // Timestamp. Timestamp *cdp.MonotonicTime `json:"timestamp"` // Timestamp.
Type page.ResourceType `json:"type"` // Resource type. Type page.ResourceType `json:"type"` // Resource type.
ErrorText string `json:"errorText"` // User friendly error message. ErrorText string `json:"errorText"` // User friendly error message.
Canceled bool `json:"canceled,omitempty"` // True if loading was canceled. Canceled bool `json:"canceled,omitempty"` // True if loading was canceled.
BlockedReason BlockedReason `json:"blockedReason,omitempty"` // The reason why loading was blocked, if any. BlockedReason BlockedReason `json:"blockedReason,omitempty"` // The reason why loading was blocked, if any.
} }
// EventWebSocketWillSendHandshakeRequest fired when WebSocket is about to // EventWebSocketWillSendHandshakeRequest fired when WebSocket is about to
// initiate handshake. // initiate handshake.
type EventWebSocketWillSendHandshakeRequest struct { type EventWebSocketWillSendHandshakeRequest struct {
RequestID RequestID `json:"requestId"` // Request identifier. RequestID RequestID `json:"requestId"` // Request identifier.
Timestamp *cdp.Timestamp `json:"timestamp"` // Timestamp. Timestamp *cdp.MonotonicTime `json:"timestamp"` // Timestamp.
WallTime *cdp.Timestamp `json:"wallTime"` // UTC Timestamp. WallTime *cdp.TimeSinceEpoch `json:"wallTime"` // UTC Timestamp.
Request *WebSocketRequest `json:"request"` // WebSocket request data. Request *WebSocketRequest `json:"request"` // WebSocket request data.
} }
// EventWebSocketHandshakeResponseReceived fired when WebSocket handshake // EventWebSocketHandshakeResponseReceived fired when WebSocket handshake
// response becomes available. // response becomes available.
type EventWebSocketHandshakeResponseReceived struct { type EventWebSocketHandshakeResponseReceived struct {
RequestID RequestID `json:"requestId"` // Request identifier. RequestID RequestID `json:"requestId"` // Request identifier.
Timestamp *cdp.Timestamp `json:"timestamp"` // Timestamp. Timestamp *cdp.MonotonicTime `json:"timestamp"` // Timestamp.
Response *WebSocketResponse `json:"response"` // WebSocket response data. Response *WebSocketResponse `json:"response"` // WebSocket response data.
} }
@ -95,39 +95,39 @@ type EventWebSocketCreated struct {
// EventWebSocketClosed fired when WebSocket is closed. // EventWebSocketClosed fired when WebSocket is closed.
type EventWebSocketClosed struct { type EventWebSocketClosed struct {
RequestID RequestID `json:"requestId"` // Request identifier. RequestID RequestID `json:"requestId"` // Request identifier.
Timestamp *cdp.Timestamp `json:"timestamp"` // Timestamp. Timestamp *cdp.MonotonicTime `json:"timestamp"` // Timestamp.
} }
// EventWebSocketFrameReceived fired when WebSocket frame is received. // EventWebSocketFrameReceived fired when WebSocket frame is received.
type EventWebSocketFrameReceived struct { type EventWebSocketFrameReceived struct {
RequestID RequestID `json:"requestId"` // Request identifier. RequestID RequestID `json:"requestId"` // Request identifier.
Timestamp *cdp.Timestamp `json:"timestamp"` // Timestamp. Timestamp *cdp.MonotonicTime `json:"timestamp"` // Timestamp.
Response *WebSocketFrame `json:"response"` // WebSocket response data. Response *WebSocketFrame `json:"response"` // WebSocket response data.
} }
// EventWebSocketFrameError fired when WebSocket frame error occurs. // EventWebSocketFrameError fired when WebSocket frame error occurs.
type EventWebSocketFrameError struct { type EventWebSocketFrameError struct {
RequestID RequestID `json:"requestId"` // Request identifier. RequestID RequestID `json:"requestId"` // Request identifier.
Timestamp *cdp.Timestamp `json:"timestamp"` // Timestamp. Timestamp *cdp.MonotonicTime `json:"timestamp"` // Timestamp.
ErrorMessage string `json:"errorMessage"` // WebSocket frame error message. ErrorMessage string `json:"errorMessage"` // WebSocket frame error message.
} }
// EventWebSocketFrameSent fired when WebSocket frame is sent. // EventWebSocketFrameSent fired when WebSocket frame is sent.
type EventWebSocketFrameSent struct { type EventWebSocketFrameSent struct {
RequestID RequestID `json:"requestId"` // Request identifier. RequestID RequestID `json:"requestId"` // Request identifier.
Timestamp *cdp.Timestamp `json:"timestamp"` // Timestamp. Timestamp *cdp.MonotonicTime `json:"timestamp"` // Timestamp.
Response *WebSocketFrame `json:"response"` // WebSocket response data. Response *WebSocketFrame `json:"response"` // WebSocket response data.
} }
// EventEventSourceMessageReceived fired when EventSource message is // EventEventSourceMessageReceived fired when EventSource message is
// received. // received.
type EventEventSourceMessageReceived struct { type EventEventSourceMessageReceived struct {
RequestID RequestID `json:"requestId"` // Request identifier. RequestID RequestID `json:"requestId"` // Request identifier.
Timestamp *cdp.Timestamp `json:"timestamp"` // Timestamp. Timestamp *cdp.MonotonicTime `json:"timestamp"` // Timestamp.
EventName string `json:"eventName"` // Message type. EventName string `json:"eventName"` // Message type.
EventID string `json:"eventId"` // Message identifier. EventID string `json:"eventId"` // Message identifier.
Data string `json:"data"` // Message content. Data string `json:"data"` // Message content.
} }
// EventRequestIntercepted details of an intercepted HTTP request, which must // EventRequestIntercepted details of an intercepted HTTP request, which must

View File

@ -399,15 +399,15 @@ func (p *DeleteCookieParams) Do(ctxt context.Context, h cdp.Handler) (err error)
// SetCookieParams sets a cookie with the given cookie data; may overwrite // SetCookieParams sets a cookie with the given cookie data; may overwrite
// equivalent cookies if they exist. // equivalent cookies if they exist.
type SetCookieParams struct { type SetCookieParams struct {
URL string `json:"url"` // The request-URI to associate with the setting of the cookie. This value can affect the default domain and path values of the created cookie. URL string `json:"url"` // The request-URI to associate with the setting of the cookie. This value can affect the default domain and path values of the created cookie.
Name string `json:"name"` // The name of the cookie. Name string `json:"name"` // The name of the cookie.
Value string `json:"value"` // The value of the cookie. Value string `json:"value"` // The value of the cookie.
Domain string `json:"domain,omitempty"` // If omitted, the cookie becomes a host-only cookie. Domain string `json:"domain,omitempty"` // If omitted, the cookie becomes a host-only cookie.
Path string `json:"path,omitempty"` // Defaults to the path portion of the url parameter. Path string `json:"path,omitempty"` // Defaults to the path portion of the url parameter.
Secure bool `json:"secure,omitempty"` // Defaults ot false. Secure bool `json:"secure,omitempty"` // Defaults ot false.
HTTPOnly bool `json:"httpOnly,omitempty"` // Defaults to false. HTTPOnly bool `json:"httpOnly,omitempty"` // Defaults to false.
SameSite CookieSameSite `json:"sameSite,omitempty"` // Defaults to browser default behavior. SameSite CookieSameSite `json:"sameSite,omitempty"` // Defaults to browser default behavior.
ExpirationDate *cdp.Timestamp `json:"expirationDate,omitempty"` // If omitted, the cookie becomes a session cookie. ExpirationDate *cdp.TimeSinceEpoch `json:"expirationDate,omitempty"` // If omitted, the cookie becomes a session cookie.
} }
// SetCookie sets a cookie with the given cookie data; may overwrite // SetCookie sets a cookie with the given cookie data; may overwrite
@ -456,7 +456,7 @@ func (p SetCookieParams) WithSameSite(sameSite CookieSameSite) *SetCookieParams
} }
// WithExpirationDate if omitted, the cookie becomes a session cookie. // WithExpirationDate if omitted, the cookie becomes a session cookie.
func (p SetCookieParams) WithExpirationDate(expirationDate *cdp.Timestamp) *SetCookieParams { func (p SetCookieParams) WithExpirationDate(expirationDate *cdp.TimeSinceEpoch) *SetCookieParams {
p.ExpirationDate = expirationDate p.ExpirationDate = expirationDate
return &p return &p
} }
@ -656,25 +656,25 @@ func (p *GetCertificateParams) Do(ctxt context.Context, h cdp.Handler) (tableNam
return res.TableNames, nil return res.TableNames, nil
} }
// EnableRequestInterceptionParams [no description]. // SetRequestInterceptionEnabledParams [no description].
type EnableRequestInterceptionParams struct { type SetRequestInterceptionEnabledParams struct {
Enabled bool `json:"enabled"` // Whether or not HTTP requests should be intercepted and Network.requestIntercepted events sent. Enabled bool `json:"enabled"` // Whether or not HTTP requests should be intercepted and Network.requestIntercepted events sent.
} }
// EnableRequestInterception [no description]. // SetRequestInterceptionEnabled [no description].
// //
// parameters: // parameters:
// enabled - Whether or not HTTP requests should be intercepted and Network.requestIntercepted events sent. // enabled - Whether or not HTTP requests should be intercepted and Network.requestIntercepted events sent.
func EnableRequestInterception(enabled bool) *EnableRequestInterceptionParams { func SetRequestInterceptionEnabled(enabled bool) *SetRequestInterceptionEnabledParams {
return &EnableRequestInterceptionParams{ return &SetRequestInterceptionEnabledParams{
Enabled: enabled, Enabled: enabled,
} }
} }
// Do executes Network.enableRequestInterception against the provided context and // Do executes Network.setRequestInterceptionEnabled against the provided context and
// target handler. // target handler.
func (p *EnableRequestInterceptionParams) Do(ctxt context.Context, h cdp.Handler) (err error) { func (p *SetRequestInterceptionEnabledParams) Do(ctxt context.Context, h cdp.Handler) (err error) {
return h.Execute(ctxt, cdp.CommandNetworkEnableRequestInterception, p, nil) return h.Execute(ctxt, cdp.CommandNetworkSetRequestInterceptionEnabled, p, nil)
} }
// ContinueInterceptedRequestParams response to Network.requestIntercepted // ContinueInterceptedRequestParams response to Network.requestIntercepted

View File

@ -284,27 +284,27 @@ func (t *ResourcePriority) UnmarshalJSON(buf []byte) error {
// Request hTTP request data. // Request hTTP request data.
type Request struct { type Request struct {
URL string `json:"url"` // Request URL. URL string `json:"url"` // Request URL.
Method string `json:"method"` // HTTP request method. Method string `json:"method"` // HTTP request method.
Headers Headers `json:"headers"` // HTTP request headers. Headers Headers `json:"headers"` // HTTP request headers.
PostData string `json:"postData,omitempty"` // HTTP POST request data. PostData string `json:"postData,omitempty"` // HTTP POST request data.
MixedContentType MixedContentType `json:"mixedContentType,omitempty"` // The mixed content status of the request, as defined in http://www.w3.org/TR/mixed-content/ MixedContentType security.MixedContentType `json:"mixedContentType,omitempty"` // The mixed content type of the request.
InitialPriority ResourcePriority `json:"initialPriority"` // Priority of the resource request at the time request is sent. InitialPriority ResourcePriority `json:"initialPriority"` // Priority of the resource request at the time request is sent.
ReferrerPolicy ReferrerPolicy `json:"referrerPolicy"` // The referrer policy of the request, as defined in https://www.w3.org/TR/referrer-policy/ ReferrerPolicy ReferrerPolicy `json:"referrerPolicy"` // The referrer policy of the request, as defined in https://www.w3.org/TR/referrer-policy/
IsLinkPreload bool `json:"isLinkPreload,omitempty"` // Whether is loaded via link preload. IsLinkPreload bool `json:"isLinkPreload,omitempty"` // Whether is loaded via link preload.
} }
// SignedCertificateTimestamp details of a signed certificate timestamp // SignedCertificateTimestamp details of a signed certificate timestamp
// (SCT). // (SCT).
type SignedCertificateTimestamp struct { type SignedCertificateTimestamp struct {
Status string `json:"status"` // Validation status. Status string `json:"status"` // Validation status.
Origin string `json:"origin"` // Origin. Origin string `json:"origin"` // Origin.
LogDescription string `json:"logDescription"` // Log name / description. LogDescription string `json:"logDescription"` // Log name / description.
LogID string `json:"logId"` // Log ID. LogID string `json:"logId"` // Log ID.
Timestamp *cdp.Timestamp `json:"timestamp"` // Issuance date. Timestamp *cdp.TimeSinceEpoch `json:"timestamp"` // Issuance date.
HashAlgorithm string `json:"hashAlgorithm"` // Hash algorithm. HashAlgorithm string `json:"hashAlgorithm"` // Hash algorithm.
SignatureAlgorithm string `json:"signatureAlgorithm"` // Signature algorithm. SignatureAlgorithm string `json:"signatureAlgorithm"` // Signature algorithm.
SignatureData string `json:"signatureData"` // Signature data. SignatureData string `json:"signatureData"` // Signature data.
} }
// SecurityDetails security details about a request. // SecurityDetails security details about a request.
@ -318,8 +318,8 @@ type SecurityDetails struct {
SubjectName string `json:"subjectName"` // Certificate subject name. SubjectName string `json:"subjectName"` // Certificate subject name.
SanList []string `json:"sanList"` // Subject Alternative Name (SAN) DNS names and IP addresses. SanList []string `json:"sanList"` // Subject Alternative Name (SAN) DNS names and IP addresses.
Issuer string `json:"issuer"` // Name of the issuing CA. Issuer string `json:"issuer"` // Name of the issuing CA.
ValidFrom *cdp.Timestamp `json:"validFrom"` // Certificate valid from date. ValidFrom *cdp.TimeSinceEpoch `json:"validFrom"` // Certificate valid from date.
ValidTo *cdp.Timestamp `json:"validTo"` // Certificate valid to (expiration) date ValidTo *cdp.TimeSinceEpoch `json:"validTo"` // Certificate valid to (expiration) date
SignedCertificateTimestampList []*SignedCertificateTimestamp `json:"signedCertificateTimestampList"` // List of signed certificate timestamps (SCTs). SignedCertificateTimestampList []*SignedCertificateTimestamp `json:"signedCertificateTimestampList"` // List of signed certificate timestamps (SCTs).
} }
@ -467,52 +467,6 @@ 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.
} }
// MixedContentType the mixed content status of the request, as defined in
// http://www.w3.org/TR/mixed-content/.
type MixedContentType string
// String returns the MixedContentType as string value.
func (t MixedContentType) String() string {
return string(t)
}
// MixedContentType values.
const (
MixedContentTypeBlockable MixedContentType = "blockable"
MixedContentTypeOptionallyBlockable MixedContentType = "optionally-blockable"
MixedContentTypeNone MixedContentType = "none"
)
// MarshalEasyJSON satisfies easyjson.Marshaler.
func (t MixedContentType) MarshalEasyJSON(out *jwriter.Writer) {
out.String(string(t))
}
// MarshalJSON satisfies json.Marshaler.
func (t MixedContentType) MarshalJSON() ([]byte, error) {
return easyjson.Marshal(t)
}
// UnmarshalEasyJSON satisfies easyjson.Unmarshaler.
func (t *MixedContentType) UnmarshalEasyJSON(in *jlexer.Lexer) {
switch MixedContentType(in.String()) {
case MixedContentTypeBlockable:
*t = MixedContentTypeBlockable
case MixedContentTypeOptionallyBlockable:
*t = MixedContentTypeOptionallyBlockable
case MixedContentTypeNone:
*t = MixedContentTypeNone
default:
in.AddError(errors.New("unknown MixedContentType value"))
}
}
// UnmarshalJSON satisfies json.Unmarshaler.
func (t *MixedContentType) UnmarshalJSON(buf []byte) error {
return easyjson.Unmarshal(buf, t)
}
// 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

@ -825,7 +825,7 @@ func easyjsonC5a4559bDecodeGithubComKnqChromedpCdpPage9(in *jlexer.Lexer, out *S
out.Timestamp = nil out.Timestamp = nil
} else { } else {
if out.Timestamp == nil { if out.Timestamp == nil {
out.Timestamp = new(Bootstamp) out.Timestamp = new(cdp.TimeSinceEpoch)
} }
(*out.Timestamp).UnmarshalEasyJSON(in) (*out.Timestamp).UnmarshalEasyJSON(in)
} }
@ -1043,7 +1043,7 @@ func (v *RequestAppBannerParams) UnmarshalJSON(data []byte) error {
func (v *RequestAppBannerParams) UnmarshalEasyJSON(l *jlexer.Lexer) { func (v *RequestAppBannerParams) UnmarshalEasyJSON(l *jlexer.Lexer) {
easyjsonC5a4559bDecodeGithubComKnqChromedpCdpPage11(l, v) easyjsonC5a4559bDecodeGithubComKnqChromedpCdpPage11(l, v)
} }
func easyjsonC5a4559bDecodeGithubComKnqChromedpCdpPage12(in *jlexer.Lexer, out *RemoveScriptToEvaluateOnLoadParams) { func easyjsonC5a4559bDecodeGithubComKnqChromedpCdpPage12(in *jlexer.Lexer, out *RemoveScriptToEvaluateOnNewDocumentParams) {
isTopLevel := in.IsStart() isTopLevel := in.IsStart()
if in.IsNull() { if in.IsNull() {
if isTopLevel { if isTopLevel {
@ -1074,7 +1074,7 @@ func easyjsonC5a4559bDecodeGithubComKnqChromedpCdpPage12(in *jlexer.Lexer, out *
in.Consumed() in.Consumed()
} }
} }
func easyjsonC5a4559bEncodeGithubComKnqChromedpCdpPage12(out *jwriter.Writer, in RemoveScriptToEvaluateOnLoadParams) { func easyjsonC5a4559bEncodeGithubComKnqChromedpCdpPage12(out *jwriter.Writer, in RemoveScriptToEvaluateOnNewDocumentParams) {
out.RawByte('{') out.RawByte('{')
first := true first := true
_ = first _ = first
@ -1088,26 +1088,26 @@ func easyjsonC5a4559bEncodeGithubComKnqChromedpCdpPage12(out *jwriter.Writer, in
} }
// MarshalJSON supports json.Marshaler interface // MarshalJSON supports json.Marshaler interface
func (v RemoveScriptToEvaluateOnLoadParams) MarshalJSON() ([]byte, error) { func (v RemoveScriptToEvaluateOnNewDocumentParams) MarshalJSON() ([]byte, error) {
w := jwriter.Writer{} w := jwriter.Writer{}
easyjsonC5a4559bEncodeGithubComKnqChromedpCdpPage12(&w, v) easyjsonC5a4559bEncodeGithubComKnqChromedpCdpPage12(&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 RemoveScriptToEvaluateOnLoadParams) MarshalEasyJSON(w *jwriter.Writer) { func (v RemoveScriptToEvaluateOnNewDocumentParams) MarshalEasyJSON(w *jwriter.Writer) {
easyjsonC5a4559bEncodeGithubComKnqChromedpCdpPage12(w, v) easyjsonC5a4559bEncodeGithubComKnqChromedpCdpPage12(w, v)
} }
// UnmarshalJSON supports json.Unmarshaler interface // UnmarshalJSON supports json.Unmarshaler interface
func (v *RemoveScriptToEvaluateOnLoadParams) UnmarshalJSON(data []byte) error { func (v *RemoveScriptToEvaluateOnNewDocumentParams) UnmarshalJSON(data []byte) error {
r := jlexer.Lexer{Data: data} r := jlexer.Lexer{Data: data}
easyjsonC5a4559bDecodeGithubComKnqChromedpCdpPage12(&r, v) easyjsonC5a4559bDecodeGithubComKnqChromedpCdpPage12(&r, v)
return r.Error() return r.Error()
} }
// UnmarshalEasyJSON supports easyjson.Unmarshaler interface // UnmarshalEasyJSON supports easyjson.Unmarshaler interface
func (v *RemoveScriptToEvaluateOnLoadParams) UnmarshalEasyJSON(l *jlexer.Lexer) { func (v *RemoveScriptToEvaluateOnNewDocumentParams) UnmarshalEasyJSON(l *jlexer.Lexer) {
easyjsonC5a4559bDecodeGithubComKnqChromedpCdpPage12(l, v) easyjsonC5a4559bDecodeGithubComKnqChromedpCdpPage12(l, v)
} }
func easyjsonC5a4559bDecodeGithubComKnqChromedpCdpPage13(in *jlexer.Lexer, out *ReloadParams) { func easyjsonC5a4559bDecodeGithubComKnqChromedpCdpPage13(in *jlexer.Lexer, out *ReloadParams) {
@ -3060,7 +3060,7 @@ func easyjsonC5a4559bDecodeGithubComKnqChromedpCdpPage34(in *jlexer.Lexer, out *
out.LastModified = nil out.LastModified = nil
} else { } else {
if out.LastModified == nil { if out.LastModified == nil {
out.LastModified = new(cdp.Timestamp) out.LastModified = new(cdp.TimeSinceEpoch)
} }
(*out.LastModified).UnmarshalEasyJSON(in) (*out.LastModified).UnmarshalEasyJSON(in)
} }
@ -3442,7 +3442,7 @@ func easyjsonC5a4559bDecodeGithubComKnqChromedpCdpPage38(in *jlexer.Lexer, out *
out.Timestamp = nil out.Timestamp = nil
} else { } else {
if out.Timestamp == nil { if out.Timestamp == nil {
out.Timestamp = new(Bootstamp) out.Timestamp = new(cdp.MonotonicTime)
} }
(*out.Timestamp).UnmarshalEasyJSON(in) (*out.Timestamp).UnmarshalEasyJSON(in)
} }
@ -4359,7 +4359,7 @@ func easyjsonC5a4559bDecodeGithubComKnqChromedpCdpPage51(in *jlexer.Lexer, out *
out.Timestamp = nil out.Timestamp = nil
} else { } else {
if out.Timestamp == nil { if out.Timestamp == nil {
out.Timestamp = new(Bootstamp) out.Timestamp = new(cdp.MonotonicTime)
} }
(*out.Timestamp).UnmarshalEasyJSON(in) (*out.Timestamp).UnmarshalEasyJSON(in)
} }
@ -4936,7 +4936,7 @@ func (v *AppManifestError) UnmarshalJSON(data []byte) error {
func (v *AppManifestError) UnmarshalEasyJSON(l *jlexer.Lexer) { func (v *AppManifestError) UnmarshalEasyJSON(l *jlexer.Lexer) {
easyjsonC5a4559bDecodeGithubComKnqChromedpCdpPage58(l, v) easyjsonC5a4559bDecodeGithubComKnqChromedpCdpPage58(l, v)
} }
func easyjsonC5a4559bDecodeGithubComKnqChromedpCdpPage59(in *jlexer.Lexer, out *AddScriptToEvaluateOnLoadReturns) { func easyjsonC5a4559bDecodeGithubComKnqChromedpCdpPage59(in *jlexer.Lexer, out *AddScriptToEvaluateOnNewDocumentReturns) {
isTopLevel := in.IsStart() isTopLevel := in.IsStart()
if in.IsNull() { if in.IsNull() {
if isTopLevel { if isTopLevel {
@ -4967,7 +4967,7 @@ func easyjsonC5a4559bDecodeGithubComKnqChromedpCdpPage59(in *jlexer.Lexer, out *
in.Consumed() in.Consumed()
} }
} }
func easyjsonC5a4559bEncodeGithubComKnqChromedpCdpPage59(out *jwriter.Writer, in AddScriptToEvaluateOnLoadReturns) { func easyjsonC5a4559bEncodeGithubComKnqChromedpCdpPage59(out *jwriter.Writer, in AddScriptToEvaluateOnNewDocumentReturns) {
out.RawByte('{') out.RawByte('{')
first := true first := true
_ = first _ = first
@ -4983,29 +4983,29 @@ func easyjsonC5a4559bEncodeGithubComKnqChromedpCdpPage59(out *jwriter.Writer, in
} }
// MarshalJSON supports json.Marshaler interface // MarshalJSON supports json.Marshaler interface
func (v AddScriptToEvaluateOnLoadReturns) MarshalJSON() ([]byte, error) { func (v AddScriptToEvaluateOnNewDocumentReturns) MarshalJSON() ([]byte, error) {
w := jwriter.Writer{} w := jwriter.Writer{}
easyjsonC5a4559bEncodeGithubComKnqChromedpCdpPage59(&w, v) easyjsonC5a4559bEncodeGithubComKnqChromedpCdpPage59(&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 AddScriptToEvaluateOnLoadReturns) MarshalEasyJSON(w *jwriter.Writer) { func (v AddScriptToEvaluateOnNewDocumentReturns) MarshalEasyJSON(w *jwriter.Writer) {
easyjsonC5a4559bEncodeGithubComKnqChromedpCdpPage59(w, v) easyjsonC5a4559bEncodeGithubComKnqChromedpCdpPage59(w, v)
} }
// UnmarshalJSON supports json.Unmarshaler interface // UnmarshalJSON supports json.Unmarshaler interface
func (v *AddScriptToEvaluateOnLoadReturns) UnmarshalJSON(data []byte) error { func (v *AddScriptToEvaluateOnNewDocumentReturns) UnmarshalJSON(data []byte) error {
r := jlexer.Lexer{Data: data} r := jlexer.Lexer{Data: data}
easyjsonC5a4559bDecodeGithubComKnqChromedpCdpPage59(&r, v) easyjsonC5a4559bDecodeGithubComKnqChromedpCdpPage59(&r, v)
return r.Error() return r.Error()
} }
// UnmarshalEasyJSON supports easyjson.Unmarshaler interface // UnmarshalEasyJSON supports easyjson.Unmarshaler interface
func (v *AddScriptToEvaluateOnLoadReturns) UnmarshalEasyJSON(l *jlexer.Lexer) { func (v *AddScriptToEvaluateOnNewDocumentReturns) UnmarshalEasyJSON(l *jlexer.Lexer) {
easyjsonC5a4559bDecodeGithubComKnqChromedpCdpPage59(l, v) easyjsonC5a4559bDecodeGithubComKnqChromedpCdpPage59(l, v)
} }
func easyjsonC5a4559bDecodeGithubComKnqChromedpCdpPage60(in *jlexer.Lexer, out *AddScriptToEvaluateOnLoadParams) { func easyjsonC5a4559bDecodeGithubComKnqChromedpCdpPage60(in *jlexer.Lexer, out *AddScriptToEvaluateOnNewDocumentParams) {
isTopLevel := in.IsStart() isTopLevel := in.IsStart()
if in.IsNull() { if in.IsNull() {
if isTopLevel { if isTopLevel {
@ -5024,8 +5024,8 @@ func easyjsonC5a4559bDecodeGithubComKnqChromedpCdpPage60(in *jlexer.Lexer, out *
continue continue
} }
switch key { switch key {
case "scriptSource": case "source":
out.ScriptSource = string(in.String()) out.Source = string(in.String())
default: default:
in.SkipRecursive() in.SkipRecursive()
} }
@ -5036,7 +5036,7 @@ func easyjsonC5a4559bDecodeGithubComKnqChromedpCdpPage60(in *jlexer.Lexer, out *
in.Consumed() in.Consumed()
} }
} }
func easyjsonC5a4559bEncodeGithubComKnqChromedpCdpPage60(out *jwriter.Writer, in AddScriptToEvaluateOnLoadParams) { func easyjsonC5a4559bEncodeGithubComKnqChromedpCdpPage60(out *jwriter.Writer, in AddScriptToEvaluateOnNewDocumentParams) {
out.RawByte('{') out.RawByte('{')
first := true first := true
_ = first _ = first
@ -5044,31 +5044,31 @@ func easyjsonC5a4559bEncodeGithubComKnqChromedpCdpPage60(out *jwriter.Writer, in
out.RawByte(',') out.RawByte(',')
} }
first = false first = false
out.RawString("\"scriptSource\":") out.RawString("\"source\":")
out.String(string(in.ScriptSource)) out.String(string(in.Source))
out.RawByte('}') out.RawByte('}')
} }
// MarshalJSON supports json.Marshaler interface // MarshalJSON supports json.Marshaler interface
func (v AddScriptToEvaluateOnLoadParams) MarshalJSON() ([]byte, error) { func (v AddScriptToEvaluateOnNewDocumentParams) MarshalJSON() ([]byte, error) {
w := jwriter.Writer{} w := jwriter.Writer{}
easyjsonC5a4559bEncodeGithubComKnqChromedpCdpPage60(&w, v) easyjsonC5a4559bEncodeGithubComKnqChromedpCdpPage60(&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 AddScriptToEvaluateOnLoadParams) MarshalEasyJSON(w *jwriter.Writer) { func (v AddScriptToEvaluateOnNewDocumentParams) MarshalEasyJSON(w *jwriter.Writer) {
easyjsonC5a4559bEncodeGithubComKnqChromedpCdpPage60(w, v) easyjsonC5a4559bEncodeGithubComKnqChromedpCdpPage60(w, v)
} }
// UnmarshalJSON supports json.Unmarshaler interface // UnmarshalJSON supports json.Unmarshaler interface
func (v *AddScriptToEvaluateOnLoadParams) UnmarshalJSON(data []byte) error { func (v *AddScriptToEvaluateOnNewDocumentParams) UnmarshalJSON(data []byte) error {
r := jlexer.Lexer{Data: data} r := jlexer.Lexer{Data: data}
easyjsonC5a4559bDecodeGithubComKnqChromedpCdpPage60(&r, v) easyjsonC5a4559bDecodeGithubComKnqChromedpCdpPage60(&r, v)
return r.Error() return r.Error()
} }
// UnmarshalEasyJSON supports easyjson.Unmarshaler interface // UnmarshalEasyJSON supports easyjson.Unmarshaler interface
func (v *AddScriptToEvaluateOnLoadParams) UnmarshalEasyJSON(l *jlexer.Lexer) { func (v *AddScriptToEvaluateOnNewDocumentParams) UnmarshalEasyJSON(l *jlexer.Lexer) {
easyjsonC5a4559bDecodeGithubComKnqChromedpCdpPage60(l, v) easyjsonC5a4559bDecodeGithubComKnqChromedpCdpPage60(l, v)
} }

View File

@ -9,12 +9,12 @@ import (
// EventDomContentEventFired [no description]. // EventDomContentEventFired [no description].
type EventDomContentEventFired struct { type EventDomContentEventFired struct {
Timestamp *Bootstamp `json:"timestamp"` Timestamp *cdp.MonotonicTime `json:"timestamp"`
} }
// EventLoadEventFired [no description]. // EventLoadEventFired [no description].
type EventLoadEventFired struct { type EventLoadEventFired struct {
Timestamp *Bootstamp `json:"timestamp"` Timestamp *cdp.MonotonicTime `json:"timestamp"`
} }
// EventFrameAttached fired when frame has been attached to its parent. // EventFrameAttached fired when frame has been attached to its parent.

View File

@ -47,35 +47,37 @@ func (p *DisableParams) Do(ctxt context.Context, h cdp.Handler) (err error) {
return h.Execute(ctxt, cdp.CommandPageDisable, nil, nil) return h.Execute(ctxt, cdp.CommandPageDisable, nil, nil)
} }
// AddScriptToEvaluateOnLoadParams [no description]. // AddScriptToEvaluateOnNewDocumentParams evaluates given script in every
type AddScriptToEvaluateOnLoadParams struct { // frame upon creation (before loading frame's scripts).
ScriptSource string `json:"scriptSource"` type AddScriptToEvaluateOnNewDocumentParams struct {
Source string `json:"source"`
} }
// AddScriptToEvaluateOnLoad [no description]. // AddScriptToEvaluateOnNewDocument evaluates given script in every frame
// upon creation (before loading frame's scripts).
// //
// parameters: // parameters:
// scriptSource // source
func AddScriptToEvaluateOnLoad(scriptSource string) *AddScriptToEvaluateOnLoadParams { func AddScriptToEvaluateOnNewDocument(source string) *AddScriptToEvaluateOnNewDocumentParams {
return &AddScriptToEvaluateOnLoadParams{ return &AddScriptToEvaluateOnNewDocumentParams{
ScriptSource: scriptSource, Source: source,
} }
} }
// AddScriptToEvaluateOnLoadReturns return values. // AddScriptToEvaluateOnNewDocumentReturns return values.
type AddScriptToEvaluateOnLoadReturns struct { type AddScriptToEvaluateOnNewDocumentReturns struct {
Identifier ScriptIdentifier `json:"identifier,omitempty"` // Identifier of the added script. Identifier ScriptIdentifier `json:"identifier,omitempty"` // Identifier of the added script.
} }
// Do executes Page.addScriptToEvaluateOnLoad against the provided context and // Do executes Page.addScriptToEvaluateOnNewDocument against the provided context and
// target handler. // target handler.
// //
// returns: // returns:
// identifier - Identifier of the added script. // identifier - Identifier of the added script.
func (p *AddScriptToEvaluateOnLoadParams) Do(ctxt context.Context, h cdp.Handler) (identifier ScriptIdentifier, err error) { func (p *AddScriptToEvaluateOnNewDocumentParams) Do(ctxt context.Context, h cdp.Handler) (identifier ScriptIdentifier, err error) {
// execute // execute
var res AddScriptToEvaluateOnLoadReturns var res AddScriptToEvaluateOnNewDocumentReturns
err = h.Execute(ctxt, cdp.CommandPageAddScriptToEvaluateOnLoad, p, &res) err = h.Execute(ctxt, cdp.CommandPageAddScriptToEvaluateOnNewDocument, p, &res)
if err != nil { if err != nil {
return "", err return "", err
} }
@ -83,25 +85,26 @@ func (p *AddScriptToEvaluateOnLoadParams) Do(ctxt context.Context, h cdp.Handler
return res.Identifier, nil return res.Identifier, nil
} }
// RemoveScriptToEvaluateOnLoadParams [no description]. // RemoveScriptToEvaluateOnNewDocumentParams removes given script from the
type RemoveScriptToEvaluateOnLoadParams struct { // list.
type RemoveScriptToEvaluateOnNewDocumentParams struct {
Identifier ScriptIdentifier `json:"identifier"` Identifier ScriptIdentifier `json:"identifier"`
} }
// RemoveScriptToEvaluateOnLoad [no description]. // RemoveScriptToEvaluateOnNewDocument removes given script from the list.
// //
// parameters: // parameters:
// identifier // identifier
func RemoveScriptToEvaluateOnLoad(identifier ScriptIdentifier) *RemoveScriptToEvaluateOnLoadParams { func RemoveScriptToEvaluateOnNewDocument(identifier ScriptIdentifier) *RemoveScriptToEvaluateOnNewDocumentParams {
return &RemoveScriptToEvaluateOnLoadParams{ return &RemoveScriptToEvaluateOnNewDocumentParams{
Identifier: identifier, Identifier: identifier,
} }
} }
// Do executes Page.removeScriptToEvaluateOnLoad against the provided context and // Do executes Page.removeScriptToEvaluateOnNewDocument against the provided context and
// target handler. // target handler.
func (p *RemoveScriptToEvaluateOnLoadParams) Do(ctxt context.Context, h cdp.Handler) (err error) { func (p *RemoveScriptToEvaluateOnNewDocumentParams) Do(ctxt context.Context, h cdp.Handler) (err error) {
return h.Execute(ctxt, cdp.CommandPageRemoveScriptToEvaluateOnLoad, p, nil) return h.Execute(ctxt, cdp.CommandPageRemoveScriptToEvaluateOnNewDocument, p, nil)
} }
// SetAutoAttachToCreatedPagesParams controls whether browser will open a new // SetAutoAttachToCreatedPagesParams controls whether browser will open a new

View File

@ -4,11 +4,8 @@ package page
import ( import (
"errors" "errors"
"strconv"
"time"
cdp "github.com/knq/chromedp/cdp" cdp "github.com/knq/chromedp/cdp"
"github.com/knq/sysutil"
"github.com/mailru/easyjson" "github.com/mailru/easyjson"
"github.com/mailru/easyjson/jlexer" "github.com/mailru/easyjson/jlexer"
"github.com/mailru/easyjson/jwriter" "github.com/mailru/easyjson/jwriter"
@ -91,13 +88,13 @@ func (t *ResourceType) UnmarshalJSON(buf []byte) error {
// FrameResource information about the Resource on the page. // FrameResource information about the Resource on the page.
type FrameResource struct { type FrameResource struct {
URL string `json:"url"` // Resource URL. URL string `json:"url"` // Resource URL.
Type ResourceType `json:"type"` // Type of this resource. Type ResourceType `json:"type"` // Type of this resource.
MimeType string `json:"mimeType"` // Resource mimeType as determined by the browser. MimeType string `json:"mimeType"` // Resource mimeType as determined by the browser.
LastModified *cdp.Timestamp `json:"lastModified,omitempty"` // last-modified timestamp as reported by server. LastModified *cdp.TimeSinceEpoch `json:"lastModified,omitempty"` // last-modified timestamp as reported by server.
ContentSize float64 `json:"contentSize,omitempty"` // Resource content size. ContentSize float64 `json:"contentSize,omitempty"` // Resource content size.
Failed bool `json:"failed,omitempty"` // True if the resource failed to load. Failed bool `json:"failed,omitempty"` // True if the resource failed to load.
Canceled bool `json:"canceled,omitempty"` // True if the resource was canceled during loading. Canceled bool `json:"canceled,omitempty"` // True if the resource was canceled during loading.
} }
// FrameResourceTree information about the Frame hierarchy along with their // FrameResourceTree information about the Frame hierarchy along with their
@ -199,13 +196,13 @@ type NavigationEntry struct {
// ScreencastFrameMetadata screencast frame metadata. // ScreencastFrameMetadata screencast frame metadata.
type ScreencastFrameMetadata struct { type ScreencastFrameMetadata struct {
OffsetTop float64 `json:"offsetTop"` // Top offset in DIP. OffsetTop float64 `json:"offsetTop"` // Top offset in DIP.
PageScaleFactor float64 `json:"pageScaleFactor"` // Page scale factor. PageScaleFactor float64 `json:"pageScaleFactor"` // Page scale factor.
DeviceWidth float64 `json:"deviceWidth"` // Device screen width in DIP. DeviceWidth float64 `json:"deviceWidth"` // Device screen width in DIP.
DeviceHeight float64 `json:"deviceHeight"` // Device screen height in DIP. DeviceHeight float64 `json:"deviceHeight"` // Device screen height in DIP.
ScrollOffsetX float64 `json:"scrollOffsetX"` // Position of horizontal scroll in CSS pixels. ScrollOffsetX float64 `json:"scrollOffsetX"` // Position of horizontal scroll in CSS pixels.
ScrollOffsetY float64 `json:"scrollOffsetY"` // Position of vertical scroll in CSS pixels. ScrollOffsetY float64 `json:"scrollOffsetY"` // Position of vertical scroll in CSS pixels.
Timestamp *Bootstamp `json:"timestamp,omitempty"` // Frame swap timestamp. Timestamp *cdp.TimeSinceEpoch `json:"timestamp,omitempty"` // Frame swap timestamp.
} }
// DialogType javascript dialog type. // DialogType javascript dialog type.
@ -330,37 +327,6 @@ type VisualViewport struct {
Scale float64 `json:"scale"` // Scale relative to the ideal viewport (size at width=device-width). Scale float64 `json:"scale"` // Scale relative to the ideal viewport (size at width=device-width).
} }
// Bootstamp bootstamp type.
type Bootstamp time.Time
// Time returns the Bootstamp as time.Time value.
func (t Bootstamp) Time() time.Time {
return time.Time(t)
}
// MarshalEasyJSON satisfies easyjson.Marshaler.
func (t Bootstamp) MarshalEasyJSON(out *jwriter.Writer) {
v := float64(time.Time(t).Sub(sysutil.BootTime())) / float64(time.Second)
out.Buffer.EnsureSpace(20)
out.Buffer.Buf = strconv.AppendFloat(out.Buffer.Buf, v, 'f', -1, 64)
}
// MarshalJSON satisfies json.Marshaler.
func (t Bootstamp) MarshalJSON() ([]byte, error) {
return easyjson.Marshal(t)
}
// UnmarshalEasyJSON satisfies easyjson.Unmarshaler.
func (t *Bootstamp) UnmarshalEasyJSON(in *jlexer.Lexer) {
*t = Bootstamp(sysutil.BootTime().Add(time.Duration(in.Float64() * float64(time.Second))))
}
// UnmarshalJSON satisfies json.Unmarshaler.
func (t *Bootstamp) UnmarshalJSON(buf []byte) error {
return easyjson.Unmarshal(buf, t)
}
// CaptureScreenshotFormat image compression format (defaults to png). // CaptureScreenshotFormat image compression format (defaults to png).
type CaptureScreenshotFormat string type CaptureScreenshotFormat string

View File

@ -44,6 +44,8 @@ func easyjsonC5a4559bDecodeGithubComKnqChromedpCdpSecurity(in *jlexer.Lexer, out
out.Description = string(in.String()) out.Description = string(in.String())
case "hasCertificate": case "hasCertificate":
out.HasCertificate = bool(in.Bool()) out.HasCertificate = bool(in.Bool())
case "mixedContentType":
(out.MixedContentType).UnmarshalEasyJSON(in)
default: default:
in.SkipRecursive() in.SkipRecursive()
} }
@ -82,6 +84,12 @@ func easyjsonC5a4559bEncodeGithubComKnqChromedpCdpSecurity(out *jwriter.Writer,
first = false first = false
out.RawString("\"hasCertificate\":") out.RawString("\"hasCertificate\":")
out.Bool(bool(in.HasCertificate)) out.Bool(bool(in.HasCertificate))
if !first {
out.RawByte(',')
}
first = false
out.RawString("\"mixedContentType\":")
(in.MixedContentType).MarshalEasyJSON(out)
out.RawByte('}') out.RawByte('}')
} }

View File

@ -18,6 +18,52 @@ func (t CertificateID) Int64() int64 {
return int64(t) return int64(t)
} }
// MixedContentType a description of mixed content (HTTP resources on HTTPS
// pages), as defined by https://www.w3.org/TR/mixed-content/#categories.
type MixedContentType string
// String returns the MixedContentType as string value.
func (t MixedContentType) String() string {
return string(t)
}
// MixedContentType values.
const (
MixedContentTypeBlockable MixedContentType = "blockable"
MixedContentTypeOptionallyBlockable MixedContentType = "optionally-blockable"
MixedContentTypeNone MixedContentType = "none"
)
// MarshalEasyJSON satisfies easyjson.Marshaler.
func (t MixedContentType) MarshalEasyJSON(out *jwriter.Writer) {
out.String(string(t))
}
// MarshalJSON satisfies json.Marshaler.
func (t MixedContentType) MarshalJSON() ([]byte, error) {
return easyjson.Marshal(t)
}
// UnmarshalEasyJSON satisfies easyjson.Unmarshaler.
func (t *MixedContentType) UnmarshalEasyJSON(in *jlexer.Lexer) {
switch MixedContentType(in.String()) {
case MixedContentTypeBlockable:
*t = MixedContentTypeBlockable
case MixedContentTypeOptionallyBlockable:
*t = MixedContentTypeOptionallyBlockable
case MixedContentTypeNone:
*t = MixedContentTypeNone
default:
in.AddError(errors.New("unknown MixedContentType value"))
}
}
// UnmarshalJSON satisfies json.Unmarshaler.
func (t *MixedContentType) UnmarshalJSON(buf []byte) error {
return easyjson.Unmarshal(buf, t)
}
// State the security level of a page or resource. // State the security level of a page or resource.
type State string type State string
@ -75,10 +121,11 @@ func (t *State) UnmarshalJSON(buf []byte) error {
// StateExplanation an explanation of an factor contributing to the security // StateExplanation an explanation of an factor contributing to the security
// state. // state.
type StateExplanation struct { type StateExplanation struct {
SecurityState State `json:"securityState"` // Security state representing the severity of the factor being explained. SecurityState State `json:"securityState"` // Security state representing the severity of the factor being explained.
Summary string `json:"summary"` // Short phrase describing the type of factor. Summary string `json:"summary"` // Short phrase describing the type of factor.
Description string `json:"description"` // Full text explanation of the factor. Description string `json:"description"` // Full text explanation of the factor.
HasCertificate bool `json:"hasCertificate"` // True if the page has a certificate. HasCertificate bool `json:"hasCertificate"` // True if the page has a certificate.
MixedContentType MixedContentType `json:"mixedContentType"` // The type of mixed content described by the explanation.
} }
// InsecureContentStatus information about insecure content on the page. // InsecureContentStatus information about insecure content on the page.

View File

@ -12,11 +12,8 @@
// - add 'Inspector.Message' type as a object with id (integer), method (MethodType), params (interface{}), error (MessageError). // - add 'Inspector.Message' type as a object with id (integer), method (MethodType), params (interface{}), error (MessageError).
// - add 'Inspector.DetachReason' type and change event 'Inspector.detached''s parameter reason's type. // - add 'Inspector.DetachReason' type and change event 'Inspector.detached''s parameter reason's type.
// - add 'Inspector.ErrorType' type. // - add 'Inspector.ErrorType' type.
// - change type of Network.Timestamp and Runtime.Timestamp to internal Timestamp type. // - change type of Network.TimeSinceEpoch, Network.MonotonicTime, and
// - add 'Page.Bootstamp' type and convert all command/event parameters named // Runtime.Timestamp to internal Timestamp type.
// 'timestamp' in the Page domain to the Bootstamp type.
// - change any object property or command/event parameter named 'timestamp'
// that doesn't have a $ref defined to 'Network.Timestamp'.
// - convert object properties and event/command parameters that are enums into independent types. // - convert object properties and event/command parameters that are enums into independent types.
// - change '*.modifiers' parameters to type Input.Modifier. // - change '*.modifiers' parameters to type Input.Modifier.
// - add 'DOM.NodeType' type and convert "nodeType" parameters to it. // - add 'DOM.NodeType' type and convert "nodeType" parameters to it.
@ -59,7 +56,8 @@ func setup() {
"Inspector.Message": true, "Inspector.Message": true,
"Inspector.MethodType": true, "Inspector.MethodType": true,
"Network.LoaderId": true, "Network.LoaderId": true,
"Network.Timestamp": true, "Network.MonotonicTime": true,
"Network.TimeSinceEpoch": true,
"Page.FrameId": true, "Page.FrameId": true,
"Page.Frame": true, "Page.Frame": true,
} }
@ -206,14 +204,6 @@ func FixDomains(domains []*internal.Domain) {
}, },
} }
// bootstamp type
bootstampType := &internal.Type{
ID: "Bootstamp",
Type: internal.TypeTimestamp,
TimestampType: internal.TimestampTypeBootstamp,
Description: "Bootstamp type.",
}
// process domains // process domains
for _, d := range domains { for _, d := range domains {
switch d.Domain { switch d.Domain {
@ -246,8 +236,14 @@ func FixDomains(domains []*internal.Domain) {
// add Input types // add Input types
d.Types = append(d.Types, modifierType) d.Types = append(d.Types, modifierType)
for _, t := range d.Types { for _, t := range d.Types {
if t.ID == "GestureSourceType" { switch t.ID {
case "GestureSourceType":
t.ID = "GestureType" t.ID = "GestureType"
case "TimeSinceEpoch":
t.Type = internal.TypeTimestamp
t.TimestampType = internal.TimestampTypeSecond
t.Extra = templates.ExtraTimestampTemplate(t, d)
} }
} }
@ -296,14 +292,8 @@ func FixDomains(domains []*internal.Domain) {
} }
case internal.DomainPage: case internal.DomainPage:
// add Page types
d.Types = append(d.Types, bootstampType)
for _, t := range d.Types { for _, t := range d.Types {
switch t.ID { switch t.ID {
case "Bootstamp":
t.Extra += templates.ExtraTimestampTemplate(t, d)
case "FrameId": case "FrameId":
t.Extra += templates.ExtraFixStringUnmarshaler(internal.ForceCamel(t.ID), "", "") t.Extra += templates.ExtraFixStringUnmarshaler(internal.ForceCamel(t.ID), "", "")
@ -352,13 +342,20 @@ func FixDomains(domains []*internal.Domain) {
case internal.DomainNetwork: case internal.DomainNetwork:
for _, t := range d.Types { for _, t := range d.Types {
// change Timestamp to TypeTimestamp and add extra unmarshaling template // change Monotonic to TypeTimestamp and add extra unmarshaling template
if t.ID == "Timestamp" { if t.ID == "TimeSinceEpoch" {
t.Type = internal.TypeTimestamp t.Type = internal.TypeTimestamp
t.TimestampType = internal.TimestampTypeSecond t.TimestampType = internal.TimestampTypeSecond
t.Extra = templates.ExtraTimestampTemplate(t, d) t.Extra = templates.ExtraTimestampTemplate(t, d)
} }
// change Monotonic to TypeTimestamp and add extra unmarshaling template
if t.ID == "MonotonicTime" {
t.Type = internal.TypeTimestamp
t.TimestampType = internal.TimestampTypeMonotonic
t.Extra = templates.ExtraTimestampTemplate(t, d)
}
// change Headers to be a map[string]interface{} // change Headers to be a map[string]interface{}
if t.ID == "Headers" { if t.ID == "Headers" {
t.Type = internal.TypeAny t.Type = internal.TypeAny
@ -464,22 +461,6 @@ func convertObjectProperties(params []*internal.Type, d *internal.Domain, name s
case p.Enum != nil: case p.Enum != nil:
r = append(r, fixupEnumParameter(name, p, d)) r = append(r, fixupEnumParameter(name, p, d))
case p.Name == "timestamp" && p.Ref == "" && d.Domain == internal.DomainPage:
r = append(r, &internal.Type{
Name: p.Name,
Ref: "Page.Bootstamp",
Description: p.Description,
Optional: p.Optional,
})
case p.Name == "timestamp" && p.Ref == "":
r = append(r, &internal.Type{
Name: p.Name,
Ref: "Network.Timestamp",
Description: p.Description,
Optional: p.Optional,
})
case p.Name == "modifiers": case p.Name == "modifiers":
r = append(r, &internal.Type{ r = append(r, &internal.Type{
Name: p.Name, Name: p.Name,

View File

@ -156,5 +156,5 @@ type TimestampType int
const ( const (
TimestampTypeMillisecond TimestampType = 1 + iota TimestampTypeMillisecond TimestampType = 1 + iota
TimestampTypeSecond TimestampTypeSecond
TimestampTypeBootstamp TimestampTypeMonotonic
) )

View File

@ -97,7 +97,8 @@
"description": "Actions and events related to the inspected page belong to the page domain.", "description": "Actions and events related to the inspected page belong to the page domain.",
"dependencies": [ "dependencies": [
"Debugger", "Debugger",
"DOM" "DOM",
"Network"
], ],
"types": [ "types": [
{ {
@ -191,7 +192,7 @@
}, },
{ {
"name": "lastModified", "name": "lastModified",
"$ref": "Network.Timestamp", "$ref": "Network.TimeSinceEpoch",
"description": "last-modified timestamp as reported by server.", "description": "last-modified timestamp as reported by server.",
"optional": true "optional": true
}, },
@ -348,7 +349,7 @@
}, },
{ {
"name": "timestamp", "name": "timestamp",
"type": "number", "$ref": "Network.TimeSinceEpoch",
"optional": true, "optional": true,
"experimental": true, "experimental": true,
"description": "Frame swap timestamp." "description": "Frame swap timestamp."
@ -503,6 +504,8 @@
"description": "Identifier of the added script." "description": "Identifier of the added script."
} }
], ],
"deprecated": true,
"description": "Deprecated, please use addScriptToEvaluateOnNewDocument instead.",
"experimental": true "experimental": true
}, },
{ {
@ -513,6 +516,37 @@
"$ref": "ScriptIdentifier" "$ref": "ScriptIdentifier"
} }
], ],
"deprecated": true,
"description": "Deprecated, please use removeScriptToEvaluateOnNewDocument instead.",
"experimental": true
},
{
"name": "addScriptToEvaluateOnNewDocument",
"parameters": [
{
"name": "source",
"type": "string"
}
],
"returns": [
{
"name": "identifier",
"$ref": "ScriptIdentifier",
"description": "Identifier of the added script."
}
],
"description": "Evaluates given script in every frame upon creation (before loading frame's scripts).",
"experimental": true
},
{
"name": "removeScriptToEvaluateOnNewDocument",
"parameters": [
{
"name": "identifier",
"$ref": "ScriptIdentifier"
}
],
"description": "Removes given script from the list.",
"experimental": true "experimental": true
}, },
{ {
@ -1226,7 +1260,7 @@
"parameters": [ "parameters": [
{ {
"name": "timestamp", "name": "timestamp",
"type": "number" "$ref": "Network.MonotonicTime"
} }
] ]
}, },
@ -1235,7 +1269,7 @@
"parameters": [ "parameters": [
{ {
"name": "timestamp", "name": "timestamp",
"type": "number" "$ref": "Network.MonotonicTime"
} }
] ]
}, },
@ -2140,6 +2174,16 @@
"type": "integer", "type": "integer",
"description": "An internal certificate ID value." "description": "An internal certificate ID value."
}, },
{
"id": "MixedContentType",
"type": "string",
"enum": [
"blockable",
"optionally-blockable",
"none"
],
"description": "A description of mixed content (HTTP resources on HTTPS pages), as defined by https://www.w3.org/TR/mixed-content/#categories"
},
{ {
"id": "SecurityState", "id": "SecurityState",
"type": "string", "type": "string",
@ -2176,6 +2220,11 @@
"name": "hasCertificate", "name": "hasCertificate",
"type": "boolean", "type": "boolean",
"description": "True if the page has a certificate." "description": "True if the page has a certificate."
},
{
"name": "mixedContentType",
"$ref": "MixedContentType",
"description": "The type of mixed content described by the explanation."
} }
], ],
"description": "An explanation of an factor contributing to the security state." "description": "An explanation of an factor contributing to the security state."
@ -2375,9 +2424,14 @@
"description": "Network level fetch failure reason." "description": "Network level fetch failure reason."
}, },
{ {
"id": "Timestamp", "id": "TimeSinceEpoch",
"type": "number", "type": "number",
"description": "Number of seconds since epoch." "description": "UTC time in seconds, counted from January 1, 1970."
},
{
"id": "MonotonicTime",
"type": "number",
"description": "Monotonically increasing time in seconds since an arbitrary point in the past."
}, },
{ {
"id": "Headers", "id": "Headers",
@ -2540,14 +2594,9 @@
}, },
{ {
"name": "mixedContentType", "name": "mixedContentType",
"$ref": "Security.MixedContentType",
"optional": true, "optional": true,
"type": "string", "description": "The mixed content type of the request."
"enum": [
"blockable",
"optionally-blockable",
"none"
],
"description": "The mixed content status of the request, as defined in http://www.w3.org/TR/mixed-content/"
}, },
{ {
"name": "initialPriority", "name": "initialPriority",
@ -2604,7 +2653,7 @@
}, },
{ {
"name": "timestamp", "name": "timestamp",
"$ref": "Timestamp", "$ref": "TimeSinceEpoch",
"description": "Issuance date." "description": "Issuance date."
}, },
{ {
@ -2681,12 +2730,12 @@
}, },
{ {
"name": "validFrom", "name": "validFrom",
"$ref": "Timestamp", "$ref": "TimeSinceEpoch",
"description": "Certificate valid from date." "description": "Certificate valid from date."
}, },
{ {
"name": "validTo", "name": "validTo",
"$ref": "Timestamp", "$ref": "TimeSinceEpoch",
"description": "Certificate valid to (expiration) date" "description": "Certificate valid to (expiration) date"
}, },
{ {
@ -3327,7 +3376,7 @@
}, },
{ {
"name": "expirationDate", "name": "expirationDate",
"$ref": "Timestamp", "$ref": "TimeSinceEpoch",
"optional": true, "optional": true,
"description": "If omitted, the cookie becomes a session cookie." "description": "If omitted, the cookie becomes a session cookie."
} }
@ -3448,7 +3497,7 @@
"experimental": true "experimental": true
}, },
{ {
"name": "enableRequestInterception", "name": "setRequestInterceptionEnabled",
"parameters": [ "parameters": [
{ {
"name": "enabled", "name": "enabled",
@ -3529,7 +3578,7 @@
}, },
{ {
"name": "timestamp", "name": "timestamp",
"$ref": "Timestamp", "$ref": "MonotonicTime",
"description": "Timestamp." "description": "Timestamp."
} }
], ],
@ -3561,14 +3610,14 @@
}, },
{ {
"name": "timestamp", "name": "timestamp",
"$ref": "Timestamp", "$ref": "MonotonicTime",
"description": "Timestamp." "description": "Timestamp."
}, },
{ {
"name": "wallTime", "name": "wallTime",
"$ref": "Timestamp", "$ref": "TimeSinceEpoch",
"experimental": true, "experimental": true,
"description": "UTC Timestamp." "description": "Timestamp."
}, },
{ {
"name": "initiator", "name": "initiator",
@ -3624,7 +3673,7 @@
}, },
{ {
"name": "timestamp", "name": "timestamp",
"$ref": "Timestamp", "$ref": "MonotonicTime",
"description": "Timestamp." "description": "Timestamp."
}, },
{ {
@ -3657,7 +3706,7 @@
}, },
{ {
"name": "timestamp", "name": "timestamp",
"$ref": "Timestamp", "$ref": "MonotonicTime",
"description": "Timestamp." "description": "Timestamp."
}, },
{ {
@ -3683,7 +3732,7 @@
}, },
{ {
"name": "timestamp", "name": "timestamp",
"$ref": "Timestamp", "$ref": "MonotonicTime",
"description": "Timestamp." "description": "Timestamp."
}, },
{ {
@ -3704,7 +3753,7 @@
}, },
{ {
"name": "timestamp", "name": "timestamp",
"$ref": "Timestamp", "$ref": "MonotonicTime",
"description": "Timestamp." "description": "Timestamp."
}, },
{ {
@ -3743,12 +3792,12 @@
}, },
{ {
"name": "timestamp", "name": "timestamp",
"$ref": "Timestamp", "$ref": "MonotonicTime",
"description": "Timestamp." "description": "Timestamp."
}, },
{ {
"name": "wallTime", "name": "wallTime",
"$ref": "Timestamp", "$ref": "TimeSinceEpoch",
"experimental": true, "experimental": true,
"description": "UTC Timestamp." "description": "UTC Timestamp."
}, },
@ -3771,7 +3820,7 @@
}, },
{ {
"name": "timestamp", "name": "timestamp",
"$ref": "Timestamp", "$ref": "MonotonicTime",
"description": "Timestamp." "description": "Timestamp."
}, },
{ {
@ -3816,7 +3865,7 @@
}, },
{ {
"name": "timestamp", "name": "timestamp",
"$ref": "Timestamp", "$ref": "MonotonicTime",
"description": "Timestamp." "description": "Timestamp."
} }
], ],
@ -3833,7 +3882,7 @@
}, },
{ {
"name": "timestamp", "name": "timestamp",
"$ref": "Timestamp", "$ref": "MonotonicTime",
"description": "Timestamp." "description": "Timestamp."
}, },
{ {
@ -3855,7 +3904,7 @@
}, },
{ {
"name": "timestamp", "name": "timestamp",
"$ref": "Timestamp", "$ref": "MonotonicTime",
"description": "Timestamp." "description": "Timestamp."
}, },
{ {
@ -3877,7 +3926,7 @@
}, },
{ {
"name": "timestamp", "name": "timestamp",
"$ref": "Timestamp", "$ref": "MonotonicTime",
"description": "Timestamp." "description": "Timestamp."
}, },
{ {
@ -3899,7 +3948,7 @@
}, },
{ {
"name": "timestamp", "name": "timestamp",
"$ref": "Timestamp", "$ref": "MonotonicTime",
"description": "Timestamp." "description": "Timestamp."
}, },
{ {
@ -8642,6 +8691,11 @@
"touch", "touch",
"mouse" "mouse"
] ]
},
{
"id": "TimeSinceEpoch",
"type": "number",
"description": "UTC time in seconds, counted from January 1, 1970."
} }
], ],
"commands": [ "commands": [
@ -8678,9 +8732,9 @@
}, },
{ {
"name": "timestamp", "name": "timestamp",
"type": "number", "$ref": "TimeSinceEpoch",
"optional": true, "optional": true,
"description": "Time at which the event occurred. Measured in UTC time in seconds since January 1, 1970 (default: current time)." "description": "Time at which the event occurred."
}, },
{ {
"name": "text", "name": "text",
@ -8776,9 +8830,9 @@
}, },
{ {
"name": "timestamp", "name": "timestamp",
"type": "number", "$ref": "TimeSinceEpoch",
"optional": true, "optional": true,
"description": "Time at which the event occurred. Measured in UTC time in seconds since January 1, 1970 (default: current time)." "description": "Time at which the event occurred."
}, },
{ {
"name": "button", "name": "button",
@ -8831,9 +8885,9 @@
}, },
{ {
"name": "timestamp", "name": "timestamp",
"type": "number", "$ref": "TimeSinceEpoch",
"optional": true, "optional": true,
"description": "Time at which the event occurred. Measured in UTC time in seconds since January 1, 1970 (default: current time)." "description": "Time at which the event occurred."
} }
], ],
"description": "Dispatches a touch event to the page." "description": "Dispatches a touch event to the page."
@ -8865,8 +8919,8 @@
}, },
{ {
"name": "timestamp", "name": "timestamp",
"type": "number", "$ref": "TimeSinceEpoch",
"description": "Time at which the event occurred. Measured in UTC time in seconds since January 1, 1970." "description": "Time at which the event occurred."
}, },
{ {
"name": "button", "name": "button",

View File

@ -6,15 +6,26 @@
// defines its JSON unmarshaling. // defines its JSON unmarshaling.
{% func ExtraTimestampTemplate(t *internal.Type, d *internal.Domain) %}{%code {% func ExtraTimestampTemplate(t *internal.Type, d *internal.Domain) %}{%code
typ := t.IDorName() typ := t.IDorName()
bootstamp := t.TimestampType == internal.TimestampTypeBootstamp monotonic := t.TimestampType == internal.TimestampTypeMonotonic
timeRes := "time.Millisecond" timeRes := "time.Millisecond"
if t.TimestampType != internal.TimestampTypeMillisecond { if t.TimestampType != internal.TimestampTypeMillisecond {
timeRes = "time.Second" timeRes = "time.Second"
} }
%} %}
{% if monotonic %}
// {%s= typ %}Epoch is the {%s= typ %} time epoch.
var {%s= typ %}Epoch *time.Time
func init() {
// initialize epoch
bt := sysutil.BootTime()
{%s= typ %}Epoch = &bt
}
{% endif %}
// MarshalEasyJSON satisfies easyjson.Marshaler. // MarshalEasyJSON satisfies easyjson.Marshaler.
func (t {%s= typ %}) MarshalEasyJSON(out *jwriter.Writer) { func (t {%s= typ %}) MarshalEasyJSON(out *jwriter.Writer) {
v := {% if bootstamp %}float64(time.Time(t).Sub(sysutil.BootTime()))/float64(time.Second){% else %}float64(time.Time(t).UnixNano()/int64({%s= timeRes %})){% endif %} v := {% if monotonic %}float64(time.Time(t).Sub(*{%s= typ %}Epoch))/float64(time.Second){% else %}float64(time.Time(t).UnixNano()/int64({%s= timeRes %})){% endif %}
out.Buffer.EnsureSpace(20) out.Buffer.EnsureSpace(20)
out.Buffer.Buf = strconv.AppendFloat(out.Buffer.Buf, v, 'f', -1, 64) out.Buffer.Buf = strconv.AppendFloat(out.Buffer.Buf, v, 'f', -1, 64)
@ -26,8 +37,8 @@ func (t {%s= typ %}) MarshalJSON() ([]byte, error) {
} }
// UnmarshalEasyJSON satisfies easyjson.Unmarshaler. // UnmarshalEasyJSON satisfies easyjson.Unmarshaler.
func (t *{%s= typ %}) UnmarshalEasyJSON(in *jlexer.Lexer) {{% if bootstamp %} func (t *{%s= typ %}) UnmarshalEasyJSON(in *jlexer.Lexer) {{% if monotonic %}
*t = {%s= typ %}(sysutil.BootTime().Add(time.Duration(in.Float64()*float64(time.Second)))){% else %} *t = {%s= typ %}({%s= typ %}Epoch.Add(time.Duration(in.Float64()*float64(time.Second)))){% else %}
*t = {%s= typ %}(time.Unix(0, int64(in.Float64()*float64({%s= timeRes %})))){% endif %} *t = {%s= typ %}(time.Unix(0, int64(in.Float64()*float64({%s= timeRes %})))){% endif %}
} }

View File

@ -29,7 +29,7 @@ var (
func StreamExtraTimestampTemplate(qw422016 *qt422016.Writer, t *internal.Type, d *internal.Domain) { func StreamExtraTimestampTemplate(qw422016 *qt422016.Writer, t *internal.Type, d *internal.Domain) {
//line templates/extra.qtpl:8 //line templates/extra.qtpl:8
typ := t.IDorName() typ := t.IDorName()
bootstamp := t.TimestampType == internal.TimestampTypeBootstamp monotonic := t.TimestampType == internal.TimestampTypeMonotonic
timeRes := "time.Millisecond" timeRes := "time.Millisecond"
if t.TimestampType != internal.TimestampTypeMillisecond { if t.TimestampType != internal.TimestampTypeMillisecond {
timeRes = "time.Second" timeRes = "time.Second"
@ -37,28 +37,67 @@ func StreamExtraTimestampTemplate(qw422016 *qt422016.Writer, t *internal.Type, d
//line templates/extra.qtpl:14 //line templates/extra.qtpl:14
qw422016.N().S(` qw422016.N().S(`
`)
//line templates/extra.qtpl:15
if monotonic {
//line templates/extra.qtpl:15
qw422016.N().S(`
// `)
//line templates/extra.qtpl:16
qw422016.N().S(typ)
//line templates/extra.qtpl:16
qw422016.N().S(`Epoch is the `)
//line templates/extra.qtpl:16
qw422016.N().S(typ)
//line templates/extra.qtpl:16
qw422016.N().S(` time epoch.
var `)
//line templates/extra.qtpl:17
qw422016.N().S(typ)
//line templates/extra.qtpl:17
qw422016.N().S(`Epoch *time.Time
func init() {
// initialize epoch
bt := sysutil.BootTime()
`)
//line templates/extra.qtpl:22
qw422016.N().S(typ)
//line templates/extra.qtpl:22
qw422016.N().S(`Epoch = &bt
}
`)
//line templates/extra.qtpl:24
}
//line templates/extra.qtpl:24
qw422016.N().S(`
// MarshalEasyJSON satisfies easyjson.Marshaler. // MarshalEasyJSON satisfies easyjson.Marshaler.
func (t `) func (t `)
//line templates/extra.qtpl:16 //line templates/extra.qtpl:27
qw422016.N().S(typ) qw422016.N().S(typ)
//line templates/extra.qtpl:16 //line templates/extra.qtpl:27
qw422016.N().S(`) MarshalEasyJSON(out *jwriter.Writer) { qw422016.N().S(`) MarshalEasyJSON(out *jwriter.Writer) {
v := `) v := `)
//line templates/extra.qtpl:17 //line templates/extra.qtpl:28
if bootstamp { if monotonic {
//line templates/extra.qtpl:17 //line templates/extra.qtpl:28
qw422016.N().S(`float64(time.Time(t).Sub(sysutil.BootTime()))/float64(time.Second)`) qw422016.N().S(`float64(time.Time(t).Sub(*`)
//line templates/extra.qtpl:17 //line templates/extra.qtpl:28
qw422016.N().S(typ)
//line templates/extra.qtpl:28
qw422016.N().S(`Epoch))/float64(time.Second)`)
//line templates/extra.qtpl:28
} else { } else {
//line templates/extra.qtpl:17 //line templates/extra.qtpl:28
qw422016.N().S(`float64(time.Time(t).UnixNano()/int64(`) qw422016.N().S(`float64(time.Time(t).UnixNano()/int64(`)
//line templates/extra.qtpl:17 //line templates/extra.qtpl:28
qw422016.N().S(timeRes) qw422016.N().S(timeRes)
//line templates/extra.qtpl:17 //line templates/extra.qtpl:28
qw422016.N().S(`))`) qw422016.N().S(`))`)
//line templates/extra.qtpl:17 //line templates/extra.qtpl:28
} }
//line templates/extra.qtpl:17 //line templates/extra.qtpl:28
qw422016.N().S(` qw422016.N().S(`
out.Buffer.EnsureSpace(20) out.Buffer.EnsureSpace(20)
@ -67,90 +106,94 @@ func (t `)
// MarshalJSON satisfies json.Marshaler. // MarshalJSON satisfies json.Marshaler.
func (t `) func (t `)
//line templates/extra.qtpl:24 //line templates/extra.qtpl:35
qw422016.N().S(typ) qw422016.N().S(typ)
//line templates/extra.qtpl:24 //line templates/extra.qtpl:35
qw422016.N().S(`) MarshalJSON() ([]byte, error) { qw422016.N().S(`) MarshalJSON() ([]byte, error) {
return easyjson.Marshal(t) return easyjson.Marshal(t)
} }
// UnmarshalEasyJSON satisfies easyjson.Unmarshaler. // UnmarshalEasyJSON satisfies easyjson.Unmarshaler.
func (t *`) func (t *`)
//line templates/extra.qtpl:29 //line templates/extra.qtpl:40
qw422016.N().S(typ) qw422016.N().S(typ)
//line templates/extra.qtpl:29 //line templates/extra.qtpl:40
qw422016.N().S(`) UnmarshalEasyJSON(in *jlexer.Lexer) {`) qw422016.N().S(`) UnmarshalEasyJSON(in *jlexer.Lexer) {`)
//line templates/extra.qtpl:29 //line templates/extra.qtpl:40
if bootstamp { if monotonic {
//line templates/extra.qtpl:29 //line templates/extra.qtpl:40
qw422016.N().S(` qw422016.N().S(`
*t = `) *t = `)
//line templates/extra.qtpl:30 //line templates/extra.qtpl:41
qw422016.N().S(typ) qw422016.N().S(typ)
//line templates/extra.qtpl:30 //line templates/extra.qtpl:41
qw422016.N().S(`(sysutil.BootTime().Add(time.Duration(in.Float64()*float64(time.Second))))`) qw422016.N().S(`(`)
//line templates/extra.qtpl:30 //line templates/extra.qtpl:41
qw422016.N().S(typ)
//line templates/extra.qtpl:41
qw422016.N().S(`Epoch.Add(time.Duration(in.Float64()*float64(time.Second))))`)
//line templates/extra.qtpl:41
} else { } else {
//line templates/extra.qtpl:30 //line templates/extra.qtpl:41
qw422016.N().S(` qw422016.N().S(`
*t = `) *t = `)
//line templates/extra.qtpl:31 //line templates/extra.qtpl:42
qw422016.N().S(typ) qw422016.N().S(typ)
//line templates/extra.qtpl:31 //line templates/extra.qtpl:42
qw422016.N().S(`(time.Unix(0, int64(in.Float64()*float64(`) qw422016.N().S(`(time.Unix(0, int64(in.Float64()*float64(`)
//line templates/extra.qtpl:31 //line templates/extra.qtpl:42
qw422016.N().S(timeRes) qw422016.N().S(timeRes)
//line templates/extra.qtpl:31 //line templates/extra.qtpl:42
qw422016.N().S(`))))`) qw422016.N().S(`))))`)
//line templates/extra.qtpl:31 //line templates/extra.qtpl:42
} }
//line templates/extra.qtpl:31 //line templates/extra.qtpl:42
qw422016.N().S(` qw422016.N().S(`
} }
// UnmarshalJSON satisfies json.Unmarshaler. // UnmarshalJSON satisfies json.Unmarshaler.
func (t *`) func (t *`)
//line templates/extra.qtpl:35 //line templates/extra.qtpl:46
qw422016.N().S(typ) qw422016.N().S(typ)
//line templates/extra.qtpl:35 //line templates/extra.qtpl:46
qw422016.N().S(`) UnmarshalJSON(buf []byte) error { qw422016.N().S(`) UnmarshalJSON(buf []byte) error {
return easyjson.Unmarshal(buf, t) return easyjson.Unmarshal(buf, t)
} }
`) `)
//line templates/extra.qtpl:38 //line templates/extra.qtpl:49
} }
//line templates/extra.qtpl:38 //line templates/extra.qtpl:49
func WriteExtraTimestampTemplate(qq422016 qtio422016.Writer, t *internal.Type, d *internal.Domain) { func WriteExtraTimestampTemplate(qq422016 qtio422016.Writer, t *internal.Type, d *internal.Domain) {
//line templates/extra.qtpl:38 //line templates/extra.qtpl:49
qw422016 := qt422016.AcquireWriter(qq422016) qw422016 := qt422016.AcquireWriter(qq422016)
//line templates/extra.qtpl:38 //line templates/extra.qtpl:49
StreamExtraTimestampTemplate(qw422016, t, d) StreamExtraTimestampTemplate(qw422016, t, d)
//line templates/extra.qtpl:38 //line templates/extra.qtpl:49
qt422016.ReleaseWriter(qw422016) qt422016.ReleaseWriter(qw422016)
//line templates/extra.qtpl:38 //line templates/extra.qtpl:49
} }
//line templates/extra.qtpl:38 //line templates/extra.qtpl:49
func ExtraTimestampTemplate(t *internal.Type, d *internal.Domain) string { func ExtraTimestampTemplate(t *internal.Type, d *internal.Domain) string {
//line templates/extra.qtpl:38 //line templates/extra.qtpl:49
qb422016 := qt422016.AcquireByteBuffer() qb422016 := qt422016.AcquireByteBuffer()
//line templates/extra.qtpl:38 //line templates/extra.qtpl:49
WriteExtraTimestampTemplate(qb422016, t, d) WriteExtraTimestampTemplate(qb422016, t, d)
//line templates/extra.qtpl:38 //line templates/extra.qtpl:49
qs422016 := string(qb422016.B) qs422016 := string(qb422016.B)
//line templates/extra.qtpl:38 //line templates/extra.qtpl:49
qt422016.ReleaseByteBuffer(qb422016) qt422016.ReleaseByteBuffer(qb422016)
//line templates/extra.qtpl:38 //line templates/extra.qtpl:49
return qs422016 return qs422016
//line templates/extra.qtpl:38 //line templates/extra.qtpl:49
} }
// ExtraFrameTemplate is a special template for the Page.Frame type, adding FrameState. // ExtraFrameTemplate is a special template for the Page.Frame type, adding FrameState.
//line templates/extra.qtpl:41 //line templates/extra.qtpl:52
func StreamExtraFrameTemplate(qw422016 *qt422016.Writer) { func StreamExtraFrameTemplate(qw422016 *qt422016.Writer) {
//line templates/extra.qtpl:41 //line templates/extra.qtpl:52
qw422016.N().S(` qw422016.N().S(`
// FrameState is the state of a Frame. // FrameState is the state of a Frame.
type FrameState uint16 type FrameState uint16
@ -189,40 +232,40 @@ func (fs FrameState) String() string {
// EmptyFrameID is the "non-existent" frame id. // EmptyFrameID is the "non-existent" frame id.
const EmptyFrameID = FrameID("") const EmptyFrameID = FrameID("")
`) `)
//line templates/extra.qtpl:78 //line templates/extra.qtpl:89
} }
//line templates/extra.qtpl:78 //line templates/extra.qtpl:89
func WriteExtraFrameTemplate(qq422016 qtio422016.Writer) { func WriteExtraFrameTemplate(qq422016 qtio422016.Writer) {
//line templates/extra.qtpl:78 //line templates/extra.qtpl:89
qw422016 := qt422016.AcquireWriter(qq422016) qw422016 := qt422016.AcquireWriter(qq422016)
//line templates/extra.qtpl:78 //line templates/extra.qtpl:89
StreamExtraFrameTemplate(qw422016) StreamExtraFrameTemplate(qw422016)
//line templates/extra.qtpl:78 //line templates/extra.qtpl:89
qt422016.ReleaseWriter(qw422016) qt422016.ReleaseWriter(qw422016)
//line templates/extra.qtpl:78 //line templates/extra.qtpl:89
} }
//line templates/extra.qtpl:78 //line templates/extra.qtpl:89
func ExtraFrameTemplate() string { func ExtraFrameTemplate() string {
//line templates/extra.qtpl:78 //line templates/extra.qtpl:89
qb422016 := qt422016.AcquireByteBuffer() qb422016 := qt422016.AcquireByteBuffer()
//line templates/extra.qtpl:78 //line templates/extra.qtpl:89
WriteExtraFrameTemplate(qb422016) WriteExtraFrameTemplate(qb422016)
//line templates/extra.qtpl:78 //line templates/extra.qtpl:89
qs422016 := string(qb422016.B) qs422016 := string(qb422016.B)
//line templates/extra.qtpl:78 //line templates/extra.qtpl:89
qt422016.ReleaseByteBuffer(qb422016) qt422016.ReleaseByteBuffer(qb422016)
//line templates/extra.qtpl:78 //line templates/extra.qtpl:89
return qs422016 return qs422016
//line templates/extra.qtpl:78 //line templates/extra.qtpl:89
} }
// ExtraNodeTemplate is a special template for the DOM.Node type, adding NodeState. // ExtraNodeTemplate is a special template for the DOM.Node type, adding NodeState.
//line templates/extra.qtpl:81 //line templates/extra.qtpl:92
func StreamExtraNodeTemplate(qw422016 *qt422016.Writer) { func StreamExtraNodeTemplate(qw422016 *qt422016.Writer) {
//line templates/extra.qtpl:81 //line templates/extra.qtpl:92
qw422016.N().S(` qw422016.N().S(`
// AttributeValue returns the named attribute for the node. // AttributeValue returns the named attribute for the node.
func (n *Node) AttributeValue(name string) string { func (n *Node) AttributeValue(name string) string {
@ -256,21 +299,21 @@ func (n *Node) xpath(stopAtDocument, stopAtID bool) string {
case stopAtID && id != "": case stopAtID && id != "":
p = "/" p = "/"
pos = `) pos = `)
//line templates/extra.qtpl:81 //line templates/extra.qtpl:92
qw422016.N().S("`") qw422016.N().S("`")
//line templates/extra.qtpl:81 //line templates/extra.qtpl:92
qw422016.N().S(`[@id='`) qw422016.N().S(`[@id='`)
//line templates/extra.qtpl:81 //line templates/extra.qtpl:92
qw422016.N().S("`") qw422016.N().S("`")
//line templates/extra.qtpl:81 //line templates/extra.qtpl:92
qw422016.N().S(`+id+`) qw422016.N().S(`+id+`)
//line templates/extra.qtpl:81 //line templates/extra.qtpl:92
qw422016.N().S("`") qw422016.N().S("`")
//line templates/extra.qtpl:81 //line templates/extra.qtpl:92
qw422016.N().S(`']`) qw422016.N().S(`']`)
//line templates/extra.qtpl:81 //line templates/extra.qtpl:92
qw422016.N().S("`") qw422016.N().S("`")
//line templates/extra.qtpl:81 //line templates/extra.qtpl:92
qw422016.N().S(` qw422016.N().S(`
case n.Parent != nil: case n.Parent != nil:
@ -354,136 +397,136 @@ func (ns NodeState) String() string {
// EmptyNodeID is the "non-existent" node id. // EmptyNodeID is the "non-existent" node id.
const EmptyNodeID = NodeID(0) const EmptyNodeID = NodeID(0)
`) `)
//line templates/extra.qtpl:195 //line templates/extra.qtpl:206
} }
//line templates/extra.qtpl:195 //line templates/extra.qtpl:206
func WriteExtraNodeTemplate(qq422016 qtio422016.Writer) { func WriteExtraNodeTemplate(qq422016 qtio422016.Writer) {
//line templates/extra.qtpl:195 //line templates/extra.qtpl:206
qw422016 := qt422016.AcquireWriter(qq422016) qw422016 := qt422016.AcquireWriter(qq422016)
//line templates/extra.qtpl:195 //line templates/extra.qtpl:206
StreamExtraNodeTemplate(qw422016) StreamExtraNodeTemplate(qw422016)
//line templates/extra.qtpl:195 //line templates/extra.qtpl:206
qt422016.ReleaseWriter(qw422016) qt422016.ReleaseWriter(qw422016)
//line templates/extra.qtpl:195 //line templates/extra.qtpl:206
} }
//line templates/extra.qtpl:195 //line templates/extra.qtpl:206
func ExtraNodeTemplate() string { func ExtraNodeTemplate() string {
//line templates/extra.qtpl:195 //line templates/extra.qtpl:206
qb422016 := qt422016.AcquireByteBuffer() qb422016 := qt422016.AcquireByteBuffer()
//line templates/extra.qtpl:195 //line templates/extra.qtpl:206
WriteExtraNodeTemplate(qb422016) WriteExtraNodeTemplate(qb422016)
//line templates/extra.qtpl:195 //line templates/extra.qtpl:206
qs422016 := string(qb422016.B) qs422016 := string(qb422016.B)
//line templates/extra.qtpl:195 //line templates/extra.qtpl:206
qt422016.ReleaseByteBuffer(qb422016) qt422016.ReleaseByteBuffer(qb422016)
//line templates/extra.qtpl:195 //line templates/extra.qtpl:206
return qs422016 return qs422016
//line templates/extra.qtpl:195 //line templates/extra.qtpl:206
} }
// ExtraFixStringUnmarshaler is a template that forces values to be parsed properly. // ExtraFixStringUnmarshaler is a template that forces values to be parsed properly.
//line templates/extra.qtpl:198 //line templates/extra.qtpl:209
func StreamExtraFixStringUnmarshaler(qw422016 *qt422016.Writer, typ, parseFunc, extra string) { func StreamExtraFixStringUnmarshaler(qw422016 *qt422016.Writer, typ, parseFunc, extra string) {
//line templates/extra.qtpl:198 //line templates/extra.qtpl:209
qw422016.N().S(` qw422016.N().S(`
// UnmarshalEasyJSON satisfies easyjson.Unmarshaler. // UnmarshalEasyJSON satisfies easyjson.Unmarshaler.
func (t *`) func (t *`)
//line templates/extra.qtpl:200 //line templates/extra.qtpl:211
qw422016.N().S(typ) qw422016.N().S(typ)
//line templates/extra.qtpl:200 //line templates/extra.qtpl:211
qw422016.N().S(`) UnmarshalEasyJSON(in *jlexer.Lexer) { qw422016.N().S(`) UnmarshalEasyJSON(in *jlexer.Lexer) {
buf := in.Raw() buf := in.Raw()
if l := len(buf); l > 2 && buf[0] == '"' && buf[l-1] == '"' { if l := len(buf); l > 2 && buf[0] == '"' && buf[l-1] == '"' {
buf = buf[1:l-1] buf = buf[1:l-1]
} }
`) `)
//line templates/extra.qtpl:205 //line templates/extra.qtpl:216
if parseFunc != "" { if parseFunc != "" {
//line templates/extra.qtpl:205 //line templates/extra.qtpl:216
qw422016.N().S(` qw422016.N().S(`
v, err := strconv.`) v, err := strconv.`)
//line templates/extra.qtpl:206 //line templates/extra.qtpl:217
qw422016.N().S(parseFunc) qw422016.N().S(parseFunc)
//line templates/extra.qtpl:206 //line templates/extra.qtpl:217
qw422016.N().S(`(string(buf)`) qw422016.N().S(`(string(buf)`)
//line templates/extra.qtpl:206 //line templates/extra.qtpl:217
qw422016.N().S(extra) qw422016.N().S(extra)
//line templates/extra.qtpl:206 //line templates/extra.qtpl:217
qw422016.N().S(`) qw422016.N().S(`)
if err != nil { if err != nil {
in.AddError(err) in.AddError(err)
} }
`) `)
//line templates/extra.qtpl:210 //line templates/extra.qtpl:221
} }
//line templates/extra.qtpl:210 //line templates/extra.qtpl:221
qw422016.N().S(` qw422016.N().S(`
*t = `) *t = `)
//line templates/extra.qtpl:211 //line templates/extra.qtpl:222
qw422016.N().S(typ) qw422016.N().S(typ)
//line templates/extra.qtpl:211 //line templates/extra.qtpl:222
qw422016.N().S(`(`) qw422016.N().S(`(`)
//line templates/extra.qtpl:211 //line templates/extra.qtpl:222
if parseFunc != "" { if parseFunc != "" {
//line templates/extra.qtpl:211 //line templates/extra.qtpl:222
qw422016.N().S(`v`) qw422016.N().S(`v`)
//line templates/extra.qtpl:211 //line templates/extra.qtpl:222
} else { } else {
//line templates/extra.qtpl:211 //line templates/extra.qtpl:222
qw422016.N().S(`buf`) qw422016.N().S(`buf`)
//line templates/extra.qtpl:211 //line templates/extra.qtpl:222
} }
//line templates/extra.qtpl:211 //line templates/extra.qtpl:222
qw422016.N().S(`) qw422016.N().S(`)
} }
// UnmarshalJSON satisfies json.Unmarshaler. // UnmarshalJSON satisfies json.Unmarshaler.
func (t *`) func (t *`)
//line templates/extra.qtpl:215 //line templates/extra.qtpl:226
qw422016.N().S(typ) qw422016.N().S(typ)
//line templates/extra.qtpl:215 //line templates/extra.qtpl:226
qw422016.N().S(`) UnmarshalJSON(buf []byte) error { qw422016.N().S(`) UnmarshalJSON(buf []byte) error {
return easyjson.Unmarshal(buf, t) return easyjson.Unmarshal(buf, t)
} }
`) `)
//line templates/extra.qtpl:218 //line templates/extra.qtpl:229
} }
//line templates/extra.qtpl:218 //line templates/extra.qtpl:229
func WriteExtraFixStringUnmarshaler(qq422016 qtio422016.Writer, typ, parseFunc, extra string) { func WriteExtraFixStringUnmarshaler(qq422016 qtio422016.Writer, typ, parseFunc, extra string) {
//line templates/extra.qtpl:218 //line templates/extra.qtpl:229
qw422016 := qt422016.AcquireWriter(qq422016) qw422016 := qt422016.AcquireWriter(qq422016)
//line templates/extra.qtpl:218 //line templates/extra.qtpl:229
StreamExtraFixStringUnmarshaler(qw422016, typ, parseFunc, extra) StreamExtraFixStringUnmarshaler(qw422016, typ, parseFunc, extra)
//line templates/extra.qtpl:218 //line templates/extra.qtpl:229
qt422016.ReleaseWriter(qw422016) qt422016.ReleaseWriter(qw422016)
//line templates/extra.qtpl:218 //line templates/extra.qtpl:229
} }
//line templates/extra.qtpl:218 //line templates/extra.qtpl:229
func ExtraFixStringUnmarshaler(typ, parseFunc, extra string) string { func ExtraFixStringUnmarshaler(typ, parseFunc, extra string) string {
//line templates/extra.qtpl:218 //line templates/extra.qtpl:229
qb422016 := qt422016.AcquireByteBuffer() qb422016 := qt422016.AcquireByteBuffer()
//line templates/extra.qtpl:218 //line templates/extra.qtpl:229
WriteExtraFixStringUnmarshaler(qb422016, typ, parseFunc, extra) WriteExtraFixStringUnmarshaler(qb422016, typ, parseFunc, extra)
//line templates/extra.qtpl:218 //line templates/extra.qtpl:229
qs422016 := string(qb422016.B) qs422016 := string(qb422016.B)
//line templates/extra.qtpl:218 //line templates/extra.qtpl:229
qt422016.ReleaseByteBuffer(qb422016) qt422016.ReleaseByteBuffer(qb422016)
//line templates/extra.qtpl:218 //line templates/extra.qtpl:229
return qs422016 return qs422016
//line templates/extra.qtpl:218 //line templates/extra.qtpl:229
} }
// ExtraExceptionDetailsTemplate is a special template for the Runtime.ExceptionDetails type that // ExtraExceptionDetailsTemplate is a special template for the Runtime.ExceptionDetails type that
// defines the standard error interface. // defines the standard error interface.
//line templates/extra.qtpl:222 //line templates/extra.qtpl:233
func StreamExtraExceptionDetailsTemplate(qw422016 *qt422016.Writer) { func StreamExtraExceptionDetailsTemplate(qw422016 *qt422016.Writer) {
//line templates/extra.qtpl:222 //line templates/extra.qtpl:233
qw422016.N().S(` qw422016.N().S(`
// Error satisfies the error interface. // Error satisfies the error interface.
func (e *ExceptionDetails) Error() string { func (e *ExceptionDetails) Error() string {
@ -492,41 +535,41 @@ func (e *ExceptionDetails) Error() string {
return fmt.Sprintf("encountered exception '%s' (%d:%d)", e.Text, e.LineNumber, e.ColumnNumber) return fmt.Sprintf("encountered exception '%s' (%d:%d)", e.Text, e.LineNumber, e.ColumnNumber)
} }
`) `)
//line templates/extra.qtpl:229 //line templates/extra.qtpl:240
} }
//line templates/extra.qtpl:229 //line templates/extra.qtpl:240
func WriteExtraExceptionDetailsTemplate(qq422016 qtio422016.Writer) { func WriteExtraExceptionDetailsTemplate(qq422016 qtio422016.Writer) {
//line templates/extra.qtpl:229 //line templates/extra.qtpl:240
qw422016 := qt422016.AcquireWriter(qq422016) qw422016 := qt422016.AcquireWriter(qq422016)
//line templates/extra.qtpl:229 //line templates/extra.qtpl:240
StreamExtraExceptionDetailsTemplate(qw422016) StreamExtraExceptionDetailsTemplate(qw422016)
//line templates/extra.qtpl:229 //line templates/extra.qtpl:240
qt422016.ReleaseWriter(qw422016) qt422016.ReleaseWriter(qw422016)
//line templates/extra.qtpl:229 //line templates/extra.qtpl:240
} }
//line templates/extra.qtpl:229 //line templates/extra.qtpl:240
func ExtraExceptionDetailsTemplate() string { func ExtraExceptionDetailsTemplate() string {
//line templates/extra.qtpl:229 //line templates/extra.qtpl:240
qb422016 := qt422016.AcquireByteBuffer() qb422016 := qt422016.AcquireByteBuffer()
//line templates/extra.qtpl:229 //line templates/extra.qtpl:240
WriteExtraExceptionDetailsTemplate(qb422016) WriteExtraExceptionDetailsTemplate(qb422016)
//line templates/extra.qtpl:229 //line templates/extra.qtpl:240
qs422016 := string(qb422016.B) qs422016 := string(qb422016.B)
//line templates/extra.qtpl:229 //line templates/extra.qtpl:240
qt422016.ReleaseByteBuffer(qb422016) qt422016.ReleaseByteBuffer(qb422016)
//line templates/extra.qtpl:229 //line templates/extra.qtpl:240
return qs422016 return qs422016
//line templates/extra.qtpl:229 //line templates/extra.qtpl:240
} }
// ExtraCDPTypes is the template for additional internal type // ExtraCDPTypes is the template for additional internal type
// declarations. // declarations.
//line templates/extra.qtpl:233 //line templates/extra.qtpl:244
func StreamExtraCDPTypes(qw422016 *qt422016.Writer) { func StreamExtraCDPTypes(qw422016 *qt422016.Writer) {
//line templates/extra.qtpl:233 //line templates/extra.qtpl:244
qw422016.N().S(` qw422016.N().S(`
// Error satisfies the error interface. // Error satisfies the error interface.
@ -560,40 +603,40 @@ type Handler interface {
Release(<-chan interface{}) Release(<-chan interface{})
} }
`) `)
//line templates/extra.qtpl:265 //line templates/extra.qtpl:276
} }
//line templates/extra.qtpl:265 //line templates/extra.qtpl:276
func WriteExtraCDPTypes(qq422016 qtio422016.Writer) { func WriteExtraCDPTypes(qq422016 qtio422016.Writer) {
//line templates/extra.qtpl:265 //line templates/extra.qtpl:276
qw422016 := qt422016.AcquireWriter(qq422016) qw422016 := qt422016.AcquireWriter(qq422016)
//line templates/extra.qtpl:265 //line templates/extra.qtpl:276
StreamExtraCDPTypes(qw422016) StreamExtraCDPTypes(qw422016)
//line templates/extra.qtpl:265 //line templates/extra.qtpl:276
qt422016.ReleaseWriter(qw422016) qt422016.ReleaseWriter(qw422016)
//line templates/extra.qtpl:265 //line templates/extra.qtpl:276
} }
//line templates/extra.qtpl:265 //line templates/extra.qtpl:276
func ExtraCDPTypes() string { func ExtraCDPTypes() string {
//line templates/extra.qtpl:265 //line templates/extra.qtpl:276
qb422016 := qt422016.AcquireByteBuffer() qb422016 := qt422016.AcquireByteBuffer()
//line templates/extra.qtpl:265 //line templates/extra.qtpl:276
WriteExtraCDPTypes(qb422016) WriteExtraCDPTypes(qb422016)
//line templates/extra.qtpl:265 //line templates/extra.qtpl:276
qs422016 := string(qb422016.B) qs422016 := string(qb422016.B)
//line templates/extra.qtpl:265 //line templates/extra.qtpl:276
qt422016.ReleaseByteBuffer(qb422016) qt422016.ReleaseByteBuffer(qb422016)
//line templates/extra.qtpl:265 //line templates/extra.qtpl:276
return qs422016 return qs422016
//line templates/extra.qtpl:265 //line templates/extra.qtpl:276
} }
// ExtraUtilTemplate generates the decode func for the Message type. // ExtraUtilTemplate generates the decode func for the Message type.
//line templates/extra.qtpl:268 //line templates/extra.qtpl:279
func StreamExtraUtilTemplate(qw422016 *qt422016.Writer, domains []*internal.Domain) { func StreamExtraUtilTemplate(qw422016 *qt422016.Writer, domains []*internal.Domain) {
//line templates/extra.qtpl:268 //line templates/extra.qtpl:279
qw422016.N().S(` qw422016.N().S(`
type empty struct{} type empty struct{}
var emptyVal = &empty{} var emptyVal = &empty{}
@ -602,66 +645,66 @@ var emptyVal = &empty{}
func UnmarshalMessage(msg *cdp.Message) (interface{}, error) { func UnmarshalMessage(msg *cdp.Message) (interface{}, error) {
var v easyjson.Unmarshaler var v easyjson.Unmarshaler
switch msg.Method {`) switch msg.Method {`)
//line templates/extra.qtpl:275 //line templates/extra.qtpl:286
for _, d := range domains { for _, d := range domains {
//line templates/extra.qtpl:275 //line templates/extra.qtpl:286
for _, c := range d.Commands { for _, c := range d.Commands {
//line templates/extra.qtpl:275 //line templates/extra.qtpl:286
qw422016.N().S(` qw422016.N().S(`
case cdp.`) case cdp.`)
//line templates/extra.qtpl:276 //line templates/extra.qtpl:287
qw422016.N().S(c.CommandMethodType(d)) qw422016.N().S(c.CommandMethodType(d))
//line templates/extra.qtpl:276 //line templates/extra.qtpl:287
qw422016.N().S(`:`) qw422016.N().S(`:`)
//line templates/extra.qtpl:276 //line templates/extra.qtpl:287
if len(c.Returns) == 0 { if len(c.Returns) == 0 {
//line templates/extra.qtpl:276 //line templates/extra.qtpl:287
qw422016.N().S(` qw422016.N().S(`
return emptyVal, nil`) return emptyVal, nil`)
//line templates/extra.qtpl:277 //line templates/extra.qtpl:288
} else { } else {
//line templates/extra.qtpl:277 //line templates/extra.qtpl:288
qw422016.N().S(` qw422016.N().S(`
v = new(`) v = new(`)
//line templates/extra.qtpl:278 //line templates/extra.qtpl:289
qw422016.N().S(d.PackageRefName()) qw422016.N().S(d.PackageRefName())
//line templates/extra.qtpl:278 //line templates/extra.qtpl:289
qw422016.N().S(`.`) qw422016.N().S(`.`)
//line templates/extra.qtpl:278 //line templates/extra.qtpl:289
qw422016.N().S(c.CommandReturnsType()) qw422016.N().S(c.CommandReturnsType())
//line templates/extra.qtpl:278 //line templates/extra.qtpl:289
qw422016.N().S(`)`) qw422016.N().S(`)`)
//line templates/extra.qtpl:278 //line templates/extra.qtpl:289
} }
//line templates/extra.qtpl:278 //line templates/extra.qtpl:289
qw422016.N().S(` qw422016.N().S(`
`) `)
//line templates/extra.qtpl:279 //line templates/extra.qtpl:290
} }
//line templates/extra.qtpl:279 //line templates/extra.qtpl:290
for _, e := range d.Events { for _, e := range d.Events {
//line templates/extra.qtpl:279 //line templates/extra.qtpl:290
qw422016.N().S(` qw422016.N().S(`
case cdp.`) case cdp.`)
//line templates/extra.qtpl:280 //line templates/extra.qtpl:291
qw422016.N().S(e.EventMethodType(d)) qw422016.N().S(e.EventMethodType(d))
//line templates/extra.qtpl:280 //line templates/extra.qtpl:291
qw422016.N().S(`: qw422016.N().S(`:
v = new(`) v = new(`)
//line templates/extra.qtpl:281 //line templates/extra.qtpl:292
qw422016.N().S(d.PackageRefName()) qw422016.N().S(d.PackageRefName())
//line templates/extra.qtpl:281 //line templates/extra.qtpl:292
qw422016.N().S(`.`) qw422016.N().S(`.`)
//line templates/extra.qtpl:281 //line templates/extra.qtpl:292
qw422016.N().S(e.EventType()) qw422016.N().S(e.EventType())
//line templates/extra.qtpl:281 //line templates/extra.qtpl:292
qw422016.N().S(`) qw422016.N().S(`)
`) `)
//line templates/extra.qtpl:282 //line templates/extra.qtpl:293
} }
//line templates/extra.qtpl:282 //line templates/extra.qtpl:293
} }
//line templates/extra.qtpl:282 //line templates/extra.qtpl:293
qw422016.N().S(`} qw422016.N().S(`}
var buf easyjson.RawMessage var buf easyjson.RawMessage
@ -684,69 +727,69 @@ func UnmarshalMessage(msg *cdp.Message) (interface{}, error) {
return v, nil return v, nil
} }
`) `)
//line templates/extra.qtpl:303 //line templates/extra.qtpl:314
} }
//line templates/extra.qtpl:303 //line templates/extra.qtpl:314
func WriteExtraUtilTemplate(qq422016 qtio422016.Writer, domains []*internal.Domain) { func WriteExtraUtilTemplate(qq422016 qtio422016.Writer, domains []*internal.Domain) {
//line templates/extra.qtpl:303 //line templates/extra.qtpl:314
qw422016 := qt422016.AcquireWriter(qq422016) qw422016 := qt422016.AcquireWriter(qq422016)
//line templates/extra.qtpl:303 //line templates/extra.qtpl:314
StreamExtraUtilTemplate(qw422016, domains) StreamExtraUtilTemplate(qw422016, domains)
//line templates/extra.qtpl:303 //line templates/extra.qtpl:314
qt422016.ReleaseWriter(qw422016) qt422016.ReleaseWriter(qw422016)
//line templates/extra.qtpl:303 //line templates/extra.qtpl:314
} }
//line templates/extra.qtpl:303 //line templates/extra.qtpl:314
func ExtraUtilTemplate(domains []*internal.Domain) string { func ExtraUtilTemplate(domains []*internal.Domain) string {
//line templates/extra.qtpl:303 //line templates/extra.qtpl:314
qb422016 := qt422016.AcquireByteBuffer() qb422016 := qt422016.AcquireByteBuffer()
//line templates/extra.qtpl:303 //line templates/extra.qtpl:314
WriteExtraUtilTemplate(qb422016, domains) WriteExtraUtilTemplate(qb422016, domains)
//line templates/extra.qtpl:303 //line templates/extra.qtpl:314
qs422016 := string(qb422016.B) qs422016 := string(qb422016.B)
//line templates/extra.qtpl:303 //line templates/extra.qtpl:314
qt422016.ReleaseByteBuffer(qb422016) qt422016.ReleaseByteBuffer(qb422016)
//line templates/extra.qtpl:303 //line templates/extra.qtpl:314
return qs422016 return qs422016
//line templates/extra.qtpl:303 //line templates/extra.qtpl:314
} }
//line templates/extra.qtpl:305 //line templates/extra.qtpl:316
func StreamExtraMethodTypeDomainDecoder(qw422016 *qt422016.Writer) { func StreamExtraMethodTypeDomainDecoder(qw422016 *qt422016.Writer) {
//line templates/extra.qtpl:305 //line templates/extra.qtpl:316
qw422016.N().S(` qw422016.N().S(`
// Domain returns the Chrome Debugging Protocol domain of the event or command. // Domain returns the Chrome Debugging Protocol domain of the event or command.
func (t MethodType) Domain() string { func (t MethodType) Domain() string {
return string(t[:strings.IndexByte(string(t), '.')]) return string(t[:strings.IndexByte(string(t), '.')])
} }
`) `)
//line templates/extra.qtpl:310 //line templates/extra.qtpl:321
} }
//line templates/extra.qtpl:310 //line templates/extra.qtpl:321
func WriteExtraMethodTypeDomainDecoder(qq422016 qtio422016.Writer) { func WriteExtraMethodTypeDomainDecoder(qq422016 qtio422016.Writer) {
//line templates/extra.qtpl:310 //line templates/extra.qtpl:321
qw422016 := qt422016.AcquireWriter(qq422016) qw422016 := qt422016.AcquireWriter(qq422016)
//line templates/extra.qtpl:310 //line templates/extra.qtpl:321
StreamExtraMethodTypeDomainDecoder(qw422016) StreamExtraMethodTypeDomainDecoder(qw422016)
//line templates/extra.qtpl:310 //line templates/extra.qtpl:321
qt422016.ReleaseWriter(qw422016) qt422016.ReleaseWriter(qw422016)
//line templates/extra.qtpl:310 //line templates/extra.qtpl:321
} }
//line templates/extra.qtpl:310 //line templates/extra.qtpl:321
func ExtraMethodTypeDomainDecoder() string { func ExtraMethodTypeDomainDecoder() string {
//line templates/extra.qtpl:310 //line templates/extra.qtpl:321
qb422016 := qt422016.AcquireByteBuffer() qb422016 := qt422016.AcquireByteBuffer()
//line templates/extra.qtpl:310 //line templates/extra.qtpl:321
WriteExtraMethodTypeDomainDecoder(qb422016) WriteExtraMethodTypeDomainDecoder(qb422016)
//line templates/extra.qtpl:310 //line templates/extra.qtpl:321
qs422016 := string(qb422016.B) qs422016 := string(qb422016.B)
//line templates/extra.qtpl:310 //line templates/extra.qtpl:321
qt422016.ReleaseByteBuffer(qb422016) qt422016.ReleaseByteBuffer(qb422016)
//line templates/extra.qtpl:310 //line templates/extra.qtpl:321
return qs422016 return qs422016
//line templates/extra.qtpl:310 //line templates/extra.qtpl:321
} }

4
nav.go
View File

@ -96,7 +96,7 @@ func CaptureScreenshot(res *[]byte) Action {
} }
// AddOnLoadScript adds a script to evaluate on page load. // AddOnLoadScript adds a script to evaluate on page load.
func AddOnLoadScript(source string, id *page.ScriptIdentifier) Action { /*func AddOnLoadScript(source string, id *page.ScriptIdentifier) Action {
if id == nil { if id == nil {
panic("id cannot be nil") panic("id cannot be nil")
} }
@ -111,7 +111,7 @@ func AddOnLoadScript(source string, id *page.ScriptIdentifier) Action {
// RemoveOnLoadScript removes a script to evaluate on page load. // RemoveOnLoadScript removes a script to evaluate on page load.
func RemoveOnLoadScript(id page.ScriptIdentifier) Action { func RemoveOnLoadScript(id page.ScriptIdentifier) Action {
return page.RemoveScriptToEvaluateOnLoad(id) return page.RemoveScriptToEvaluateOnLoad(id)
} }*/
// Location retrieves the document location. // Location retrieves the document location.
func Location(urlstr *string) Action { func Location(urlstr *string) Action {

View File

@ -328,7 +328,7 @@ func TestCaptureScreenshot(t *testing.T) {
//TODO: test image //TODO: test image
} }
func TestAddOnLoadScript(t *testing.T) { /*func TestAddOnLoadScript(t *testing.T) {
t.Parallel() t.Parallel()
var err error var err error
@ -384,7 +384,7 @@ func TestRemoveOnLoadScript(t *testing.T) {
} }
time.Sleep(50 * time.Millisecond) time.Sleep(50 * time.Millisecond)
} }*/
func TestLocation(t *testing.T) { func TestLocation(t *testing.T) {
t.Parallel() t.Parallel()