Fixing timestamp issues

Adding full timestamp types. Fixes #71
This commit is contained in:
Kenneth Shaw 2017-07-01 20:06:43 +07:00
parent f27ba717b1
commit d70d54233f
25 changed files with 988 additions and 461 deletions

View File

@ -7,6 +7,7 @@ import (
"strconv"
"strings"
"sync"
"time"
"github.com/mailru/easyjson"
"github.com/mailru/easyjson/jlexer"
@ -1501,11 +1502,34 @@ func (t LoaderID) String() string {
}
// Timestamp number of seconds since epoch.
type Timestamp float64
type Timestamp time.Time
// Float64 returns the Timestamp as float64 value.
func (t Timestamp) Float64() float64 {
return float64(t)
// Time returns the Timestamp as time.Time value.
func (t Timestamp) Time() time.Time {
return time.Time(t)
}
// MarshalEasyJSON satisfies easyjson.Marshaler.
func (t Timestamp) 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 Timestamp) MarshalJSON() ([]byte, error) {
return easyjson.Marshal(t)
}
// UnmarshalEasyJSON satisfies easyjson.Unmarshaler.
func (t *Timestamp) UnmarshalEasyJSON(in *jlexer.Lexer) {
*t = Timestamp(time.Unix(0, int64(in.Float64()*float64(time.Second))))
}
// UnmarshalJSON satisfies json.Unmarshaler.
func (t *Timestamp) UnmarshalJSON(buf []byte) error {
return easyjson.Unmarshal(buf, t)
}
// NodeID unique DOM node identifier.

View File

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

View File

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

View File

@ -4,6 +4,7 @@ package input
import (
json "encoding/json"
cdp "github.com/knq/chromedp/cdp"
easyjson "github.com/mailru/easyjson"
jlexer "github.com/mailru/easyjson/jlexer"
jwriter "github.com/mailru/easyjson/jwriter"
@ -632,7 +633,15 @@ func easyjsonC5a4559bDecodeGithubComKnqChromedpCdpInput5(in *jlexer.Lexer, out *
case "y":
out.Y = int64(in.Int64())
case "timestamp":
out.Timestamp = float64(in.Float64())
if in.IsNull() {
in.Skip()
out.Timestamp = nil
} else {
if out.Timestamp == nil {
out.Timestamp = new(cdp.Timestamp)
}
(*out.Timestamp).UnmarshalEasyJSON(in)
}
case "button":
(out.Button).UnmarshalEasyJSON(in)
case "deltaX":
@ -680,7 +689,11 @@ func easyjsonC5a4559bEncodeGithubComKnqChromedpCdpInput5(out *jwriter.Writer, in
}
first = false
out.RawString("\"timestamp\":")
out.Float64(float64(in.Timestamp))
if in.Timestamp == nil {
out.RawString("null")
} else {
(*in.Timestamp).MarshalEasyJSON(out)
}
if !first {
out.RawByte(',')
}
@ -800,7 +813,15 @@ func easyjsonC5a4559bDecodeGithubComKnqChromedpCdpInput6(in *jlexer.Lexer, out *
case "modifiers":
(out.Modifiers).UnmarshalEasyJSON(in)
case "timestamp":
out.Timestamp = float64(in.Float64())
if in.IsNull() {
in.Skip()
out.Timestamp = nil
} else {
if out.Timestamp == nil {
out.Timestamp = new(cdp.Timestamp)
}
(*out.Timestamp).UnmarshalEasyJSON(in)
}
default:
in.SkipRecursive()
}
@ -850,13 +871,17 @@ func easyjsonC5a4559bEncodeGithubComKnqChromedpCdpInput6(out *jwriter.Writer, in
out.RawString("\"modifiers\":")
(in.Modifiers).MarshalEasyJSON(out)
}
if in.Timestamp != 0 {
if in.Timestamp != nil {
if !first {
out.RawByte(',')
}
first = false
out.RawString("\"timestamp\":")
out.Float64(float64(in.Timestamp))
if in.Timestamp == nil {
out.RawString("null")
} else {
(*in.Timestamp).MarshalEasyJSON(out)
}
}
out.RawByte('}')
}
@ -912,7 +937,15 @@ func easyjsonC5a4559bDecodeGithubComKnqChromedpCdpInput7(in *jlexer.Lexer, out *
case "modifiers":
(out.Modifiers).UnmarshalEasyJSON(in)
case "timestamp":
out.Timestamp = float64(in.Float64())
if in.IsNull() {
in.Skip()
out.Timestamp = nil
} else {
if out.Timestamp == nil {
out.Timestamp = new(cdp.Timestamp)
}
(*out.Timestamp).UnmarshalEasyJSON(in)
}
case "button":
(out.Button).UnmarshalEasyJSON(in)
case "clickCount":
@ -957,13 +990,17 @@ func easyjsonC5a4559bEncodeGithubComKnqChromedpCdpInput7(out *jwriter.Writer, in
out.RawString("\"modifiers\":")
(in.Modifiers).MarshalEasyJSON(out)
}
if in.Timestamp != 0 {
if in.Timestamp != nil {
if !first {
out.RawByte(',')
}
first = false
out.RawString("\"timestamp\":")
out.Float64(float64(in.Timestamp))
if in.Timestamp == nil {
out.RawString("null")
} else {
(*in.Timestamp).MarshalEasyJSON(out)
}
}
if in.Button != "" {
if !first {
@ -1031,7 +1068,15 @@ func easyjsonC5a4559bDecodeGithubComKnqChromedpCdpInput8(in *jlexer.Lexer, out *
case "modifiers":
(out.Modifiers).UnmarshalEasyJSON(in)
case "timestamp":
out.Timestamp = float64(in.Float64())
if in.IsNull() {
in.Skip()
out.Timestamp = nil
} else {
if out.Timestamp == nil {
out.Timestamp = new(cdp.Timestamp)
}
(*out.Timestamp).UnmarshalEasyJSON(in)
}
case "text":
out.Text = string(in.String())
case "unmodifiedText":
@ -1080,13 +1125,17 @@ func easyjsonC5a4559bEncodeGithubComKnqChromedpCdpInput8(out *jwriter.Writer, in
out.RawString("\"modifiers\":")
(in.Modifiers).MarshalEasyJSON(out)
}
if in.Timestamp != 0 {
if in.Timestamp != nil {
if !first {
out.RawByte(',')
}
first = false
out.RawString("\"timestamp\":")
out.Float64(float64(in.Timestamp))
if in.Timestamp == nil {
out.RawString("null")
} else {
(*in.Timestamp).MarshalEasyJSON(out)
}
}
if in.Text != "" {
if !first {

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.
type DispatchKeyEventParams struct {
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).
Timestamp float64 `json:"timestamp,omitempty"` // Time at which the event occurred. Measured in UTC time in seconds since January 1, 1970 (default: current time).
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: "").
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: "").
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).
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).
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).
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).
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).
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: "").
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: "").
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).
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).
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).
}
// DispatchKeyEvent dispatches a key event to the page.
@ -70,7 +70,7 @@ func (p DispatchKeyEventParams) WithModifiers(modifiers Modifier) *DispatchKeyEv
// WithTimestamp time at which the event occurred. Measured in UTC time in
// seconds since January 1, 1970 (default: current time).
func (p DispatchKeyEventParams) WithTimestamp(timestamp float64) *DispatchKeyEventParams {
func (p DispatchKeyEventParams) WithTimestamp(timestamp *cdp.Timestamp) *DispatchKeyEventParams {
p.Timestamp = timestamp
return &p
}
@ -152,13 +152,13 @@ func (p *DispatchKeyEventParams) Do(ctxt context.Context, h cdp.Handler) (err er
// DispatchMouseEventParams dispatches a mouse event to the page.
type DispatchMouseEventParams struct {
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.
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).
Timestamp float64 `json:"timestamp,omitempty"` // Time at which the event occurred. Measured in UTC time in seconds since January 1, 1970 (default: current time).
Button ButtonType `json:"button,omitempty"` // Mouse button (default: "none").
ClickCount int64 `json:"clickCount,omitempty"` // Number of times the mouse button was clicked (default: 0).
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.
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).
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).
Button ButtonType `json:"button,omitempty"` // Mouse button (default: "none").
ClickCount int64 `json:"clickCount,omitempty"` // Number of times the mouse button was clicked (default: 0).
}
// DispatchMouseEvent dispatches a mouse event to the page.
@ -184,7 +184,7 @@ func (p DispatchMouseEventParams) WithModifiers(modifiers Modifier) *DispatchMou
// WithTimestamp time at which the event occurred. Measured in UTC time in
// seconds since January 1, 1970 (default: current time).
func (p DispatchMouseEventParams) WithTimestamp(timestamp float64) *DispatchMouseEventParams {
func (p DispatchMouseEventParams) WithTimestamp(timestamp *cdp.Timestamp) *DispatchMouseEventParams {
p.Timestamp = timestamp
return &p
}
@ -209,10 +209,10 @@ func (p *DispatchMouseEventParams) Do(ctxt context.Context, h cdp.Handler) (err
// DispatchTouchEventParams dispatches a touch event to the page.
type DispatchTouchEventParams struct {
Type TouchType `json:"type"` // Type of the touch event.
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).
Timestamp float64 `json:"timestamp,omitempty"` // Time at which the event occurred. Measured in UTC time in seconds since January 1, 1970 (default: current time).
Type TouchType `json:"type"` // Type of the touch event.
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).
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).
}
// DispatchTouchEvent dispatches a touch event to the page.
@ -236,7 +236,7 @@ func (p DispatchTouchEventParams) WithModifiers(modifiers Modifier) *DispatchTou
// WithTimestamp time at which the event occurred. Measured in UTC time in
// seconds since January 1, 1970 (default: current time).
func (p DispatchTouchEventParams) WithTimestamp(timestamp float64) *DispatchTouchEventParams {
func (p DispatchTouchEventParams) WithTimestamp(timestamp *cdp.Timestamp) *DispatchTouchEventParams {
p.Timestamp = timestamp
return &p
}
@ -250,15 +250,15 @@ func (p *DispatchTouchEventParams) Do(ctxt context.Context, h cdp.Handler) (err
// EmulateTouchFromMouseEventParams emulates touch event from the mouse event
// parameters.
type EmulateTouchFromMouseEventParams struct {
Type MouseType `json:"type"` // Type of the mouse event.
X int64 `json:"x"` // X coordinate of the mouse pointer in DIP.
Y int64 `json:"y"` // Y coordinate of the mouse pointer in DIP.
Timestamp float64 `json:"timestamp"` // Time at which the event occurred. Measured in UTC time in seconds since January 1, 1970.
Button ButtonType `json:"button"` // Mouse button.
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).
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).
Type MouseType `json:"type"` // Type of the mouse event.
X int64 `json:"x"` // X 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.
Button ButtonType `json:"button"` // Mouse button.
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).
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).
}
// EmulateTouchFromMouseEvent emulates touch event from the mouse event
@ -270,7 +270,7 @@ type EmulateTouchFromMouseEventParams struct {
// 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.
// button - Mouse button.
func EmulateTouchFromMouseEvent(typeVal MouseType, x int64, y int64, timestamp float64, button ButtonType) *EmulateTouchFromMouseEventParams {
func EmulateTouchFromMouseEvent(typeVal MouseType, x int64, y int64, timestamp *cdp.Timestamp, button ButtonType) *EmulateTouchFromMouseEventParams {
return &EmulateTouchFromMouseEventParams{
Type: typeVal,
X: x,

View File

@ -375,7 +375,15 @@ func easyjsonC5a4559bDecodeGithubComKnqChromedpCdpLog4(in *jlexer.Lexer, out *En
case "text":
out.Text = string(in.String())
case "timestamp":
out.Timestamp = runtime.Timestamp(in.Float64())
if in.IsNull() {
in.Skip()
out.Timestamp = nil
} else {
if out.Timestamp == nil {
out.Timestamp = new(runtime.Timestamp)
}
(*out.Timestamp).UnmarshalEasyJSON(in)
}
case "url":
out.URL = string(in.String())
case "lineNumber":
@ -432,13 +440,17 @@ func easyjsonC5a4559bEncodeGithubComKnqChromedpCdpLog4(out *jwriter.Writer, in E
out.RawString("\"text\":")
out.String(string(in.Text))
}
if in.Timestamp != 0 {
if in.Timestamp != nil {
if !first {
out.RawByte(',')
}
first = false
out.RawString("\"timestamp\":")
out.Float64(float64(in.Timestamp))
if in.Timestamp == nil {
out.RawString("null")
} else {
(*in.Timestamp).MarshalEasyJSON(out)
}
}
if in.URL != "" {
if !first {

View File

@ -17,7 +17,7 @@ type Entry struct {
Source Source `json:"source,omitempty"` // Log entry source.
Level Level `json:"level,omitempty"` // Log entry severity.
Text string `json:"text,omitempty"` // Logged text.
Timestamp runtime.Timestamp `json:"timestamp,omitempty"` // Timestamp when this entry was added.
Timestamp *runtime.Timestamp `json:"timestamp,omitempty"` // Timestamp when this entry was added.
URL string `json:"url,omitempty"` // URL of the resource if known.
LineNumber int64 `json:"lineNumber,omitempty"` // Line number in the resource.
StackTrace *runtime.StackTrace `json:"stackTrace,omitempty"` // JavaScript stack trace.

View File

@ -460,7 +460,15 @@ func easyjsonC5a4559bDecodeGithubComKnqChromedpCdpNetwork3(in *jlexer.Lexer, out
case "logId":
out.LogID = string(in.String())
case "timestamp":
out.Timestamp = cdp.Timestamp(in.Float64())
if in.IsNull() {
in.Skip()
out.Timestamp = nil
} else {
if out.Timestamp == nil {
out.Timestamp = new(cdp.Timestamp)
}
(*out.Timestamp).UnmarshalEasyJSON(in)
}
case "hashAlgorithm":
out.HashAlgorithm = string(in.String())
case "signatureAlgorithm":
@ -513,13 +521,17 @@ func easyjsonC5a4559bEncodeGithubComKnqChromedpCdpNetwork3(out *jwriter.Writer,
out.RawString("\"logId\":")
out.String(string(in.LogID))
}
if in.Timestamp != 0 {
if in.Timestamp != nil {
if !first {
out.RawByte(',')
}
first = false
out.RawString("\"timestamp\":")
out.Float64(float64(in.Timestamp))
if in.Timestamp == nil {
out.RawString("null")
} else {
(*in.Timestamp).MarshalEasyJSON(out)
}
}
if in.HashAlgorithm != "" {
if !first {
@ -930,7 +942,15 @@ func easyjsonC5a4559bDecodeGithubComKnqChromedpCdpNetwork8(in *jlexer.Lexer, out
case "sameSite":
(out.SameSite).UnmarshalEasyJSON(in)
case "expirationDate":
out.ExpirationDate = cdp.Timestamp(in.Float64())
if in.IsNull() {
in.Skip()
out.ExpirationDate = nil
} else {
if out.ExpirationDate == nil {
out.ExpirationDate = new(cdp.Timestamp)
}
(*out.ExpirationDate).UnmarshalEasyJSON(in)
}
default:
in.SkipRecursive()
}
@ -1003,13 +1023,17 @@ func easyjsonC5a4559bEncodeGithubComKnqChromedpCdpNetwork8(out *jwriter.Writer,
out.RawString("\"sameSite\":")
(in.SameSite).MarshalEasyJSON(out)
}
if in.ExpirationDate != 0 {
if in.ExpirationDate != nil {
if !first {
out.RawByte(',')
}
first = false
out.RawString("\"expirationDate\":")
out.Float64(float64(in.ExpirationDate))
if in.ExpirationDate == nil {
out.RawString("null")
} else {
(*in.ExpirationDate).MarshalEasyJSON(out)
}
}
out.RawByte('}')
}
@ -1329,9 +1353,25 @@ func easyjsonC5a4559bDecodeGithubComKnqChromedpCdpNetwork12(in *jlexer.Lexer, ou
case "issuer":
out.Issuer = string(in.String())
case "validFrom":
out.ValidFrom = cdp.Timestamp(in.Float64())
if in.IsNull() {
in.Skip()
out.ValidFrom = nil
} else {
if out.ValidFrom == nil {
out.ValidFrom = new(cdp.Timestamp)
}
(*out.ValidFrom).UnmarshalEasyJSON(in)
}
case "validTo":
out.ValidTo = cdp.Timestamp(in.Float64())
if in.IsNull() {
in.Skip()
out.ValidTo = nil
} else {
if out.ValidTo == nil {
out.ValidTo = new(cdp.Timestamp)
}
(*out.ValidTo).UnmarshalEasyJSON(in)
}
case "signedCertificateTimestampList":
if in.IsNull() {
in.Skip()
@ -1460,21 +1500,29 @@ func easyjsonC5a4559bEncodeGithubComKnqChromedpCdpNetwork12(out *jwriter.Writer,
out.RawString("\"issuer\":")
out.String(string(in.Issuer))
}
if in.ValidFrom != 0 {
if in.ValidFrom != nil {
if !first {
out.RawByte(',')
}
first = false
out.RawString("\"validFrom\":")
out.Float64(float64(in.ValidFrom))
if in.ValidFrom == nil {
out.RawString("null")
} else {
(*in.ValidFrom).MarshalEasyJSON(out)
}
}
if in.ValidTo != 0 {
if in.ValidTo != nil {
if !first {
out.RawByte(',')
}
first = false
out.RawString("\"validTo\":")
out.Float64(float64(in.ValidTo))
if in.ValidTo == nil {
out.RawString("null")
} else {
(*in.ValidTo).MarshalEasyJSON(out)
}
}
if len(in.SignedCertificateTimestampList) != 0 {
if !first {
@ -3191,9 +3239,25 @@ func easyjsonC5a4559bDecodeGithubComKnqChromedpCdpNetwork26(in *jlexer.Lexer, ou
case "requestId":
out.RequestID = RequestID(in.String())
case "timestamp":
out.Timestamp = cdp.Timestamp(in.Float64())
if in.IsNull() {
in.Skip()
out.Timestamp = nil
} else {
if out.Timestamp == nil {
out.Timestamp = new(cdp.Timestamp)
}
(*out.Timestamp).UnmarshalEasyJSON(in)
}
case "wallTime":
out.WallTime = cdp.Timestamp(in.Float64())
if in.IsNull() {
in.Skip()
out.WallTime = nil
} else {
if out.WallTime == nil {
out.WallTime = new(cdp.Timestamp)
}
(*out.WallTime).UnmarshalEasyJSON(in)
}
case "request":
if in.IsNull() {
in.Skip()
@ -3226,21 +3290,29 @@ func easyjsonC5a4559bEncodeGithubComKnqChromedpCdpNetwork26(out *jwriter.Writer,
out.RawString("\"requestId\":")
out.String(string(in.RequestID))
}
if in.Timestamp != 0 {
if in.Timestamp != nil {
if !first {
out.RawByte(',')
}
first = false
out.RawString("\"timestamp\":")
out.Float64(float64(in.Timestamp))
if in.Timestamp == nil {
out.RawString("null")
} else {
(*in.Timestamp).MarshalEasyJSON(out)
}
}
if in.WallTime != 0 {
if in.WallTime != nil {
if !first {
out.RawByte(',')
}
first = false
out.RawString("\"wallTime\":")
out.Float64(float64(in.WallTime))
if in.WallTime == nil {
out.RawString("null")
} else {
(*in.WallTime).MarshalEasyJSON(out)
}
}
if in.Request != nil {
if !first {
@ -3302,7 +3374,15 @@ func easyjsonC5a4559bDecodeGithubComKnqChromedpCdpNetwork27(in *jlexer.Lexer, ou
case "requestId":
out.RequestID = RequestID(in.String())
case "timestamp":
out.Timestamp = cdp.Timestamp(in.Float64())
if in.IsNull() {
in.Skip()
out.Timestamp = nil
} else {
if out.Timestamp == nil {
out.Timestamp = new(cdp.Timestamp)
}
(*out.Timestamp).UnmarshalEasyJSON(in)
}
case "response":
if in.IsNull() {
in.Skip()
@ -3335,13 +3415,17 @@ func easyjsonC5a4559bEncodeGithubComKnqChromedpCdpNetwork27(out *jwriter.Writer,
out.RawString("\"requestId\":")
out.String(string(in.RequestID))
}
if in.Timestamp != 0 {
if in.Timestamp != nil {
if !first {
out.RawByte(',')
}
first = false
out.RawString("\"timestamp\":")
out.Float64(float64(in.Timestamp))
if in.Timestamp == nil {
out.RawString("null")
} else {
(*in.Timestamp).MarshalEasyJSON(out)
}
}
if in.Response != nil {
if !first {
@ -3403,7 +3487,15 @@ func easyjsonC5a4559bDecodeGithubComKnqChromedpCdpNetwork28(in *jlexer.Lexer, ou
case "requestId":
out.RequestID = RequestID(in.String())
case "timestamp":
out.Timestamp = cdp.Timestamp(in.Float64())
if in.IsNull() {
in.Skip()
out.Timestamp = nil
} else {
if out.Timestamp == nil {
out.Timestamp = new(cdp.Timestamp)
}
(*out.Timestamp).UnmarshalEasyJSON(in)
}
case "response":
if in.IsNull() {
in.Skip()
@ -3436,13 +3528,17 @@ func easyjsonC5a4559bEncodeGithubComKnqChromedpCdpNetwork28(out *jwriter.Writer,
out.RawString("\"requestId\":")
out.String(string(in.RequestID))
}
if in.Timestamp != 0 {
if in.Timestamp != nil {
if !first {
out.RawByte(',')
}
first = false
out.RawString("\"timestamp\":")
out.Float64(float64(in.Timestamp))
if in.Timestamp == nil {
out.RawString("null")
} else {
(*in.Timestamp).MarshalEasyJSON(out)
}
}
if in.Response != nil {
if !first {
@ -3504,7 +3600,15 @@ func easyjsonC5a4559bDecodeGithubComKnqChromedpCdpNetwork29(in *jlexer.Lexer, ou
case "requestId":
out.RequestID = RequestID(in.String())
case "timestamp":
out.Timestamp = cdp.Timestamp(in.Float64())
if in.IsNull() {
in.Skip()
out.Timestamp = nil
} else {
if out.Timestamp == nil {
out.Timestamp = new(cdp.Timestamp)
}
(*out.Timestamp).UnmarshalEasyJSON(in)
}
case "response":
if in.IsNull() {
in.Skip()
@ -3537,13 +3641,17 @@ func easyjsonC5a4559bEncodeGithubComKnqChromedpCdpNetwork29(out *jwriter.Writer,
out.RawString("\"requestId\":")
out.String(string(in.RequestID))
}
if in.Timestamp != 0 {
if in.Timestamp != nil {
if !first {
out.RawByte(',')
}
first = false
out.RawString("\"timestamp\":")
out.Float64(float64(in.Timestamp))
if in.Timestamp == nil {
out.RawString("null")
} else {
(*in.Timestamp).MarshalEasyJSON(out)
}
}
if in.Response != nil {
if !first {
@ -3605,7 +3713,15 @@ func easyjsonC5a4559bDecodeGithubComKnqChromedpCdpNetwork30(in *jlexer.Lexer, ou
case "requestId":
out.RequestID = RequestID(in.String())
case "timestamp":
out.Timestamp = cdp.Timestamp(in.Float64())
if in.IsNull() {
in.Skip()
out.Timestamp = nil
} else {
if out.Timestamp == nil {
out.Timestamp = new(cdp.Timestamp)
}
(*out.Timestamp).UnmarshalEasyJSON(in)
}
case "errorMessage":
out.ErrorMessage = string(in.String())
default:
@ -3630,13 +3746,17 @@ func easyjsonC5a4559bEncodeGithubComKnqChromedpCdpNetwork30(out *jwriter.Writer,
out.RawString("\"requestId\":")
out.String(string(in.RequestID))
}
if in.Timestamp != 0 {
if in.Timestamp != nil {
if !first {
out.RawByte(',')
}
first = false
out.RawString("\"timestamp\":")
out.Float64(float64(in.Timestamp))
if in.Timestamp == nil {
out.RawString("null")
} else {
(*in.Timestamp).MarshalEasyJSON(out)
}
}
if in.ErrorMessage != "" {
if !first {
@ -3795,7 +3915,15 @@ func easyjsonC5a4559bDecodeGithubComKnqChromedpCdpNetwork32(in *jlexer.Lexer, ou
case "requestId":
out.RequestID = RequestID(in.String())
case "timestamp":
out.Timestamp = cdp.Timestamp(in.Float64())
if in.IsNull() {
in.Skip()
out.Timestamp = nil
} else {
if out.Timestamp == nil {
out.Timestamp = new(cdp.Timestamp)
}
(*out.Timestamp).UnmarshalEasyJSON(in)
}
default:
in.SkipRecursive()
}
@ -3818,13 +3946,17 @@ func easyjsonC5a4559bEncodeGithubComKnqChromedpCdpNetwork32(out *jwriter.Writer,
out.RawString("\"requestId\":")
out.String(string(in.RequestID))
}
if in.Timestamp != 0 {
if in.Timestamp != nil {
if !first {
out.RawByte(',')
}
first = false
out.RawString("\"timestamp\":")
out.Float64(float64(in.Timestamp))
if in.Timestamp == nil {
out.RawString("null")
} else {
(*in.Timestamp).MarshalEasyJSON(out)
}
}
out.RawByte('}')
}
@ -3878,7 +4010,15 @@ func easyjsonC5a4559bDecodeGithubComKnqChromedpCdpNetwork33(in *jlexer.Lexer, ou
case "loaderId":
out.LoaderID = cdp.LoaderID(in.String())
case "timestamp":
out.Timestamp = cdp.Timestamp(in.Float64())
if in.IsNull() {
in.Skip()
out.Timestamp = nil
} else {
if out.Timestamp == nil {
out.Timestamp = new(cdp.Timestamp)
}
(*out.Timestamp).UnmarshalEasyJSON(in)
}
case "type":
(out.Type).UnmarshalEasyJSON(in)
case "response":
@ -3929,13 +4069,17 @@ func easyjsonC5a4559bEncodeGithubComKnqChromedpCdpNetwork33(out *jwriter.Writer,
out.RawString("\"loaderId\":")
out.String(string(in.LoaderID))
}
if in.Timestamp != 0 {
if in.Timestamp != nil {
if !first {
out.RawByte(',')
}
first = false
out.RawString("\"timestamp\":")
out.Float64(float64(in.Timestamp))
if in.Timestamp == nil {
out.RawString("null")
} else {
(*in.Timestamp).MarshalEasyJSON(out)
}
}
if in.Type != "" {
if !first {
@ -4007,7 +4151,15 @@ func easyjsonC5a4559bDecodeGithubComKnqChromedpCdpNetwork34(in *jlexer.Lexer, ou
case "newPriority":
(out.NewPriority).UnmarshalEasyJSON(in)
case "timestamp":
out.Timestamp = cdp.Timestamp(in.Float64())
if in.IsNull() {
in.Skip()
out.Timestamp = nil
} else {
if out.Timestamp == nil {
out.Timestamp = new(cdp.Timestamp)
}
(*out.Timestamp).UnmarshalEasyJSON(in)
}
default:
in.SkipRecursive()
}
@ -4038,13 +4190,17 @@ func easyjsonC5a4559bEncodeGithubComKnqChromedpCdpNetwork34(out *jwriter.Writer,
out.RawString("\"newPriority\":")
(in.NewPriority).MarshalEasyJSON(out)
}
if in.Timestamp != 0 {
if in.Timestamp != nil {
if !first {
out.RawByte(',')
}
first = false
out.RawString("\"timestamp\":")
out.Float64(float64(in.Timestamp))
if in.Timestamp == nil {
out.RawString("null")
} else {
(*in.Timestamp).MarshalEasyJSON(out)
}
}
out.RawByte('}')
}
@ -4110,9 +4266,25 @@ func easyjsonC5a4559bDecodeGithubComKnqChromedpCdpNetwork35(in *jlexer.Lexer, ou
(*out.Request).UnmarshalEasyJSON(in)
}
case "timestamp":
out.Timestamp = cdp.Timestamp(in.Float64())
if in.IsNull() {
in.Skip()
out.Timestamp = nil
} else {
if out.Timestamp == nil {
out.Timestamp = new(cdp.Timestamp)
}
(*out.Timestamp).UnmarshalEasyJSON(in)
}
case "wallTime":
out.WallTime = cdp.Timestamp(in.Float64())
if in.IsNull() {
in.Skip()
out.WallTime = nil
} else {
if out.WallTime == nil {
out.WallTime = new(cdp.Timestamp)
}
(*out.WallTime).UnmarshalEasyJSON(in)
}
case "initiator":
if in.IsNull() {
in.Skip()
@ -4193,21 +4365,29 @@ func easyjsonC5a4559bEncodeGithubComKnqChromedpCdpNetwork35(out *jwriter.Writer,
(*in.Request).MarshalEasyJSON(out)
}
}
if in.Timestamp != 0 {
if in.Timestamp != nil {
if !first {
out.RawByte(',')
}
first = false
out.RawString("\"timestamp\":")
out.Float64(float64(in.Timestamp))
if in.Timestamp == nil {
out.RawString("null")
} else {
(*in.Timestamp).MarshalEasyJSON(out)
}
}
if in.WallTime != 0 {
if in.WallTime != nil {
if !first {
out.RawByte(',')
}
first = false
out.RawString("\"wallTime\":")
out.Float64(float64(in.WallTime))
if in.WallTime == nil {
out.RawString("null")
} else {
(*in.WallTime).MarshalEasyJSON(out)
}
}
if in.Initiator != nil {
if !first {
@ -4556,7 +4736,15 @@ func easyjsonC5a4559bDecodeGithubComKnqChromedpCdpNetwork38(in *jlexer.Lexer, ou
case "requestId":
out.RequestID = RequestID(in.String())
case "timestamp":
out.Timestamp = cdp.Timestamp(in.Float64())
if in.IsNull() {
in.Skip()
out.Timestamp = nil
} else {
if out.Timestamp == nil {
out.Timestamp = new(cdp.Timestamp)
}
(*out.Timestamp).UnmarshalEasyJSON(in)
}
case "encodedDataLength":
out.EncodedDataLength = float64(in.Float64())
default:
@ -4581,13 +4769,17 @@ func easyjsonC5a4559bEncodeGithubComKnqChromedpCdpNetwork38(out *jwriter.Writer,
out.RawString("\"requestId\":")
out.String(string(in.RequestID))
}
if in.Timestamp != 0 {
if in.Timestamp != nil {
if !first {
out.RawByte(',')
}
first = false
out.RawString("\"timestamp\":")
out.Float64(float64(in.Timestamp))
if in.Timestamp == nil {
out.RawString("null")
} else {
(*in.Timestamp).MarshalEasyJSON(out)
}
}
if in.EncodedDataLength != 0 {
if !first {
@ -4645,7 +4837,15 @@ func easyjsonC5a4559bDecodeGithubComKnqChromedpCdpNetwork39(in *jlexer.Lexer, ou
case "requestId":
out.RequestID = RequestID(in.String())
case "timestamp":
out.Timestamp = cdp.Timestamp(in.Float64())
if in.IsNull() {
in.Skip()
out.Timestamp = nil
} else {
if out.Timestamp == nil {
out.Timestamp = new(cdp.Timestamp)
}
(*out.Timestamp).UnmarshalEasyJSON(in)
}
case "type":
(out.Type).UnmarshalEasyJSON(in)
case "errorText":
@ -4676,13 +4876,17 @@ func easyjsonC5a4559bEncodeGithubComKnqChromedpCdpNetwork39(out *jwriter.Writer,
out.RawString("\"requestId\":")
out.String(string(in.RequestID))
}
if in.Timestamp != 0 {
if in.Timestamp != nil {
if !first {
out.RawByte(',')
}
first = false
out.RawString("\"timestamp\":")
out.Float64(float64(in.Timestamp))
if in.Timestamp == nil {
out.RawString("null")
} else {
(*in.Timestamp).MarshalEasyJSON(out)
}
}
if in.Type != "" {
if !first {
@ -4764,7 +4968,15 @@ func easyjsonC5a4559bDecodeGithubComKnqChromedpCdpNetwork40(in *jlexer.Lexer, ou
case "requestId":
out.RequestID = RequestID(in.String())
case "timestamp":
out.Timestamp = cdp.Timestamp(in.Float64())
if in.IsNull() {
in.Skip()
out.Timestamp = nil
} else {
if out.Timestamp == nil {
out.Timestamp = new(cdp.Timestamp)
}
(*out.Timestamp).UnmarshalEasyJSON(in)
}
case "eventName":
out.EventName = string(in.String())
case "eventId":
@ -4793,13 +5005,17 @@ func easyjsonC5a4559bEncodeGithubComKnqChromedpCdpNetwork40(out *jwriter.Writer,
out.RawString("\"requestId\":")
out.String(string(in.RequestID))
}
if in.Timestamp != 0 {
if in.Timestamp != nil {
if !first {
out.RawByte(',')
}
first = false
out.RawString("\"timestamp\":")
out.Float64(float64(in.Timestamp))
if in.Timestamp == nil {
out.RawString("null")
} else {
(*in.Timestamp).MarshalEasyJSON(out)
}
}
if in.EventName != "" {
if !first {
@ -4873,7 +5089,15 @@ func easyjsonC5a4559bDecodeGithubComKnqChromedpCdpNetwork41(in *jlexer.Lexer, ou
case "requestId":
out.RequestID = RequestID(in.String())
case "timestamp":
out.Timestamp = cdp.Timestamp(in.Float64())
if in.IsNull() {
in.Skip()
out.Timestamp = nil
} else {
if out.Timestamp == nil {
out.Timestamp = new(cdp.Timestamp)
}
(*out.Timestamp).UnmarshalEasyJSON(in)
}
case "dataLength":
out.DataLength = int64(in.Int64())
case "encodedDataLength":
@ -4900,13 +5124,17 @@ func easyjsonC5a4559bEncodeGithubComKnqChromedpCdpNetwork41(out *jwriter.Writer,
out.RawString("\"requestId\":")
out.String(string(in.RequestID))
}
if in.Timestamp != 0 {
if in.Timestamp != nil {
if !first {
out.RawByte(',')
}
first = false
out.RawString("\"timestamp\":")
out.Float64(float64(in.Timestamp))
if in.Timestamp == nil {
out.RawString("null")
} else {
(*in.Timestamp).MarshalEasyJSON(out)
}
}
if in.DataLength != 0 {
if !first {

View File

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

View File

@ -407,7 +407,7 @@ type SetCookieParams struct {
Secure bool `json:"secure,omitempty"` // Defaults ot false.
HTTPOnly bool `json:"httpOnly,omitempty"` // Defaults to false.
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.Timestamp `json:"expirationDate,omitempty"` // If omitted, the cookie becomes a session cookie.
}
// 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.
func (p SetCookieParams) WithExpirationDate(expirationDate cdp.Timestamp) *SetCookieParams {
func (p SetCookieParams) WithExpirationDate(expirationDate *cdp.Timestamp) *SetCookieParams {
p.ExpirationDate = expirationDate
return &p
}

View File

@ -297,14 +297,14 @@ type Request struct {
// SignedCertificateTimestamp details of a signed certificate timestamp
// (SCT).
type SignedCertificateTimestamp struct {
Status string `json:"status,omitempty"` // Validation status.
Origin string `json:"origin,omitempty"` // Origin.
LogDescription string `json:"logDescription,omitempty"` // Log name / description.
LogID string `json:"logId,omitempty"` // Log ID.
Timestamp cdp.Timestamp `json:"timestamp,omitempty"` // Issuance date.
HashAlgorithm string `json:"hashAlgorithm,omitempty"` // Hash algorithm.
SignatureAlgorithm string `json:"signatureAlgorithm,omitempty"` // Signature algorithm.
SignatureData string `json:"signatureData,omitempty"` // Signature data.
Status string `json:"status,omitempty"` // Validation status.
Origin string `json:"origin,omitempty"` // Origin.
LogDescription string `json:"logDescription,omitempty"` // Log name / description.
LogID string `json:"logId,omitempty"` // Log ID.
Timestamp *cdp.Timestamp `json:"timestamp,omitempty"` // Issuance date.
HashAlgorithm string `json:"hashAlgorithm,omitempty"` // Hash algorithm.
SignatureAlgorithm string `json:"signatureAlgorithm,omitempty"` // Signature algorithm.
SignatureData string `json:"signatureData,omitempty"` // Signature data.
}
// SecurityDetails security details about a request.
@ -318,8 +318,8 @@ type SecurityDetails struct {
SubjectName string `json:"subjectName,omitempty"` // Certificate subject name.
SanList []string `json:"sanList,omitempty"` // Subject Alternative Name (SAN) DNS names and IP addresses.
Issuer string `json:"issuer,omitempty"` // Name of the issuing CA.
ValidFrom cdp.Timestamp `json:"validFrom,omitempty"` // Certificate valid from date.
ValidTo cdp.Timestamp `json:"validTo,omitempty"` // Certificate valid to (expiration) date
ValidFrom *cdp.Timestamp `json:"validFrom,omitempty"` // Certificate valid from date.
ValidTo *cdp.Timestamp `json:"validTo,omitempty"` // Certificate valid to (expiration) date
SignedCertificateTimestampList []*SignedCertificateTimestamp `json:"signedCertificateTimestampList,omitempty"` // List of signed certificate timestamps (SCTs).
}

View File

@ -834,7 +834,15 @@ func easyjsonC5a4559bDecodeGithubComKnqChromedpCdpPage9(in *jlexer.Lexer, out *S
case "scrollOffsetY":
out.ScrollOffsetY = float64(in.Float64())
case "timestamp":
out.Timestamp = float64(in.Float64())
if in.IsNull() {
in.Skip()
out.Timestamp = nil
} else {
if out.Timestamp == nil {
out.Timestamp = new(Bootstamp)
}
(*out.Timestamp).UnmarshalEasyJSON(in)
}
default:
in.SkipRecursive()
}
@ -897,13 +905,17 @@ func easyjsonC5a4559bEncodeGithubComKnqChromedpCdpPage9(out *jwriter.Writer, in
out.RawString("\"scrollOffsetY\":")
out.Float64(float64(in.ScrollOffsetY))
}
if in.Timestamp != 0 {
if in.Timestamp != nil {
if !first {
out.RawByte(',')
}
first = false
out.RawString("\"timestamp\":")
out.Float64(float64(in.Timestamp))
if in.Timestamp == nil {
out.RawString("null")
} else {
(*in.Timestamp).MarshalEasyJSON(out)
}
}
out.RawByte('}')
}
@ -3091,7 +3103,15 @@ func easyjsonC5a4559bDecodeGithubComKnqChromedpCdpPage34(in *jlexer.Lexer, out *
case "mimeType":
out.MimeType = string(in.String())
case "lastModified":
out.LastModified = cdp.Timestamp(in.Float64())
if in.IsNull() {
in.Skip()
out.LastModified = nil
} else {
if out.LastModified == nil {
out.LastModified = new(cdp.Timestamp)
}
(*out.LastModified).UnmarshalEasyJSON(in)
}
case "contentSize":
out.ContentSize = float64(in.Float64())
case "failed":
@ -3136,13 +3156,17 @@ func easyjsonC5a4559bEncodeGithubComKnqChromedpCdpPage34(out *jwriter.Writer, in
out.RawString("\"mimeType\":")
out.String(string(in.MimeType))
}
if in.LastModified != 0 {
if in.LastModified != nil {
if !first {
out.RawByte(',')
}
first = false
out.RawString("\"lastModified\":")
out.Float64(float64(in.LastModified))
if in.LastModified == nil {
out.RawString("null")
} else {
(*in.LastModified).MarshalEasyJSON(out)
}
}
if in.ContentSize != 0 {
if !first {
@ -3483,7 +3507,15 @@ func easyjsonC5a4559bDecodeGithubComKnqChromedpCdpPage38(in *jlexer.Lexer, out *
}
switch key {
case "timestamp":
out.Timestamp = float64(in.Float64())
if in.IsNull() {
in.Skip()
out.Timestamp = nil
} else {
if out.Timestamp == nil {
out.Timestamp = new(Bootstamp)
}
(*out.Timestamp).UnmarshalEasyJSON(in)
}
default:
in.SkipRecursive()
}
@ -3498,13 +3530,17 @@ func easyjsonC5a4559bEncodeGithubComKnqChromedpCdpPage38(out *jwriter.Writer, in
out.RawByte('{')
first := true
_ = first
if in.Timestamp != 0 {
if in.Timestamp != nil {
if !first {
out.RawByte(',')
}
first = false
out.RawString("\"timestamp\":")
out.Float64(float64(in.Timestamp))
if in.Timestamp == nil {
out.RawString("null")
} else {
(*in.Timestamp).MarshalEasyJSON(out)
}
}
out.RawByte('}')
}
@ -4414,7 +4450,15 @@ func easyjsonC5a4559bDecodeGithubComKnqChromedpCdpPage51(in *jlexer.Lexer, out *
}
switch key {
case "timestamp":
out.Timestamp = float64(in.Float64())
if in.IsNull() {
in.Skip()
out.Timestamp = nil
} else {
if out.Timestamp == nil {
out.Timestamp = new(Bootstamp)
}
(*out.Timestamp).UnmarshalEasyJSON(in)
}
default:
in.SkipRecursive()
}
@ -4429,13 +4473,17 @@ func easyjsonC5a4559bEncodeGithubComKnqChromedpCdpPage51(out *jwriter.Writer, in
out.RawByte('{')
first := true
_ = first
if in.Timestamp != 0 {
if in.Timestamp != nil {
if !first {
out.RawByte(',')
}
first = false
out.RawString("\"timestamp\":")
out.Float64(float64(in.Timestamp))
if in.Timestamp == nil {
out.RawString("null")
} else {
(*in.Timestamp).MarshalEasyJSON(out)
}
}
out.RawByte('}')
}

View File

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

View File

@ -4,8 +4,11 @@ package page
import (
"errors"
"strconv"
"time"
cdp "github.com/knq/chromedp/cdp"
"github.com/knq/sysutil"
"github.com/mailru/easyjson"
"github.com/mailru/easyjson/jlexer"
"github.com/mailru/easyjson/jwriter"
@ -88,13 +91,13 @@ func (t *ResourceType) UnmarshalJSON(buf []byte) error {
// FrameResource information about the Resource on the page.
type FrameResource struct {
URL string `json:"url,omitempty"` // Resource URL.
Type ResourceType `json:"type,omitempty"` // Type of this resource.
MimeType string `json:"mimeType,omitempty"` // Resource mimeType as determined by the browser.
LastModified cdp.Timestamp `json:"lastModified,omitempty"` // last-modified timestamp as reported by server.
ContentSize float64 `json:"contentSize,omitempty"` // Resource content size.
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.
URL string `json:"url,omitempty"` // Resource URL.
Type ResourceType `json:"type,omitempty"` // Type of this resource.
MimeType string `json:"mimeType,omitempty"` // Resource mimeType as determined by the browser.
LastModified *cdp.Timestamp `json:"lastModified,omitempty"` // last-modified timestamp as reported by server.
ContentSize float64 `json:"contentSize,omitempty"` // Resource content size.
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.
}
// FrameResourceTree information about the Frame hierarchy along with their
@ -196,13 +199,13 @@ type NavigationEntry struct {
// ScreencastFrameMetadata screencast frame metadata.
type ScreencastFrameMetadata struct {
OffsetTop float64 `json:"offsetTop,omitempty"` // Top offset in DIP.
PageScaleFactor float64 `json:"pageScaleFactor,omitempty"` // Page scale factor.
DeviceWidth float64 `json:"deviceWidth,omitempty"` // Device screen width in DIP.
DeviceHeight float64 `json:"deviceHeight,omitempty"` // Device screen height in DIP.
ScrollOffsetX float64 `json:"scrollOffsetX,omitempty"` // Position of horizontal scroll in CSS pixels.
ScrollOffsetY float64 `json:"scrollOffsetY,omitempty"` // Position of vertical scroll in CSS pixels.
Timestamp float64 `json:"timestamp,omitempty"` // Frame swap timestamp.
OffsetTop float64 `json:"offsetTop,omitempty"` // Top offset in DIP.
PageScaleFactor float64 `json:"pageScaleFactor,omitempty"` // Page scale factor.
DeviceWidth float64 `json:"deviceWidth,omitempty"` // Device screen width in DIP.
DeviceHeight float64 `json:"deviceHeight,omitempty"` // Device screen height in DIP.
ScrollOffsetX float64 `json:"scrollOffsetX,omitempty"` // Position of horizontal scroll in CSS pixels.
ScrollOffsetY float64 `json:"scrollOffsetY,omitempty"` // Position of vertical scroll in CSS pixels.
Timestamp *Bootstamp `json:"timestamp,omitempty"` // Frame swap timestamp.
}
// DialogType javascript dialog type.
@ -327,6 +330,37 @@ type VisualViewport struct {
Scale float64 `json:"scale,omitempty"` // 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).
type CaptureScreenshotFormat string

View File

@ -2361,7 +2361,15 @@ func easyjsonC5a4559bDecodeGithubComKnqChromedpCdpRuntime20(in *jlexer.Lexer, ou
}
switch key {
case "timestamp":
out.Timestamp = Timestamp(in.Float64())
if in.IsNull() {
in.Skip()
out.Timestamp = nil
} else {
if out.Timestamp == nil {
out.Timestamp = new(Timestamp)
}
(*out.Timestamp).UnmarshalEasyJSON(in)
}
case "exceptionDetails":
if in.IsNull() {
in.Skip()
@ -2386,13 +2394,17 @@ func easyjsonC5a4559bEncodeGithubComKnqChromedpCdpRuntime20(out *jwriter.Writer,
out.RawByte('{')
first := true
_ = first
if in.Timestamp != 0 {
if in.Timestamp != nil {
if !first {
out.RawByte(',')
}
first = false
out.RawString("\"timestamp\":")
out.Float64(float64(in.Timestamp))
if in.Timestamp == nil {
out.RawString("null")
} else {
(*in.Timestamp).MarshalEasyJSON(out)
}
}
if in.ExceptionDetails != nil {
if !first {
@ -2566,7 +2578,15 @@ func easyjsonC5a4559bDecodeGithubComKnqChromedpCdpRuntime22(in *jlexer.Lexer, ou
case "executionContextId":
out.ExecutionContextID = ExecutionContextID(in.Int64())
case "timestamp":
out.Timestamp = Timestamp(in.Float64())
if in.IsNull() {
in.Skip()
out.Timestamp = nil
} else {
if out.Timestamp == nil {
out.Timestamp = new(Timestamp)
}
(*out.Timestamp).UnmarshalEasyJSON(in)
}
case "stackTrace":
if in.IsNull() {
in.Skip()
@ -2632,13 +2652,17 @@ func easyjsonC5a4559bEncodeGithubComKnqChromedpCdpRuntime22(out *jwriter.Writer,
out.RawString("\"executionContextId\":")
out.Int64(int64(in.ExecutionContextID))
}
if in.Timestamp != 0 {
if in.Timestamp != nil {
if !first {
out.RawByte(',')
}
first = false
out.RawString("\"timestamp\":")
out.Float64(float64(in.Timestamp))
if in.Timestamp == nil {
out.RawString("null")
} else {
(*in.Timestamp).MarshalEasyJSON(out)
}
}
if in.StackTrace != nil {
if !first {

View File

@ -23,7 +23,7 @@ type EventExecutionContextsCleared struct{}
// EventExceptionThrown issued when exception was thrown and unhandled.
type EventExceptionThrown struct {
Timestamp Timestamp `json:"timestamp,omitempty"` // Timestamp of the exception.
Timestamp *Timestamp `json:"timestamp,omitempty"` // Timestamp of the exception.
ExceptionDetails *ExceptionDetails `json:"exceptionDetails,omitempty"`
}
@ -38,7 +38,7 @@ type EventConsoleAPICalled struct {
Type APIType `json:"type,omitempty"` // Type of the call.
Args []*RemoteObject `json:"args,omitempty"` // Call arguments.
ExecutionContextID ExecutionContextID `json:"executionContextId,omitempty"` // Identifier of the context where the call was made.
Timestamp Timestamp `json:"timestamp,omitempty"` // Call timestamp.
Timestamp *Timestamp `json:"timestamp,omitempty"` // Call timestamp.
StackTrace *StackTrace `json:"stackTrace,omitempty"` // Stack trace captured when the call was made.
Context string `json:"context,omitempty"` // Console context descriptor for calls on non-default console context (not console.*): 'anonymous#unique-logger-id' for call on unnamed context, 'name#unique-logger-id' for call on named context.
}

View File

@ -3,6 +3,8 @@ package runtime
import (
"errors"
"fmt"
"strconv"
"time"
"github.com/mailru/easyjson"
"github.com/mailru/easyjson/jlexer"
@ -190,11 +192,34 @@ func (e *ExceptionDetails) Error() string {
}
// Timestamp number of milliseconds since epoch.
type Timestamp float64
type Timestamp time.Time
// Float64 returns the Timestamp as float64 value.
func (t Timestamp) Float64() float64 {
return float64(t)
// Time returns the Timestamp as time.Time value.
func (t Timestamp) Time() time.Time {
return time.Time(t)
}
// MarshalEasyJSON satisfies easyjson.Marshaler.
func (t Timestamp) MarshalEasyJSON(out *jwriter.Writer) {
v := float64(time.Time(t).UnixNano() / int64(time.Millisecond))
out.Buffer.EnsureSpace(20)
out.Buffer.Buf = strconv.AppendFloat(out.Buffer.Buf, v, 'f', -1, 64)
}
// MarshalJSON satisfies json.Marshaler.
func (t Timestamp) MarshalJSON() ([]byte, error) {
return easyjson.Marshal(t)
}
// UnmarshalEasyJSON satisfies easyjson.Unmarshaler.
func (t *Timestamp) UnmarshalEasyJSON(in *jlexer.Lexer) {
*t = Timestamp(time.Unix(0, int64(in.Float64()*float64(time.Millisecond))))
}
// UnmarshalJSON satisfies json.Unmarshaler.
func (t *Timestamp) UnmarshalJSON(buf []byte) error {
return easyjson.Unmarshal(buf, t)
}
// CallFrame stack entry for runtime errors and assertions.

View File

@ -12,14 +12,19 @@
// - 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.ErrorType' type.
// - change type of Network.Timestamp and Runtime.Timestamp to internal Timestamp type.
// - add 'Page.Bootstamp' type and convert all command/event parameters named
// '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 'Runtime.Timestamp'.
// that doesn't have a $ref defined to 'Network.Timestamp'.
// - convert object properties and event/command parameters that are enums into independent types.
// - change '*.modifiers' parameters to type Input.Modifier.
// - add 'DOM.NodeType' type and convert "nodeType" parameters to it.
// - change Page.Frame.id/parentID to FrameID type.
// - add additional properties to 'Page.Frame' and 'DOM.Node' for use by higher level packages.
// - add special unmarshaler to NodeId, BackendNodeId, FrameId to handle values from older (v1.1) protocol versions. -- NOTE: this might need to be applied to more types, such as network.LoaderId
// - add special unmarshaler to NodeId, BackendNodeId, FrameId to handle
// values from older (v1.1) protocol versions. -- NOTE: this might need to be
// applied to more types, such as network.LoaderId
// - rename 'Input.GestureSourceType' -> 'Input.GestureType'.
// - rename CSS.CSS* types.
// - add Error() method to 'Runtime.ExceptionDetails' type so that it can be used as error.
@ -33,7 +38,6 @@ package fixup
import (
"fmt"
"log"
"strings"
"github.com/knq/chromedp/cmd/chromedp-gen/internal"
@ -197,6 +201,14 @@ func FixDomains(domains []*internal.Domain) {
},
}
// bootstamp type
bootstampType := &internal.Type{
ID: "Bootstamp",
Type: internal.TypeTimestamp,
TimestampType: internal.TimestampTypeBootstamp,
Description: "Bootstamp type.",
}
// process domains
for _, d := range domains {
switch d.Domain {
@ -279,8 +291,14 @@ func FixDomains(domains []*internal.Domain) {
}
case internal.DomainPage:
// add Page types
d.Types = append(d.Types, bootstampType)
for _, t := range d.Types {
switch t.ID {
case "Bootstamp":
t.Extra += templates.ExtraTimestampTemplate(t, d)
case "FrameId":
t.Extra += templates.ExtraFixStringUnmarshaler(internal.ForceCamel(t.ID), "", "")
@ -330,10 +348,11 @@ func FixDomains(domains []*internal.Domain) {
case internal.DomainNetwork:
for _, t := range d.Types {
// change Timestamp to TypeTimestamp and add extra unmarshaling template
/*if t.ID == "Timestamp" {
if t.ID == "Timestamp" {
t.Type = internal.TypeTimestamp
t.TimestampType = internal.TimestampTypeSecond
t.Extra = templates.ExtraTimestampTemplate(t, d)
}*/
}
// change Headers to be a map[string]interface{}
if t.ID == "Headers" {
@ -346,9 +365,10 @@ func FixDomains(domains []*internal.Domain) {
var types []*internal.Type
for _, t := range d.Types {
switch t.ID {
/*case "Timestamp":
t.Type = internal.TypeTimestamp
t.Extra += templates.ExtraBootstampTemplate(t, d)*/
case "Timestamp":
t.Type = internal.TypeTimestamp
t.TimestampType = internal.TimestampTypeMillisecond
t.Extra += templates.ExtraTimestampTemplate(t, d)
case "ExceptionDetails":
t.Extra += templates.ExtraExceptionDetailsTemplate()
@ -439,15 +459,21 @@ func convertObjectProperties(params []*internal.Type, d *internal.Domain, name s
case p.Enum != nil:
r = append(r, fixupEnumParameter(name, p, d))
case p.Name == "timestamp":
log.Printf(">>> %s.%s.%s", d.Domain, name, p.Name)
r = append(r, p)
/*r = append(r, &internal.Type{
Name: p.Name,
Ref: "Runtime.Timestamp",
Description: p.Description,
Optional: p.Optional,
})*/
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":
r = append(r, &internal.Type{

View File

@ -148,3 +148,12 @@ func (te TypeEnum) GoEmptyValue() string {
return `nil`
}
// TimestampType are the various timestamp subtypes.
type TimestampType int
const (
TimestampTypeMillisecond TimestampType = 1 + iota
TimestampTypeSecond
TimestampTypeBootstamp
)

View File

@ -145,6 +145,9 @@ type Type struct {
// Redirect is the redirect value for the command or event.
Redirect DomainType `json:"redirect,omitempty"`
// TimestampType is the timestamp subtype.
TimestampType TimestampType `json:"-"`
// NoExpose toggles whether or not to expose the type.
NoExpose bool `json:"-"`

View File

@ -6,14 +6,18 @@
// defines its JSON unmarshaling.
{% func ExtraTimestampTemplate(t *internal.Type, d *internal.Domain) %}{%code
typ := t.IDorName()
bootstamp := false
bootstamp := t.TimestampType == internal.TimestampTypeBootstamp
timeRes := "time.Millisecond"
if t.TimestampType != internal.TimestampTypeMillisecond {
timeRes = "time.Second"
}
%}
// MarshalEasyJSON satisfies easyjson.Marshaler.
func (t {%s= typ %}) MarshalEasyJSON(out *jwriter.Writer) {
{% if bootstamp %}
out.Float64(float64(time.Time(t).Sub(sysutil.BootTime()))/float64(time.Second)){% else %}
out.Float64(float64(time.Time(t))/float64(time.Second))
{% endif %}
v := {% if bootstamp %}float64(time.Time(t).Sub(sysutil.BootTime()))/float64(time.Second){% else %}float64(time.Time(t).UnixNano()/int64({%s= timeRes %})){% endif %}
out.Buffer.EnsureSpace(20)
out.Buffer.Buf = strconv.AppendFloat(out.Buffer.Buf, v, 'f', -1, 64)
}
// MarshalJSON satisfies json.Marshaler.
@ -22,11 +26,9 @@ func (t {%s= typ %}) MarshalJSON() ([]byte, error) {
}
// UnmarshalEasyJSON satisfies easyjson.Unmarshaler.
func (t *{%s= typ %}) UnmarshalEasyJSON(in *jlexer.Lexer) {
{% if bootstamp %}
func (t *{%s= typ %}) UnmarshalEasyJSON(in *jlexer.Lexer) {{% if bootstamp %}
*t = {%s= typ %}(sysutil.BootTime().Add(time.Duration(in.Float64()*float64(time.Second)))){% else %}
*t = {%s= typ %}(time.Duration(in.Float64()*float64(time.Second)))
{% endif %}
*t = {%s= typ %}(time.Unix(0, int64(in.Float64()*float64({%s= timeRes %})))){% endif %}
}
// UnmarshalJSON satisfies json.Unmarshaler.

View File

@ -29,118 +29,128 @@ var (
func StreamExtraTimestampTemplate(qw422016 *qt422016.Writer, t *internal.Type, d *internal.Domain) {
//line templates/extra.qtpl:8
typ := t.IDorName()
bootstamp := false
bootstamp := t.TimestampType == internal.TimestampTypeBootstamp
timeRes := "time.Millisecond"
if t.TimestampType != internal.TimestampTypeMillisecond {
timeRes = "time.Second"
}
//line templates/extra.qtpl:10
//line templates/extra.qtpl:14
qw422016.N().S(`
// MarshalEasyJSON satisfies easyjson.Marshaler.
func (t `)
//line templates/extra.qtpl:12
qw422016.N().S(typ)
//line templates/extra.qtpl:12
qw422016.N().S(`) MarshalEasyJSON(out *jwriter.Writer) {
`)
//line templates/extra.qtpl:13
if bootstamp {
//line templates/extra.qtpl:13
qw422016.N().S(`
out.Float64(float64(time.Time(t).Sub(sysutil.BootTime()))/float64(time.Second))`)
//line templates/extra.qtpl:14
} else {
//line templates/extra.qtpl:14
qw422016.N().S(`
out.Float64(float64(time.Time(t))/float64(time.Second))
`)
//line templates/extra.qtpl:16
}
//line templates/extra.qtpl:16
qw422016.N().S(typ)
//line templates/extra.qtpl:16
qw422016.N().S(`) MarshalEasyJSON(out *jwriter.Writer) {
v := `)
//line templates/extra.qtpl:17
if bootstamp {
//line templates/extra.qtpl:17
qw422016.N().S(`float64(time.Time(t).Sub(sysutil.BootTime()))/float64(time.Second)`)
//line templates/extra.qtpl:17
} else {
//line templates/extra.qtpl:17
qw422016.N().S(`float64(time.Time(t).UnixNano()/int64(`)
//line templates/extra.qtpl:17
qw422016.N().S(timeRes)
//line templates/extra.qtpl:17
qw422016.N().S(`))`)
//line templates/extra.qtpl:17
}
//line templates/extra.qtpl:17
qw422016.N().S(`
out.Buffer.EnsureSpace(20)
out.Buffer.Buf = strconv.AppendFloat(out.Buffer.Buf, v, 'f', -1, 64)
}
// MarshalJSON satisfies json.Marshaler.
func (t `)
//line templates/extra.qtpl:20
//line templates/extra.qtpl:24
qw422016.N().S(typ)
//line templates/extra.qtpl:20
//line templates/extra.qtpl:24
qw422016.N().S(`) MarshalJSON() ([]byte, error) {
return easyjson.Marshal(t)
}
// UnmarshalEasyJSON satisfies easyjson.Unmarshaler.
func (t *`)
//line templates/extra.qtpl:25
qw422016.N().S(typ)
//line templates/extra.qtpl:25
qw422016.N().S(`) UnmarshalEasyJSON(in *jlexer.Lexer) {
`)
//line templates/extra.qtpl:26
if bootstamp {
//line templates/extra.qtpl:26
qw422016.N().S(`
*t = `)
//line templates/extra.qtpl:27
qw422016.N().S(typ)
//line templates/extra.qtpl:27
qw422016.N().S(`(sysutil.BootTime().Add(time.Duration(in.Float64()*float64(time.Second))))`)
//line templates/extra.qtpl:27
} else {
//line templates/extra.qtpl:27
qw422016.N().S(`
*t = `)
//line templates/extra.qtpl:28
qw422016.N().S(typ)
//line templates/extra.qtpl:28
qw422016.N().S(`(time.Duration(in.Float64()*float64(time.Second)))
`)
//line templates/extra.qtpl:29
}
//line templates/extra.qtpl:29
qw422016.N().S(typ)
//line templates/extra.qtpl:29
qw422016.N().S(`) UnmarshalEasyJSON(in *jlexer.Lexer) {`)
//line templates/extra.qtpl:29
if bootstamp {
//line templates/extra.qtpl:29
qw422016.N().S(`
*t = `)
//line templates/extra.qtpl:30
qw422016.N().S(typ)
//line templates/extra.qtpl:30
qw422016.N().S(`(sysutil.BootTime().Add(time.Duration(in.Float64()*float64(time.Second))))`)
//line templates/extra.qtpl:30
} else {
//line templates/extra.qtpl:30
qw422016.N().S(`
*t = `)
//line templates/extra.qtpl:31
qw422016.N().S(typ)
//line templates/extra.qtpl:31
qw422016.N().S(`(time.Unix(0, int64(in.Float64()*float64(`)
//line templates/extra.qtpl:31
qw422016.N().S(timeRes)
//line templates/extra.qtpl:31
qw422016.N().S(`))))`)
//line templates/extra.qtpl:31
}
//line templates/extra.qtpl:31
qw422016.N().S(`
}
// UnmarshalJSON satisfies json.Unmarshaler.
func (t *`)
//line templates/extra.qtpl:33
//line templates/extra.qtpl:35
qw422016.N().S(typ)
//line templates/extra.qtpl:33
//line templates/extra.qtpl:35
qw422016.N().S(`) UnmarshalJSON(buf []byte) error {
return easyjson.Unmarshal(buf, t)
}
`)
//line templates/extra.qtpl:36
//line templates/extra.qtpl:38
}
//line templates/extra.qtpl:36
//line templates/extra.qtpl:38
func WriteExtraTimestampTemplate(qq422016 qtio422016.Writer, t *internal.Type, d *internal.Domain) {
//line templates/extra.qtpl:36
//line templates/extra.qtpl:38
qw422016 := qt422016.AcquireWriter(qq422016)
//line templates/extra.qtpl:36
//line templates/extra.qtpl:38
StreamExtraTimestampTemplate(qw422016, t, d)
//line templates/extra.qtpl:36
//line templates/extra.qtpl:38
qt422016.ReleaseWriter(qw422016)
//line templates/extra.qtpl:36
//line templates/extra.qtpl:38
}
//line templates/extra.qtpl:36
//line templates/extra.qtpl:38
func ExtraTimestampTemplate(t *internal.Type, d *internal.Domain) string {
//line templates/extra.qtpl:36
//line templates/extra.qtpl:38
qb422016 := qt422016.AcquireByteBuffer()
//line templates/extra.qtpl:36
//line templates/extra.qtpl:38
WriteExtraTimestampTemplate(qb422016, t, d)
//line templates/extra.qtpl:36
//line templates/extra.qtpl:38
qs422016 := string(qb422016.B)
//line templates/extra.qtpl:36
//line templates/extra.qtpl:38
qt422016.ReleaseByteBuffer(qb422016)
//line templates/extra.qtpl:36
//line templates/extra.qtpl:38
return qs422016
//line templates/extra.qtpl:36
//line templates/extra.qtpl:38
}
// ExtraFrameTemplate is a special template for the Page.Frame type, adding FrameState.
//line templates/extra.qtpl:39
//line templates/extra.qtpl:41
func StreamExtraFrameTemplate(qw422016 *qt422016.Writer) {
//line templates/extra.qtpl:39
//line templates/extra.qtpl:41
qw422016.N().S(`
// FrameState is the state of a Frame.
type FrameState uint16
@ -179,40 +189,40 @@ func (fs FrameState) String() string {
// EmptyFrameID is the "non-existent" frame id.
const EmptyFrameID = FrameID("")
`)
//line templates/extra.qtpl:76
//line templates/extra.qtpl:78
}
//line templates/extra.qtpl:76
//line templates/extra.qtpl:78
func WriteExtraFrameTemplate(qq422016 qtio422016.Writer) {
//line templates/extra.qtpl:76
//line templates/extra.qtpl:78
qw422016 := qt422016.AcquireWriter(qq422016)
//line templates/extra.qtpl:76
//line templates/extra.qtpl:78
StreamExtraFrameTemplate(qw422016)
//line templates/extra.qtpl:76
//line templates/extra.qtpl:78
qt422016.ReleaseWriter(qw422016)
//line templates/extra.qtpl:76
//line templates/extra.qtpl:78
}
//line templates/extra.qtpl:76
//line templates/extra.qtpl:78
func ExtraFrameTemplate() string {
//line templates/extra.qtpl:76
//line templates/extra.qtpl:78
qb422016 := qt422016.AcquireByteBuffer()
//line templates/extra.qtpl:76
//line templates/extra.qtpl:78
WriteExtraFrameTemplate(qb422016)
//line templates/extra.qtpl:76
//line templates/extra.qtpl:78
qs422016 := string(qb422016.B)
//line templates/extra.qtpl:76
//line templates/extra.qtpl:78
qt422016.ReleaseByteBuffer(qb422016)
//line templates/extra.qtpl:76
//line templates/extra.qtpl:78
return qs422016
//line templates/extra.qtpl:76
//line templates/extra.qtpl:78
}
// ExtraNodeTemplate is a special template for the DOM.Node type, adding NodeState.
//line templates/extra.qtpl:79
//line templates/extra.qtpl:81
func StreamExtraNodeTemplate(qw422016 *qt422016.Writer) {
//line templates/extra.qtpl:79
//line templates/extra.qtpl:81
qw422016.N().S(`
// AttributeValue returns the named attribute for the node.
func (n *Node) AttributeValue(name string) string {
@ -246,21 +256,21 @@ func (n *Node) xpath(stopAtDocument, stopAtID bool) string {
case stopAtID && id != "":
p = "/"
pos = `)
//line templates/extra.qtpl:79
//line templates/extra.qtpl:81
qw422016.N().S("`")
//line templates/extra.qtpl:79
//line templates/extra.qtpl:81
qw422016.N().S(`[@id='`)
//line templates/extra.qtpl:79
//line templates/extra.qtpl:81
qw422016.N().S("`")
//line templates/extra.qtpl:79
//line templates/extra.qtpl:81
qw422016.N().S(`+id+`)
//line templates/extra.qtpl:79
//line templates/extra.qtpl:81
qw422016.N().S("`")
//line templates/extra.qtpl:79
//line templates/extra.qtpl:81
qw422016.N().S(`']`)
//line templates/extra.qtpl:79
//line templates/extra.qtpl:81
qw422016.N().S("`")
//line templates/extra.qtpl:79
//line templates/extra.qtpl:81
qw422016.N().S(`
case n.Parent != nil:
@ -344,136 +354,136 @@ func (ns NodeState) String() string {
// EmptyNodeID is the "non-existent" node id.
const EmptyNodeID = NodeID(0)
`)
//line templates/extra.qtpl:193
//line templates/extra.qtpl:195
}
//line templates/extra.qtpl:193
//line templates/extra.qtpl:195
func WriteExtraNodeTemplate(qq422016 qtio422016.Writer) {
//line templates/extra.qtpl:193
//line templates/extra.qtpl:195
qw422016 := qt422016.AcquireWriter(qq422016)
//line templates/extra.qtpl:193
//line templates/extra.qtpl:195
StreamExtraNodeTemplate(qw422016)
//line templates/extra.qtpl:193
//line templates/extra.qtpl:195
qt422016.ReleaseWriter(qw422016)
//line templates/extra.qtpl:193
//line templates/extra.qtpl:195
}
//line templates/extra.qtpl:193
//line templates/extra.qtpl:195
func ExtraNodeTemplate() string {
//line templates/extra.qtpl:193
//line templates/extra.qtpl:195
qb422016 := qt422016.AcquireByteBuffer()
//line templates/extra.qtpl:193
//line templates/extra.qtpl:195
WriteExtraNodeTemplate(qb422016)
//line templates/extra.qtpl:193
//line templates/extra.qtpl:195
qs422016 := string(qb422016.B)
//line templates/extra.qtpl:193
//line templates/extra.qtpl:195
qt422016.ReleaseByteBuffer(qb422016)
//line templates/extra.qtpl:193
//line templates/extra.qtpl:195
return qs422016
//line templates/extra.qtpl:193
//line templates/extra.qtpl:195
}
// ExtraFixStringUnmarshaler is a template that forces values to be parsed properly.
//line templates/extra.qtpl:196
//line templates/extra.qtpl:198
func StreamExtraFixStringUnmarshaler(qw422016 *qt422016.Writer, typ, parseFunc, extra string) {
//line templates/extra.qtpl:196
//line templates/extra.qtpl:198
qw422016.N().S(`
// UnmarshalEasyJSON satisfies easyjson.Unmarshaler.
func (t *`)
//line templates/extra.qtpl:198
//line templates/extra.qtpl:200
qw422016.N().S(typ)
//line templates/extra.qtpl:198
//line templates/extra.qtpl:200
qw422016.N().S(`) UnmarshalEasyJSON(in *jlexer.Lexer) {
buf := in.Raw()
if l := len(buf); l > 2 && buf[0] == '"' && buf[l-1] == '"' {
buf = buf[1:l-1]
}
`)
//line templates/extra.qtpl:203
//line templates/extra.qtpl:205
if parseFunc != "" {
//line templates/extra.qtpl:203
//line templates/extra.qtpl:205
qw422016.N().S(`
v, err := strconv.`)
//line templates/extra.qtpl:204
//line templates/extra.qtpl:206
qw422016.N().S(parseFunc)
//line templates/extra.qtpl:204
//line templates/extra.qtpl:206
qw422016.N().S(`(string(buf)`)
//line templates/extra.qtpl:204
//line templates/extra.qtpl:206
qw422016.N().S(extra)
//line templates/extra.qtpl:204
//line templates/extra.qtpl:206
qw422016.N().S(`)
if err != nil {
in.AddError(err)
}
`)
//line templates/extra.qtpl:208
//line templates/extra.qtpl:210
}
//line templates/extra.qtpl:208
//line templates/extra.qtpl:210
qw422016.N().S(`
*t = `)
//line templates/extra.qtpl:209
//line templates/extra.qtpl:211
qw422016.N().S(typ)
//line templates/extra.qtpl:209
//line templates/extra.qtpl:211
qw422016.N().S(`(`)
//line templates/extra.qtpl:209
//line templates/extra.qtpl:211
if parseFunc != "" {
//line templates/extra.qtpl:209
//line templates/extra.qtpl:211
qw422016.N().S(`v`)
//line templates/extra.qtpl:209
//line templates/extra.qtpl:211
} else {
//line templates/extra.qtpl:209
//line templates/extra.qtpl:211
qw422016.N().S(`buf`)
//line templates/extra.qtpl:209
//line templates/extra.qtpl:211
}
//line templates/extra.qtpl:209
//line templates/extra.qtpl:211
qw422016.N().S(`)
}
// UnmarshalJSON satisfies json.Unmarshaler.
func (t *`)
//line templates/extra.qtpl:213
//line templates/extra.qtpl:215
qw422016.N().S(typ)
//line templates/extra.qtpl:213
//line templates/extra.qtpl:215
qw422016.N().S(`) UnmarshalJSON(buf []byte) error {
return easyjson.Unmarshal(buf, t)
}
`)
//line templates/extra.qtpl:216
//line templates/extra.qtpl:218
}
//line templates/extra.qtpl:216
//line templates/extra.qtpl:218
func WriteExtraFixStringUnmarshaler(qq422016 qtio422016.Writer, typ, parseFunc, extra string) {
//line templates/extra.qtpl:216
//line templates/extra.qtpl:218
qw422016 := qt422016.AcquireWriter(qq422016)
//line templates/extra.qtpl:216
//line templates/extra.qtpl:218
StreamExtraFixStringUnmarshaler(qw422016, typ, parseFunc, extra)
//line templates/extra.qtpl:216
//line templates/extra.qtpl:218
qt422016.ReleaseWriter(qw422016)
//line templates/extra.qtpl:216
//line templates/extra.qtpl:218
}
//line templates/extra.qtpl:216
//line templates/extra.qtpl:218
func ExtraFixStringUnmarshaler(typ, parseFunc, extra string) string {
//line templates/extra.qtpl:216
//line templates/extra.qtpl:218
qb422016 := qt422016.AcquireByteBuffer()
//line templates/extra.qtpl:216
//line templates/extra.qtpl:218
WriteExtraFixStringUnmarshaler(qb422016, typ, parseFunc, extra)
//line templates/extra.qtpl:216
//line templates/extra.qtpl:218
qs422016 := string(qb422016.B)
//line templates/extra.qtpl:216
//line templates/extra.qtpl:218
qt422016.ReleaseByteBuffer(qb422016)
//line templates/extra.qtpl:216
//line templates/extra.qtpl:218
return qs422016
//line templates/extra.qtpl:216
//line templates/extra.qtpl:218
}
// ExtraExceptionDetailsTemplate is a special template for the Runtime.ExceptionDetails type that
// defines the standard error interface.
//line templates/extra.qtpl:220
//line templates/extra.qtpl:222
func StreamExtraExceptionDetailsTemplate(qw422016 *qt422016.Writer) {
//line templates/extra.qtpl:220
//line templates/extra.qtpl:222
qw422016.N().S(`
// Error satisfies the error interface.
func (e *ExceptionDetails) Error() string {
@ -482,41 +492,41 @@ func (e *ExceptionDetails) Error() string {
return fmt.Sprintf("encountered exception '%s' (%d:%d)", e.Text, e.LineNumber, e.ColumnNumber)
}
`)
//line templates/extra.qtpl:227
//line templates/extra.qtpl:229
}
//line templates/extra.qtpl:227
//line templates/extra.qtpl:229
func WriteExtraExceptionDetailsTemplate(qq422016 qtio422016.Writer) {
//line templates/extra.qtpl:227
//line templates/extra.qtpl:229
qw422016 := qt422016.AcquireWriter(qq422016)
//line templates/extra.qtpl:227
//line templates/extra.qtpl:229
StreamExtraExceptionDetailsTemplate(qw422016)
//line templates/extra.qtpl:227
//line templates/extra.qtpl:229
qt422016.ReleaseWriter(qw422016)
//line templates/extra.qtpl:227
//line templates/extra.qtpl:229
}
//line templates/extra.qtpl:227
//line templates/extra.qtpl:229
func ExtraExceptionDetailsTemplate() string {
//line templates/extra.qtpl:227
//line templates/extra.qtpl:229
qb422016 := qt422016.AcquireByteBuffer()
//line templates/extra.qtpl:227
//line templates/extra.qtpl:229
WriteExtraExceptionDetailsTemplate(qb422016)
//line templates/extra.qtpl:227
//line templates/extra.qtpl:229
qs422016 := string(qb422016.B)
//line templates/extra.qtpl:227
//line templates/extra.qtpl:229
qt422016.ReleaseByteBuffer(qb422016)
//line templates/extra.qtpl:227
//line templates/extra.qtpl:229
return qs422016
//line templates/extra.qtpl:227
//line templates/extra.qtpl:229
}
// ExtraCDPTypes is the template for additional internal type
// declarations.
//line templates/extra.qtpl:231
//line templates/extra.qtpl:233
func StreamExtraCDPTypes(qw422016 *qt422016.Writer) {
//line templates/extra.qtpl:231
//line templates/extra.qtpl:233
qw422016.N().S(`
// Error satisfies the error interface.
@ -550,40 +560,40 @@ type Handler interface {
Release(<-chan interface{})
}
`)
//line templates/extra.qtpl:263
//line templates/extra.qtpl:265
}
//line templates/extra.qtpl:263
//line templates/extra.qtpl:265
func WriteExtraCDPTypes(qq422016 qtio422016.Writer) {
//line templates/extra.qtpl:263
//line templates/extra.qtpl:265
qw422016 := qt422016.AcquireWriter(qq422016)
//line templates/extra.qtpl:263
//line templates/extra.qtpl:265
StreamExtraCDPTypes(qw422016)
//line templates/extra.qtpl:263
//line templates/extra.qtpl:265
qt422016.ReleaseWriter(qw422016)
//line templates/extra.qtpl:263
//line templates/extra.qtpl:265
}
//line templates/extra.qtpl:263
//line templates/extra.qtpl:265
func ExtraCDPTypes() string {
//line templates/extra.qtpl:263
//line templates/extra.qtpl:265
qb422016 := qt422016.AcquireByteBuffer()
//line templates/extra.qtpl:263
//line templates/extra.qtpl:265
WriteExtraCDPTypes(qb422016)
//line templates/extra.qtpl:263
//line templates/extra.qtpl:265
qs422016 := string(qb422016.B)
//line templates/extra.qtpl:263
//line templates/extra.qtpl:265
qt422016.ReleaseByteBuffer(qb422016)
//line templates/extra.qtpl:263
//line templates/extra.qtpl:265
return qs422016
//line templates/extra.qtpl:263
//line templates/extra.qtpl:265
}
// ExtraUtilTemplate generates the decode func for the Message type.
//line templates/extra.qtpl:266
//line templates/extra.qtpl:268
func StreamExtraUtilTemplate(qw422016 *qt422016.Writer, domains []*internal.Domain) {
//line templates/extra.qtpl:266
//line templates/extra.qtpl:268
qw422016.N().S(`
type empty struct{}
var emptyVal = &empty{}
@ -592,66 +602,66 @@ var emptyVal = &empty{}
func UnmarshalMessage(msg *cdp.Message) (interface{}, error) {
var v easyjson.Unmarshaler
switch msg.Method {`)
//line templates/extra.qtpl:273
//line templates/extra.qtpl:275
for _, d := range domains {
//line templates/extra.qtpl:273
//line templates/extra.qtpl:275
for _, c := range d.Commands {
//line templates/extra.qtpl:273
//line templates/extra.qtpl:275
qw422016.N().S(`
case cdp.`)
//line templates/extra.qtpl:274
//line templates/extra.qtpl:276
qw422016.N().S(c.CommandMethodType(d))
//line templates/extra.qtpl:274
//line templates/extra.qtpl:276
qw422016.N().S(`:`)
//line templates/extra.qtpl:274
//line templates/extra.qtpl:276
if len(c.Returns) == 0 {
//line templates/extra.qtpl:274
//line templates/extra.qtpl:276
qw422016.N().S(`
return emptyVal, nil`)
//line templates/extra.qtpl:275
//line templates/extra.qtpl:277
} else {
//line templates/extra.qtpl:275
//line templates/extra.qtpl:277
qw422016.N().S(`
v = new(`)
//line templates/extra.qtpl:276
//line templates/extra.qtpl:278
qw422016.N().S(d.PackageRefName())
//line templates/extra.qtpl:276
//line templates/extra.qtpl:278
qw422016.N().S(`.`)
//line templates/extra.qtpl:276
//line templates/extra.qtpl:278
qw422016.N().S(c.CommandReturnsType())
//line templates/extra.qtpl:276
//line templates/extra.qtpl:278
qw422016.N().S(`)`)
//line templates/extra.qtpl:276
//line templates/extra.qtpl:278
}
//line templates/extra.qtpl:276
//line templates/extra.qtpl:278
qw422016.N().S(`
`)
//line templates/extra.qtpl:277
//line templates/extra.qtpl:279
}
//line templates/extra.qtpl:277
//line templates/extra.qtpl:279
for _, e := range d.Events {
//line templates/extra.qtpl:277
//line templates/extra.qtpl:279
qw422016.N().S(`
case cdp.`)
//line templates/extra.qtpl:278
//line templates/extra.qtpl:280
qw422016.N().S(e.EventMethodType(d))
//line templates/extra.qtpl:278
//line templates/extra.qtpl:280
qw422016.N().S(`:
v = new(`)
//line templates/extra.qtpl:279
//line templates/extra.qtpl:281
qw422016.N().S(d.PackageRefName())
//line templates/extra.qtpl:279
//line templates/extra.qtpl:281
qw422016.N().S(`.`)
//line templates/extra.qtpl:279
//line templates/extra.qtpl:281
qw422016.N().S(e.EventType())
//line templates/extra.qtpl:279
//line templates/extra.qtpl:281
qw422016.N().S(`)
`)
//line templates/extra.qtpl:280
//line templates/extra.qtpl:282
}
//line templates/extra.qtpl:280
//line templates/extra.qtpl:282
}
//line templates/extra.qtpl:280
//line templates/extra.qtpl:282
qw422016.N().S(`}
var buf easyjson.RawMessage
@ -674,69 +684,69 @@ func UnmarshalMessage(msg *cdp.Message) (interface{}, error) {
return v, nil
}
`)
//line templates/extra.qtpl:301
}
//line templates/extra.qtpl:301
func WriteExtraUtilTemplate(qq422016 qtio422016.Writer, domains []*internal.Domain) {
//line templates/extra.qtpl:301
qw422016 := qt422016.AcquireWriter(qq422016)
//line templates/extra.qtpl:301
StreamExtraUtilTemplate(qw422016, domains)
//line templates/extra.qtpl:301
qt422016.ReleaseWriter(qw422016)
//line templates/extra.qtpl:301
}
//line templates/extra.qtpl:301
func ExtraUtilTemplate(domains []*internal.Domain) string {
//line templates/extra.qtpl:301
qb422016 := qt422016.AcquireByteBuffer()
//line templates/extra.qtpl:301
WriteExtraUtilTemplate(qb422016, domains)
//line templates/extra.qtpl:301
qs422016 := string(qb422016.B)
//line templates/extra.qtpl:301
qt422016.ReleaseByteBuffer(qb422016)
//line templates/extra.qtpl:301
return qs422016
//line templates/extra.qtpl:301
//line templates/extra.qtpl:303
}
//line templates/extra.qtpl:303
func StreamExtraMethodTypeDomainDecoder(qw422016 *qt422016.Writer) {
func WriteExtraUtilTemplate(qq422016 qtio422016.Writer, domains []*internal.Domain) {
//line templates/extra.qtpl:303
qw422016 := qt422016.AcquireWriter(qq422016)
//line templates/extra.qtpl:303
StreamExtraUtilTemplate(qw422016, domains)
//line templates/extra.qtpl:303
qt422016.ReleaseWriter(qw422016)
//line templates/extra.qtpl:303
}
//line templates/extra.qtpl:303
func ExtraUtilTemplate(domains []*internal.Domain) string {
//line templates/extra.qtpl:303
qb422016 := qt422016.AcquireByteBuffer()
//line templates/extra.qtpl:303
WriteExtraUtilTemplate(qb422016, domains)
//line templates/extra.qtpl:303
qs422016 := string(qb422016.B)
//line templates/extra.qtpl:303
qt422016.ReleaseByteBuffer(qb422016)
//line templates/extra.qtpl:303
return qs422016
//line templates/extra.qtpl:303
}
//line templates/extra.qtpl:305
func StreamExtraMethodTypeDomainDecoder(qw422016 *qt422016.Writer) {
//line templates/extra.qtpl:305
qw422016.N().S(`
// Domain returns the Chrome Debugging Protocol domain of the event or command.
func (t MethodType) Domain() string {
return string(t[:strings.IndexByte(string(t), '.')])
}
`)
//line templates/extra.qtpl:308
//line templates/extra.qtpl:310
}
//line templates/extra.qtpl:308
//line templates/extra.qtpl:310
func WriteExtraMethodTypeDomainDecoder(qq422016 qtio422016.Writer) {
//line templates/extra.qtpl:308
//line templates/extra.qtpl:310
qw422016 := qt422016.AcquireWriter(qq422016)
//line templates/extra.qtpl:308
//line templates/extra.qtpl:310
StreamExtraMethodTypeDomainDecoder(qw422016)
//line templates/extra.qtpl:308
//line templates/extra.qtpl:310
qt422016.ReleaseWriter(qw422016)
//line templates/extra.qtpl:308
//line templates/extra.qtpl:310
}
//line templates/extra.qtpl:308
//line templates/extra.qtpl:310
func ExtraMethodTypeDomainDecoder() string {
//line templates/extra.qtpl:308
//line templates/extra.qtpl:310
qb422016 := qt422016.AcquireByteBuffer()
//line templates/extra.qtpl:308
//line templates/extra.qtpl:310
WriteExtraMethodTypeDomainDecoder(qb422016)
//line templates/extra.qtpl:308
//line templates/extra.qtpl:310
qs422016 := string(qb422016.B)
//line templates/extra.qtpl:308
//line templates/extra.qtpl:310
qt422016.ReleaseByteBuffer(qb422016)
//line templates/extra.qtpl:308
//line templates/extra.qtpl:310
return qs422016
//line templates/extra.qtpl:308
//line templates/extra.qtpl:310
}

View File

@ -1 +1,2 @@
cookie
cookie.exe

View File

@ -8,6 +8,7 @@ import (
"fmt"
"log"
"net/http"
"time"
cdp "github.com/knq/chromedp"
cdptypes "github.com/knq/chromedp/cdp"
@ -26,7 +27,7 @@ func main() {
// setup http server
mux := http.NewServeMux()
mux.HandleFunc("/", func(res http.ResponseWriter, req *http.Request) {
buf, err := json.Marshal(req.Cookies())
buf, err := json.MarshalIndent(req.Cookies(), "", " ")
if err != nil {
http.Error(res, err.Error(), http.StatusInternalServerError)
return
@ -70,7 +71,12 @@ func main() {
func setcookies(host string, res *string) cdp.Tasks {
return cdp.Tasks{
cdp.ActionFunc(func(ctxt context.Context, h cdptypes.Handler) error {
success, err := network.SetCookie(host, "cookiename", "cookievalue").Do(ctxt, h)
expr := cdptypes.Timestamp(time.Now().Add(180 * 24 * time.Hour))
success, err := network.SetCookie(host, "cookiename", "cookievalue").
WithExpirationDate(&expr).
WithDomain("localhost").
WithHTTPOnly(true).
Do(ctxt, h)
if err != nil {
return err
}
@ -81,6 +87,18 @@ func setcookies(host string, res *string) cdp.Tasks {
}),
cdp.Navigate(host),
cdp.Text(`#result`, res, cdp.ByID, cdp.NodeVisible),
cdp.ActionFunc(func(ctxt context.Context, h cdptypes.Handler) error {
cookies, err := network.GetAllCookies().Do(ctxt, h)
if err != nil {
return err
}
for i, cookie := range cookies {
log.Printf("cookie %d: %+v", i, cookie)
}
return nil
}),
}
}

View File

@ -1 +1,2 @@
upload
upload.exe