Fixing issue with timestamps

This commit is contained in:
Kenneth Shaw 2017-07-01 14:20:18 +07:00
parent 69ade91d70
commit 2f321ca865
16 changed files with 564 additions and 142 deletions

View File

@ -4,6 +4,7 @@ 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"
@ -1124,7 +1125,15 @@ func easyjsonC5a4559bDecodeGithubComKnqChromedpCdpHeapprofiler14(in *jlexer.Lexe
case "lastSeenObjectId": case "lastSeenObjectId":
out.LastSeenObjectID = int64(in.Int64()) out.LastSeenObjectID = int64(in.Int64())
case "timestamp": case "timestamp":
(out.Timestamp).UnmarshalEasyJSON(in) if in.IsNull() {
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,13 +1156,17 @@ func easyjsonC5a4559bEncodeGithubComKnqChromedpCdpHeapprofiler14(out *jwriter.Wr
out.RawString("\"lastSeenObjectId\":") out.RawString("\"lastSeenObjectId\":")
out.Int64(int64(in.LastSeenObjectID)) out.Int64(int64(in.LastSeenObjectID))
} }
if true { if in.Timestamp != nil {
if !first { if !first {
out.RawByte(',') out.RawByte(',')
} }
first = false first = false
out.RawString("\"timestamp\":") out.RawString("\"timestamp\":")
(in.Timestamp).MarshalEasyJSON(out) if in.Timestamp == nil {
out.RawString("null")
} else {
(*in.Timestamp).MarshalEasyJSON(out)
}
} }
out.RawByte('}') out.RawByte('}')
} }

View File

