Skip to content

Commit

Permalink
Updated to latest gcd / protocol.json file for 74.0.3729.131. Added …
Browse files Browse the repository at this point in the history
…Audits and WebAudio APIs.
  • Loading branch information
wirepair committed May 4, 2019
1 parent 2f7807e commit 2f60966
Show file tree
Hide file tree
Showing 16 changed files with 249 additions and 74 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# Changelog (2019)
- May 4th: Updated to latest gcd / protocol.json file for 74.0.3729.131. Added Audits and WebAudio APIs.
- March 13th: Updated to latest gcd / protocol.json file for 73.0.3683.75. Added ability custom start the process

# Changelog (2018)
Expand Down
15 changes: 9 additions & 6 deletions chrome_target.go
Original file line number Diff line number Diff line change
Expand Up @@ -70,20 +70,22 @@ type ChromeTarget struct {
Accessibility *gcdapi.Accessibility
Animation *gcdapi.Animation
ApplicationCache *gcdapi.ApplicationCache // application cache API
Browser *gcdapi.Browser
Audits *gcdapi.Audits
BackgroundService *gcdapi.BackgroundService
Browser *gcdapi.Browser
CacheStorage *gcdapi.CacheStorage
Cast *gcdapi.Cast
Console *gcdapi.Console // console API
CSS *gcdapi.CSS // CSS API
Database *gcdapi.Database // Database API
Debugger *gcdapi.Debugger // JS Debugger API
DeviceOrientation *gcdapi.DeviceOrientation // Device Orientation API
DOMDebugger *gcdapi.DOMDebugger // DOM Debugger API
DOM *gcdapi.DOM // DOM API
DOMDebugger *gcdapi.DOMDebugger // DOM Debugger API
DOMSnapshot *gcdapi.DOMSnapshot
DOMStorage *gcdapi.DOMStorage // DOM Storage API
Emulation *gcdapi.Emulation
Fetch *gcdapi.Fetch
HeadlessExperimental *gcdapi.HeadlessExperimental
HeapProfiler *gcdapi.HeapProfiler // HeapProfiler API
IndexedDB *gcdapi.IndexedDB // IndexedDB API
Expand All @@ -96,19 +98,19 @@ type ChromeTarget struct {
Network *gcdapi.Network
Overlay *gcdapi.Overlay
Page *gcdapi.Page
Profiler *gcdapi.Profiler
Performance *gcdapi.Performance // if stable channel you'll need to uncomment
Profiler *gcdapi.Profiler
Runtime *gcdapi.Runtime
Schema *gcdapi.Schema
Security *gcdapi.Security
ServiceWorker *gcdapi.ServiceWorker
Storage *gcdapi.Storage
SystemInfo *gcdapi.SystemInfo
TargetApi *gcdapi.Target // buh name collision
Tracing *gcdapi.Tracing
Tethering *gcdapi.Tethering
Testing *gcdapi.Testing
Fetch *gcdapi.Fetch
Tracing *gcdapi.Tracing
WebAudio *gcdapi.WebAudio

Target *TargetInfo // The target information see, TargetInfo
sendCh chan *gcdmessage.Message // The channel used for API components to send back to use
Expand Down Expand Up @@ -143,6 +145,7 @@ func (c *ChromeTarget) Init() {
c.Accessibility = gcdapi.NewAccessibility(c)
c.Animation = gcdapi.NewAnimation(c)
c.ApplicationCache = gcdapi.NewApplicationCache(c)
c.Audits = gcdapi.NewAudits(c)
c.Browser = gcdapi.NewBrowser(c)
c.BackgroundService = gcdapi.NewBackgroundService(c)
c.CacheStorage = gcdapi.NewCacheStorage(c)
Expand Down Expand Up @@ -178,10 +181,10 @@ func (c *ChromeTarget) Init() {
c.Tracing = gcdapi.NewTracing(c)
c.Tethering = gcdapi.NewTethering(c)
c.HeadlessExperimental = gcdapi.NewHeadlessExperimental(c)
// if stable channel you'll need to comment this out
c.Performance = gcdapi.NewPerformance(c)
c.Testing = gcdapi.NewTesting(c)
c.Fetch = gcdapi.NewFetch(c)
c.WebAudio = gcdapi.NewWebAudio(c)
}

// clean up this target
Expand Down
4 changes: 2 additions & 2 deletions gcdapi/browser.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ func NewBrowser(target gcdmessage.ChromeTargeter) *Browser {
type BrowserGrantPermissionsParams struct {
//
Origin string `json:"origin"`
// enum values: accessibilityEvents, audioCapture, backgroundSync, backgroundFetch, clipboardRead, clipboardWrite, durableStorage, flash, geolocation, midi, midiSysex, notifications, paymentHandler, protectedMediaIdentifier, sensors, videoCapture, idleDetection
// enum values: accessibilityEvents, audioCapture, backgroundSync, backgroundFetch, clipboardRead, clipboardWrite, durableStorage, flash, geolocation, midi, midiSysex, notifications, paymentHandler, periodicBackgroundSync, protectedMediaIdentifier, sensors, videoCapture, idleDetection
Permissions []string `json:"permissions"`
// BrowserContext to override permissions. When omitted, default browser context is used.
BrowserContextId string `json:"browserContextId,omitempty"`
Expand All @@ -58,7 +58,7 @@ func (c *Browser) GrantPermissionsWithParams(v *BrowserGrantPermissionsParams) (

// GrantPermissions - Grant specific permissions to the given origin and reject all others.
// origin -
// permissions - enum values: accessibilityEvents, audioCapture, backgroundSync, backgroundFetch, clipboardRead, clipboardWrite, durableStorage, flash, geolocation, midi, midiSysex, notifications, paymentHandler, protectedMediaIdentifier, sensors, videoCapture, idleDetection
// permissions - enum values: accessibilityEvents, audioCapture, backgroundSync, backgroundFetch, clipboardRead, clipboardWrite, durableStorage, flash, geolocation, midi, midiSysex, notifications, paymentHandler, periodicBackgroundSync, protectedMediaIdentifier, sensors, videoCapture, idleDetection
// browserContextId - BrowserContext to override permissions. When omitted, default browser context is used.
func (c *Browser) GrantPermissions(origin string, permissions []string, browserContextId string) (*gcdmessage.ChromeResponse, error) {
var v BrowserGrantPermissionsParams
Expand Down
20 changes: 10 additions & 10 deletions gcdapi/cachestorage.go
Original file line number Diff line number Diff line change
Expand Up @@ -200,45 +200,45 @@ type CacheStorageRequestEntriesParams struct {
}

// RequestEntriesWithParams - Requests data from cache.
// Returns - cacheDataEntries - Array of object store data entries. hasMore - If true, there are more entries to fetch in the given range.
func (c *CacheStorage) RequestEntriesWithParams(v *CacheStorageRequestEntriesParams) ([]*CacheStorageDataEntry, bool, error) {
// Returns - cacheDataEntries - Array of object store data entries. returnCount - Count of returned entries from this storage. If pathFilter is empty, it is the count of all entries from this storage.
func (c *CacheStorage) RequestEntriesWithParams(v *CacheStorageRequestEntriesParams) ([]*CacheStorageDataEntry, float64, error) {
resp, err := gcdmessage.SendCustomReturn(c.target, c.target.GetSendCh(), &gcdmessage.ParamRequest{Id: c.target.GetId(), Method: "CacheStorage.requestEntries", Params: v})
if err != nil {
return nil, false, err
return nil, 0, err
}

var chromeData struct {
Result struct {
CacheDataEntries []*CacheStorageDataEntry
HasMore bool
ReturnCount float64
}
}

if resp == nil {
return nil, false, &gcdmessage.ChromeEmptyResponseErr{}
return nil, 0, &gcdmessage.ChromeEmptyResponseErr{}
}

// test if error first
cerr := &gcdmessage.ChromeErrorResponse{}
json.Unmarshal(resp.Data, cerr)
if cerr != nil && cerr.Error != nil {
return nil, false, &gcdmessage.ChromeRequestErr{Resp: cerr}
return nil, 0, &gcdmessage.ChromeRequestErr{Resp: cerr}
}

if err := json.Unmarshal(resp.Data, &chromeData); err != nil {
return nil, false, err
return nil, 0, err
}

return chromeData.Result.CacheDataEntries, chromeData.Result.HasMore, nil
return chromeData.Result.CacheDataEntries, chromeData.Result.ReturnCount, nil
}

// RequestEntries - Requests data from cache.
// cacheId - ID of cache to get entries from.
// skipCount - Number of records to skip.
// pageSize - Number of records to fetch.
// pathFilter - If present, only return the entries containing this substring in the path
// Returns - cacheDataEntries - Array of object store data entries. hasMore - If true, there are more entries to fetch in the given range.
func (c *CacheStorage) RequestEntries(cacheId string, skipCount int, pageSize int, pathFilter string) ([]*CacheStorageDataEntry, bool, error) {
// Returns - cacheDataEntries - Array of object store data entries. returnCount - Count of returned entries from this storage. If pathFilter is empty, it is the count of all entries from this storage.
func (c *CacheStorage) RequestEntries(cacheId string, skipCount int, pageSize int, pathFilter string) ([]*CacheStorageDataEntry, float64, error) {
var v CacheStorageRequestEntriesParams
v.CacheId = cacheId
v.SkipCount = skipCount
Expand Down
20 changes: 17 additions & 3 deletions gcdapi/debugger.go
Original file line number Diff line number Diff line change
Expand Up @@ -159,10 +159,15 @@ func (c *Debugger) Disable() (*gcdmessage.ChromeResponse, error) {
return gcdmessage.SendDefaultRequest(c.target, c.target.GetSendCh(), &gcdmessage.ParamRequest{Id: c.target.GetId(), Method: "Debugger.disable"})
}

// Enable - Enables debugger for the given page. Clients should not assume that the debugging has been enabled until the result for this command is received.
type DebuggerEnableParams struct {
// The maximum size in bytes of collected scripts (not referenced by other heap objects) the debugger can hold. Puts no limit if paramter is omitted.
MaxScriptsCacheSize float64 `json:"maxScriptsCacheSize,omitempty"`
}

// EnableWithParams - Enables debugger for the given page. Clients should not assume that the debugging has been enabled until the result for this command is received.
// Returns - debuggerId - Unique identifier of the debugger.
func (c *Debugger) Enable() (string, error) {
resp, err := gcdmessage.SendCustomReturn(c.target, c.target.GetSendCh(), &gcdmessage.ParamRequest{Id: c.target.GetId(), Method: "Debugger.enable"})
func (c *Debugger) EnableWithParams(v *DebuggerEnableParams) (string, error) {
resp, err := gcdmessage.SendCustomReturn(c.target, c.target.GetSendCh(), &gcdmessage.ParamRequest{Id: c.target.GetId(), Method: "Debugger.enable", Params: v})
if err != nil {
return "", err
}
Expand Down Expand Up @@ -191,6 +196,15 @@ func (c *Debugger) Enable() (string, error) {
return chromeData.Result.DebuggerId, nil
}

// Enable - Enables debugger for the given page. Clients should not assume that the debugging has been enabled until the result for this command is received.
// maxScriptsCacheSize - The maximum size in bytes of collected scripts (not referenced by other heap objects) the debugger can hold. Puts no limit if paramter is omitted.
// Returns - debuggerId - Unique identifier of the debugger.
func (c *Debugger) Enable(maxScriptsCacheSize float64) (string, error) {
var v DebuggerEnableParams
v.MaxScriptsCacheSize = maxScriptsCacheSize
return c.EnableWithParams(&v)
}

type DebuggerEvaluateOnCallFrameParams struct {
// Call frame identifier to evaluate on.
CallFrameId string `json:"callFrameId"`
Expand Down
1 change: 1 addition & 0 deletions gcdapi/fetch.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ type FetchRequestPausedEvent struct {
ResponseErrorReason string `json:"responseErrorReason,omitempty"` // Response error if intercepted at response stage. enum values: Failed, Aborted, TimedOut, AccessDenied, ConnectionClosed, ConnectionReset, ConnectionRefused, ConnectionAborted, ConnectionFailed, NameNotResolved, InternetDisconnected, AddressUnreachable, BlockedByClient, BlockedByResponse
ResponseStatusCode int `json:"responseStatusCode,omitempty"` // Response code if intercepted at response stage.
ResponseHeaders []*FetchHeaderEntry `json:"responseHeaders,omitempty"` // Response headers if intercepted at the response stage.
NetworkId string `json:"networkId,omitempty"` // If the intercepted request had a corresponding Network.requestWillBeSent event fired for it, then this networkId will be the same as the requestId present in the requestWillBeSent event.
} `json:"Params,omitempty"`
}

Expand Down
33 changes: 17 additions & 16 deletions gcdapi/indexeddb.go
Original file line number Diff line number Diff line change
Expand Up @@ -231,7 +231,7 @@ func (c *IndexedDB) RequestData(securityOrigin string, databaseName string, obje
return c.RequestDataWithParams(&v)
}

type IndexedDBGetKeyGeneratorCurrentNumberParams struct {
type IndexedDBGetMetadataParams struct {
// Security origin.
SecurityOrigin string `json:"securityOrigin"`
// Database name.
Expand All @@ -240,49 +240,50 @@ type IndexedDBGetKeyGeneratorCurrentNumberParams struct {
ObjectStoreName string `json:"objectStoreName"`
}

// GetKeyGeneratorCurrentNumberWithParams - Gets the auto increment number of an object store. Only meaningful when objectStore.autoIncrement is true.
// Returns - currentNumber - the current value of key generator, to become the next inserted key into the object store.
func (c *IndexedDB) GetKeyGeneratorCurrentNumberWithParams(v *IndexedDBGetKeyGeneratorCurrentNumberParams) (float64, error) {
resp, err := gcdmessage.SendCustomReturn(c.target, c.target.GetSendCh(), &gcdmessage.ParamRequest{Id: c.target.GetId(), Method: "IndexedDB.getKeyGeneratorCurrentNumber", Params: v})
// GetMetadataWithParams - Gets metadata of an object store
// Returns - entriesCount - the entries count keyGeneratorValue - the current value of key generator, to become the next inserted key into the object store. Valid if objectStore.autoIncrement is true.
func (c *IndexedDB) GetMetadataWithParams(v *IndexedDBGetMetadataParams) (float64, float64, error) {
resp, err := gcdmessage.SendCustomReturn(c.target, c.target.GetSendCh(), &gcdmessage.ParamRequest{Id: c.target.GetId(), Method: "IndexedDB.getMetadata", Params: v})
if err != nil {
return 0, err
return 0, 0, err
}

var chromeData struct {
Result struct {
CurrentNumber float64
EntriesCount float64
KeyGeneratorValue float64
}
}

if resp == nil {
return 0, &gcdmessage.ChromeEmptyResponseErr{}
return 0, 0, &gcdmessage.ChromeEmptyResponseErr{}
}

// test if error first
cerr := &gcdmessage.ChromeErrorResponse{}
json.Unmarshal(resp.Data, cerr)
if cerr != nil && cerr.Error != nil {
return 0, &gcdmessage.ChromeRequestErr{Resp: cerr}
return 0, 0, &gcdmessage.ChromeRequestErr{Resp: cerr}
}

if err := json.Unmarshal(resp.Data, &chromeData); err != nil {
return 0, err
return 0, 0, err
}

return chromeData.Result.CurrentNumber, nil
return chromeData.Result.EntriesCount, chromeData.Result.KeyGeneratorValue, nil
}

// GetKeyGeneratorCurrentNumber - Gets the auto increment number of an object store. Only meaningful when objectStore.autoIncrement is true.
// GetMetadata - Gets metadata of an object store
// securityOrigin - Security origin.
// databaseName - Database name.
// objectStoreName - Object store name.
// Returns - currentNumber - the current value of key generator, to become the next inserted key into the object store.
func (c *IndexedDB) GetKeyGeneratorCurrentNumber(securityOrigin string, databaseName string, objectStoreName string) (float64, error) {
var v IndexedDBGetKeyGeneratorCurrentNumberParams
// Returns - entriesCount - the entries count keyGeneratorValue - the current value of key generator, to become the next inserted key into the object store. Valid if objectStore.autoIncrement is true.
func (c *IndexedDB) GetMetadata(securityOrigin string, databaseName string, objectStoreName string) (float64, float64, error) {
var v IndexedDBGetMetadataParams
v.SecurityOrigin = securityOrigin
v.DatabaseName = databaseName
v.ObjectStoreName = objectStoreName
return c.GetKeyGeneratorCurrentNumberWithParams(&v)
return c.GetMetadataWithParams(&v)
}

type IndexedDBRequestDatabaseParams struct {
Expand Down
13 changes: 7 additions & 6 deletions gcdapi/network.go
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ type NetworkCookie struct {
HttpOnly bool `json:"httpOnly"` // True if cookie is http-only.
Secure bool `json:"secure"` // True if cookie is secure.
Session bool `json:"session"` // True in case of session cookie.
SameSite string `json:"sameSite,omitempty"` // Cookie SameSite type. enum values: Strict, Lax
SameSite string `json:"sameSite,omitempty"` // Cookie SameSite type. enum values: Strict, Lax, Extended, None
}

// Cookie parameter object
Expand All @@ -156,7 +156,7 @@ type NetworkCookieParam struct {
Path string `json:"path,omitempty"` // Cookie path.
Secure bool `json:"secure,omitempty"` // True if cookie is secure.
HttpOnly bool `json:"httpOnly,omitempty"` // True if cookie is http-only.
SameSite string `json:"sameSite,omitempty"` // Cookie SameSite type. enum values: Strict, Lax
SameSite string `json:"sameSite,omitempty"` // Cookie SameSite type. enum values: Strict, Lax, Extended, None
Expires float64 `json:"expires,omitempty"` // Cookie expiration date, session cookie if not set
}

Expand Down Expand Up @@ -280,6 +280,7 @@ type NetworkRequestInterceptedEvent struct {
ResponseErrorReason string `json:"responseErrorReason,omitempty"` // Response error if intercepted at response stage or if redirect occurred while intercepting request. enum values: Failed, Aborted, TimedOut, AccessDenied, ConnectionClosed, ConnectionReset, ConnectionRefused, ConnectionAborted, ConnectionFailed, NameNotResolved, InternetDisconnected, AddressUnreachable, BlockedByClient, BlockedByResponse
ResponseStatusCode int `json:"responseStatusCode,omitempty"` // Response code if intercepted at response stage or if redirect occurred while intercepting request or auth retry occurred.
ResponseHeaders map[string]interface{} `json:"responseHeaders,omitempty"` // Response headers if intercepted at the response stage or if redirect occurred while intercepting request or auth retry occurred.
RequestId string `json:"requestId,omitempty"` // If the intercepted request had a corresponding requestWillBeSent event fired for it, then this requestId will be the same as the requestId present in the requestWillBeSent event.
} `json:"Params,omitempty"`
}

Expand Down Expand Up @@ -1122,7 +1123,7 @@ type NetworkSetCookieParams struct {
Secure bool `json:"secure,omitempty"`
// True if cookie is http-only.
HttpOnly bool `json:"httpOnly,omitempty"`
// Cookie SameSite type. enum values: Strict, Lax
// Cookie SameSite type. enum values: Strict, Lax, Extended, None
SameSite string `json:"sameSite,omitempty"`
// Cookie expiration date, session cookie if not set
Expires float64 `json:"expires,omitempty"`
Expand Down Expand Up @@ -1168,7 +1169,7 @@ func (c *Network) SetCookieWithParams(v *NetworkSetCookieParams) (bool, error) {
// path - Cookie path.
// secure - True if cookie is secure.
// httpOnly - True if cookie is http-only.
// sameSite - Cookie SameSite type. enum values: Strict, Lax
// sameSite - Cookie SameSite type. enum values: Strict, Lax, Extended, None
// expires - Cookie expiration date, session cookie if not set
// Returns - success - True if successfully set cookie.
func (c *Network) SetCookie(name string, value string, url string, domain string, path string, secure bool, httpOnly bool, sameSite string, expires float64) (bool, error) {
Expand Down Expand Up @@ -1248,12 +1249,12 @@ type NetworkSetRequestInterceptionParams struct {
Patterns []*NetworkRequestPattern `json:"patterns"`
}

// SetRequestInterceptionWithParams - Sets the requests to intercept that match a the provided patterns and optionally resource types.
// SetRequestInterceptionWithParams - Sets the requests to intercept that match the provided patterns and optionally resource types.
func (c *Network) SetRequestInterceptionWithParams(v *NetworkSetRequestInterceptionParams) (*gcdmessage.ChromeResponse, error) {
return gcdmessage.SendDefaultRequest(c.target, c.target.GetSendCh(), &gcdmessage.ParamRequest{Id: c.target.GetId(), Method: "Network.setRequestInterception", Params: v})
}

// SetRequestInterception - Sets the requests to intercept that match a the provided patterns and optionally resource types.
// SetRequestInterception - Sets the requests to intercept that match the provided patterns and optionally resource types.
// patterns - Requests matching any of these patterns will be forwarded and wait for the corresponding continueInterceptedRequest call.
func (c *Network) SetRequestInterception(patterns []*NetworkRequestPattern) (*gcdmessage.ChromeResponse, error) {
var v NetworkSetRequestInterceptionParams
Expand Down
Loading

0 comments on commit 2f60966

Please sign in to comment.