@ -28,7 +28,7 @@ type EventReportHeapSnapshotProgress struct {
// lastSeenObjectId event. // lastSeenObjectId event.
type EventLastSeenObjectID struct { type EventLastSeenObjectID struct {
LastSeenObjectID int64 `json:"lastSeenObjectId,omitempty"` LastSeenObjectID int64 `json:"lastSeenObjectId,omitempty"`
Timestamp cdp.Timestamp `json:"timestamp,omitempty"` Timestamp *cdp.Timestamp `json:"timestamp,omitempty"`
} }
// EventHeapStatsUpdate if heap objects tracking has been started then // EventHeapStatsUpdate if heap objects tracking has been started then

View File

@ -4,6 +4,7 @@ package log
import ( import (
json "encoding/json" json "encoding/json"
cdp "github.com/knq/chromedp/cdp"
network "github.com/knq/chromedp/cdp/network" network "github.com/knq/chromedp/cdp/network"
runtime "github.com/knq/chromedp/cdp/runtime" runtime "github.com/knq/chromedp/cdp/runtime"
easyjson "github.com/mailru/easyjson" easyjson "github.com/mailru/easyjson"
@ -375,7 +376,15 @@ func easyjsonC5a4559bDecodeGithubComKnqChromedpCdpLog4(in *jlexer.Lexer, out *En
case "text": case "text":
out.Text = string(in.String()) out.Text = string(in.String())
case "timestamp": case "timestamp":
(out.Timestamp).UnmarshalEasyJSON(in) if in.IsNull() {
in.Skip()
out.Timestamp = nil
} else {
if out.Timestamp == nil {
out.Timestamp = new(cdp.Timestamp)
}
(*out.Timestamp).UnmarshalEasyJSON(in)
}
case "url": case "url":
out.URL = string(in.String()) out.URL = string(in.String())
case "lineNumber": case "lineNumber":
@ -432,13 +441,17 @@ func easyjsonC5a4559bEncodeGithubComKnqChromedpCdpLog4(out *jwriter.Writer, in E
out.RawString("\"text\":") out.RawString("\"text\":")
out.String(string(in.Text)) out.String(string(in.Text))
} }
if true { if in.Timestamp != nil {
if !first { if !first {
out.RawByte(',') out.RawByte(',')
} }
first = false first = false
out.RawString("\"timestamp\":") out.RawString("\"timestamp\":")
(in.Timestamp).MarshalEasyJSON(out) if in.Timestamp == nil {
out.RawString("null")
} else {
(*in.Timestamp).MarshalEasyJSON(out)
}
} }
if in.URL != "" { if in.URL != "" {
if !first { if !first {

View File

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

View File

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

View File

@ -12,7 +12,7 @@ import (
type EventResourceChangedPriority struct { type EventResourceChangedPriority struct {
RequestID RequestID `json:"requestId,omitempty"` // Request identifier. RequestID RequestID `json:"requestId,omitempty"` // Request identifier.
NewPriority ResourcePriority `json:"newPriority,omitempty"` // New priority 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. // 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. LoaderID cdp.LoaderID `json:"loaderId,omitempty"` // Loader identifier.
DocumentURL string `json:"documentURL,omitempty"` // URL of the document this request is loaded for. DocumentURL string `json:"documentURL,omitempty"` // URL of the document this request is loaded for.
Request *Request `json:"request,omitempty"` // Request data. Request *Request `json:"request,omitempty"` // Request data.
Timestamp cdp.Timestamp `json:"timestamp,omitempty"` // Timestamp. Timestamp *cdp.Timestamp `json:"timestamp,omitempty"` // Timestamp.
WallTime cdp.Timestamp `json:"wallTime,omitempty"` // UTC Timestamp. WallTime *cdp.Timestamp `json:"wallTime,omitempty"` // UTC Timestamp.
Initiator *Initiator `json:"initiator,omitempty"` // Request initiator. Initiator *Initiator `json:"initiator,omitempty"` // 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.
@ -39,7 +39,7 @@ type EventResponseReceived struct {
RequestID RequestID `json:"requestId,omitempty"` // Request identifier. RequestID RequestID `json:"requestId,omitempty"` // Request identifier.
FrameID cdp.FrameID `json:"frameId,omitempty"` // Frame identifier. FrameID cdp.FrameID `json:"frameId,omitempty"` // Frame identifier.
LoaderID cdp.LoaderID `json:"loaderId,omitempty"` // Loader 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. Type page.ResourceType `json:"type,omitempty"` // Resource type.
Response *Response `json:"response,omitempty"` // Response data. Response *Response `json:"response,omitempty"` // Response data.
} }
@ -47,7 +47,7 @@ type EventResponseReceived struct {
// 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,omitempty"` // Request identifier. RequestID RequestID `json:"requestId,omitempty"` // Request identifier.
Timestamp cdp.Timestamp `json:"timestamp,omitempty"` // Timestamp. Timestamp *cdp.Timestamp `json:"timestamp,omitempty"` // Timestamp.
DataLength int64 `json:"dataLength,omitempty"` // Data chunk length. DataLength int64 `json:"dataLength,omitempty"` // Data chunk length.
EncodedDataLength int64 `json:"encodedDataLength,omitempty"` // Actual bytes received (might be less than dataLength for compressed encodings). EncodedDataLength int64 `json:"encodedDataLength,omitempty"` // Actual bytes received (might be less than dataLength for compressed encodings).
} }
@ -55,14 +55,14 @@ type EventDataReceived struct {
// 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,omitempty"` // Request identifier. RequestID RequestID `json:"requestId,omitempty"` // Request identifier.
Timestamp cdp.Timestamp `json:"timestamp,omitempty"` // Timestamp. Timestamp *cdp.Timestamp `json:"timestamp,omitempty"` // Timestamp.
EncodedDataLength float64 `json:"encodedDataLength,omitempty"` // Total number of bytes received for this request. EncodedDataLength float64 `json:"encodedDataLength,omitempty"` // 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,omitempty"` // Request identifier. 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. Type page.ResourceType `json:"type,omitempty"` // Resource type.
ErrorText string `json:"errorText,omitempty"` // User friendly error message. ErrorText string `json:"errorText,omitempty"` // User friendly error message.
Canceled bool `json:"canceled,omitempty"` // True if loading was canceled. Canceled bool `json:"canceled,omitempty"` // True if loading was canceled.
@ -73,8 +73,8 @@ type EventLoadingFailed struct {
// initiate handshake. // initiate handshake.
type EventWebSocketWillSendHandshakeRequest struct { type EventWebSocketWillSendHandshakeRequest struct {
RequestID RequestID `json:"requestId,omitempty"` // Request identifier. RequestID RequestID `json:"requestId,omitempty"` // Request identifier.
Timestamp cdp.Timestamp `json:"timestamp,omitempty"` // Timestamp. Timestamp *cdp.Timestamp `json:"timestamp,omitempty"` // Timestamp.
WallTime cdp.Timestamp `json:"wallTime,omitempty"` // UTC Timestamp. WallTime *cdp.Timestamp `json:"wallTime,omitempty"` // UTC Timestamp.
Request *WebSocketRequest `json:"request,omitempty"` // WebSocket request data. Request *WebSocketRequest `json:"request,omitempty"` // WebSocket request data.
} }
@ -82,7 +82,7 @@ type EventWebSocketWillSendHandshakeRequest struct {
// response becomes available. // response becomes available.
type EventWebSocketHandshakeResponseReceived struct { type EventWebSocketHandshakeResponseReceived struct {
RequestID RequestID `json:"requestId,omitempty"` // Request identifier. 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. Response *WebSocketResponse `json:"response,omitempty"` // WebSocket response data.
} }
@ -96,27 +96,27 @@ 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,omitempty"` // Request identifier. RequestID RequestID `json:"requestId,omitempty"` // Request identifier.
Timestamp cdp.Timestamp `json:"timestamp,omitempty"` // Timestamp. Timestamp *cdp.Timestamp `json:"timestamp,omitempty"` // 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,omitempty"` // Request identifier. 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. Response *WebSocketFrame `json:"response,omitempty"` // 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,omitempty"` // Request identifier. RequestID RequestID `json:"requestId,omitempty"` // Request identifier.
Timestamp cdp.Timestamp `json:"timestamp,omitempty"` // Timestamp. Timestamp *cdp.Timestamp `json:"timestamp,omitempty"` // Timestamp.
ErrorMessage string `json:"errorMessage,omitempty"` // WebSocket frame error message. ErrorMessage string `json:"errorMessage,omitempty"` // 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,omitempty"` // Request identifier. 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. Response *WebSocketFrame `json:"response,omitempty"` // WebSocket response data.
} }
@ -124,7 +124,7 @@ type EventWebSocketFrameSent struct {
// received. // received.
type EventEventSourceMessageReceived struct { type EventEventSourceMessageReceived struct {
RequestID RequestID `json:"requestId,omitempty"` // Request identifier. RequestID RequestID `json:"requestId,omitempty"` // Request identifier.
Timestamp cdp.Timestamp `json:"timestamp,omitempty"` // Timestamp. Timestamp *cdp.Timestamp `json:"timestamp,omitempty"` // Timestamp.
EventName string `json:"eventName,omitempty"` // Message type. EventName string `json:"eventName,omitempty"` // Message type.
EventID string `json:"eventId,omitempty"` // Message identifier. EventID string `json:"eventId,omitempty"` // Message identifier.
Data string `json:"data,omitempty"` // Message content. Data string `json:"data,omitempty"` // Message content.

View File

@ -407,7 +407,7 @@ type SetCookieParams struct {
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.Timestamp `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.Timestamp) *SetCookieParams {
p.ExpirationDate = expirationDate p.ExpirationDate = expirationDate
return &p return &p
} }

View File

@ -301,7 +301,7 @@ type SignedCertificateTimestamp struct {
Origin string `json:"origin,omitempty"` // Origin. Origin string `json:"origin,omitempty"` // Origin.
LogDescription string `json:"logDescription,omitempty"` // Log name / description. LogDescription string `json:"logDescription,omitempty"` // Log name / description.
LogID string `json:"logId,omitempty"` // Log ID. LogID string `json:"logId,omitempty"` // Log ID.
Timestamp cdp.Timestamp `json:"timestamp,omitempty"` // Issuance date. Timestamp *cdp.Timestamp `json:"timestamp,omitempty"` // Issuance date.
HashAlgorithm string `json:"hashAlgorithm,omitempty"` // Hash algorithm. HashAlgorithm string `json:"hashAlgorithm,omitempty"` // Hash algorithm.
SignatureAlgorithm string `json:"signatureAlgorithm,omitempty"` // Signature algorithm. SignatureAlgorithm string `json:"signatureAlgorithm,omitempty"` // Signature algorithm.
SignatureData string `json:"signatureData,omitempty"` // Signature data. SignatureData string `json:"signatureData,omitempty"` // Signature data.
@ -318,8 +318,8 @@ type SecurityDetails struct {
SubjectName string `json:"subjectName,omitempty"` // Certificate subject name. SubjectName string `json:"subjectName,omitempty"` // Certificate subject name.
SanList []string `json:"sanList,omitempty"` // Subject Alternative Name (SAN) DNS names and IP addresses. SanList []string `json:"sanList,omitempty"` // Subject Alternative Name (SAN) DNS names and IP addresses.
Issuer string `json:"issuer,omitempty"` // Name of the issuing CA. Issuer string `json:"issuer,omitempty"` // Name of the issuing CA.
ValidFrom cdp.Timestamp `json:"validFrom,omitempty"` // Certificate valid from date. ValidFrom *cdp.Timestamp `json:"validFrom,omitempty"` // Certificate valid from date.
ValidTo cdp.Timestamp `json:"validTo,omitempty"` // Certificate valid to (expiration) date ValidTo *cdp.Timestamp `json:"validTo,omitempty"` // Certificate valid to (expiration) date
SignedCertificateTimestampList []*SignedCertificateTimestamp `json:"signedCertificateTimestampList,omitempty"` // List of signed certificate timestamps (SCTs). 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": case "scrollOffsetY":
out.ScrollOffsetY = float64(in.Float64()) out.ScrollOffsetY = float64(in.Float64())
case "timestamp": case "timestamp":
(out.Timestamp).UnmarshalEasyJSON(in) if in.IsNull() {
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()
} }
@ -897,13 +905,17 @@ func easyjsonC5a4559bEncodeGithubComKnqChromedpCdpPage9(out *jwriter.Writer, in
out.RawString("\"scrollOffsetY\":") out.RawString("\"scrollOffsetY\":")
out.Float64(float64(in.ScrollOffsetY)) out.Float64(float64(in.ScrollOffsetY))
} }
if true { if in.Timestamp != nil {
if !first { if !first {
out.RawByte(',') out.RawByte(',')
} }
first = false first = false
out.RawString("\"timestamp\":") out.RawString("\"timestamp\":")
(in.Timestamp).MarshalEasyJSON(out) if in.Timestamp == nil {
out.RawString("null")
} else {
(*in.Timestamp).MarshalEasyJSON(out)
}
} }
out.RawByte('}') out.RawByte('}')
} }
@ -3091,7 +3103,15 @@ func easyjsonC5a4559bDecodeGithubComKnqChromedpCdpPage34(in *jlexer.Lexer, out *
case "mimeType": case "mimeType":
out.MimeType = string(in.String()) out.MimeType = string(in.String())
case "lastModified": case "lastModified":
(out.LastModified).UnmarshalEasyJSON(in) if in.IsNull() {
in.Skip()
out.LastModified = nil
} else {
if out.LastModified == nil {
out.LastModified = new(cdp.Timestamp)
}
(*out.LastModified).UnmarshalEasyJSON(in)
}
case "contentSize": case "contentSize":
out.ContentSize = float64(in.Float64()) out.ContentSize = float64(in.Float64())
case "failed": case "failed":
@ -3136,13 +3156,17 @@ func easyjsonC5a4559bEncodeGithubComKnqChromedpCdpPage34(out *jwriter.Writer, in
out.RawString("\"mimeType\":") out.RawString("\"mimeType\":")
out.String(string(in.MimeType)) out.String(string(in.MimeType))
} }
if true { if in.LastModified != nil {
if !first { if !first {
out.RawByte(',') out.RawByte(',')
} }
first = false first = false
out.RawString("\"lastModified\":") out.RawString("\"lastModified\":")
(in.LastModified).MarshalEasyJSON(out) if in.LastModified == nil {
out.RawString("null")
} else {
(*in.LastModified).MarshalEasyJSON(out)
}
} }
if in.ContentSize != 0 { if in.ContentSize != 0 {
if !first { if !first {
@ -3483,7 +3507,15 @@ func easyjsonC5a4559bDecodeGithubComKnqChromedpCdpPage38(in *jlexer.Lexer, out *
} }
switch key { switch key {
case "timestamp": case "timestamp":
(out.Timestamp).UnmarshalEasyJSON(in) if in.IsNull() {
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()
} }
@ -3498,13 +3530,17 @@ func easyjsonC5a4559bEncodeGithubComKnqChromedpCdpPage38(out *jwriter.Writer, in
out.RawByte('{') out.RawByte('{')
first := true first := true
_ = first _ = first
if true { if in.Timestamp != nil {
if !first { if !first {
out.RawByte(',') out.RawByte(',')
} }
first = false first = false
out.RawString("\"timestamp\":") out.RawString("\"timestamp\":")
(in.Timestamp).MarshalEasyJSON(out) if in.Timestamp == nil {
out.RawString("null")
} else {
(*in.Timestamp).MarshalEasyJSON(out)
}
} }
out.RawByte('}') out.RawByte('}')
} }
@ -4414,7 +4450,15 @@ func easyjsonC5a4559bDecodeGithubComKnqChromedpCdpPage51(in *jlexer.Lexer, out *
} }
switch key { switch key {
case "timestamp": case "timestamp":
(out.Timestamp).UnmarshalEasyJSON(in) if in.IsNull() {
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()
} }
@ -4429,13 +4473,17 @@ func easyjsonC5a4559bEncodeGithubComKnqChromedpCdpPage51(out *jwriter.Writer, in
out.RawByte('{') out.RawByte('{')
first := true first := true
_ = first _ = first
if true { if in.Timestamp != nil {
if !first { if !first {
out.RawByte(',') out.RawByte(',')
} }
first = false first = false
out.RawString("\"timestamp\":") out.RawString("\"timestamp\":")
(in.Timestamp).MarshalEasyJSON(out) if in.Timestamp == nil {
out.RawString("null")
} else {
(*in.Timestamp).MarshalEasyJSON(out)
}
} }
out.RawByte('}') out.RawByte('}')
} }

View File

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

View File

@ -91,7 +91,7 @@ type FrameResource struct {
URL string `json:"url,omitempty"` // Resource URL. URL string `json:"url,omitempty"` // Resource URL.
Type ResourceType `json:"type,omitempty"` // Type of this resource. Type ResourceType `json:"type,omitempty"` // Type of this resource.
MimeType string `json:"mimeType,omitempty"` // Resource mimeType as determined by the browser. 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. LastModified *cdp.Timestamp `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.
@ -202,7 +202,7 @@ type ScreencastFrameMetadata struct {
DeviceHeight float64 `json:"deviceHeight,omitempty"` // Device screen height in DIP. DeviceHeight float64 `json:"deviceHeight,omitempty"` // Device screen height in DIP.
ScrollOffsetX float64 `json:"scrollOffsetX,omitempty"` // Position of horizontal scroll in CSS pixels. ScrollOffsetX float64 `json:"scrollOffsetX,omitempty"` // Position of horizontal scroll in CSS pixels.
ScrollOffsetY float64 `json:"scrollOffsetY,omitempty"` // Position of vertical scroll in CSS pixels. ScrollOffsetY float64 `json:"scrollOffsetY,omitempty"` // Position of vertical scroll in CSS pixels.
Timestamp cdp.Timestamp `json:"timestamp,omitempty"` // Frame swap timestamp. Timestamp *cdp.Timestamp `json:"timestamp,omitempty"` // Frame swap timestamp.
} }
// DialogType javascript dialog type. // DialogType javascript dialog type.

View File

@ -4,6 +4,7 @@ package runtime
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"
@ -2361,7 +2362,15 @@ func easyjsonC5a4559bDecodeGithubComKnqChromedpCdpRuntime20(in *jlexer.Lexer, ou
} }
switch key { switch key {
case "timestamp": case "timestamp":
(out.Timestamp).UnmarshalEasyJSON(in) if in.IsNull() {
in.Skip()
out.Timestamp = nil
} else {
if out.Timestamp == nil {
out.Timestamp = new(cdp.Timestamp)
}
(*out.Timestamp).UnmarshalEasyJSON(in)
}
case "exceptionDetails": case "exceptionDetails":
if in.IsNull() { if in.IsNull() {
in.Skip() in.Skip()
@ -2386,13 +2395,17 @@ func easyjsonC5a4559bEncodeGithubComKnqChromedpCdpRuntime20(out *jwriter.Writer,
out.RawByte('{') out.RawByte('{')
first := true first := true
_ = first _ = first
if true { if in.Timestamp != nil {
if !first { if !first {
out.RawByte(',') out.RawByte(',')
} }
first = false first = false
out.RawString("\"timestamp\":") out.RawString("\"timestamp\":")
(in.Timestamp).MarshalEasyJSON(out) if in.Timestamp == nil {
out.RawString("null")
} else {
(*in.Timestamp).MarshalEasyJSON(out)
}
} }
if in.ExceptionDetails != nil { if in.ExceptionDetails != nil {
if !first { if !first {
@ -2566,7 +2579,15 @@ func easyjsonC5a4559bDecodeGithubComKnqChromedpCdpRuntime22(in *jlexer.Lexer, ou
case "executionContextId": case "executionContextId":
out.ExecutionContextID = ExecutionContextID(in.Int64()) out.ExecutionContextID = ExecutionContextID(in.Int64())
case "timestamp": case "timestamp":
(out.Timestamp).UnmarshalEasyJSON(in) if in.IsNull() {
in.Skip()
out.Timestamp = nil
} else {
if out.Timestamp == nil {
out.Timestamp = new(cdp.Timestamp)
}
(*out.Timestamp).UnmarshalEasyJSON(in)
}
case "stackTrace": case "stackTrace":
if in.IsNull() { if in.IsNull() {
in.Skip() in.Skip()
@ -2632,13 +2653,17 @@ func easyjsonC5a4559bEncodeGithubComKnqChromedpCdpRuntime22(out *jwriter.Writer,
out.RawString("\"executionContextId\":") out.RawString("\"executionContextId\":")
out.Int64(int64(in.ExecutionContextID)) out.Int64(int64(in.ExecutionContextID))
} }
if true { if in.Timestamp != nil {
if !first { if !first {
out.RawByte(',') out.RawByte(',')
} }
first = false first = false
out.RawString("\"timestamp\":") out.RawString("\"timestamp\":")
(in.Timestamp).MarshalEasyJSON(out) if in.Timestamp == nil {
out.RawString("null")
} else {
(*in.Timestamp).MarshalEasyJSON(out)
}
} }
if in.StackTrace != nil { if in.StackTrace != nil {
if !first { if !first {

View File

@ -23,7 +23,7 @@ type EventExecutionContextsCleared struct{}
// EventExceptionThrown issued when exception was thrown and unhandled. // EventExceptionThrown issued when exception was thrown and unhandled.
type EventExceptionThrown struct { type EventExceptionThrown struct {
Timestamp cdp.Timestamp `json:"timestamp,omitempty"` // Timestamp of the exception. Timestamp *cdp.Timestamp `json:"timestamp,omitempty"` // Timestamp of the exception.
ExceptionDetails *ExceptionDetails `json:"exceptionDetails,omitempty"` ExceptionDetails *ExceptionDetails `json:"exceptionDetails,omitempty"`
} }
@ -38,7 +38,7 @@ type EventConsoleAPICalled struct {
Type APIType `json:"type,omitempty"` // Type of the call. Type APIType `json:"type,omitempty"` // Type of the call.
Args []*RemoteObject `json:"args,omitempty"` // Call arguments. Args []*RemoteObject `json:"args,omitempty"` // Call arguments.
ExecutionContextID ExecutionContextID `json:"executionContextId,omitempty"` // Identifier of the context where the call was made. ExecutionContextID ExecutionContextID `json:"executionContextId,omitempty"` // Identifier of the context where the call was made.
Timestamp cdp.Timestamp `json:"timestamp,omitempty"` // Call timestamp. Timestamp *cdp.Timestamp `json:"timestamp,omitempty"` // Call timestamp.
StackTrace *StackTrace `json:"stackTrace,omitempty"` // Stack trace captured when the call was made. 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. 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

@ -177,7 +177,7 @@ func (t *Type) ResolveType(d *Domain, domains []*Domain) (DomainType, *Type, str
// add ptr if object // add ptr if object
ptr := "" ptr := ""
switch typ.Type { switch typ.Type {
case TypeObject: case TypeObject, TypeTimestamp:
ptr = "*" ptr = "*"
} }

1
examples/cookie/.gitignore vendored Normal file
View File

@ -0,0 +1 @@
cookie

94
examples/cookie/main.go Normal file
View File

@ -0,0 +1,94 @@
package main
import (
"context"
"encoding/json"
"errors"
"flag"
"fmt"
"log"
"net/http"
cdp "github.com/knq/chromedp"
cdptypes "github.com/knq/chromedp/cdp"
"github.com/knq/chromedp/cdp/network"
)
var (
flagPort = flag.Int("port", 8544, "port")
)
func main() {
var err error
flag.Parse()
// setup http server
mux := http.NewServeMux()
mux.HandleFunc("/", func(res http.ResponseWriter, req *http.Request) {
buf, err := json.Marshal(req.Cookies())
if err != nil {
http.Error(res, err.Error(), http.StatusInternalServerError)
return
}
fmt.Fprintf(res, indexHTML, string(buf))
})
go http.ListenAndServe(fmt.Sprintf(":%d", *flagPort), mux)
// create context
ctxt, cancel := context.WithCancel(context.Background())
defer cancel()
// create chrome instance
c, err := cdp.New(ctxt, cdp.WithLog(log.Printf))
if err != nil {
log.Fatal(err)
}
// run task list
var res string
err = c.Run(ctxt, setcookies(fmt.Sprintf("http://localhost:%d", *flagPort), &res))
if err != nil {
log.Fatal(err)
}
// shutdown chrome
err = c.Shutdown(ctxt)
if err != nil {
log.Fatal(err)
}
// wait for chrome to finish
err = c.Wait()
if err != nil {
log.Fatal(err)
}
log.Printf("passed cookies: %s", res)
}
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)
if err != nil {
return err
}
if !success {
return errors.New("could not set cookie")
}
return nil
}),
cdp.Navigate(host),
cdp.Text(`#result`, res, cdp.ByID, cdp.NodeVisible),
}
}
const (
indexHTML = `<!doctype html>
<html>
<body>
<div id="result">%s</div>
</body>
</html>`
)