diff --git a/cdp/animation/animation.go b/cdp/animation/animation.go index f61dd7c..d831c6f 100644 --- a/cdp/animation/animation.go +++ b/cdp/animation/animation.go @@ -13,20 +13,6 @@ import ( "github.com/knq/chromedp/cdp/runtime" ) -// EnableParams enables animation domain notifications. -type EnableParams struct{} - -// Enable enables animation domain notifications. -func Enable() *EnableParams { - return &EnableParams{} -} - -// Do executes Animation.enable against the provided context and -// target handler. -func (p *EnableParams) Do(ctxt context.Context, h cdp.Handler) (err error) { - return h.Execute(ctxt, cdp.CommandAnimationEnable, nil, nil) -} - // DisableParams disables animation domain notifications. type DisableParams struct{} @@ -41,54 +27,18 @@ func (p *DisableParams) Do(ctxt context.Context, h cdp.Handler) (err error) { return h.Execute(ctxt, cdp.CommandAnimationDisable, nil, nil) } -// GetPlaybackRateParams gets the playback rate of the document timeline. -type GetPlaybackRateParams struct{} +// EnableParams enables animation domain notifications. +type EnableParams struct{} -// GetPlaybackRate gets the playback rate of the document timeline. -func GetPlaybackRate() *GetPlaybackRateParams { - return &GetPlaybackRateParams{} +// Enable enables animation domain notifications. +func Enable() *EnableParams { + return &EnableParams{} } -// GetPlaybackRateReturns return values. -type GetPlaybackRateReturns struct { - PlaybackRate float64 `json:"playbackRate,omitempty"` // Playback rate for animations on page. -} - -// Do executes Animation.getPlaybackRate against the provided context and +// Do executes Animation.enable against the provided context and // target handler. -// -// returns: -// playbackRate - Playback rate for animations on page. -func (p *GetPlaybackRateParams) Do(ctxt context.Context, h cdp.Handler) (playbackRate float64, err error) { - // execute - var res GetPlaybackRateReturns - err = h.Execute(ctxt, cdp.CommandAnimationGetPlaybackRate, nil, &res) - if err != nil { - return 0, err - } - - return res.PlaybackRate, nil -} - -// SetPlaybackRateParams sets the playback rate of the document timeline. -type SetPlaybackRateParams struct { - PlaybackRate float64 `json:"playbackRate"` // Playback rate for animations on page -} - -// SetPlaybackRate sets the playback rate of the document timeline. -// -// parameters: -// playbackRate - Playback rate for animations on page -func SetPlaybackRate(playbackRate float64) *SetPlaybackRateParams { - return &SetPlaybackRateParams{ - PlaybackRate: playbackRate, - } -} - -// Do executes Animation.setPlaybackRate against the provided context and -// target handler. -func (p *SetPlaybackRateParams) Do(ctxt context.Context, h cdp.Handler) (err error) { - return h.Execute(ctxt, cdp.CommandAnimationSetPlaybackRate, p, nil) +func (p *EnableParams) Do(ctxt context.Context, h cdp.Handler) (err error) { + return h.Execute(ctxt, cdp.CommandAnimationEnable, nil, nil) } // GetCurrentTimeParams returns the current time of the an animation. @@ -127,81 +77,33 @@ func (p *GetCurrentTimeParams) Do(ctxt context.Context, h cdp.Handler) (currentT return res.CurrentTime, nil } -// SetPausedParams sets the paused state of a set of animations. -type SetPausedParams struct { - Animations []string `json:"animations"` // Animations to set the pause state of. - Paused bool `json:"paused"` // Paused state to set to. +// GetPlaybackRateParams gets the playback rate of the document timeline. +type GetPlaybackRateParams struct{} + +// GetPlaybackRate gets the playback rate of the document timeline. +func GetPlaybackRate() *GetPlaybackRateParams { + return &GetPlaybackRateParams{} } -// SetPaused sets the paused state of a set of animations. -// -// parameters: -// animations - Animations to set the pause state of. -// paused - Paused state to set to. -func SetPaused(animations []string, paused bool) *SetPausedParams { - return &SetPausedParams{ - Animations: animations, - Paused: paused, - } +// GetPlaybackRateReturns return values. +type GetPlaybackRateReturns struct { + PlaybackRate float64 `json:"playbackRate,omitempty"` // Playback rate for animations on page. } -// Do executes Animation.setPaused against the provided context and +// Do executes Animation.getPlaybackRate against the provided context and // target handler. -func (p *SetPausedParams) Do(ctxt context.Context, h cdp.Handler) (err error) { - return h.Execute(ctxt, cdp.CommandAnimationSetPaused, p, nil) -} - -// SetTimingParams sets the timing of an animation node. -type SetTimingParams struct { - AnimationID string `json:"animationId"` // Animation id. - Duration float64 `json:"duration"` // Duration of the animation. - Delay float64 `json:"delay"` // Delay of the animation. -} - -// SetTiming sets the timing of an animation node. // -// parameters: -// animationID - Animation id. -// duration - Duration of the animation. -// delay - Delay of the animation. -func SetTiming(animationID string, duration float64, delay float64) *SetTimingParams { - return &SetTimingParams{ - AnimationID: animationID, - Duration: duration, - Delay: delay, +// returns: +// playbackRate - Playback rate for animations on page. +func (p *GetPlaybackRateParams) Do(ctxt context.Context, h cdp.Handler) (playbackRate float64, err error) { + // execute + var res GetPlaybackRateReturns + err = h.Execute(ctxt, cdp.CommandAnimationGetPlaybackRate, nil, &res) + if err != nil { + return 0, err } -} -// Do executes Animation.setTiming against the provided context and -// target handler. -func (p *SetTimingParams) Do(ctxt context.Context, h cdp.Handler) (err error) { - return h.Execute(ctxt, cdp.CommandAnimationSetTiming, p, nil) -} - -// SeekAnimationsParams seek a set of animations to a particular time within -// each animation. -type SeekAnimationsParams struct { - Animations []string `json:"animations"` // List of animation ids to seek. - CurrentTime float64 `json:"currentTime"` // Set the current time of each animation. -} - -// SeekAnimations seek a set of animations to a particular time within each -// animation. -// -// parameters: -// animations - List of animation ids to seek. -// currentTime - Set the current time of each animation. -func SeekAnimations(animations []string, currentTime float64) *SeekAnimationsParams { - return &SeekAnimationsParams{ - Animations: animations, - CurrentTime: currentTime, - } -} - -// Do executes Animation.seekAnimations against the provided context and -// target handler. -func (p *SeekAnimationsParams) Do(ctxt context.Context, h cdp.Handler) (err error) { - return h.Execute(ctxt, cdp.CommandAnimationSeekAnimations, p, nil) + return res.PlaybackRate, nil } // ReleaseAnimationsParams releases a set of animations to no longer be @@ -262,3 +164,101 @@ func (p *ResolveAnimationParams) Do(ctxt context.Context, h cdp.Handler) (remote return res.RemoteObject, nil } + +// SeekAnimationsParams seek a set of animations to a particular time within +// each animation. +type SeekAnimationsParams struct { + Animations []string `json:"animations"` // List of animation ids to seek. + CurrentTime float64 `json:"currentTime"` // Set the current time of each animation. +} + +// SeekAnimations seek a set of animations to a particular time within each +// animation. +// +// parameters: +// animations - List of animation ids to seek. +// currentTime - Set the current time of each animation. +func SeekAnimations(animations []string, currentTime float64) *SeekAnimationsParams { + return &SeekAnimationsParams{ + Animations: animations, + CurrentTime: currentTime, + } +} + +// Do executes Animation.seekAnimations against the provided context and +// target handler. +func (p *SeekAnimationsParams) Do(ctxt context.Context, h cdp.Handler) (err error) { + return h.Execute(ctxt, cdp.CommandAnimationSeekAnimations, p, nil) +} + +// SetPausedParams sets the paused state of a set of animations. +type SetPausedParams struct { + Animations []string `json:"animations"` // Animations to set the pause state of. + Paused bool `json:"paused"` // Paused state to set to. +} + +// SetPaused sets the paused state of a set of animations. +// +// parameters: +// animations - Animations to set the pause state of. +// paused - Paused state to set to. +func SetPaused(animations []string, paused bool) *SetPausedParams { + return &SetPausedParams{ + Animations: animations, + Paused: paused, + } +} + +// Do executes Animation.setPaused against the provided context and +// target handler. +func (p *SetPausedParams) Do(ctxt context.Context, h cdp.Handler) (err error) { + return h.Execute(ctxt, cdp.CommandAnimationSetPaused, p, nil) +} + +// SetPlaybackRateParams sets the playback rate of the document timeline. +type SetPlaybackRateParams struct { + PlaybackRate float64 `json:"playbackRate"` // Playback rate for animations on page +} + +// SetPlaybackRate sets the playback rate of the document timeline. +// +// parameters: +// playbackRate - Playback rate for animations on page +func SetPlaybackRate(playbackRate float64) *SetPlaybackRateParams { + return &SetPlaybackRateParams{ + PlaybackRate: playbackRate, + } +} + +// Do executes Animation.setPlaybackRate against the provided context and +// target handler. +func (p *SetPlaybackRateParams) Do(ctxt context.Context, h cdp.Handler) (err error) { + return h.Execute(ctxt, cdp.CommandAnimationSetPlaybackRate, p, nil) +} + +// SetTimingParams sets the timing of an animation node. +type SetTimingParams struct { + AnimationID string `json:"animationId"` // Animation id. + Duration float64 `json:"duration"` // Duration of the animation. + Delay float64 `json:"delay"` // Delay of the animation. +} + +// SetTiming sets the timing of an animation node. +// +// parameters: +// animationID - Animation id. +// duration - Duration of the animation. +// delay - Delay of the animation. +func SetTiming(animationID string, duration float64, delay float64) *SetTimingParams { + return &SetTimingParams{ + AnimationID: animationID, + Duration: duration, + Delay: delay, + } +} + +// Do executes Animation.setTiming against the provided context and +// target handler. +func (p *SetTimingParams) Do(ctxt context.Context, h cdp.Handler) (err error) { + return h.Execute(ctxt, cdp.CommandAnimationSetTiming, p, nil) +} diff --git a/cdp/animation/events.go b/cdp/animation/events.go index 4dec6da..1647719 100644 --- a/cdp/animation/events.go +++ b/cdp/animation/events.go @@ -6,6 +6,11 @@ import ( cdp "github.com/knq/chromedp/cdp" ) +// EventAnimationCanceled event for when an animation has been cancelled. +type EventAnimationCanceled struct { + ID string `json:"id"` // Id of the animation that was cancelled. +} + // EventAnimationCreated event for each animation that has been created. type EventAnimationCreated struct { ID string `json:"id"` // Id of the animation that was created. @@ -16,14 +21,9 @@ type EventAnimationStarted struct { Animation *Animation `json:"animation"` // Animation that was started. } -// EventAnimationCanceled event for when an animation has been cancelled. -type EventAnimationCanceled struct { - ID string `json:"id"` // Id of the animation that was cancelled. -} - // EventTypes all event types in the domain. var EventTypes = []cdp.MethodType{ + cdp.EventAnimationAnimationCanceled, cdp.EventAnimationAnimationCreated, cdp.EventAnimationAnimationStarted, - cdp.EventAnimationAnimationCanceled, } diff --git a/cdp/applicationcache/applicationcache.go b/cdp/applicationcache/applicationcache.go index 0a4dd6f..d34a944 100644 --- a/cdp/applicationcache/applicationcache.go +++ b/cdp/applicationcache/applicationcache.go @@ -12,39 +12,6 @@ import ( cdp "github.com/knq/chromedp/cdp" ) -// GetFramesWithManifestsParams returns array of frame identifiers with -// manifest urls for each frame containing a document associated with some -// application cache. -type GetFramesWithManifestsParams struct{} - -// GetFramesWithManifests returns array of frame identifiers with manifest -// urls for each frame containing a document associated with some application -// cache. -func GetFramesWithManifests() *GetFramesWithManifestsParams { - return &GetFramesWithManifestsParams{} -} - -// GetFramesWithManifestsReturns return values. -type GetFramesWithManifestsReturns struct { - FrameIds []*FrameWithManifest `json:"frameIds,omitempty"` // Array of frame identifiers with manifest urls for each frame containing a document associated with some application cache. -} - -// Do executes ApplicationCache.getFramesWithManifests against the provided context and -// target handler. -// -// returns: -// frameIds - Array of frame identifiers with manifest urls for each frame containing a document associated with some application cache. -func (p *GetFramesWithManifestsParams) Do(ctxt context.Context, h cdp.Handler) (frameIds []*FrameWithManifest, err error) { - // execute - var res GetFramesWithManifestsReturns - err = h.Execute(ctxt, cdp.CommandApplicationCacheGetFramesWithManifests, nil, &res) - if err != nil { - return nil, err - } - - return res.FrameIds, nil -} - // EnableParams enables application cache domain notifications. type EnableParams struct{} @@ -59,43 +26,6 @@ func (p *EnableParams) Do(ctxt context.Context, h cdp.Handler) (err error) { return h.Execute(ctxt, cdp.CommandApplicationCacheEnable, nil, nil) } -// GetManifestForFrameParams returns manifest URL for document in the given -// frame. -type GetManifestForFrameParams struct { - FrameID cdp.FrameID `json:"frameId"` // Identifier of the frame containing document whose manifest is retrieved. -} - -// GetManifestForFrame returns manifest URL for document in the given frame. -// -// parameters: -// frameID - Identifier of the frame containing document whose manifest is retrieved. -func GetManifestForFrame(frameID cdp.FrameID) *GetManifestForFrameParams { - return &GetManifestForFrameParams{ - FrameID: frameID, - } -} - -// GetManifestForFrameReturns return values. -type GetManifestForFrameReturns struct { - ManifestURL string `json:"manifestURL,omitempty"` // Manifest URL for document in the given frame. -} - -// Do executes ApplicationCache.getManifestForFrame against the provided context and -// target handler. -// -// returns: -// manifestURL - Manifest URL for document in the given frame. -func (p *GetManifestForFrameParams) Do(ctxt context.Context, h cdp.Handler) (manifestURL string, err error) { - // execute - var res GetManifestForFrameReturns - err = h.Execute(ctxt, cdp.CommandApplicationCacheGetManifestForFrame, p, &res) - if err != nil { - return "", err - } - - return res.ManifestURL, nil -} - // GetApplicationCacheForFrameParams returns relevant application cache data // for the document in given frame. type GetApplicationCacheForFrameParams struct { @@ -133,3 +63,73 @@ func (p *GetApplicationCacheForFrameParams) Do(ctxt context.Context, h cdp.Handl return res.ApplicationCache, nil } + +// GetFramesWithManifestsParams returns array of frame identifiers with +// manifest urls for each frame containing a document associated with some +// application cache. +type GetFramesWithManifestsParams struct{} + +// GetFramesWithManifests returns array of frame identifiers with manifest +// urls for each frame containing a document associated with some application +// cache. +func GetFramesWithManifests() *GetFramesWithManifestsParams { + return &GetFramesWithManifestsParams{} +} + +// GetFramesWithManifestsReturns return values. +type GetFramesWithManifestsReturns struct { + FrameIds []*FrameWithManifest `json:"frameIds,omitempty"` // Array of frame identifiers with manifest urls for each frame containing a document associated with some application cache. +} + +// Do executes ApplicationCache.getFramesWithManifests against the provided context and +// target handler. +// +// returns: +// frameIds - Array of frame identifiers with manifest urls for each frame containing a document associated with some application cache. +func (p *GetFramesWithManifestsParams) Do(ctxt context.Context, h cdp.Handler) (frameIds []*FrameWithManifest, err error) { + // execute + var res GetFramesWithManifestsReturns + err = h.Execute(ctxt, cdp.CommandApplicationCacheGetFramesWithManifests, nil, &res) + if err != nil { + return nil, err + } + + return res.FrameIds, nil +} + +// GetManifestForFrameParams returns manifest URL for document in the given +// frame. +type GetManifestForFrameParams struct { + FrameID cdp.FrameID `json:"frameId"` // Identifier of the frame containing document whose manifest is retrieved. +} + +// GetManifestForFrame returns manifest URL for document in the given frame. +// +// parameters: +// frameID - Identifier of the frame containing document whose manifest is retrieved. +func GetManifestForFrame(frameID cdp.FrameID) *GetManifestForFrameParams { + return &GetManifestForFrameParams{ + FrameID: frameID, + } +} + +// GetManifestForFrameReturns return values. +type GetManifestForFrameReturns struct { + ManifestURL string `json:"manifestURL,omitempty"` // Manifest URL for document in the given frame. +} + +// Do executes ApplicationCache.getManifestForFrame against the provided context and +// target handler. +// +// returns: +// manifestURL - Manifest URL for document in the given frame. +func (p *GetManifestForFrameParams) Do(ctxt context.Context, h cdp.Handler) (manifestURL string, err error) { + // execute + var res GetManifestForFrameReturns + err = h.Execute(ctxt, cdp.CommandApplicationCacheGetManifestForFrame, p, &res) + if err != nil { + return "", err + } + + return res.ManifestURL, nil +} diff --git a/cdp/browser/browser.go b/cdp/browser/browser.go index 6a3b371..3773531 100644 --- a/cdp/browser/browser.go +++ b/cdp/browser/browser.go @@ -29,6 +29,79 @@ func (p *CloseParams) Do(ctxt context.Context, h cdp.Handler) (err error) { return h.Execute(ctxt, cdp.CommandBrowserClose, nil, nil) } +// GetVersionParams returns version information. +type GetVersionParams struct{} + +// GetVersion returns version information. +func GetVersion() *GetVersionParams { + return &GetVersionParams{} +} + +// GetVersionReturns return values. +type GetVersionReturns struct { + ProtocolVersion string `json:"protocolVersion,omitempty"` // Protocol version. + Product string `json:"product,omitempty"` // Product name. + Revision string `json:"revision,omitempty"` // Product revision. + UserAgent string `json:"userAgent,omitempty"` // User-Agent. + JsVersion string `json:"jsVersion,omitempty"` // V8 version. +} + +// Do executes Browser.getVersion against the provided context and +// target handler. +// +// returns: +// protocolVersion - Protocol version. +// product - Product name. +// revision - Product revision. +// userAgent - User-Agent. +// jsVersion - V8 version. +func (p *GetVersionParams) Do(ctxt context.Context, h cdp.Handler) (protocolVersion string, product string, revision string, userAgent string, jsVersion string, err error) { + // execute + var res GetVersionReturns + err = h.Execute(ctxt, cdp.CommandBrowserGetVersion, nil, &res) + if err != nil { + return "", "", "", "", "", err + } + + return res.ProtocolVersion, res.Product, res.Revision, res.UserAgent, res.JsVersion, nil +} + +// GetWindowBoundsParams get position and size of the browser window. +type GetWindowBoundsParams struct { + WindowID WindowID `json:"windowId"` // Browser window id. +} + +// GetWindowBounds get position and size of the browser window. +// +// parameters: +// windowID - Browser window id. +func GetWindowBounds(windowID WindowID) *GetWindowBoundsParams { + return &GetWindowBoundsParams{ + WindowID: windowID, + } +} + +// GetWindowBoundsReturns return values. +type GetWindowBoundsReturns struct { + Bounds *Bounds `json:"bounds,omitempty"` // Bounds information of the window. When window state is 'minimized', the restored window position and size are returned. +} + +// Do executes Browser.getWindowBounds against the provided context and +// target handler. +// +// returns: +// bounds - Bounds information of the window. When window state is 'minimized', the restored window position and size are returned. +func (p *GetWindowBoundsParams) Do(ctxt context.Context, h cdp.Handler) (bounds *Bounds, err error) { + // execute + var res GetWindowBoundsReturns + err = h.Execute(ctxt, cdp.CommandBrowserGetWindowBounds, p, &res) + if err != nil { + return nil, err + } + + return res.Bounds, nil +} + // GetWindowForTargetParams get the browser window that contains the devtools // target. type GetWindowForTargetParams struct { @@ -69,43 +142,6 @@ func (p *GetWindowForTargetParams) Do(ctxt context.Context, h cdp.Handler) (wind return res.WindowID, res.Bounds, nil } -// GetVersionParams returns version information. -type GetVersionParams struct{} - -// GetVersion returns version information. -func GetVersion() *GetVersionParams { - return &GetVersionParams{} -} - -// GetVersionReturns return values. -type GetVersionReturns struct { - ProtocolVersion string `json:"protocolVersion,omitempty"` // Protocol version. - Product string `json:"product,omitempty"` // Product name. - Revision string `json:"revision,omitempty"` // Product revision. - UserAgent string `json:"userAgent,omitempty"` // User-Agent. - JsVersion string `json:"jsVersion,omitempty"` // V8 version. -} - -// Do executes Browser.getVersion against the provided context and -// target handler. -// -// returns: -// protocolVersion - Protocol version. -// product - Product name. -// revision - Product revision. -// userAgent - User-Agent. -// jsVersion - V8 version. -func (p *GetVersionParams) Do(ctxt context.Context, h cdp.Handler) (protocolVersion string, product string, revision string, userAgent string, jsVersion string, err error) { - // execute - var res GetVersionReturns - err = h.Execute(ctxt, cdp.CommandBrowserGetVersion, nil, &res) - if err != nil { - return "", "", "", "", "", err - } - - return res.ProtocolVersion, res.Product, res.Revision, res.UserAgent, res.JsVersion, nil -} - // SetWindowBoundsParams set position and/or size of the browser window. type SetWindowBoundsParams struct { WindowID WindowID `json:"windowId"` // Browser window id. @@ -129,39 +165,3 @@ func SetWindowBounds(windowID WindowID, bounds *Bounds) *SetWindowBoundsParams { func (p *SetWindowBoundsParams) Do(ctxt context.Context, h cdp.Handler) (err error) { return h.Execute(ctxt, cdp.CommandBrowserSetWindowBounds, p, nil) } - -// GetWindowBoundsParams get position and size of the browser window. -type GetWindowBoundsParams struct { - WindowID WindowID `json:"windowId"` // Browser window id. -} - -// GetWindowBounds get position and size of the browser window. -// -// parameters: -// windowID - Browser window id. -func GetWindowBounds(windowID WindowID) *GetWindowBoundsParams { - return &GetWindowBoundsParams{ - WindowID: windowID, - } -} - -// GetWindowBoundsReturns return values. -type GetWindowBoundsReturns struct { - Bounds *Bounds `json:"bounds,omitempty"` // Bounds information of the window. When window state is 'minimized', the restored window position and size are returned. -} - -// Do executes Browser.getWindowBounds against the provided context and -// target handler. -// -// returns: -// bounds - Bounds information of the window. When window state is 'minimized', the restored window position and size are returned. -func (p *GetWindowBoundsParams) Do(ctxt context.Context, h cdp.Handler) (bounds *Bounds, err error) { - // execute - var res GetWindowBoundsReturns - err = h.Execute(ctxt, cdp.CommandBrowserGetWindowBounds, p, &res) - if err != nil { - return nil, err - } - - return res.Bounds, nil -} diff --git a/cdp/cachestorage/cachestorage.go b/cdp/cachestorage/cachestorage.go index c54b82d..864c99d 100644 --- a/cdp/cachestorage/cachestorage.go +++ b/cdp/cachestorage/cachestorage.go @@ -12,86 +12,6 @@ import ( cdp "github.com/knq/chromedp/cdp" ) -// RequestCacheNamesParams requests cache names. -type RequestCacheNamesParams struct { - SecurityOrigin string `json:"securityOrigin"` // Security origin. -} - -// RequestCacheNames requests cache names. -// -// parameters: -// securityOrigin - Security origin. -func RequestCacheNames(securityOrigin string) *RequestCacheNamesParams { - return &RequestCacheNamesParams{ - SecurityOrigin: securityOrigin, - } -} - -// RequestCacheNamesReturns return values. -type RequestCacheNamesReturns struct { - Caches []*Cache `json:"caches,omitempty"` // Caches for the security origin. -} - -// Do executes CacheStorage.requestCacheNames against the provided context and -// target handler. -// -// returns: -// caches - Caches for the security origin. -func (p *RequestCacheNamesParams) Do(ctxt context.Context, h cdp.Handler) (caches []*Cache, err error) { - // execute - var res RequestCacheNamesReturns - err = h.Execute(ctxt, cdp.CommandCacheStorageRequestCacheNames, p, &res) - if err != nil { - return nil, err - } - - return res.Caches, nil -} - -// RequestEntriesParams requests data from cache. -type RequestEntriesParams struct { - CacheID CacheID `json:"cacheId"` // ID of cache to get entries from. - SkipCount int64 `json:"skipCount"` // Number of records to skip. - PageSize int64 `json:"pageSize"` // Number of records to fetch. -} - -// RequestEntries requests data from cache. -// -// parameters: -// cacheID - ID of cache to get entries from. -// skipCount - Number of records to skip. -// pageSize - Number of records to fetch. -func RequestEntries(cacheID CacheID, skipCount int64, pageSize int64) *RequestEntriesParams { - return &RequestEntriesParams{ - CacheID: cacheID, - SkipCount: skipCount, - PageSize: pageSize, - } -} - -// RequestEntriesReturns return values. -type RequestEntriesReturns struct { - CacheDataEntries []*DataEntry `json:"cacheDataEntries,omitempty"` // Array of object store data entries. - HasMore bool `json:"hasMore,omitempty"` // If true, there are more entries to fetch in the given range. -} - -// Do executes CacheStorage.requestEntries against the provided context and -// target handler. -// -// returns: -// cacheDataEntries - Array of object store data entries. -// hasMore - If true, there are more entries to fetch in the given range. -func (p *RequestEntriesParams) Do(ctxt context.Context, h cdp.Handler) (cacheDataEntries []*DataEntry, hasMore bool, err error) { - // execute - var res RequestEntriesReturns - err = h.Execute(ctxt, cdp.CommandCacheStorageRequestEntries, p, &res) - if err != nil { - return nil, false, err - } - - return res.CacheDataEntries, res.HasMore, nil -} - // DeleteCacheParams deletes a cache. type DeleteCacheParams struct { CacheID CacheID `json:"cacheId"` // Id of cache for deletion. @@ -137,6 +57,42 @@ func (p *DeleteEntryParams) Do(ctxt context.Context, h cdp.Handler) (err error) return h.Execute(ctxt, cdp.CommandCacheStorageDeleteEntry, p, nil) } +// RequestCacheNamesParams requests cache names. +type RequestCacheNamesParams struct { + SecurityOrigin string `json:"securityOrigin"` // Security origin. +} + +// RequestCacheNames requests cache names. +// +// parameters: +// securityOrigin - Security origin. +func RequestCacheNames(securityOrigin string) *RequestCacheNamesParams { + return &RequestCacheNamesParams{ + SecurityOrigin: securityOrigin, + } +} + +// RequestCacheNamesReturns return values. +type RequestCacheNamesReturns struct { + Caches []*Cache `json:"caches,omitempty"` // Caches for the security origin. +} + +// Do executes CacheStorage.requestCacheNames against the provided context and +// target handler. +// +// returns: +// caches - Caches for the security origin. +func (p *RequestCacheNamesParams) Do(ctxt context.Context, h cdp.Handler) (caches []*Cache, err error) { + // execute + var res RequestCacheNamesReturns + err = h.Execute(ctxt, cdp.CommandCacheStorageRequestCacheNames, p, &res) + if err != nil { + return nil, err + } + + return res.Caches, nil +} + // RequestCachedResponseParams fetches cache entry. type RequestCachedResponseParams struct { CacheID CacheID `json:"cacheId"` // Id of cache that contains the enty. @@ -175,3 +131,47 @@ func (p *RequestCachedResponseParams) Do(ctxt context.Context, h cdp.Handler) (r return res.Response, nil } + +// RequestEntriesParams requests data from cache. +type RequestEntriesParams struct { + CacheID CacheID `json:"cacheId"` // ID of cache to get entries from. + SkipCount int64 `json:"skipCount"` // Number of records to skip. + PageSize int64 `json:"pageSize"` // Number of records to fetch. +} + +// RequestEntries requests data from cache. +// +// parameters: +// cacheID - ID of cache to get entries from. +// skipCount - Number of records to skip. +// pageSize - Number of records to fetch. +func RequestEntries(cacheID CacheID, skipCount int64, pageSize int64) *RequestEntriesParams { + return &RequestEntriesParams{ + CacheID: cacheID, + SkipCount: skipCount, + PageSize: pageSize, + } +} + +// RequestEntriesReturns return values. +type RequestEntriesReturns struct { + CacheDataEntries []*DataEntry `json:"cacheDataEntries,omitempty"` // Array of object store data entries. + HasMore bool `json:"hasMore,omitempty"` // If true, there are more entries to fetch in the given range. +} + +// Do executes CacheStorage.requestEntries against the provided context and +// target handler. +// +// returns: +// cacheDataEntries - Array of object store data entries. +// hasMore - If true, there are more entries to fetch in the given range. +func (p *RequestEntriesParams) Do(ctxt context.Context, h cdp.Handler) (cacheDataEntries []*DataEntry, hasMore bool, err error) { + // execute + var res RequestEntriesReturns + err = h.Execute(ctxt, cdp.CommandCacheStorageRequestEntries, p, &res) + if err != nil { + return nil, false, err + } + + return res.CacheDataEntries, res.HasMore, nil +} diff --git a/cdp/cdp.go b/cdp/cdp.go index 5bb945e..1c04cce 100644 --- a/cdp/cdp.go +++ b/cdp/cdp.go @@ -17,1678 +17,6 @@ import ( // Code generated by chromedp-gen. DO NOT EDIT. -// MessageError message error type. -type MessageError struct { - Code int64 `json:"code"` // Error code. - Message string `json:"message"` // Error message. -} - -// Error satisfies error interface. -func (e *MessageError) Error() string { - return fmt.Sprintf("%s (%d)", e.Message, e.Code) -} - -// Message chrome Debugging Protocol message sent to/read over websocket -// connection. -type Message struct { - ID int64 `json:"id,omitempty"` // Unique message identifier. - Method MethodType `json:"method,omitempty"` // Event or command type. - Params easyjson.RawMessage `json:"params,omitempty"` // Event or command parameters. - Result easyjson.RawMessage `json:"result,omitempty"` // Command return values. - Error *MessageError `json:"error,omitempty"` // Error message. -} - -// MethodType chrome Debugging Protocol method type (ie, event and command -// names). -type MethodType string - -// String returns the MethodType as string value. -func (t MethodType) String() string { - return string(t) -} - -// MethodType values. -const ( - EventInspectorDetached MethodType = "Inspector.detached" - EventInspectorTargetCrashed MethodType = "Inspector.targetCrashed" - CommandInspectorEnable MethodType = "Inspector.enable" - CommandInspectorDisable MethodType = "Inspector.disable" - CommandMemoryGetDOMCounters MethodType = "Memory.getDOMCounters" - CommandMemoryPrepareForLeakDetection MethodType = "Memory.prepareForLeakDetection" - CommandMemorySetPressureNotificationsSuppressed MethodType = "Memory.setPressureNotificationsSuppressed" - CommandMemorySimulatePressureNotification MethodType = "Memory.simulatePressureNotification" - EventPerformanceMetrics MethodType = "Performance.metrics" - CommandPerformanceEnable MethodType = "Performance.enable" - CommandPerformanceDisable MethodType = "Performance.disable" - CommandPerformanceGetMetrics MethodType = "Performance.getMetrics" - EventPageDomContentEventFired MethodType = "Page.domContentEventFired" - EventPageLoadEventFired MethodType = "Page.loadEventFired" - EventPageLifecycleEvent MethodType = "Page.lifecycleEvent" - EventPageFrameAttached MethodType = "Page.frameAttached" - EventPageFrameNavigated MethodType = "Page.frameNavigated" - EventPageFrameDetached MethodType = "Page.frameDetached" - EventPageFrameStartedLoading MethodType = "Page.frameStartedLoading" - EventPageFrameStoppedLoading MethodType = "Page.frameStoppedLoading" - EventPageFrameScheduledNavigation MethodType = "Page.frameScheduledNavigation" - EventPageFrameClearedScheduledNavigation MethodType = "Page.frameClearedScheduledNavigation" - EventPageFrameResized MethodType = "Page.frameResized" - EventPageJavascriptDialogOpening MethodType = "Page.javascriptDialogOpening" - EventPageJavascriptDialogClosed MethodType = "Page.javascriptDialogClosed" - EventPageScreencastFrame MethodType = "Page.screencastFrame" - EventPageScreencastVisibilityChanged MethodType = "Page.screencastVisibilityChanged" - EventPageInterstitialShown MethodType = "Page.interstitialShown" - EventPageInterstitialHidden MethodType = "Page.interstitialHidden" - EventPageWindowOpen MethodType = "Page.windowOpen" - CommandPageEnable MethodType = "Page.enable" - CommandPageDisable MethodType = "Page.disable" - CommandPageAddScriptToEvaluateOnNewDocument MethodType = "Page.addScriptToEvaluateOnNewDocument" - CommandPageRemoveScriptToEvaluateOnNewDocument MethodType = "Page.removeScriptToEvaluateOnNewDocument" - CommandPageSetAutoAttachToCreatedPages MethodType = "Page.setAutoAttachToCreatedPages" - CommandPageSetLifecycleEventsEnabled MethodType = "Page.setLifecycleEventsEnabled" - CommandPageReload MethodType = "Page.reload" - CommandPageSetAdBlockingEnabled MethodType = "Page.setAdBlockingEnabled" - CommandPageNavigate MethodType = "Page.navigate" - CommandPageStopLoading MethodType = "Page.stopLoading" - CommandPageGetNavigationHistory MethodType = "Page.getNavigationHistory" - CommandPageNavigateToHistoryEntry MethodType = "Page.navigateToHistoryEntry" - CommandPageGetResourceTree MethodType = "Page.getResourceTree" - CommandPageGetFrameTree MethodType = "Page.getFrameTree" - CommandPageGetResourceContent MethodType = "Page.getResourceContent" - CommandPageSearchInResource MethodType = "Page.searchInResource" - CommandPageSetDocumentContent MethodType = "Page.setDocumentContent" - CommandPageCaptureScreenshot MethodType = "Page.captureScreenshot" - CommandPagePrintToPDF MethodType = "Page.printToPDF" - CommandPageStartScreencast MethodType = "Page.startScreencast" - CommandPageStopScreencast MethodType = "Page.stopScreencast" - CommandPageScreencastFrameAck MethodType = "Page.screencastFrameAck" - CommandPageHandleJavaScriptDialog MethodType = "Page.handleJavaScriptDialog" - CommandPageGetAppManifest MethodType = "Page.getAppManifest" - CommandPageRequestAppBanner MethodType = "Page.requestAppBanner" - CommandPageGetLayoutMetrics MethodType = "Page.getLayoutMetrics" - CommandPageCreateIsolatedWorld MethodType = "Page.createIsolatedWorld" - CommandPageBringToFront MethodType = "Page.bringToFront" - CommandPageSetDownloadBehavior MethodType = "Page.setDownloadBehavior" - EventOverlayNodeHighlightRequested MethodType = "Overlay.nodeHighlightRequested" - EventOverlayInspectNodeRequested MethodType = "Overlay.inspectNodeRequested" - EventOverlayScreenshotRequested MethodType = "Overlay.screenshotRequested" - CommandOverlayEnable MethodType = "Overlay.enable" - CommandOverlayDisable MethodType = "Overlay.disable" - CommandOverlaySetShowPaintRects MethodType = "Overlay.setShowPaintRects" - CommandOverlaySetShowDebugBorders MethodType = "Overlay.setShowDebugBorders" - CommandOverlaySetShowFPSCounter MethodType = "Overlay.setShowFPSCounter" - CommandOverlaySetShowScrollBottleneckRects MethodType = "Overlay.setShowScrollBottleneckRects" - CommandOverlaySetShowViewportSizeOnResize MethodType = "Overlay.setShowViewportSizeOnResize" - CommandOverlaySetPausedInDebuggerMessage MethodType = "Overlay.setPausedInDebuggerMessage" - CommandOverlaySetSuspended MethodType = "Overlay.setSuspended" - CommandOverlaySetInspectMode MethodType = "Overlay.setInspectMode" - CommandOverlayHighlightRect MethodType = "Overlay.highlightRect" - CommandOverlayHighlightQuad MethodType = "Overlay.highlightQuad" - CommandOverlayHighlightNode MethodType = "Overlay.highlightNode" - CommandOverlayHighlightFrame MethodType = "Overlay.highlightFrame" - CommandOverlayHideHighlight MethodType = "Overlay.hideHighlight" - CommandOverlayGetHighlightObjectForTest MethodType = "Overlay.getHighlightObjectForTest" - EventEmulationVirtualTimeBudgetExpired MethodType = "Emulation.virtualTimeBudgetExpired" - EventEmulationVirtualTimeAdvanced MethodType = "Emulation.virtualTimeAdvanced" - EventEmulationVirtualTimePaused MethodType = "Emulation.virtualTimePaused" - CommandEmulationSetDeviceMetricsOverride MethodType = "Emulation.setDeviceMetricsOverride" - CommandEmulationClearDeviceMetricsOverride MethodType = "Emulation.clearDeviceMetricsOverride" - CommandEmulationResetPageScaleFactor MethodType = "Emulation.resetPageScaleFactor" - CommandEmulationSetPageScaleFactor MethodType = "Emulation.setPageScaleFactor" - CommandEmulationSetScriptExecutionDisabled MethodType = "Emulation.setScriptExecutionDisabled" - CommandEmulationSetGeolocationOverride MethodType = "Emulation.setGeolocationOverride" - CommandEmulationClearGeolocationOverride MethodType = "Emulation.clearGeolocationOverride" - CommandEmulationSetTouchEmulationEnabled MethodType = "Emulation.setTouchEmulationEnabled" - CommandEmulationSetEmitTouchEventsForMouse MethodType = "Emulation.setEmitTouchEventsForMouse" - CommandEmulationSetEmulatedMedia MethodType = "Emulation.setEmulatedMedia" - CommandEmulationSetCPUThrottlingRate MethodType = "Emulation.setCPUThrottlingRate" - CommandEmulationCanEmulate MethodType = "Emulation.canEmulate" - CommandEmulationSetVirtualTimePolicy MethodType = "Emulation.setVirtualTimePolicy" - CommandEmulationSetNavigatorOverrides MethodType = "Emulation.setNavigatorOverrides" - CommandEmulationSetDefaultBackgroundColorOverride MethodType = "Emulation.setDefaultBackgroundColorOverride" - EventSecuritySecurityStateChanged MethodType = "Security.securityStateChanged" - EventSecurityCertificateError MethodType = "Security.certificateError" - CommandSecurityEnable MethodType = "Security.enable" - CommandSecurityDisable MethodType = "Security.disable" - CommandSecurityHandleCertificateError MethodType = "Security.handleCertificateError" - CommandSecuritySetOverrideCertificateErrors MethodType = "Security.setOverrideCertificateErrors" - CommandAuditsGetEncodedResponse MethodType = "Audits.getEncodedResponse" - EventNetworkResourceChangedPriority MethodType = "Network.resourceChangedPriority" - EventNetworkRequestWillBeSent MethodType = "Network.requestWillBeSent" - EventNetworkRequestServedFromCache MethodType = "Network.requestServedFromCache" - EventNetworkResponseReceived MethodType = "Network.responseReceived" - EventNetworkDataReceived MethodType = "Network.dataReceived" - EventNetworkLoadingFinished MethodType = "Network.loadingFinished" - EventNetworkLoadingFailed MethodType = "Network.loadingFailed" - EventNetworkWebSocketWillSendHandshakeRequest MethodType = "Network.webSocketWillSendHandshakeRequest" - EventNetworkWebSocketHandshakeResponseReceived MethodType = "Network.webSocketHandshakeResponseReceived" - EventNetworkWebSocketCreated MethodType = "Network.webSocketCreated" - EventNetworkWebSocketClosed MethodType = "Network.webSocketClosed" - EventNetworkWebSocketFrameReceived MethodType = "Network.webSocketFrameReceived" - EventNetworkWebSocketFrameError MethodType = "Network.webSocketFrameError" - EventNetworkWebSocketFrameSent MethodType = "Network.webSocketFrameSent" - EventNetworkEventSourceMessageReceived MethodType = "Network.eventSourceMessageReceived" - EventNetworkRequestIntercepted MethodType = "Network.requestIntercepted" - CommandNetworkEnable MethodType = "Network.enable" - CommandNetworkDisable MethodType = "Network.disable" - CommandNetworkSetUserAgentOverride MethodType = "Network.setUserAgentOverride" - CommandNetworkSearchInResponseBody MethodType = "Network.searchInResponseBody" - CommandNetworkSetExtraHTTPHeaders MethodType = "Network.setExtraHTTPHeaders" - CommandNetworkGetResponseBody MethodType = "Network.getResponseBody" - CommandNetworkSetBlockedURLS MethodType = "Network.setBlockedURLs" - CommandNetworkReplayXHR MethodType = "Network.replayXHR" - CommandNetworkClearBrowserCache MethodType = "Network.clearBrowserCache" - CommandNetworkClearBrowserCookies MethodType = "Network.clearBrowserCookies" - CommandNetworkGetCookies MethodType = "Network.getCookies" - CommandNetworkGetAllCookies MethodType = "Network.getAllCookies" - CommandNetworkDeleteCookies MethodType = "Network.deleteCookies" - CommandNetworkSetCookie MethodType = "Network.setCookie" - CommandNetworkSetCookies MethodType = "Network.setCookies" - CommandNetworkEmulateNetworkConditions MethodType = "Network.emulateNetworkConditions" - CommandNetworkSetCacheDisabled MethodType = "Network.setCacheDisabled" - CommandNetworkSetBypassServiceWorker MethodType = "Network.setBypassServiceWorker" - CommandNetworkSetDataSizeLimitsForTest MethodType = "Network.setDataSizeLimitsForTest" - CommandNetworkGetCertificate MethodType = "Network.getCertificate" - CommandNetworkSetRequestInterception MethodType = "Network.setRequestInterception" - CommandNetworkContinueInterceptedRequest MethodType = "Network.continueInterceptedRequest" - CommandNetworkGetResponseBodyForInterception MethodType = "Network.getResponseBodyForInterception" - EventDatabaseAddDatabase MethodType = "Database.addDatabase" - CommandDatabaseEnable MethodType = "Database.enable" - CommandDatabaseDisable MethodType = "Database.disable" - CommandDatabaseGetDatabaseTableNames MethodType = "Database.getDatabaseTableNames" - CommandDatabaseExecuteSQL MethodType = "Database.executeSQL" - CommandIndexedDBEnable MethodType = "IndexedDB.enable" - CommandIndexedDBDisable MethodType = "IndexedDB.disable" - CommandIndexedDBRequestDatabaseNames MethodType = "IndexedDB.requestDatabaseNames" - CommandIndexedDBRequestDatabase MethodType = "IndexedDB.requestDatabase" - CommandIndexedDBRequestData MethodType = "IndexedDB.requestData" - CommandIndexedDBClearObjectStore MethodType = "IndexedDB.clearObjectStore" - CommandIndexedDBDeleteDatabase MethodType = "IndexedDB.deleteDatabase" - CommandCacheStorageRequestCacheNames MethodType = "CacheStorage.requestCacheNames" - CommandCacheStorageRequestEntries MethodType = "CacheStorage.requestEntries" - CommandCacheStorageDeleteCache MethodType = "CacheStorage.deleteCache" - CommandCacheStorageDeleteEntry MethodType = "CacheStorage.deleteEntry" - CommandCacheStorageRequestCachedResponse MethodType = "CacheStorage.requestCachedResponse" - EventDOMStorageDomStorageItemsCleared MethodType = "DOMStorage.domStorageItemsCleared" - EventDOMStorageDomStorageItemRemoved MethodType = "DOMStorage.domStorageItemRemoved" - EventDOMStorageDomStorageItemAdded MethodType = "DOMStorage.domStorageItemAdded" - EventDOMStorageDomStorageItemUpdated MethodType = "DOMStorage.domStorageItemUpdated" - CommandDOMStorageEnable MethodType = "DOMStorage.enable" - CommandDOMStorageDisable MethodType = "DOMStorage.disable" - CommandDOMStorageClear MethodType = "DOMStorage.clear" - CommandDOMStorageGetDOMStorageItems MethodType = "DOMStorage.getDOMStorageItems" - CommandDOMStorageSetDOMStorageItem MethodType = "DOMStorage.setDOMStorageItem" - CommandDOMStorageRemoveDOMStorageItem MethodType = "DOMStorage.removeDOMStorageItem" - EventApplicationCacheApplicationCacheStatusUpdated MethodType = "ApplicationCache.applicationCacheStatusUpdated" - EventApplicationCacheNetworkStateUpdated MethodType = "ApplicationCache.networkStateUpdated" - CommandApplicationCacheGetFramesWithManifests MethodType = "ApplicationCache.getFramesWithManifests" - CommandApplicationCacheEnable MethodType = "ApplicationCache.enable" - CommandApplicationCacheGetManifestForFrame MethodType = "ApplicationCache.getManifestForFrame" - CommandApplicationCacheGetApplicationCacheForFrame MethodType = "ApplicationCache.getApplicationCacheForFrame" - EventDOMDocumentUpdated MethodType = "DOM.documentUpdated" - EventDOMSetChildNodes MethodType = "DOM.setChildNodes" - EventDOMAttributeModified MethodType = "DOM.attributeModified" - EventDOMAttributeRemoved MethodType = "DOM.attributeRemoved" - EventDOMInlineStyleInvalidated MethodType = "DOM.inlineStyleInvalidated" - EventDOMCharacterDataModified MethodType = "DOM.characterDataModified" - EventDOMChildNodeCountUpdated MethodType = "DOM.childNodeCountUpdated" - EventDOMChildNodeInserted MethodType = "DOM.childNodeInserted" - EventDOMChildNodeRemoved MethodType = "DOM.childNodeRemoved" - EventDOMShadowRootPushed MethodType = "DOM.shadowRootPushed" - EventDOMShadowRootPopped MethodType = "DOM.shadowRootPopped" - EventDOMPseudoElementAdded MethodType = "DOM.pseudoElementAdded" - EventDOMPseudoElementRemoved MethodType = "DOM.pseudoElementRemoved" - EventDOMDistributedNodesUpdated MethodType = "DOM.distributedNodesUpdated" - CommandDOMEnable MethodType = "DOM.enable" - CommandDOMDisable MethodType = "DOM.disable" - CommandDOMGetDocument MethodType = "DOM.getDocument" - CommandDOMGetFlattenedDocument MethodType = "DOM.getFlattenedDocument" - CommandDOMCollectClassNamesFromSubtree MethodType = "DOM.collectClassNamesFromSubtree" - CommandDOMRequestChildNodes MethodType = "DOM.requestChildNodes" - CommandDOMQuerySelector MethodType = "DOM.querySelector" - CommandDOMQuerySelectorAll MethodType = "DOM.querySelectorAll" - CommandDOMSetNodeName MethodType = "DOM.setNodeName" - CommandDOMSetNodeValue MethodType = "DOM.setNodeValue" - CommandDOMRemoveNode MethodType = "DOM.removeNode" - CommandDOMSetAttributeValue MethodType = "DOM.setAttributeValue" - CommandDOMSetAttributesAsText MethodType = "DOM.setAttributesAsText" - CommandDOMRemoveAttribute MethodType = "DOM.removeAttribute" - CommandDOMGetOuterHTML MethodType = "DOM.getOuterHTML" - CommandDOMSetOuterHTML MethodType = "DOM.setOuterHTML" - CommandDOMPerformSearch MethodType = "DOM.performSearch" - CommandDOMGetSearchResults MethodType = "DOM.getSearchResults" - CommandDOMDiscardSearchResults MethodType = "DOM.discardSearchResults" - CommandDOMRequestNode MethodType = "DOM.requestNode" - CommandDOMPushNodeByPathToFrontend MethodType = "DOM.pushNodeByPathToFrontend" - CommandDOMPushNodesByBackendIdsToFrontend MethodType = "DOM.pushNodesByBackendIdsToFrontend" - CommandDOMSetInspectedNode MethodType = "DOM.setInspectedNode" - CommandDOMResolveNode MethodType = "DOM.resolveNode" - CommandDOMGetAttributes MethodType = "DOM.getAttributes" - CommandDOMCopyTo MethodType = "DOM.copyTo" - CommandDOMMoveTo MethodType = "DOM.moveTo" - CommandDOMUndo MethodType = "DOM.undo" - CommandDOMRedo MethodType = "DOM.redo" - CommandDOMMarkUndoableState MethodType = "DOM.markUndoableState" - CommandDOMFocus MethodType = "DOM.focus" - CommandDOMSetFileInputFiles MethodType = "DOM.setFileInputFiles" - CommandDOMGetBoxModel MethodType = "DOM.getBoxModel" - CommandDOMGetNodeForLocation MethodType = "DOM.getNodeForLocation" - CommandDOMGetRelayoutBoundary MethodType = "DOM.getRelayoutBoundary" - CommandDOMDescribeNode MethodType = "DOM.describeNode" - EventCSSMediaQueryResultChanged MethodType = "CSS.mediaQueryResultChanged" - EventCSSFontsUpdated MethodType = "CSS.fontsUpdated" - EventCSSStyleSheetChanged MethodType = "CSS.styleSheetChanged" - EventCSSStyleSheetAdded MethodType = "CSS.styleSheetAdded" - EventCSSStyleSheetRemoved MethodType = "CSS.styleSheetRemoved" - CommandCSSEnable MethodType = "CSS.enable" - CommandCSSDisable MethodType = "CSS.disable" - CommandCSSGetMatchedStylesForNode MethodType = "CSS.getMatchedStylesForNode" - CommandCSSGetInlineStylesForNode MethodType = "CSS.getInlineStylesForNode" - CommandCSSGetComputedStyleForNode MethodType = "CSS.getComputedStyleForNode" - CommandCSSGetPlatformFontsForNode MethodType = "CSS.getPlatformFontsForNode" - CommandCSSGetStyleSheetText MethodType = "CSS.getStyleSheetText" - CommandCSSCollectClassNames MethodType = "CSS.collectClassNames" - CommandCSSSetStyleSheetText MethodType = "CSS.setStyleSheetText" - CommandCSSSetRuleSelector MethodType = "CSS.setRuleSelector" - CommandCSSSetKeyframeKey MethodType = "CSS.setKeyframeKey" - CommandCSSSetStyleTexts MethodType = "CSS.setStyleTexts" - CommandCSSSetMediaText MethodType = "CSS.setMediaText" - CommandCSSCreateStyleSheet MethodType = "CSS.createStyleSheet" - CommandCSSAddRule MethodType = "CSS.addRule" - CommandCSSForcePseudoState MethodType = "CSS.forcePseudoState" - CommandCSSGetMediaQueries MethodType = "CSS.getMediaQueries" - CommandCSSSetEffectivePropertyValueForNode MethodType = "CSS.setEffectivePropertyValueForNode" - CommandCSSGetBackgroundColors MethodType = "CSS.getBackgroundColors" - CommandCSSStartRuleUsageTracking MethodType = "CSS.startRuleUsageTracking" - CommandCSSTakeCoverageDelta MethodType = "CSS.takeCoverageDelta" - CommandCSSStopRuleUsageTracking MethodType = "CSS.stopRuleUsageTracking" - CommandDOMSnapshotGetSnapshot MethodType = "DOMSnapshot.getSnapshot" - CommandIORead MethodType = "IO.read" - CommandIOClose MethodType = "IO.close" - CommandIOResolveBlob MethodType = "IO.resolveBlob" - CommandDOMDebuggerSetDOMBreakpoint MethodType = "DOMDebugger.setDOMBreakpoint" - CommandDOMDebuggerRemoveDOMBreakpoint MethodType = "DOMDebugger.removeDOMBreakpoint" - CommandDOMDebuggerSetEventListenerBreakpoint MethodType = "DOMDebugger.setEventListenerBreakpoint" - CommandDOMDebuggerRemoveEventListenerBreakpoint MethodType = "DOMDebugger.removeEventListenerBreakpoint" - CommandDOMDebuggerSetInstrumentationBreakpoint MethodType = "DOMDebugger.setInstrumentationBreakpoint" - CommandDOMDebuggerRemoveInstrumentationBreakpoint MethodType = "DOMDebugger.removeInstrumentationBreakpoint" - CommandDOMDebuggerSetXHRBreakpoint MethodType = "DOMDebugger.setXHRBreakpoint" - CommandDOMDebuggerRemoveXHRBreakpoint MethodType = "DOMDebugger.removeXHRBreakpoint" - CommandDOMDebuggerGetEventListeners MethodType = "DOMDebugger.getEventListeners" - EventTargetTargetCreated MethodType = "Target.targetCreated" - EventTargetTargetInfoChanged MethodType = "Target.targetInfoChanged" - EventTargetTargetDestroyed MethodType = "Target.targetDestroyed" - EventTargetAttachedToTarget MethodType = "Target.attachedToTarget" - EventTargetDetachedFromTarget MethodType = "Target.detachedFromTarget" - EventTargetReceivedMessageFromTarget MethodType = "Target.receivedMessageFromTarget" - CommandTargetSetDiscoverTargets MethodType = "Target.setDiscoverTargets" - CommandTargetSetAutoAttach MethodType = "Target.setAutoAttach" - CommandTargetSetAttachToFrames MethodType = "Target.setAttachToFrames" - CommandTargetSetRemoteLocations MethodType = "Target.setRemoteLocations" - CommandTargetSendMessageToTarget MethodType = "Target.sendMessageToTarget" - CommandTargetGetTargetInfo MethodType = "Target.getTargetInfo" - CommandTargetActivateTarget MethodType = "Target.activateTarget" - CommandTargetCloseTarget MethodType = "Target.closeTarget" - CommandTargetAttachToTarget MethodType = "Target.attachToTarget" - CommandTargetDetachFromTarget MethodType = "Target.detachFromTarget" - CommandTargetCreateBrowserContext MethodType = "Target.createBrowserContext" - CommandTargetDisposeBrowserContext MethodType = "Target.disposeBrowserContext" - CommandTargetCreateTarget MethodType = "Target.createTarget" - CommandTargetGetTargets MethodType = "Target.getTargets" - EventHeadlessExperimentalNeedsBeginFramesChanged MethodType = "HeadlessExperimental.needsBeginFramesChanged" - EventHeadlessExperimentalMainFrameReadyForScreenshots MethodType = "HeadlessExperimental.mainFrameReadyForScreenshots" - CommandHeadlessExperimentalEnable MethodType = "HeadlessExperimental.enable" - CommandHeadlessExperimentalDisable MethodType = "HeadlessExperimental.disable" - CommandHeadlessExperimentalBeginFrame MethodType = "HeadlessExperimental.beginFrame" - EventServiceWorkerWorkerRegistrationUpdated MethodType = "ServiceWorker.workerRegistrationUpdated" - EventServiceWorkerWorkerVersionUpdated MethodType = "ServiceWorker.workerVersionUpdated" - EventServiceWorkerWorkerErrorReported MethodType = "ServiceWorker.workerErrorReported" - CommandServiceWorkerEnable MethodType = "ServiceWorker.enable" - CommandServiceWorkerDisable MethodType = "ServiceWorker.disable" - CommandServiceWorkerUnregister MethodType = "ServiceWorker.unregister" - CommandServiceWorkerUpdateRegistration MethodType = "ServiceWorker.updateRegistration" - CommandServiceWorkerStartWorker MethodType = "ServiceWorker.startWorker" - CommandServiceWorkerSkipWaiting MethodType = "ServiceWorker.skipWaiting" - CommandServiceWorkerStopWorker MethodType = "ServiceWorker.stopWorker" - CommandServiceWorkerStopAllWorkers MethodType = "ServiceWorker.stopAllWorkers" - CommandServiceWorkerInspectWorker MethodType = "ServiceWorker.inspectWorker" - CommandServiceWorkerSetForceUpdateOnPageLoad MethodType = "ServiceWorker.setForceUpdateOnPageLoad" - CommandServiceWorkerDeliverPushMessage MethodType = "ServiceWorker.deliverPushMessage" - CommandServiceWorkerDispatchSyncEvent MethodType = "ServiceWorker.dispatchSyncEvent" - CommandInputSetIgnoreInputEvents MethodType = "Input.setIgnoreInputEvents" - CommandInputDispatchKeyEvent MethodType = "Input.dispatchKeyEvent" - CommandInputDispatchMouseEvent MethodType = "Input.dispatchMouseEvent" - CommandInputDispatchTouchEvent MethodType = "Input.dispatchTouchEvent" - CommandInputEmulateTouchFromMouseEvent MethodType = "Input.emulateTouchFromMouseEvent" - CommandInputSynthesizePinchGesture MethodType = "Input.synthesizePinchGesture" - CommandInputSynthesizeScrollGesture MethodType = "Input.synthesizeScrollGesture" - CommandInputSynthesizeTapGesture MethodType = "Input.synthesizeTapGesture" - EventLayerTreeLayerTreeDidChange MethodType = "LayerTree.layerTreeDidChange" - EventLayerTreeLayerPainted MethodType = "LayerTree.layerPainted" - CommandLayerTreeEnable MethodType = "LayerTree.enable" - CommandLayerTreeDisable MethodType = "LayerTree.disable" - CommandLayerTreeCompositingReasons MethodType = "LayerTree.compositingReasons" - CommandLayerTreeMakeSnapshot MethodType = "LayerTree.makeSnapshot" - CommandLayerTreeLoadSnapshot MethodType = "LayerTree.loadSnapshot" - CommandLayerTreeReleaseSnapshot MethodType = "LayerTree.releaseSnapshot" - CommandLayerTreeProfileSnapshot MethodType = "LayerTree.profileSnapshot" - CommandLayerTreeReplaySnapshot MethodType = "LayerTree.replaySnapshot" - CommandLayerTreeSnapshotCommandLog MethodType = "LayerTree.snapshotCommandLog" - CommandDeviceOrientationSetDeviceOrientationOverride MethodType = "DeviceOrientation.setDeviceOrientationOverride" - CommandDeviceOrientationClearDeviceOrientationOverride MethodType = "DeviceOrientation.clearDeviceOrientationOverride" - EventTracingDataCollected MethodType = "Tracing.dataCollected" - EventTracingTracingComplete MethodType = "Tracing.tracingComplete" - EventTracingBufferUsage MethodType = "Tracing.bufferUsage" - CommandTracingStart MethodType = "Tracing.start" - CommandTracingEnd MethodType = "Tracing.end" - CommandTracingGetCategories MethodType = "Tracing.getCategories" - CommandTracingRequestMemoryDump MethodType = "Tracing.requestMemoryDump" - CommandTracingRecordClockSyncMarker MethodType = "Tracing.recordClockSyncMarker" - EventAnimationAnimationCreated MethodType = "Animation.animationCreated" - EventAnimationAnimationStarted MethodType = "Animation.animationStarted" - EventAnimationAnimationCanceled MethodType = "Animation.animationCanceled" - CommandAnimationEnable MethodType = "Animation.enable" - CommandAnimationDisable MethodType = "Animation.disable" - CommandAnimationGetPlaybackRate MethodType = "Animation.getPlaybackRate" - CommandAnimationSetPlaybackRate MethodType = "Animation.setPlaybackRate" - CommandAnimationGetCurrentTime MethodType = "Animation.getCurrentTime" - CommandAnimationSetPaused MethodType = "Animation.setPaused" - CommandAnimationSetTiming MethodType = "Animation.setTiming" - CommandAnimationSeekAnimations MethodType = "Animation.seekAnimations" - CommandAnimationReleaseAnimations MethodType = "Animation.releaseAnimations" - CommandAnimationResolveAnimation MethodType = "Animation.resolveAnimation" - CommandAccessibilityGetPartialAXTree MethodType = "Accessibility.getPartialAXTree" - EventStorageCacheStorageListUpdated MethodType = "Storage.cacheStorageListUpdated" - EventStorageCacheStorageContentUpdated MethodType = "Storage.cacheStorageContentUpdated" - EventStorageIndexedDBListUpdated MethodType = "Storage.indexedDBListUpdated" - EventStorageIndexedDBContentUpdated MethodType = "Storage.indexedDBContentUpdated" - CommandStorageClearDataForOrigin MethodType = "Storage.clearDataForOrigin" - CommandStorageGetUsageAndQuota MethodType = "Storage.getUsageAndQuota" - CommandStorageTrackCacheStorageForOrigin MethodType = "Storage.trackCacheStorageForOrigin" - CommandStorageUntrackCacheStorageForOrigin MethodType = "Storage.untrackCacheStorageForOrigin" - CommandStorageTrackIndexedDBForOrigin MethodType = "Storage.trackIndexedDBForOrigin" - CommandStorageUntrackIndexedDBForOrigin MethodType = "Storage.untrackIndexedDBForOrigin" - EventLogEntryAdded MethodType = "Log.entryAdded" - CommandLogEnable MethodType = "Log.enable" - CommandLogDisable MethodType = "Log.disable" - CommandLogClear MethodType = "Log.clear" - CommandLogStartViolationsReport MethodType = "Log.startViolationsReport" - CommandLogStopViolationsReport MethodType = "Log.stopViolationsReport" - CommandSystemInfoGetInfo MethodType = "SystemInfo.getInfo" - EventTetheringAccepted MethodType = "Tethering.accepted" - CommandTetheringBind MethodType = "Tethering.bind" - CommandTetheringUnbind MethodType = "Tethering.unbind" - CommandBrowserClose MethodType = "Browser.close" - CommandBrowserGetWindowForTarget MethodType = "Browser.getWindowForTarget" - CommandBrowserGetVersion MethodType = "Browser.getVersion" - CommandBrowserSetWindowBounds MethodType = "Browser.setWindowBounds" - CommandBrowserGetWindowBounds MethodType = "Browser.getWindowBounds" - EventRuntimeExecutionContextCreated MethodType = "Runtime.executionContextCreated" - EventRuntimeExecutionContextDestroyed MethodType = "Runtime.executionContextDestroyed" - EventRuntimeExecutionContextsCleared MethodType = "Runtime.executionContextsCleared" - EventRuntimeExceptionThrown MethodType = "Runtime.exceptionThrown" - EventRuntimeExceptionRevoked MethodType = "Runtime.exceptionRevoked" - EventRuntimeConsoleAPICalled MethodType = "Runtime.consoleAPICalled" - EventRuntimeInspectRequested MethodType = "Runtime.inspectRequested" - CommandRuntimeEvaluate MethodType = "Runtime.evaluate" - CommandRuntimeAwaitPromise MethodType = "Runtime.awaitPromise" - CommandRuntimeCallFunctionOn MethodType = "Runtime.callFunctionOn" - CommandRuntimeGetProperties MethodType = "Runtime.getProperties" - CommandRuntimeReleaseObject MethodType = "Runtime.releaseObject" - CommandRuntimeReleaseObjectGroup MethodType = "Runtime.releaseObjectGroup" - CommandRuntimeRunIfWaitingForDebugger MethodType = "Runtime.runIfWaitingForDebugger" - CommandRuntimeEnable MethodType = "Runtime.enable" - CommandRuntimeDisable MethodType = "Runtime.disable" - CommandRuntimeDiscardConsoleEntries MethodType = "Runtime.discardConsoleEntries" - CommandRuntimeSetCustomObjectFormatterEnabled MethodType = "Runtime.setCustomObjectFormatterEnabled" - CommandRuntimeCompileScript MethodType = "Runtime.compileScript" - CommandRuntimeRunScript MethodType = "Runtime.runScript" - CommandRuntimeQueryObjects MethodType = "Runtime.queryObjects" - CommandRuntimeGlobalLexicalScopeNames MethodType = "Runtime.globalLexicalScopeNames" - EventDebuggerScriptParsed MethodType = "Debugger.scriptParsed" - EventDebuggerScriptFailedToParse MethodType = "Debugger.scriptFailedToParse" - EventDebuggerBreakpointResolved MethodType = "Debugger.breakpointResolved" - EventDebuggerPaused MethodType = "Debugger.paused" - EventDebuggerResumed MethodType = "Debugger.resumed" - CommandDebuggerEnable MethodType = "Debugger.enable" - CommandDebuggerDisable MethodType = "Debugger.disable" - CommandDebuggerSetBreakpointsActive MethodType = "Debugger.setBreakpointsActive" - CommandDebuggerSetSkipAllPauses MethodType = "Debugger.setSkipAllPauses" - CommandDebuggerSetBreakpointByURL MethodType = "Debugger.setBreakpointByUrl" - CommandDebuggerSetBreakpoint MethodType = "Debugger.setBreakpoint" - CommandDebuggerRemoveBreakpoint MethodType = "Debugger.removeBreakpoint" - CommandDebuggerGetPossibleBreakpoints MethodType = "Debugger.getPossibleBreakpoints" - CommandDebuggerContinueToLocation MethodType = "Debugger.continueToLocation" - CommandDebuggerPauseOnAsyncCall MethodType = "Debugger.pauseOnAsyncCall" - CommandDebuggerStepOver MethodType = "Debugger.stepOver" - CommandDebuggerStepInto MethodType = "Debugger.stepInto" - CommandDebuggerStepOut MethodType = "Debugger.stepOut" - CommandDebuggerPause MethodType = "Debugger.pause" - CommandDebuggerScheduleStepIntoAsync MethodType = "Debugger.scheduleStepIntoAsync" - CommandDebuggerResume MethodType = "Debugger.resume" - CommandDebuggerGetStackTrace MethodType = "Debugger.getStackTrace" - CommandDebuggerSearchInContent MethodType = "Debugger.searchInContent" - CommandDebuggerSetScriptSource MethodType = "Debugger.setScriptSource" - CommandDebuggerRestartFrame MethodType = "Debugger.restartFrame" - CommandDebuggerGetScriptSource MethodType = "Debugger.getScriptSource" - CommandDebuggerSetPauseOnExceptions MethodType = "Debugger.setPauseOnExceptions" - CommandDebuggerEvaluateOnCallFrame MethodType = "Debugger.evaluateOnCallFrame" - CommandDebuggerSetVariableValue MethodType = "Debugger.setVariableValue" - CommandDebuggerSetReturnValue MethodType = "Debugger.setReturnValue" - CommandDebuggerSetAsyncCallStackDepth MethodType = "Debugger.setAsyncCallStackDepth" - CommandDebuggerSetBlackboxPatterns MethodType = "Debugger.setBlackboxPatterns" - CommandDebuggerSetBlackboxedRanges MethodType = "Debugger.setBlackboxedRanges" - EventProfilerConsoleProfileStarted MethodType = "Profiler.consoleProfileStarted" - EventProfilerConsoleProfileFinished MethodType = "Profiler.consoleProfileFinished" - CommandProfilerEnable MethodType = "Profiler.enable" - CommandProfilerDisable MethodType = "Profiler.disable" - CommandProfilerSetSamplingInterval MethodType = "Profiler.setSamplingInterval" - CommandProfilerStart MethodType = "Profiler.start" - CommandProfilerStop MethodType = "Profiler.stop" - CommandProfilerStartPreciseCoverage MethodType = "Profiler.startPreciseCoverage" - CommandProfilerStopPreciseCoverage MethodType = "Profiler.stopPreciseCoverage" - CommandProfilerTakePreciseCoverage MethodType = "Profiler.takePreciseCoverage" - CommandProfilerGetBestEffortCoverage MethodType = "Profiler.getBestEffortCoverage" - CommandProfilerStartTypeProfile MethodType = "Profiler.startTypeProfile" - CommandProfilerStopTypeProfile MethodType = "Profiler.stopTypeProfile" - CommandProfilerTakeTypeProfile MethodType = "Profiler.takeTypeProfile" - EventHeapProfilerAddHeapSnapshotChunk MethodType = "HeapProfiler.addHeapSnapshotChunk" - EventHeapProfilerResetProfiles MethodType = "HeapProfiler.resetProfiles" - EventHeapProfilerReportHeapSnapshotProgress MethodType = "HeapProfiler.reportHeapSnapshotProgress" - EventHeapProfilerLastSeenObjectID MethodType = "HeapProfiler.lastSeenObjectId" - EventHeapProfilerHeapStatsUpdate MethodType = "HeapProfiler.heapStatsUpdate" - CommandHeapProfilerEnable MethodType = "HeapProfiler.enable" - CommandHeapProfilerDisable MethodType = "HeapProfiler.disable" - CommandHeapProfilerStartTrackingHeapObjects MethodType = "HeapProfiler.startTrackingHeapObjects" - CommandHeapProfilerStopTrackingHeapObjects MethodType = "HeapProfiler.stopTrackingHeapObjects" - CommandHeapProfilerTakeHeapSnapshot MethodType = "HeapProfiler.takeHeapSnapshot" - CommandHeapProfilerCollectGarbage MethodType = "HeapProfiler.collectGarbage" - CommandHeapProfilerGetObjectByHeapObjectID MethodType = "HeapProfiler.getObjectByHeapObjectId" - CommandHeapProfilerAddInspectedHeapObject MethodType = "HeapProfiler.addInspectedHeapObject" - CommandHeapProfilerGetHeapObjectID MethodType = "HeapProfiler.getHeapObjectId" - CommandHeapProfilerStartSampling MethodType = "HeapProfiler.startSampling" - CommandHeapProfilerStopSampling MethodType = "HeapProfiler.stopSampling" - CommandHeapProfilerGetSamplingProfile MethodType = "HeapProfiler.getSamplingProfile" -) - -// MarshalEasyJSON satisfies easyjson.Marshaler. -func (t MethodType) MarshalEasyJSON(out *jwriter.Writer) { - out.String(string(t)) -} - -// MarshalJSON satisfies json.Marshaler. -func (t MethodType) MarshalJSON() ([]byte, error) { - return easyjson.Marshal(t) -} - -// UnmarshalEasyJSON satisfies easyjson.Unmarshaler. -func (t *MethodType) UnmarshalEasyJSON(in *jlexer.Lexer) { - switch MethodType(in.String()) { - case EventInspectorDetached: - *t = EventInspectorDetached - case EventInspectorTargetCrashed: - *t = EventInspectorTargetCrashed - case CommandInspectorEnable: - *t = CommandInspectorEnable - case CommandInspectorDisable: - *t = CommandInspectorDisable - case CommandMemoryGetDOMCounters: - *t = CommandMemoryGetDOMCounters - case CommandMemoryPrepareForLeakDetection: - *t = CommandMemoryPrepareForLeakDetection - case CommandMemorySetPressureNotificationsSuppressed: - *t = CommandMemorySetPressureNotificationsSuppressed - case CommandMemorySimulatePressureNotification: - *t = CommandMemorySimulatePressureNotification - case EventPerformanceMetrics: - *t = EventPerformanceMetrics - case CommandPerformanceEnable: - *t = CommandPerformanceEnable - case CommandPerformanceDisable: - *t = CommandPerformanceDisable - case CommandPerformanceGetMetrics: - *t = CommandPerformanceGetMetrics - case EventPageDomContentEventFired: - *t = EventPageDomContentEventFired - case EventPageLoadEventFired: - *t = EventPageLoadEventFired - case EventPageLifecycleEvent: - *t = EventPageLifecycleEvent - case EventPageFrameAttached: - *t = EventPageFrameAttached - case EventPageFrameNavigated: - *t = EventPageFrameNavigated - case EventPageFrameDetached: - *t = EventPageFrameDetached - case EventPageFrameStartedLoading: - *t = EventPageFrameStartedLoading - case EventPageFrameStoppedLoading: - *t = EventPageFrameStoppedLoading - case EventPageFrameScheduledNavigation: - *t = EventPageFrameScheduledNavigation - case EventPageFrameClearedScheduledNavigation: - *t = EventPageFrameClearedScheduledNavigation - case EventPageFrameResized: - *t = EventPageFrameResized - case EventPageJavascriptDialogOpening: - *t = EventPageJavascriptDialogOpening - case EventPageJavascriptDialogClosed: - *t = EventPageJavascriptDialogClosed - case EventPageScreencastFrame: - *t = EventPageScreencastFrame - case EventPageScreencastVisibilityChanged: - *t = EventPageScreencastVisibilityChanged - case EventPageInterstitialShown: - *t = EventPageInterstitialShown - case EventPageInterstitialHidden: - *t = EventPageInterstitialHidden - case EventPageWindowOpen: - *t = EventPageWindowOpen - case CommandPageEnable: - *t = CommandPageEnable - case CommandPageDisable: - *t = CommandPageDisable - case CommandPageAddScriptToEvaluateOnNewDocument: - *t = CommandPageAddScriptToEvaluateOnNewDocument - case CommandPageRemoveScriptToEvaluateOnNewDocument: - *t = CommandPageRemoveScriptToEvaluateOnNewDocument - case CommandPageSetAutoAttachToCreatedPages: - *t = CommandPageSetAutoAttachToCreatedPages - case CommandPageSetLifecycleEventsEnabled: - *t = CommandPageSetLifecycleEventsEnabled - case CommandPageReload: - *t = CommandPageReload - case CommandPageSetAdBlockingEnabled: - *t = CommandPageSetAdBlockingEnabled - case CommandPageNavigate: - *t = CommandPageNavigate - case CommandPageStopLoading: - *t = CommandPageStopLoading - case CommandPageGetNavigationHistory: - *t = CommandPageGetNavigationHistory - case CommandPageNavigateToHistoryEntry: - *t = CommandPageNavigateToHistoryEntry - case CommandPageGetResourceTree: - *t = CommandPageGetResourceTree - case CommandPageGetFrameTree: - *t = CommandPageGetFrameTree - case CommandPageGetResourceContent: - *t = CommandPageGetResourceContent - case CommandPageSearchInResource: - *t = CommandPageSearchInResource - case CommandPageSetDocumentContent: - *t = CommandPageSetDocumentContent - case CommandPageCaptureScreenshot: - *t = CommandPageCaptureScreenshot - case CommandPagePrintToPDF: - *t = CommandPagePrintToPDF - case CommandPageStartScreencast: - *t = CommandPageStartScreencast - case CommandPageStopScreencast: - *t = CommandPageStopScreencast - case CommandPageScreencastFrameAck: - *t = CommandPageScreencastFrameAck - case CommandPageHandleJavaScriptDialog: - *t = CommandPageHandleJavaScriptDialog - case CommandPageGetAppManifest: - *t = CommandPageGetAppManifest - case CommandPageRequestAppBanner: - *t = CommandPageRequestAppBanner - case CommandPageGetLayoutMetrics: - *t = CommandPageGetLayoutMetrics - case CommandPageCreateIsolatedWorld: - *t = CommandPageCreateIsolatedWorld - case CommandPageBringToFront: - *t = CommandPageBringToFront - case CommandPageSetDownloadBehavior: - *t = CommandPageSetDownloadBehavior - case EventOverlayNodeHighlightRequested: - *t = EventOverlayNodeHighlightRequested - case EventOverlayInspectNodeRequested: - *t = EventOverlayInspectNodeRequested - case EventOverlayScreenshotRequested: - *t = EventOverlayScreenshotRequested - case CommandOverlayEnable: - *t = CommandOverlayEnable - case CommandOverlayDisable: - *t = CommandOverlayDisable - case CommandOverlaySetShowPaintRects: - *t = CommandOverlaySetShowPaintRects - case CommandOverlaySetShowDebugBorders: - *t = CommandOverlaySetShowDebugBorders - case CommandOverlaySetShowFPSCounter: - *t = CommandOverlaySetShowFPSCounter - case CommandOverlaySetShowScrollBottleneckRects: - *t = CommandOverlaySetShowScrollBottleneckRects - case CommandOverlaySetShowViewportSizeOnResize: - *t = CommandOverlaySetShowViewportSizeOnResize - case CommandOverlaySetPausedInDebuggerMessage: - *t = CommandOverlaySetPausedInDebuggerMessage - case CommandOverlaySetSuspended: - *t = CommandOverlaySetSuspended - case CommandOverlaySetInspectMode: - *t = CommandOverlaySetInspectMode - case CommandOverlayHighlightRect: - *t = CommandOverlayHighlightRect - case CommandOverlayHighlightQuad: - *t = CommandOverlayHighlightQuad - case CommandOverlayHighlightNode: - *t = CommandOverlayHighlightNode - case CommandOverlayHighlightFrame: - *t = CommandOverlayHighlightFrame - case CommandOverlayHideHighlight: - *t = CommandOverlayHideHighlight - case CommandOverlayGetHighlightObjectForTest: - *t = CommandOverlayGetHighlightObjectForTest - case EventEmulationVirtualTimeBudgetExpired: - *t = EventEmulationVirtualTimeBudgetExpired - case EventEmulationVirtualTimeAdvanced: - *t = EventEmulationVirtualTimeAdvanced - case EventEmulationVirtualTimePaused: - *t = EventEmulationVirtualTimePaused - case CommandEmulationSetDeviceMetricsOverride: - *t = CommandEmulationSetDeviceMetricsOverride - case CommandEmulationClearDeviceMetricsOverride: - *t = CommandEmulationClearDeviceMetricsOverride - case CommandEmulationResetPageScaleFactor: - *t = CommandEmulationResetPageScaleFactor - case CommandEmulationSetPageScaleFactor: - *t = CommandEmulationSetPageScaleFactor - case CommandEmulationSetScriptExecutionDisabled: - *t = CommandEmulationSetScriptExecutionDisabled - case CommandEmulationSetGeolocationOverride: - *t = CommandEmulationSetGeolocationOverride - case CommandEmulationClearGeolocationOverride: - *t = CommandEmulationClearGeolocationOverride - case CommandEmulationSetTouchEmulationEnabled: - *t = CommandEmulationSetTouchEmulationEnabled - case CommandEmulationSetEmitTouchEventsForMouse: - *t = CommandEmulationSetEmitTouchEventsForMouse - case CommandEmulationSetEmulatedMedia: - *t = CommandEmulationSetEmulatedMedia - case CommandEmulationSetCPUThrottlingRate: - *t = CommandEmulationSetCPUThrottlingRate - case CommandEmulationCanEmulate: - *t = CommandEmulationCanEmulate - case CommandEmulationSetVirtualTimePolicy: - *t = CommandEmulationSetVirtualTimePolicy - case CommandEmulationSetNavigatorOverrides: - *t = CommandEmulationSetNavigatorOverrides - case CommandEmulationSetDefaultBackgroundColorOverride: - *t = CommandEmulationSetDefaultBackgroundColorOverride - case EventSecuritySecurityStateChanged: - *t = EventSecuritySecurityStateChanged - case EventSecurityCertificateError: - *t = EventSecurityCertificateError - case CommandSecurityEnable: - *t = CommandSecurityEnable - case CommandSecurityDisable: - *t = CommandSecurityDisable - case CommandSecurityHandleCertificateError: - *t = CommandSecurityHandleCertificateError - case CommandSecuritySetOverrideCertificateErrors: - *t = CommandSecuritySetOverrideCertificateErrors - case CommandAuditsGetEncodedResponse: - *t = CommandAuditsGetEncodedResponse - case EventNetworkResourceChangedPriority: - *t = EventNetworkResourceChangedPriority - case EventNetworkRequestWillBeSent: - *t = EventNetworkRequestWillBeSent - case EventNetworkRequestServedFromCache: - *t = EventNetworkRequestServedFromCache - case EventNetworkResponseReceived: - *t = EventNetworkResponseReceived - case EventNetworkDataReceived: - *t = EventNetworkDataReceived - case EventNetworkLoadingFinished: - *t = EventNetworkLoadingFinished - case EventNetworkLoadingFailed: - *t = EventNetworkLoadingFailed - case EventNetworkWebSocketWillSendHandshakeRequest: - *t = EventNetworkWebSocketWillSendHandshakeRequest - case EventNetworkWebSocketHandshakeResponseReceived: - *t = EventNetworkWebSocketHandshakeResponseReceived - case EventNetworkWebSocketCreated: - *t = EventNetworkWebSocketCreated - case EventNetworkWebSocketClosed: - *t = EventNetworkWebSocketClosed - case EventNetworkWebSocketFrameReceived: - *t = EventNetworkWebSocketFrameReceived - case EventNetworkWebSocketFrameError: - *t = EventNetworkWebSocketFrameError - case EventNetworkWebSocketFrameSent: - *t = EventNetworkWebSocketFrameSent - case EventNetworkEventSourceMessageReceived: - *t = EventNetworkEventSourceMessageReceived - case EventNetworkRequestIntercepted: - *t = EventNetworkRequestIntercepted - case CommandNetworkEnable: - *t = CommandNetworkEnable - case CommandNetworkDisable: - *t = CommandNetworkDisable - case CommandNetworkSetUserAgentOverride: - *t = CommandNetworkSetUserAgentOverride - case CommandNetworkSearchInResponseBody: - *t = CommandNetworkSearchInResponseBody - case CommandNetworkSetExtraHTTPHeaders: - *t = CommandNetworkSetExtraHTTPHeaders - case CommandNetworkGetResponseBody: - *t = CommandNetworkGetResponseBody - case CommandNetworkSetBlockedURLS: - *t = CommandNetworkSetBlockedURLS - case CommandNetworkReplayXHR: - *t = CommandNetworkReplayXHR - case CommandNetworkClearBrowserCache: - *t = CommandNetworkClearBrowserCache - case CommandNetworkClearBrowserCookies: - *t = CommandNetworkClearBrowserCookies - case CommandNetworkGetCookies: - *t = CommandNetworkGetCookies - case CommandNetworkGetAllCookies: - *t = CommandNetworkGetAllCookies - case CommandNetworkDeleteCookies: - *t = CommandNetworkDeleteCookies - case CommandNetworkSetCookie: - *t = CommandNetworkSetCookie - case CommandNetworkSetCookies: - *t = CommandNetworkSetCookies - case CommandNetworkEmulateNetworkConditions: - *t = CommandNetworkEmulateNetworkConditions - case CommandNetworkSetCacheDisabled: - *t = CommandNetworkSetCacheDisabled - case CommandNetworkSetBypassServiceWorker: - *t = CommandNetworkSetBypassServiceWorker - case CommandNetworkSetDataSizeLimitsForTest: - *t = CommandNetworkSetDataSizeLimitsForTest - case CommandNetworkGetCertificate: - *t = CommandNetworkGetCertificate - case CommandNetworkSetRequestInterception: - *t = CommandNetworkSetRequestInterception - case CommandNetworkContinueInterceptedRequest: - *t = CommandNetworkContinueInterceptedRequest - case CommandNetworkGetResponseBodyForInterception: - *t = CommandNetworkGetResponseBodyForInterception - case EventDatabaseAddDatabase: - *t = EventDatabaseAddDatabase - case CommandDatabaseEnable: - *t = CommandDatabaseEnable - case CommandDatabaseDisable: - *t = CommandDatabaseDisable - case CommandDatabaseGetDatabaseTableNames: - *t = CommandDatabaseGetDatabaseTableNames - case CommandDatabaseExecuteSQL: - *t = CommandDatabaseExecuteSQL - case CommandIndexedDBEnable: - *t = CommandIndexedDBEnable - case CommandIndexedDBDisable: - *t = CommandIndexedDBDisable - case CommandIndexedDBRequestDatabaseNames: - *t = CommandIndexedDBRequestDatabaseNames - case CommandIndexedDBRequestDatabase: - *t = CommandIndexedDBRequestDatabase - case CommandIndexedDBRequestData: - *t = CommandIndexedDBRequestData - case CommandIndexedDBClearObjectStore: - *t = CommandIndexedDBClearObjectStore - case CommandIndexedDBDeleteDatabase: - *t = CommandIndexedDBDeleteDatabase - case CommandCacheStorageRequestCacheNames: - *t = CommandCacheStorageRequestCacheNames - case CommandCacheStorageRequestEntries: - *t = CommandCacheStorageRequestEntries - case CommandCacheStorageDeleteCache: - *t = CommandCacheStorageDeleteCache - case CommandCacheStorageDeleteEntry: - *t = CommandCacheStorageDeleteEntry - case CommandCacheStorageRequestCachedResponse: - *t = CommandCacheStorageRequestCachedResponse - case EventDOMStorageDomStorageItemsCleared: - *t = EventDOMStorageDomStorageItemsCleared - case EventDOMStorageDomStorageItemRemoved: - *t = EventDOMStorageDomStorageItemRemoved - case EventDOMStorageDomStorageItemAdded: - *t = EventDOMStorageDomStorageItemAdded - case EventDOMStorageDomStorageItemUpdated: - *t = EventDOMStorageDomStorageItemUpdated - case CommandDOMStorageEnable: - *t = CommandDOMStorageEnable - case CommandDOMStorageDisable: - *t = CommandDOMStorageDisable - case CommandDOMStorageClear: - *t = CommandDOMStorageClear - case CommandDOMStorageGetDOMStorageItems: - *t = CommandDOMStorageGetDOMStorageItems - case CommandDOMStorageSetDOMStorageItem: - *t = CommandDOMStorageSetDOMStorageItem - case CommandDOMStorageRemoveDOMStorageItem: - *t = CommandDOMStorageRemoveDOMStorageItem - case EventApplicationCacheApplicationCacheStatusUpdated: - *t = EventApplicationCacheApplicationCacheStatusUpdated - case EventApplicationCacheNetworkStateUpdated: - *t = EventApplicationCacheNetworkStateUpdated - case CommandApplicationCacheGetFramesWithManifests: - *t = CommandApplicationCacheGetFramesWithManifests - case CommandApplicationCacheEnable: - *t = CommandApplicationCacheEnable - case CommandApplicationCacheGetManifestForFrame: - *t = CommandApplicationCacheGetManifestForFrame - case CommandApplicationCacheGetApplicationCacheForFrame: - *t = CommandApplicationCacheGetApplicationCacheForFrame - case EventDOMDocumentUpdated: - *t = EventDOMDocumentUpdated - case EventDOMSetChildNodes: - *t = EventDOMSetChildNodes - case EventDOMAttributeModified: - *t = EventDOMAttributeModified - case EventDOMAttributeRemoved: - *t = EventDOMAttributeRemoved - case EventDOMInlineStyleInvalidated: - *t = EventDOMInlineStyleInvalidated - case EventDOMCharacterDataModified: - *t = EventDOMCharacterDataModified - case EventDOMChildNodeCountUpdated: - *t = EventDOMChildNodeCountUpdated - case EventDOMChildNodeInserted: - *t = EventDOMChildNodeInserted - case EventDOMChildNodeRemoved: - *t = EventDOMChildNodeRemoved - case EventDOMShadowRootPushed: - *t = EventDOMShadowRootPushed - case EventDOMShadowRootPopped: - *t = EventDOMShadowRootPopped - case EventDOMPseudoElementAdded: - *t = EventDOMPseudoElementAdded - case EventDOMPseudoElementRemoved: - *t = EventDOMPseudoElementRemoved - case EventDOMDistributedNodesUpdated: - *t = EventDOMDistributedNodesUpdated - case CommandDOMEnable: - *t = CommandDOMEnable - case CommandDOMDisable: - *t = CommandDOMDisable - case CommandDOMGetDocument: - *t = CommandDOMGetDocument - case CommandDOMGetFlattenedDocument: - *t = CommandDOMGetFlattenedDocument - case CommandDOMCollectClassNamesFromSubtree: - *t = CommandDOMCollectClassNamesFromSubtree - case CommandDOMRequestChildNodes: - *t = CommandDOMRequestChildNodes - case CommandDOMQuerySelector: - *t = CommandDOMQuerySelector - case CommandDOMQuerySelectorAll: - *t = CommandDOMQuerySelectorAll - case CommandDOMSetNodeName: - *t = CommandDOMSetNodeName - case CommandDOMSetNodeValue: - *t = CommandDOMSetNodeValue - case CommandDOMRemoveNode: - *t = CommandDOMRemoveNode - case CommandDOMSetAttributeValue: - *t = CommandDOMSetAttributeValue - case CommandDOMSetAttributesAsText: - *t = CommandDOMSetAttributesAsText - case CommandDOMRemoveAttribute: - *t = CommandDOMRemoveAttribute - case CommandDOMGetOuterHTML: - *t = CommandDOMGetOuterHTML - case CommandDOMSetOuterHTML: - *t = CommandDOMSetOuterHTML - case CommandDOMPerformSearch: - *t = CommandDOMPerformSearch - case CommandDOMGetSearchResults: - *t = CommandDOMGetSearchResults - case CommandDOMDiscardSearchResults: - *t = CommandDOMDiscardSearchResults - case CommandDOMRequestNode: - *t = CommandDOMRequestNode - case CommandDOMPushNodeByPathToFrontend: - *t = CommandDOMPushNodeByPathToFrontend - case CommandDOMPushNodesByBackendIdsToFrontend: - *t = CommandDOMPushNodesByBackendIdsToFrontend - case CommandDOMSetInspectedNode: - *t = CommandDOMSetInspectedNode - case CommandDOMResolveNode: - *t = CommandDOMResolveNode - case CommandDOMGetAttributes: - *t = CommandDOMGetAttributes - case CommandDOMCopyTo: - *t = CommandDOMCopyTo - case CommandDOMMoveTo: - *t = CommandDOMMoveTo - case CommandDOMUndo: - *t = CommandDOMUndo - case CommandDOMRedo: - *t = CommandDOMRedo - case CommandDOMMarkUndoableState: - *t = CommandDOMMarkUndoableState - case CommandDOMFocus: - *t = CommandDOMFocus - case CommandDOMSetFileInputFiles: - *t = CommandDOMSetFileInputFiles - case CommandDOMGetBoxModel: - *t = CommandDOMGetBoxModel - case CommandDOMGetNodeForLocation: - *t = CommandDOMGetNodeForLocation - case CommandDOMGetRelayoutBoundary: - *t = CommandDOMGetRelayoutBoundary - case CommandDOMDescribeNode: - *t = CommandDOMDescribeNode - case EventCSSMediaQueryResultChanged: - *t = EventCSSMediaQueryResultChanged - case EventCSSFontsUpdated: - *t = EventCSSFontsUpdated - case EventCSSStyleSheetChanged: - *t = EventCSSStyleSheetChanged - case EventCSSStyleSheetAdded: - *t = EventCSSStyleSheetAdded - case EventCSSStyleSheetRemoved: - *t = EventCSSStyleSheetRemoved - case CommandCSSEnable: - *t = CommandCSSEnable - case CommandCSSDisable: - *t = CommandCSSDisable - case CommandCSSGetMatchedStylesForNode: - *t = CommandCSSGetMatchedStylesForNode - case CommandCSSGetInlineStylesForNode: - *t = CommandCSSGetInlineStylesForNode - case CommandCSSGetComputedStyleForNode: - *t = CommandCSSGetComputedStyleForNode - case CommandCSSGetPlatformFontsForNode: - *t = CommandCSSGetPlatformFontsForNode - case CommandCSSGetStyleSheetText: - *t = CommandCSSGetStyleSheetText - case CommandCSSCollectClassNames: - *t = CommandCSSCollectClassNames - case CommandCSSSetStyleSheetText: - *t = CommandCSSSetStyleSheetText - case CommandCSSSetRuleSelector: - *t = CommandCSSSetRuleSelector - case CommandCSSSetKeyframeKey: - *t = CommandCSSSetKeyframeKey - case CommandCSSSetStyleTexts: - *t = CommandCSSSetStyleTexts - case CommandCSSSetMediaText: - *t = CommandCSSSetMediaText - case CommandCSSCreateStyleSheet: - *t = CommandCSSCreateStyleSheet - case CommandCSSAddRule: - *t = CommandCSSAddRule - case CommandCSSForcePseudoState: - *t = CommandCSSForcePseudoState - case CommandCSSGetMediaQueries: - *t = CommandCSSGetMediaQueries - case CommandCSSSetEffectivePropertyValueForNode: - *t = CommandCSSSetEffectivePropertyValueForNode - case CommandCSSGetBackgroundColors: - *t = CommandCSSGetBackgroundColors - case CommandCSSStartRuleUsageTracking: - *t = CommandCSSStartRuleUsageTracking - case CommandCSSTakeCoverageDelta: - *t = CommandCSSTakeCoverageDelta - case CommandCSSStopRuleUsageTracking: - *t = CommandCSSStopRuleUsageTracking - case CommandDOMSnapshotGetSnapshot: - *t = CommandDOMSnapshotGetSnapshot - case CommandIORead: - *t = CommandIORead - case CommandIOClose: - *t = CommandIOClose - case CommandIOResolveBlob: - *t = CommandIOResolveBlob - case CommandDOMDebuggerSetDOMBreakpoint: - *t = CommandDOMDebuggerSetDOMBreakpoint - case CommandDOMDebuggerRemoveDOMBreakpoint: - *t = CommandDOMDebuggerRemoveDOMBreakpoint - case CommandDOMDebuggerSetEventListenerBreakpoint: - *t = CommandDOMDebuggerSetEventListenerBreakpoint - case CommandDOMDebuggerRemoveEventListenerBreakpoint: - *t = CommandDOMDebuggerRemoveEventListenerBreakpoint - case CommandDOMDebuggerSetInstrumentationBreakpoint: - *t = CommandDOMDebuggerSetInstrumentationBreakpoint - case CommandDOMDebuggerRemoveInstrumentationBreakpoint: - *t = CommandDOMDebuggerRemoveInstrumentationBreakpoint - case CommandDOMDebuggerSetXHRBreakpoint: - *t = CommandDOMDebuggerSetXHRBreakpoint - case CommandDOMDebuggerRemoveXHRBreakpoint: - *t = CommandDOMDebuggerRemoveXHRBreakpoint - case CommandDOMDebuggerGetEventListeners: - *t = CommandDOMDebuggerGetEventListeners - case EventTargetTargetCreated: - *t = EventTargetTargetCreated - case EventTargetTargetInfoChanged: - *t = EventTargetTargetInfoChanged - case EventTargetTargetDestroyed: - *t = EventTargetTargetDestroyed - case EventTargetAttachedToTarget: - *t = EventTargetAttachedToTarget - case EventTargetDetachedFromTarget: - *t = EventTargetDetachedFromTarget - case EventTargetReceivedMessageFromTarget: - *t = EventTargetReceivedMessageFromTarget - case CommandTargetSetDiscoverTargets: - *t = CommandTargetSetDiscoverTargets - case CommandTargetSetAutoAttach: - *t = CommandTargetSetAutoAttach - case CommandTargetSetAttachToFrames: - *t = CommandTargetSetAttachToFrames - case CommandTargetSetRemoteLocations: - *t = CommandTargetSetRemoteLocations - case CommandTargetSendMessageToTarget: - *t = CommandTargetSendMessageToTarget - case CommandTargetGetTargetInfo: - *t = CommandTargetGetTargetInfo - case CommandTargetActivateTarget: - *t = CommandTargetActivateTarget - case CommandTargetCloseTarget: - *t = CommandTargetCloseTarget - case CommandTargetAttachToTarget: - *t = CommandTargetAttachToTarget - case CommandTargetDetachFromTarget: - *t = CommandTargetDetachFromTarget - case CommandTargetCreateBrowserContext: - *t = CommandTargetCreateBrowserContext - case CommandTargetDisposeBrowserContext: - *t = CommandTargetDisposeBrowserContext - case CommandTargetCreateTarget: - *t = CommandTargetCreateTarget - case CommandTargetGetTargets: - *t = CommandTargetGetTargets - case EventHeadlessExperimentalNeedsBeginFramesChanged: - *t = EventHeadlessExperimentalNeedsBeginFramesChanged - case EventHeadlessExperimentalMainFrameReadyForScreenshots: - *t = EventHeadlessExperimentalMainFrameReadyForScreenshots - case CommandHeadlessExperimentalEnable: - *t = CommandHeadlessExperimentalEnable - case CommandHeadlessExperimentalDisable: - *t = CommandHeadlessExperimentalDisable - case CommandHeadlessExperimentalBeginFrame: - *t = CommandHeadlessExperimentalBeginFrame - case EventServiceWorkerWorkerRegistrationUpdated: - *t = EventServiceWorkerWorkerRegistrationUpdated - case EventServiceWorkerWorkerVersionUpdated: - *t = EventServiceWorkerWorkerVersionUpdated - case EventServiceWorkerWorkerErrorReported: - *t = EventServiceWorkerWorkerErrorReported - case CommandServiceWorkerEnable: - *t = CommandServiceWorkerEnable - case CommandServiceWorkerDisable: - *t = CommandServiceWorkerDisable - case CommandServiceWorkerUnregister: - *t = CommandServiceWorkerUnregister - case CommandServiceWorkerUpdateRegistration: - *t = CommandServiceWorkerUpdateRegistration - case CommandServiceWorkerStartWorker: - *t = CommandServiceWorkerStartWorker - case CommandServiceWorkerSkipWaiting: - *t = CommandServiceWorkerSkipWaiting - case CommandServiceWorkerStopWorker: - *t = CommandServiceWorkerStopWorker - case CommandServiceWorkerStopAllWorkers: - *t = CommandServiceWorkerStopAllWorkers - case CommandServiceWorkerInspectWorker: - *t = CommandServiceWorkerInspectWorker - case CommandServiceWorkerSetForceUpdateOnPageLoad: - *t = CommandServiceWorkerSetForceUpdateOnPageLoad - case CommandServiceWorkerDeliverPushMessage: - *t = CommandServiceWorkerDeliverPushMessage - case CommandServiceWorkerDispatchSyncEvent: - *t = CommandServiceWorkerDispatchSyncEvent - case CommandInputSetIgnoreInputEvents: - *t = CommandInputSetIgnoreInputEvents - case CommandInputDispatchKeyEvent: - *t = CommandInputDispatchKeyEvent - case CommandInputDispatchMouseEvent: - *t = CommandInputDispatchMouseEvent - case CommandInputDispatchTouchEvent: - *t = CommandInputDispatchTouchEvent - case CommandInputEmulateTouchFromMouseEvent: - *t = CommandInputEmulateTouchFromMouseEvent - case CommandInputSynthesizePinchGesture: - *t = CommandInputSynthesizePinchGesture - case CommandInputSynthesizeScrollGesture: - *t = CommandInputSynthesizeScrollGesture - case CommandInputSynthesizeTapGesture: - *t = CommandInputSynthesizeTapGesture - case EventLayerTreeLayerTreeDidChange: - *t = EventLayerTreeLayerTreeDidChange - case EventLayerTreeLayerPainted: - *t = EventLayerTreeLayerPainted - case CommandLayerTreeEnable: - *t = CommandLayerTreeEnable - case CommandLayerTreeDisable: - *t = CommandLayerTreeDisable - case CommandLayerTreeCompositingReasons: - *t = CommandLayerTreeCompositingReasons - case CommandLayerTreeMakeSnapshot: - *t = CommandLayerTreeMakeSnapshot - case CommandLayerTreeLoadSnapshot: - *t = CommandLayerTreeLoadSnapshot - case CommandLayerTreeReleaseSnapshot: - *t = CommandLayerTreeReleaseSnapshot - case CommandLayerTreeProfileSnapshot: - *t = CommandLayerTreeProfileSnapshot - case CommandLayerTreeReplaySnapshot: - *t = CommandLayerTreeReplaySnapshot - case CommandLayerTreeSnapshotCommandLog: - *t = CommandLayerTreeSnapshotCommandLog - case CommandDeviceOrientationSetDeviceOrientationOverride: - *t = CommandDeviceOrientationSetDeviceOrientationOverride - case CommandDeviceOrientationClearDeviceOrientationOverride: - *t = CommandDeviceOrientationClearDeviceOrientationOverride - case EventTracingDataCollected: - *t = EventTracingDataCollected - case EventTracingTracingComplete: - *t = EventTracingTracingComplete - case EventTracingBufferUsage: - *t = EventTracingBufferUsage - case CommandTracingStart: - *t = CommandTracingStart - case CommandTracingEnd: - *t = CommandTracingEnd - case CommandTracingGetCategories: - *t = CommandTracingGetCategories - case CommandTracingRequestMemoryDump: - *t = CommandTracingRequestMemoryDump - case CommandTracingRecordClockSyncMarker: - *t = CommandTracingRecordClockSyncMarker - case EventAnimationAnimationCreated: - *t = EventAnimationAnimationCreated - case EventAnimationAnimationStarted: - *t = EventAnimationAnimationStarted - case EventAnimationAnimationCanceled: - *t = EventAnimationAnimationCanceled - case CommandAnimationEnable: - *t = CommandAnimationEnable - case CommandAnimationDisable: - *t = CommandAnimationDisable - case CommandAnimationGetPlaybackRate: - *t = CommandAnimationGetPlaybackRate - case CommandAnimationSetPlaybackRate: - *t = CommandAnimationSetPlaybackRate - case CommandAnimationGetCurrentTime: - *t = CommandAnimationGetCurrentTime - case CommandAnimationSetPaused: - *t = CommandAnimationSetPaused - case CommandAnimationSetTiming: - *t = CommandAnimationSetTiming - case CommandAnimationSeekAnimations: - *t = CommandAnimationSeekAnimations - case CommandAnimationReleaseAnimations: - *t = CommandAnimationReleaseAnimations - case CommandAnimationResolveAnimation: - *t = CommandAnimationResolveAnimation - case CommandAccessibilityGetPartialAXTree: - *t = CommandAccessibilityGetPartialAXTree - case EventStorageCacheStorageListUpdated: - *t = EventStorageCacheStorageListUpdated - case EventStorageCacheStorageContentUpdated: - *t = EventStorageCacheStorageContentUpdated - case EventStorageIndexedDBListUpdated: - *t = EventStorageIndexedDBListUpdated - case EventStorageIndexedDBContentUpdated: - *t = EventStorageIndexedDBContentUpdated - case CommandStorageClearDataForOrigin: - *t = CommandStorageClearDataForOrigin - case CommandStorageGetUsageAndQuota: - *t = CommandStorageGetUsageAndQuota - case CommandStorageTrackCacheStorageForOrigin: - *t = CommandStorageTrackCacheStorageForOrigin - case CommandStorageUntrackCacheStorageForOrigin: - *t = CommandStorageUntrackCacheStorageForOrigin - case CommandStorageTrackIndexedDBForOrigin: - *t = CommandStorageTrackIndexedDBForOrigin - case CommandStorageUntrackIndexedDBForOrigin: - *t = CommandStorageUntrackIndexedDBForOrigin - case EventLogEntryAdded: - *t = EventLogEntryAdded - case CommandLogEnable: - *t = CommandLogEnable - case CommandLogDisable: - *t = CommandLogDisable - case CommandLogClear: - *t = CommandLogClear - case CommandLogStartViolationsReport: - *t = CommandLogStartViolationsReport - case CommandLogStopViolationsReport: - *t = CommandLogStopViolationsReport - case CommandSystemInfoGetInfo: - *t = CommandSystemInfoGetInfo - case EventTetheringAccepted: - *t = EventTetheringAccepted - case CommandTetheringBind: - *t = CommandTetheringBind - case CommandTetheringUnbind: - *t = CommandTetheringUnbind - case CommandBrowserClose: - *t = CommandBrowserClose - case CommandBrowserGetWindowForTarget: - *t = CommandBrowserGetWindowForTarget - case CommandBrowserGetVersion: - *t = CommandBrowserGetVersion - case CommandBrowserSetWindowBounds: - *t = CommandBrowserSetWindowBounds - case CommandBrowserGetWindowBounds: - *t = CommandBrowserGetWindowBounds - case EventRuntimeExecutionContextCreated: - *t = EventRuntimeExecutionContextCreated - case EventRuntimeExecutionContextDestroyed: - *t = EventRuntimeExecutionContextDestroyed - case EventRuntimeExecutionContextsCleared: - *t = EventRuntimeExecutionContextsCleared - case EventRuntimeExceptionThrown: - *t = EventRuntimeExceptionThrown - case EventRuntimeExceptionRevoked: - *t = EventRuntimeExceptionRevoked - case EventRuntimeConsoleAPICalled: - *t = EventRuntimeConsoleAPICalled - case EventRuntimeInspectRequested: - *t = EventRuntimeInspectRequested - case CommandRuntimeEvaluate: - *t = CommandRuntimeEvaluate - case CommandRuntimeAwaitPromise: - *t = CommandRuntimeAwaitPromise - case CommandRuntimeCallFunctionOn: - *t = CommandRuntimeCallFunctionOn - case CommandRuntimeGetProperties: - *t = CommandRuntimeGetProperties - case CommandRuntimeReleaseObject: - *t = CommandRuntimeReleaseObject - case CommandRuntimeReleaseObjectGroup: - *t = CommandRuntimeReleaseObjectGroup - case CommandRuntimeRunIfWaitingForDebugger: - *t = CommandRuntimeRunIfWaitingForDebugger - case CommandRuntimeEnable: - *t = CommandRuntimeEnable - case CommandRuntimeDisable: - *t = CommandRuntimeDisable - case CommandRuntimeDiscardConsoleEntries: - *t = CommandRuntimeDiscardConsoleEntries - case CommandRuntimeSetCustomObjectFormatterEnabled: - *t = CommandRuntimeSetCustomObjectFormatterEnabled - case CommandRuntimeCompileScript: - *t = CommandRuntimeCompileScript - case CommandRuntimeRunScript: - *t = CommandRuntimeRunScript - case CommandRuntimeQueryObjects: - *t = CommandRuntimeQueryObjects - case CommandRuntimeGlobalLexicalScopeNames: - *t = CommandRuntimeGlobalLexicalScopeNames - case EventDebuggerScriptParsed: - *t = EventDebuggerScriptParsed - case EventDebuggerScriptFailedToParse: - *t = EventDebuggerScriptFailedToParse - case EventDebuggerBreakpointResolved: - *t = EventDebuggerBreakpointResolved - case EventDebuggerPaused: - *t = EventDebuggerPaused - case EventDebuggerResumed: - *t = EventDebuggerResumed - case CommandDebuggerEnable: - *t = CommandDebuggerEnable - case CommandDebuggerDisable: - *t = CommandDebuggerDisable - case CommandDebuggerSetBreakpointsActive: - *t = CommandDebuggerSetBreakpointsActive - case CommandDebuggerSetSkipAllPauses: - *t = CommandDebuggerSetSkipAllPauses - case CommandDebuggerSetBreakpointByURL: - *t = CommandDebuggerSetBreakpointByURL - case CommandDebuggerSetBreakpoint: - *t = CommandDebuggerSetBreakpoint - case CommandDebuggerRemoveBreakpoint: - *t = CommandDebuggerRemoveBreakpoint - case CommandDebuggerGetPossibleBreakpoints: - *t = CommandDebuggerGetPossibleBreakpoints - case CommandDebuggerContinueToLocation: - *t = CommandDebuggerContinueToLocation - case CommandDebuggerPauseOnAsyncCall: - *t = CommandDebuggerPauseOnAsyncCall - case CommandDebuggerStepOver: - *t = CommandDebuggerStepOver - case CommandDebuggerStepInto: - *t = CommandDebuggerStepInto - case CommandDebuggerStepOut: - *t = CommandDebuggerStepOut - case CommandDebuggerPause: - *t = CommandDebuggerPause - case CommandDebuggerScheduleStepIntoAsync: - *t = CommandDebuggerScheduleStepIntoAsync - case CommandDebuggerResume: - *t = CommandDebuggerResume - case CommandDebuggerGetStackTrace: - *t = CommandDebuggerGetStackTrace - case CommandDebuggerSearchInContent: - *t = CommandDebuggerSearchInContent - case CommandDebuggerSetScriptSource: - *t = CommandDebuggerSetScriptSource - case CommandDebuggerRestartFrame: - *t = CommandDebuggerRestartFrame - case CommandDebuggerGetScriptSource: - *t = CommandDebuggerGetScriptSource - case CommandDebuggerSetPauseOnExceptions: - *t = CommandDebuggerSetPauseOnExceptions - case CommandDebuggerEvaluateOnCallFrame: - *t = CommandDebuggerEvaluateOnCallFrame - case CommandDebuggerSetVariableValue: - *t = CommandDebuggerSetVariableValue - case CommandDebuggerSetReturnValue: - *t = CommandDebuggerSetReturnValue - case CommandDebuggerSetAsyncCallStackDepth: - *t = CommandDebuggerSetAsyncCallStackDepth - case CommandDebuggerSetBlackboxPatterns: - *t = CommandDebuggerSetBlackboxPatterns - case CommandDebuggerSetBlackboxedRanges: - *t = CommandDebuggerSetBlackboxedRanges - case EventProfilerConsoleProfileStarted: - *t = EventProfilerConsoleProfileStarted - case EventProfilerConsoleProfileFinished: - *t = EventProfilerConsoleProfileFinished - case CommandProfilerEnable: - *t = CommandProfilerEnable - case CommandProfilerDisable: - *t = CommandProfilerDisable - case CommandProfilerSetSamplingInterval: - *t = CommandProfilerSetSamplingInterval - case CommandProfilerStart: - *t = CommandProfilerStart - case CommandProfilerStop: - *t = CommandProfilerStop - case CommandProfilerStartPreciseCoverage: - *t = CommandProfilerStartPreciseCoverage - case CommandProfilerStopPreciseCoverage: - *t = CommandProfilerStopPreciseCoverage - case CommandProfilerTakePreciseCoverage: - *t = CommandProfilerTakePreciseCoverage - case CommandProfilerGetBestEffortCoverage: - *t = CommandProfilerGetBestEffortCoverage - case CommandProfilerStartTypeProfile: - *t = CommandProfilerStartTypeProfile - case CommandProfilerStopTypeProfile: - *t = CommandProfilerStopTypeProfile - case CommandProfilerTakeTypeProfile: - *t = CommandProfilerTakeTypeProfile - case EventHeapProfilerAddHeapSnapshotChunk: - *t = EventHeapProfilerAddHeapSnapshotChunk - case EventHeapProfilerResetProfiles: - *t = EventHeapProfilerResetProfiles - case EventHeapProfilerReportHeapSnapshotProgress: - *t = EventHeapProfilerReportHeapSnapshotProgress - case EventHeapProfilerLastSeenObjectID: - *t = EventHeapProfilerLastSeenObjectID - case EventHeapProfilerHeapStatsUpdate: - *t = EventHeapProfilerHeapStatsUpdate - case CommandHeapProfilerEnable: - *t = CommandHeapProfilerEnable - case CommandHeapProfilerDisable: - *t = CommandHeapProfilerDisable - case CommandHeapProfilerStartTrackingHeapObjects: - *t = CommandHeapProfilerStartTrackingHeapObjects - case CommandHeapProfilerStopTrackingHeapObjects: - *t = CommandHeapProfilerStopTrackingHeapObjects - case CommandHeapProfilerTakeHeapSnapshot: - *t = CommandHeapProfilerTakeHeapSnapshot - case CommandHeapProfilerCollectGarbage: - *t = CommandHeapProfilerCollectGarbage - case CommandHeapProfilerGetObjectByHeapObjectID: - *t = CommandHeapProfilerGetObjectByHeapObjectID - case CommandHeapProfilerAddInspectedHeapObject: - *t = CommandHeapProfilerAddInspectedHeapObject - case CommandHeapProfilerGetHeapObjectID: - *t = CommandHeapProfilerGetHeapObjectID - case CommandHeapProfilerStartSampling: - *t = CommandHeapProfilerStartSampling - case CommandHeapProfilerStopSampling: - *t = CommandHeapProfilerStopSampling - case CommandHeapProfilerGetSamplingProfile: - *t = CommandHeapProfilerGetSamplingProfile - - default: - in.AddError(errors.New("unknown MethodType value")) - } -} - -// UnmarshalJSON satisfies json.Unmarshaler. -func (t *MethodType) UnmarshalJSON(buf []byte) error { - return easyjson.Unmarshal(buf, t) -} - -// Domain returns the Chrome Debugging Protocol domain of the event or command. -func (t MethodType) Domain() string { - return string(t[:strings.IndexByte(string(t), '.')]) -} - -// ErrorType error type. -type ErrorType string - -// String returns the ErrorType as string value. -func (t ErrorType) String() string { - return string(t) -} - -// ErrorType values. -const ( - ErrChannelClosed ErrorType = "channel closed" - ErrInvalidResult ErrorType = "invalid result" - ErrUnknownResult ErrorType = "unknown result" -) - -// MarshalEasyJSON satisfies easyjson.Marshaler. -func (t ErrorType) MarshalEasyJSON(out *jwriter.Writer) { - out.String(string(t)) -} - -// MarshalJSON satisfies json.Marshaler. -func (t ErrorType) MarshalJSON() ([]byte, error) { - return easyjson.Marshal(t) -} - -// UnmarshalEasyJSON satisfies easyjson.Unmarshaler. -func (t *ErrorType) UnmarshalEasyJSON(in *jlexer.Lexer) { - switch ErrorType(in.String()) { - case ErrChannelClosed: - *t = ErrChannelClosed - case ErrInvalidResult: - *t = ErrInvalidResult - case ErrUnknownResult: - *t = ErrUnknownResult - - default: - in.AddError(errors.New("unknown ErrorType value")) - } -} - -// UnmarshalJSON satisfies json.Unmarshaler. -func (t *ErrorType) UnmarshalJSON(buf []byte) error { - return easyjson.Unmarshal(buf, t) -} - -// Error satisfies the error interface. -func (t ErrorType) Error() string { - return string(t) -} - -// Handler is the common interface for a Chrome Debugging Protocol target. -type Handler interface { - // SetActive changes the top level frame id. - SetActive(context.Context, FrameID) error - - // GetRoot returns the root document node for the top level frame. - GetRoot(context.Context) (*Node, error) - - // WaitFrame waits for a frame to be available. - WaitFrame(context.Context, FrameID) (*Frame, error) - - // WaitNode waits for a node to be available. - WaitNode(context.Context, *Frame, NodeID) (*Node, error) - - // Execute executes the specified command using the supplied context and - // parameters. - Execute(context.Context, MethodType, easyjson.Marshaler, easyjson.Unmarshaler) error - - // Listen creates a channel that will receive an event for the types - // specified. - Listen(...MethodType) <-chan interface{} - - // Release releases a channel returned from Listen. - Release(<-chan interface{}) -} - -// FrameID unique frame identifier. -type FrameID string - -// String returns the FrameID as string value. -func (t FrameID) String() string { - return string(t) -} - -// UnmarshalEasyJSON satisfies easyjson.Unmarshaler. -func (t *FrameID) UnmarshalEasyJSON(in *jlexer.Lexer) { - buf := in.Raw() - if l := len(buf); l > 2 && buf[0] == '"' && buf[l-1] == '"' { - buf = buf[1 : l-1] - } - - *t = FrameID(buf) -} - -// UnmarshalJSON satisfies json.Unmarshaler. -func (t *FrameID) UnmarshalJSON(buf []byte) error { - return easyjson.Unmarshal(buf, t) -} - -// Frame information about the Frame on the page. -type Frame struct { - ID FrameID `json:"id"` // Frame unique identifier. - ParentID FrameID `json:"parentId,omitempty"` // Parent frame identifier. - LoaderID LoaderID `json:"loaderId"` // Identifier of the loader associated with this frame. - Name string `json:"name,omitempty"` // Frame's name as specified in the tag. - URL string `json:"url"` // Frame document's URL. - SecurityOrigin string `json:"securityOrigin"` // Frame document's security origin. - MimeType string `json:"mimeType"` // Frame document's mimeType as determined by the browser. - UnreachableURL string `json:"unreachableUrl,omitempty"` // If the frame failed to load, this contains the URL that could not be loaded. - State FrameState `json:"-"` // Frame state. - Root *Node `json:"-"` // Frame document root. - Nodes map[NodeID]*Node `json:"-"` // Frame nodes. - sync.RWMutex `json:"-"` // Read write mutex. -} - -// FrameState is the state of a Frame. -type FrameState uint16 - -// FrameState enum values. -const ( - FrameDOMContentEventFired FrameState = 1 << (15 - iota) - FrameLoadEventFired - FrameAttached - FrameNavigated - FrameLoading - FrameScheduledNavigation -) - -// frameStateNames are the names of the frame states. -var frameStateNames = map[FrameState]string{ - FrameDOMContentEventFired: "DOMContentEventFired", - FrameLoadEventFired: "LoadEventFired", - FrameAttached: "Attached", - FrameNavigated: "Navigated", - FrameLoading: "Loading", - FrameScheduledNavigation: "ScheduledNavigation", -} - -// String satisfies stringer interface. -func (fs FrameState) String() string { - var s []string - for k, v := range frameStateNames { - if fs&k != 0 { - s = append(s, v) - } - } - return "[" + strings.Join(s, " ") + "]" -} - -// EmptyFrameID is the "non-existent" frame id. -const EmptyFrameID = FrameID("") - -// LoaderID unique loader identifier. -type LoaderID string - -// String returns the LoaderID as string value. -func (t LoaderID) String() string { - return string(t) -} - -// TimeSinceEpoch uTC time in seconds, counted from January 1, 1970. -type TimeSinceEpoch time.Time - -// Time returns the TimeSinceEpoch as time.Time value. -func (t TimeSinceEpoch) Time() time.Time { - return time.Time(t) -} - -// MarshalEasyJSON satisfies easyjson.Marshaler. -func (t TimeSinceEpoch) MarshalEasyJSON(out *jwriter.Writer) { - v := float64(time.Time(t).UnixNano() / int64(time.Second)) - - out.Buffer.EnsureSpace(20) - out.Buffer.Buf = strconv.AppendFloat(out.Buffer.Buf, v, 'f', -1, 64) -} - -// MarshalJSON satisfies json.Marshaler. -func (t TimeSinceEpoch) MarshalJSON() ([]byte, error) { - return easyjson.Marshal(t) -} - -// UnmarshalEasyJSON satisfies easyjson.Unmarshaler. -func (t *TimeSinceEpoch) UnmarshalEasyJSON(in *jlexer.Lexer) { - *t = TimeSinceEpoch(time.Unix(0, int64(in.Float64()*float64(time.Second)))) -} - -// UnmarshalJSON satisfies json.Unmarshaler. -func (t *TimeSinceEpoch) UnmarshalJSON(buf []byte) error { - return easyjson.Unmarshal(buf, t) -} - -// MonotonicTime monotonically increasing time in seconds since an arbitrary -// point in the past. -type MonotonicTime time.Time - -// Time returns the MonotonicTime as time.Time value. -func (t MonotonicTime) Time() time.Time { - return time.Time(t) -} - -// MonotonicTimeEpoch is the MonotonicTime time epoch. -var MonotonicTimeEpoch *time.Time - -func init() { - // initialize epoch - bt := sysutil.BootTime() - MonotonicTimeEpoch = &bt -} - -// MarshalEasyJSON satisfies easyjson.Marshaler. -func (t MonotonicTime) MarshalEasyJSON(out *jwriter.Writer) { - v := float64(time.Time(t).Sub(*MonotonicTimeEpoch)) / float64(time.Second) - - out.Buffer.EnsureSpace(20) - out.Buffer.Buf = strconv.AppendFloat(out.Buffer.Buf, v, 'f', -1, 64) -} - -// MarshalJSON satisfies json.Marshaler. -func (t MonotonicTime) MarshalJSON() ([]byte, error) { - return easyjson.Marshal(t) -} - -// UnmarshalEasyJSON satisfies easyjson.Unmarshaler. -func (t *MonotonicTime) UnmarshalEasyJSON(in *jlexer.Lexer) { - *t = MonotonicTime(MonotonicTimeEpoch.Add(time.Duration(in.Float64() * float64(time.Second)))) -} - -// UnmarshalJSON satisfies json.Unmarshaler. -func (t *MonotonicTime) UnmarshalJSON(buf []byte) error { - return easyjson.Unmarshal(buf, t) -} - // NodeID unique DOM node identifier. type NodeID int64 @@ -2141,3 +469,1678 @@ func (t *NodeType) UnmarshalEasyJSON(in *jlexer.Lexer) { func (t *NodeType) UnmarshalJSON(buf []byte) error { return easyjson.Unmarshal(buf, t) } + +// MessageError message error type. +type MessageError struct { + Code int64 `json:"code"` // Error code. + Message string `json:"message"` // Error message. +} + +// Error satisfies error interface. +func (e *MessageError) Error() string { + return fmt.Sprintf("%s (%d)", e.Message, e.Code) +} + +// Message chrome Debugging Protocol message sent to/read over websocket +// connection. +type Message struct { + ID int64 `json:"id,omitempty"` // Unique message identifier. + Method MethodType `json:"method,omitempty"` // Event or command type. + Params easyjson.RawMessage `json:"params,omitempty"` // Event or command parameters. + Result easyjson.RawMessage `json:"result,omitempty"` // Command return values. + Error *MessageError `json:"error,omitempty"` // Error message. +} + +// MethodType chrome Debugging Protocol method type (ie, event and command +// names). +type MethodType string + +// String returns the MethodType as string value. +func (t MethodType) String() string { + return string(t) +} + +// MethodType values. +const ( + CommandAccessibilityGetPartialAXTree MethodType = "Accessibility.getPartialAXTree" + EventAnimationAnimationCanceled MethodType = "Animation.animationCanceled" + EventAnimationAnimationCreated MethodType = "Animation.animationCreated" + EventAnimationAnimationStarted MethodType = "Animation.animationStarted" + CommandAnimationDisable MethodType = "Animation.disable" + CommandAnimationEnable MethodType = "Animation.enable" + CommandAnimationGetCurrentTime MethodType = "Animation.getCurrentTime" + CommandAnimationGetPlaybackRate MethodType = "Animation.getPlaybackRate" + CommandAnimationReleaseAnimations MethodType = "Animation.releaseAnimations" + CommandAnimationResolveAnimation MethodType = "Animation.resolveAnimation" + CommandAnimationSeekAnimations MethodType = "Animation.seekAnimations" + CommandAnimationSetPaused MethodType = "Animation.setPaused" + CommandAnimationSetPlaybackRate MethodType = "Animation.setPlaybackRate" + CommandAnimationSetTiming MethodType = "Animation.setTiming" + EventApplicationCacheApplicationCacheStatusUpdated MethodType = "ApplicationCache.applicationCacheStatusUpdated" + EventApplicationCacheNetworkStateUpdated MethodType = "ApplicationCache.networkStateUpdated" + CommandApplicationCacheEnable MethodType = "ApplicationCache.enable" + CommandApplicationCacheGetApplicationCacheForFrame MethodType = "ApplicationCache.getApplicationCacheForFrame" + CommandApplicationCacheGetFramesWithManifests MethodType = "ApplicationCache.getFramesWithManifests" + CommandApplicationCacheGetManifestForFrame MethodType = "ApplicationCache.getManifestForFrame" + CommandAuditsGetEncodedResponse MethodType = "Audits.getEncodedResponse" + CommandBrowserClose MethodType = "Browser.close" + CommandBrowserGetVersion MethodType = "Browser.getVersion" + CommandBrowserGetWindowBounds MethodType = "Browser.getWindowBounds" + CommandBrowserGetWindowForTarget MethodType = "Browser.getWindowForTarget" + CommandBrowserSetWindowBounds MethodType = "Browser.setWindowBounds" + EventCSSFontsUpdated MethodType = "CSS.fontsUpdated" + EventCSSMediaQueryResultChanged MethodType = "CSS.mediaQueryResultChanged" + EventCSSStyleSheetAdded MethodType = "CSS.styleSheetAdded" + EventCSSStyleSheetChanged MethodType = "CSS.styleSheetChanged" + EventCSSStyleSheetRemoved MethodType = "CSS.styleSheetRemoved" + CommandCSSAddRule MethodType = "CSS.addRule" + CommandCSSCollectClassNames MethodType = "CSS.collectClassNames" + CommandCSSCreateStyleSheet MethodType = "CSS.createStyleSheet" + CommandCSSDisable MethodType = "CSS.disable" + CommandCSSEnable MethodType = "CSS.enable" + CommandCSSForcePseudoState MethodType = "CSS.forcePseudoState" + CommandCSSGetBackgroundColors MethodType = "CSS.getBackgroundColors" + CommandCSSGetComputedStyleForNode MethodType = "CSS.getComputedStyleForNode" + CommandCSSGetInlineStylesForNode MethodType = "CSS.getInlineStylesForNode" + CommandCSSGetMatchedStylesForNode MethodType = "CSS.getMatchedStylesForNode" + CommandCSSGetMediaQueries MethodType = "CSS.getMediaQueries" + CommandCSSGetPlatformFontsForNode MethodType = "CSS.getPlatformFontsForNode" + CommandCSSGetStyleSheetText MethodType = "CSS.getStyleSheetText" + CommandCSSSetEffectivePropertyValueForNode MethodType = "CSS.setEffectivePropertyValueForNode" + CommandCSSSetKeyframeKey MethodType = "CSS.setKeyframeKey" + CommandCSSSetMediaText MethodType = "CSS.setMediaText" + CommandCSSSetRuleSelector MethodType = "CSS.setRuleSelector" + CommandCSSSetStyleSheetText MethodType = "CSS.setStyleSheetText" + CommandCSSSetStyleTexts MethodType = "CSS.setStyleTexts" + CommandCSSStartRuleUsageTracking MethodType = "CSS.startRuleUsageTracking" + CommandCSSStopRuleUsageTracking MethodType = "CSS.stopRuleUsageTracking" + CommandCSSTakeCoverageDelta MethodType = "CSS.takeCoverageDelta" + CommandCacheStorageDeleteCache MethodType = "CacheStorage.deleteCache" + CommandCacheStorageDeleteEntry MethodType = "CacheStorage.deleteEntry" + CommandCacheStorageRequestCacheNames MethodType = "CacheStorage.requestCacheNames" + CommandCacheStorageRequestCachedResponse MethodType = "CacheStorage.requestCachedResponse" + CommandCacheStorageRequestEntries MethodType = "CacheStorage.requestEntries" + EventDOMAttributeModified MethodType = "DOM.attributeModified" + EventDOMAttributeRemoved MethodType = "DOM.attributeRemoved" + EventDOMCharacterDataModified MethodType = "DOM.characterDataModified" + EventDOMChildNodeCountUpdated MethodType = "DOM.childNodeCountUpdated" + EventDOMChildNodeInserted MethodType = "DOM.childNodeInserted" + EventDOMChildNodeRemoved MethodType = "DOM.childNodeRemoved" + EventDOMDistributedNodesUpdated MethodType = "DOM.distributedNodesUpdated" + EventDOMDocumentUpdated MethodType = "DOM.documentUpdated" + EventDOMInlineStyleInvalidated MethodType = "DOM.inlineStyleInvalidated" + EventDOMPseudoElementAdded MethodType = "DOM.pseudoElementAdded" + EventDOMPseudoElementRemoved MethodType = "DOM.pseudoElementRemoved" + EventDOMSetChildNodes MethodType = "DOM.setChildNodes" + EventDOMShadowRootPopped MethodType = "DOM.shadowRootPopped" + EventDOMShadowRootPushed MethodType = "DOM.shadowRootPushed" + CommandDOMCollectClassNamesFromSubtree MethodType = "DOM.collectClassNamesFromSubtree" + CommandDOMCopyTo MethodType = "DOM.copyTo" + CommandDOMDescribeNode MethodType = "DOM.describeNode" + CommandDOMDisable MethodType = "DOM.disable" + CommandDOMDiscardSearchResults MethodType = "DOM.discardSearchResults" + CommandDOMEnable MethodType = "DOM.enable" + CommandDOMFocus MethodType = "DOM.focus" + CommandDOMGetAttributes MethodType = "DOM.getAttributes" + CommandDOMGetBoxModel MethodType = "DOM.getBoxModel" + CommandDOMGetDocument MethodType = "DOM.getDocument" + CommandDOMGetFlattenedDocument MethodType = "DOM.getFlattenedDocument" + CommandDOMGetNodeForLocation MethodType = "DOM.getNodeForLocation" + CommandDOMGetOuterHTML MethodType = "DOM.getOuterHTML" + CommandDOMGetRelayoutBoundary MethodType = "DOM.getRelayoutBoundary" + CommandDOMGetSearchResults MethodType = "DOM.getSearchResults" + CommandDOMMarkUndoableState MethodType = "DOM.markUndoableState" + CommandDOMMoveTo MethodType = "DOM.moveTo" + CommandDOMPerformSearch MethodType = "DOM.performSearch" + CommandDOMPushNodeByPathToFrontend MethodType = "DOM.pushNodeByPathToFrontend" + CommandDOMPushNodesByBackendIdsToFrontend MethodType = "DOM.pushNodesByBackendIdsToFrontend" + CommandDOMQuerySelector MethodType = "DOM.querySelector" + CommandDOMQuerySelectorAll MethodType = "DOM.querySelectorAll" + CommandDOMRedo MethodType = "DOM.redo" + CommandDOMRemoveAttribute MethodType = "DOM.removeAttribute" + CommandDOMRemoveNode MethodType = "DOM.removeNode" + CommandDOMRequestChildNodes MethodType = "DOM.requestChildNodes" + CommandDOMRequestNode MethodType = "DOM.requestNode" + CommandDOMResolveNode MethodType = "DOM.resolveNode" + CommandDOMSetAttributeValue MethodType = "DOM.setAttributeValue" + CommandDOMSetAttributesAsText MethodType = "DOM.setAttributesAsText" + CommandDOMSetFileInputFiles MethodType = "DOM.setFileInputFiles" + CommandDOMSetInspectedNode MethodType = "DOM.setInspectedNode" + CommandDOMSetNodeName MethodType = "DOM.setNodeName" + CommandDOMSetNodeValue MethodType = "DOM.setNodeValue" + CommandDOMSetOuterHTML MethodType = "DOM.setOuterHTML" + CommandDOMUndo MethodType = "DOM.undo" + CommandDOMDebuggerGetEventListeners MethodType = "DOMDebugger.getEventListeners" + CommandDOMDebuggerRemoveDOMBreakpoint MethodType = "DOMDebugger.removeDOMBreakpoint" + CommandDOMDebuggerRemoveEventListenerBreakpoint MethodType = "DOMDebugger.removeEventListenerBreakpoint" + CommandDOMDebuggerRemoveInstrumentationBreakpoint MethodType = "DOMDebugger.removeInstrumentationBreakpoint" + CommandDOMDebuggerRemoveXHRBreakpoint MethodType = "DOMDebugger.removeXHRBreakpoint" + CommandDOMDebuggerSetDOMBreakpoint MethodType = "DOMDebugger.setDOMBreakpoint" + CommandDOMDebuggerSetEventListenerBreakpoint MethodType = "DOMDebugger.setEventListenerBreakpoint" + CommandDOMDebuggerSetInstrumentationBreakpoint MethodType = "DOMDebugger.setInstrumentationBreakpoint" + CommandDOMDebuggerSetXHRBreakpoint MethodType = "DOMDebugger.setXHRBreakpoint" + CommandDOMSnapshotGetSnapshot MethodType = "DOMSnapshot.getSnapshot" + EventDOMStorageDomStorageItemAdded MethodType = "DOMStorage.domStorageItemAdded" + EventDOMStorageDomStorageItemRemoved MethodType = "DOMStorage.domStorageItemRemoved" + EventDOMStorageDomStorageItemUpdated MethodType = "DOMStorage.domStorageItemUpdated" + EventDOMStorageDomStorageItemsCleared MethodType = "DOMStorage.domStorageItemsCleared" + CommandDOMStorageClear MethodType = "DOMStorage.clear" + CommandDOMStorageDisable MethodType = "DOMStorage.disable" + CommandDOMStorageEnable MethodType = "DOMStorage.enable" + CommandDOMStorageGetDOMStorageItems MethodType = "DOMStorage.getDOMStorageItems" + CommandDOMStorageRemoveDOMStorageItem MethodType = "DOMStorage.removeDOMStorageItem" + CommandDOMStorageSetDOMStorageItem MethodType = "DOMStorage.setDOMStorageItem" + EventDatabaseAddDatabase MethodType = "Database.addDatabase" + CommandDatabaseDisable MethodType = "Database.disable" + CommandDatabaseEnable MethodType = "Database.enable" + CommandDatabaseExecuteSQL MethodType = "Database.executeSQL" + CommandDatabaseGetDatabaseTableNames MethodType = "Database.getDatabaseTableNames" + CommandDeviceOrientationClearDeviceOrientationOverride MethodType = "DeviceOrientation.clearDeviceOrientationOverride" + CommandDeviceOrientationSetDeviceOrientationOverride MethodType = "DeviceOrientation.setDeviceOrientationOverride" + EventEmulationVirtualTimeAdvanced MethodType = "Emulation.virtualTimeAdvanced" + EventEmulationVirtualTimeBudgetExpired MethodType = "Emulation.virtualTimeBudgetExpired" + EventEmulationVirtualTimePaused MethodType = "Emulation.virtualTimePaused" + CommandEmulationCanEmulate MethodType = "Emulation.canEmulate" + CommandEmulationClearDeviceMetricsOverride MethodType = "Emulation.clearDeviceMetricsOverride" + CommandEmulationClearGeolocationOverride MethodType = "Emulation.clearGeolocationOverride" + CommandEmulationResetPageScaleFactor MethodType = "Emulation.resetPageScaleFactor" + CommandEmulationSetCPUThrottlingRate MethodType = "Emulation.setCPUThrottlingRate" + CommandEmulationSetDefaultBackgroundColorOverride MethodType = "Emulation.setDefaultBackgroundColorOverride" + CommandEmulationSetDeviceMetricsOverride MethodType = "Emulation.setDeviceMetricsOverride" + CommandEmulationSetEmitTouchEventsForMouse MethodType = "Emulation.setEmitTouchEventsForMouse" + CommandEmulationSetEmulatedMedia MethodType = "Emulation.setEmulatedMedia" + CommandEmulationSetGeolocationOverride MethodType = "Emulation.setGeolocationOverride" + CommandEmulationSetNavigatorOverrides MethodType = "Emulation.setNavigatorOverrides" + CommandEmulationSetPageScaleFactor MethodType = "Emulation.setPageScaleFactor" + CommandEmulationSetScriptExecutionDisabled MethodType = "Emulation.setScriptExecutionDisabled" + CommandEmulationSetTouchEmulationEnabled MethodType = "Emulation.setTouchEmulationEnabled" + CommandEmulationSetVirtualTimePolicy MethodType = "Emulation.setVirtualTimePolicy" + EventHeadlessExperimentalMainFrameReadyForScreenshots MethodType = "HeadlessExperimental.mainFrameReadyForScreenshots" + EventHeadlessExperimentalNeedsBeginFramesChanged MethodType = "HeadlessExperimental.needsBeginFramesChanged" + CommandHeadlessExperimentalBeginFrame MethodType = "HeadlessExperimental.beginFrame" + CommandHeadlessExperimentalDisable MethodType = "HeadlessExperimental.disable" + CommandHeadlessExperimentalEnable MethodType = "HeadlessExperimental.enable" + CommandIOClose MethodType = "IO.close" + CommandIORead MethodType = "IO.read" + CommandIOResolveBlob MethodType = "IO.resolveBlob" + CommandIndexedDBClearObjectStore MethodType = "IndexedDB.clearObjectStore" + CommandIndexedDBDeleteDatabase MethodType = "IndexedDB.deleteDatabase" + CommandIndexedDBDeleteObjectStoreEntries MethodType = "IndexedDB.deleteObjectStoreEntries" + CommandIndexedDBDisable MethodType = "IndexedDB.disable" + CommandIndexedDBEnable MethodType = "IndexedDB.enable" + CommandIndexedDBRequestData MethodType = "IndexedDB.requestData" + CommandIndexedDBRequestDatabase MethodType = "IndexedDB.requestDatabase" + CommandIndexedDBRequestDatabaseNames MethodType = "IndexedDB.requestDatabaseNames" + CommandInputDispatchKeyEvent MethodType = "Input.dispatchKeyEvent" + CommandInputDispatchMouseEvent MethodType = "Input.dispatchMouseEvent" + CommandInputDispatchTouchEvent MethodType = "Input.dispatchTouchEvent" + CommandInputEmulateTouchFromMouseEvent MethodType = "Input.emulateTouchFromMouseEvent" + CommandInputSetIgnoreInputEvents MethodType = "Input.setIgnoreInputEvents" + CommandInputSynthesizePinchGesture MethodType = "Input.synthesizePinchGesture" + CommandInputSynthesizeScrollGesture MethodType = "Input.synthesizeScrollGesture" + CommandInputSynthesizeTapGesture MethodType = "Input.synthesizeTapGesture" + EventInspectorDetached MethodType = "Inspector.detached" + EventInspectorTargetCrashed MethodType = "Inspector.targetCrashed" + CommandInspectorDisable MethodType = "Inspector.disable" + CommandInspectorEnable MethodType = "Inspector.enable" + EventLayerTreeLayerPainted MethodType = "LayerTree.layerPainted" + EventLayerTreeLayerTreeDidChange MethodType = "LayerTree.layerTreeDidChange" + CommandLayerTreeCompositingReasons MethodType = "LayerTree.compositingReasons" + CommandLayerTreeDisable MethodType = "LayerTree.disable" + CommandLayerTreeEnable MethodType = "LayerTree.enable" + CommandLayerTreeLoadSnapshot MethodType = "LayerTree.loadSnapshot" + CommandLayerTreeMakeSnapshot MethodType = "LayerTree.makeSnapshot" + CommandLayerTreeProfileSnapshot MethodType = "LayerTree.profileSnapshot" + CommandLayerTreeReleaseSnapshot MethodType = "LayerTree.releaseSnapshot" + CommandLayerTreeReplaySnapshot MethodType = "LayerTree.replaySnapshot" + CommandLayerTreeSnapshotCommandLog MethodType = "LayerTree.snapshotCommandLog" + EventLogEntryAdded MethodType = "Log.entryAdded" + CommandLogClear MethodType = "Log.clear" + CommandLogDisable MethodType = "Log.disable" + CommandLogEnable MethodType = "Log.enable" + CommandLogStartViolationsReport MethodType = "Log.startViolationsReport" + CommandLogStopViolationsReport MethodType = "Log.stopViolationsReport" + CommandMemoryGetDOMCounters MethodType = "Memory.getDOMCounters" + CommandMemoryPrepareForLeakDetection MethodType = "Memory.prepareForLeakDetection" + CommandMemorySetPressureNotificationsSuppressed MethodType = "Memory.setPressureNotificationsSuppressed" + CommandMemorySimulatePressureNotification MethodType = "Memory.simulatePressureNotification" + EventNetworkDataReceived MethodType = "Network.dataReceived" + EventNetworkEventSourceMessageReceived MethodType = "Network.eventSourceMessageReceived" + EventNetworkLoadingFailed MethodType = "Network.loadingFailed" + EventNetworkLoadingFinished MethodType = "Network.loadingFinished" + EventNetworkRequestIntercepted MethodType = "Network.requestIntercepted" + EventNetworkRequestServedFromCache MethodType = "Network.requestServedFromCache" + EventNetworkRequestWillBeSent MethodType = "Network.requestWillBeSent" + EventNetworkResourceChangedPriority MethodType = "Network.resourceChangedPriority" + EventNetworkResponseReceived MethodType = "Network.responseReceived" + EventNetworkWebSocketClosed MethodType = "Network.webSocketClosed" + EventNetworkWebSocketCreated MethodType = "Network.webSocketCreated" + EventNetworkWebSocketFrameError MethodType = "Network.webSocketFrameError" + EventNetworkWebSocketFrameReceived MethodType = "Network.webSocketFrameReceived" + EventNetworkWebSocketFrameSent MethodType = "Network.webSocketFrameSent" + EventNetworkWebSocketHandshakeResponseReceived MethodType = "Network.webSocketHandshakeResponseReceived" + EventNetworkWebSocketWillSendHandshakeRequest MethodType = "Network.webSocketWillSendHandshakeRequest" + CommandNetworkClearBrowserCache MethodType = "Network.clearBrowserCache" + CommandNetworkClearBrowserCookies MethodType = "Network.clearBrowserCookies" + CommandNetworkContinueInterceptedRequest MethodType = "Network.continueInterceptedRequest" + CommandNetworkDeleteCookies MethodType = "Network.deleteCookies" + CommandNetworkDisable MethodType = "Network.disable" + CommandNetworkEmulateNetworkConditions MethodType = "Network.emulateNetworkConditions" + CommandNetworkEnable MethodType = "Network.enable" + CommandNetworkGetAllCookies MethodType = "Network.getAllCookies" + CommandNetworkGetCertificate MethodType = "Network.getCertificate" + CommandNetworkGetCookies MethodType = "Network.getCookies" + CommandNetworkGetResponseBody MethodType = "Network.getResponseBody" + CommandNetworkGetResponseBodyForInterception MethodType = "Network.getResponseBodyForInterception" + CommandNetworkReplayXHR MethodType = "Network.replayXHR" + CommandNetworkSearchInResponseBody MethodType = "Network.searchInResponseBody" + CommandNetworkSetBlockedURLS MethodType = "Network.setBlockedURLs" + CommandNetworkSetBypassServiceWorker MethodType = "Network.setBypassServiceWorker" + CommandNetworkSetCacheDisabled MethodType = "Network.setCacheDisabled" + CommandNetworkSetCookie MethodType = "Network.setCookie" + CommandNetworkSetCookies MethodType = "Network.setCookies" + CommandNetworkSetDataSizeLimitsForTest MethodType = "Network.setDataSizeLimitsForTest" + CommandNetworkSetExtraHTTPHeaders MethodType = "Network.setExtraHTTPHeaders" + CommandNetworkSetRequestInterception MethodType = "Network.setRequestInterception" + CommandNetworkSetUserAgentOverride MethodType = "Network.setUserAgentOverride" + EventOverlayInspectNodeRequested MethodType = "Overlay.inspectNodeRequested" + EventOverlayNodeHighlightRequested MethodType = "Overlay.nodeHighlightRequested" + EventOverlayScreenshotRequested MethodType = "Overlay.screenshotRequested" + CommandOverlayDisable MethodType = "Overlay.disable" + CommandOverlayEnable MethodType = "Overlay.enable" + CommandOverlayGetHighlightObjectForTest MethodType = "Overlay.getHighlightObjectForTest" + CommandOverlayHideHighlight MethodType = "Overlay.hideHighlight" + CommandOverlayHighlightFrame MethodType = "Overlay.highlightFrame" + CommandOverlayHighlightNode MethodType = "Overlay.highlightNode" + CommandOverlayHighlightQuad MethodType = "Overlay.highlightQuad" + CommandOverlayHighlightRect MethodType = "Overlay.highlightRect" + CommandOverlaySetInspectMode MethodType = "Overlay.setInspectMode" + CommandOverlaySetPausedInDebuggerMessage MethodType = "Overlay.setPausedInDebuggerMessage" + CommandOverlaySetShowDebugBorders MethodType = "Overlay.setShowDebugBorders" + CommandOverlaySetShowFPSCounter MethodType = "Overlay.setShowFPSCounter" + CommandOverlaySetShowPaintRects MethodType = "Overlay.setShowPaintRects" + CommandOverlaySetShowScrollBottleneckRects MethodType = "Overlay.setShowScrollBottleneckRects" + CommandOverlaySetShowViewportSizeOnResize MethodType = "Overlay.setShowViewportSizeOnResize" + CommandOverlaySetSuspended MethodType = "Overlay.setSuspended" + EventPageDomContentEventFired MethodType = "Page.domContentEventFired" + EventPageFrameAttached MethodType = "Page.frameAttached" + EventPageFrameClearedScheduledNavigation MethodType = "Page.frameClearedScheduledNavigation" + EventPageFrameDetached MethodType = "Page.frameDetached" + EventPageFrameNavigated MethodType = "Page.frameNavigated" + EventPageFrameResized MethodType = "Page.frameResized" + EventPageFrameScheduledNavigation MethodType = "Page.frameScheduledNavigation" + EventPageFrameStartedLoading MethodType = "Page.frameStartedLoading" + EventPageFrameStoppedLoading MethodType = "Page.frameStoppedLoading" + EventPageInterstitialHidden MethodType = "Page.interstitialHidden" + EventPageInterstitialShown MethodType = "Page.interstitialShown" + EventPageJavascriptDialogClosed MethodType = "Page.javascriptDialogClosed" + EventPageJavascriptDialogOpening MethodType = "Page.javascriptDialogOpening" + EventPageLifecycleEvent MethodType = "Page.lifecycleEvent" + EventPageLoadEventFired MethodType = "Page.loadEventFired" + EventPageScreencastFrame MethodType = "Page.screencastFrame" + EventPageScreencastVisibilityChanged MethodType = "Page.screencastVisibilityChanged" + EventPageWindowOpen MethodType = "Page.windowOpen" + CommandPageAddScriptToEvaluateOnNewDocument MethodType = "Page.addScriptToEvaluateOnNewDocument" + CommandPageBringToFront MethodType = "Page.bringToFront" + CommandPageCaptureScreenshot MethodType = "Page.captureScreenshot" + CommandPageCreateIsolatedWorld MethodType = "Page.createIsolatedWorld" + CommandPageDisable MethodType = "Page.disable" + CommandPageEnable MethodType = "Page.enable" + CommandPageGetAppManifest MethodType = "Page.getAppManifest" + CommandPageGetFrameTree MethodType = "Page.getFrameTree" + CommandPageGetLayoutMetrics MethodType = "Page.getLayoutMetrics" + CommandPageGetNavigationHistory MethodType = "Page.getNavigationHistory" + CommandPageGetResourceContent MethodType = "Page.getResourceContent" + CommandPageGetResourceTree MethodType = "Page.getResourceTree" + CommandPageHandleJavaScriptDialog MethodType = "Page.handleJavaScriptDialog" + CommandPageNavigate MethodType = "Page.navigate" + CommandPageNavigateToHistoryEntry MethodType = "Page.navigateToHistoryEntry" + CommandPagePrintToPDF MethodType = "Page.printToPDF" + CommandPageReload MethodType = "Page.reload" + CommandPageRemoveScriptToEvaluateOnNewDocument MethodType = "Page.removeScriptToEvaluateOnNewDocument" + CommandPageRequestAppBanner MethodType = "Page.requestAppBanner" + CommandPageScreencastFrameAck MethodType = "Page.screencastFrameAck" + CommandPageSearchInResource MethodType = "Page.searchInResource" + CommandPageSetAdBlockingEnabled MethodType = "Page.setAdBlockingEnabled" + CommandPageSetAutoAttachToCreatedPages MethodType = "Page.setAutoAttachToCreatedPages" + CommandPageSetDocumentContent MethodType = "Page.setDocumentContent" + CommandPageSetDownloadBehavior MethodType = "Page.setDownloadBehavior" + CommandPageSetLifecycleEventsEnabled MethodType = "Page.setLifecycleEventsEnabled" + CommandPageStartScreencast MethodType = "Page.startScreencast" + CommandPageStopLoading MethodType = "Page.stopLoading" + CommandPageStopScreencast MethodType = "Page.stopScreencast" + EventPerformanceMetrics MethodType = "Performance.metrics" + CommandPerformanceDisable MethodType = "Performance.disable" + CommandPerformanceEnable MethodType = "Performance.enable" + CommandPerformanceGetMetrics MethodType = "Performance.getMetrics" + EventSecurityCertificateError MethodType = "Security.certificateError" + EventSecuritySecurityStateChanged MethodType = "Security.securityStateChanged" + CommandSecurityDisable MethodType = "Security.disable" + CommandSecurityEnable MethodType = "Security.enable" + CommandSecurityHandleCertificateError MethodType = "Security.handleCertificateError" + CommandSecuritySetOverrideCertificateErrors MethodType = "Security.setOverrideCertificateErrors" + EventServiceWorkerWorkerErrorReported MethodType = "ServiceWorker.workerErrorReported" + EventServiceWorkerWorkerRegistrationUpdated MethodType = "ServiceWorker.workerRegistrationUpdated" + EventServiceWorkerWorkerVersionUpdated MethodType = "ServiceWorker.workerVersionUpdated" + CommandServiceWorkerDeliverPushMessage MethodType = "ServiceWorker.deliverPushMessage" + CommandServiceWorkerDisable MethodType = "ServiceWorker.disable" + CommandServiceWorkerDispatchSyncEvent MethodType = "ServiceWorker.dispatchSyncEvent" + CommandServiceWorkerEnable MethodType = "ServiceWorker.enable" + CommandServiceWorkerInspectWorker MethodType = "ServiceWorker.inspectWorker" + CommandServiceWorkerSetForceUpdateOnPageLoad MethodType = "ServiceWorker.setForceUpdateOnPageLoad" + CommandServiceWorkerSkipWaiting MethodType = "ServiceWorker.skipWaiting" + CommandServiceWorkerStartWorker MethodType = "ServiceWorker.startWorker" + CommandServiceWorkerStopAllWorkers MethodType = "ServiceWorker.stopAllWorkers" + CommandServiceWorkerStopWorker MethodType = "ServiceWorker.stopWorker" + CommandServiceWorkerUnregister MethodType = "ServiceWorker.unregister" + CommandServiceWorkerUpdateRegistration MethodType = "ServiceWorker.updateRegistration" + EventStorageCacheStorageContentUpdated MethodType = "Storage.cacheStorageContentUpdated" + EventStorageCacheStorageListUpdated MethodType = "Storage.cacheStorageListUpdated" + EventStorageIndexedDBContentUpdated MethodType = "Storage.indexedDBContentUpdated" + EventStorageIndexedDBListUpdated MethodType = "Storage.indexedDBListUpdated" + CommandStorageClearDataForOrigin MethodType = "Storage.clearDataForOrigin" + CommandStorageGetUsageAndQuota MethodType = "Storage.getUsageAndQuota" + CommandStorageTrackCacheStorageForOrigin MethodType = "Storage.trackCacheStorageForOrigin" + CommandStorageTrackIndexedDBForOrigin MethodType = "Storage.trackIndexedDBForOrigin" + CommandStorageUntrackCacheStorageForOrigin MethodType = "Storage.untrackCacheStorageForOrigin" + CommandStorageUntrackIndexedDBForOrigin MethodType = "Storage.untrackIndexedDBForOrigin" + CommandSystemInfoGetInfo MethodType = "SystemInfo.getInfo" + EventTargetAttachedToTarget MethodType = "Target.attachedToTarget" + EventTargetDetachedFromTarget MethodType = "Target.detachedFromTarget" + EventTargetReceivedMessageFromTarget MethodType = "Target.receivedMessageFromTarget" + EventTargetTargetCreated MethodType = "Target.targetCreated" + EventTargetTargetDestroyed MethodType = "Target.targetDestroyed" + EventTargetTargetInfoChanged MethodType = "Target.targetInfoChanged" + CommandTargetActivateTarget MethodType = "Target.activateTarget" + CommandTargetAttachToTarget MethodType = "Target.attachToTarget" + CommandTargetCloseTarget MethodType = "Target.closeTarget" + CommandTargetCreateBrowserContext MethodType = "Target.createBrowserContext" + CommandTargetCreateTarget MethodType = "Target.createTarget" + CommandTargetDetachFromTarget MethodType = "Target.detachFromTarget" + CommandTargetDisposeBrowserContext MethodType = "Target.disposeBrowserContext" + CommandTargetGetTargetInfo MethodType = "Target.getTargetInfo" + CommandTargetGetTargets MethodType = "Target.getTargets" + CommandTargetSendMessageToTarget MethodType = "Target.sendMessageToTarget" + CommandTargetSetAttachToFrames MethodType = "Target.setAttachToFrames" + CommandTargetSetAutoAttach MethodType = "Target.setAutoAttach" + CommandTargetSetDiscoverTargets MethodType = "Target.setDiscoverTargets" + CommandTargetSetRemoteLocations MethodType = "Target.setRemoteLocations" + EventTetheringAccepted MethodType = "Tethering.accepted" + CommandTetheringBind MethodType = "Tethering.bind" + CommandTetheringUnbind MethodType = "Tethering.unbind" + EventTracingBufferUsage MethodType = "Tracing.bufferUsage" + EventTracingDataCollected MethodType = "Tracing.dataCollected" + EventTracingTracingComplete MethodType = "Tracing.tracingComplete" + CommandTracingEnd MethodType = "Tracing.end" + CommandTracingGetCategories MethodType = "Tracing.getCategories" + CommandTracingRecordClockSyncMarker MethodType = "Tracing.recordClockSyncMarker" + CommandTracingRequestMemoryDump MethodType = "Tracing.requestMemoryDump" + CommandTracingStart MethodType = "Tracing.start" + EventDebuggerBreakpointResolved MethodType = "Debugger.breakpointResolved" + EventDebuggerPaused MethodType = "Debugger.paused" + EventDebuggerResumed MethodType = "Debugger.resumed" + EventDebuggerScriptFailedToParse MethodType = "Debugger.scriptFailedToParse" + EventDebuggerScriptParsed MethodType = "Debugger.scriptParsed" + CommandDebuggerContinueToLocation MethodType = "Debugger.continueToLocation" + CommandDebuggerDisable MethodType = "Debugger.disable" + CommandDebuggerEnable MethodType = "Debugger.enable" + CommandDebuggerEvaluateOnCallFrame MethodType = "Debugger.evaluateOnCallFrame" + CommandDebuggerGetPossibleBreakpoints MethodType = "Debugger.getPossibleBreakpoints" + CommandDebuggerGetScriptSource MethodType = "Debugger.getScriptSource" + CommandDebuggerGetStackTrace MethodType = "Debugger.getStackTrace" + CommandDebuggerPause MethodType = "Debugger.pause" + CommandDebuggerPauseOnAsyncCall MethodType = "Debugger.pauseOnAsyncCall" + CommandDebuggerRemoveBreakpoint MethodType = "Debugger.removeBreakpoint" + CommandDebuggerRestartFrame MethodType = "Debugger.restartFrame" + CommandDebuggerResume MethodType = "Debugger.resume" + CommandDebuggerScheduleStepIntoAsync MethodType = "Debugger.scheduleStepIntoAsync" + CommandDebuggerSearchInContent MethodType = "Debugger.searchInContent" + CommandDebuggerSetAsyncCallStackDepth MethodType = "Debugger.setAsyncCallStackDepth" + CommandDebuggerSetBlackboxPatterns MethodType = "Debugger.setBlackboxPatterns" + CommandDebuggerSetBlackboxedRanges MethodType = "Debugger.setBlackboxedRanges" + CommandDebuggerSetBreakpoint MethodType = "Debugger.setBreakpoint" + CommandDebuggerSetBreakpointByURL MethodType = "Debugger.setBreakpointByUrl" + CommandDebuggerSetBreakpointsActive MethodType = "Debugger.setBreakpointsActive" + CommandDebuggerSetPauseOnExceptions MethodType = "Debugger.setPauseOnExceptions" + CommandDebuggerSetReturnValue MethodType = "Debugger.setReturnValue" + CommandDebuggerSetScriptSource MethodType = "Debugger.setScriptSource" + CommandDebuggerSetSkipAllPauses MethodType = "Debugger.setSkipAllPauses" + CommandDebuggerSetVariableValue MethodType = "Debugger.setVariableValue" + CommandDebuggerStepInto MethodType = "Debugger.stepInto" + CommandDebuggerStepOut MethodType = "Debugger.stepOut" + CommandDebuggerStepOver MethodType = "Debugger.stepOver" + EventHeapProfilerAddHeapSnapshotChunk MethodType = "HeapProfiler.addHeapSnapshotChunk" + EventHeapProfilerHeapStatsUpdate MethodType = "HeapProfiler.heapStatsUpdate" + EventHeapProfilerLastSeenObjectID MethodType = "HeapProfiler.lastSeenObjectId" + EventHeapProfilerReportHeapSnapshotProgress MethodType = "HeapProfiler.reportHeapSnapshotProgress" + EventHeapProfilerResetProfiles MethodType = "HeapProfiler.resetProfiles" + CommandHeapProfilerAddInspectedHeapObject MethodType = "HeapProfiler.addInspectedHeapObject" + CommandHeapProfilerCollectGarbage MethodType = "HeapProfiler.collectGarbage" + CommandHeapProfilerDisable MethodType = "HeapProfiler.disable" + CommandHeapProfilerEnable MethodType = "HeapProfiler.enable" + CommandHeapProfilerGetHeapObjectID MethodType = "HeapProfiler.getHeapObjectId" + CommandHeapProfilerGetObjectByHeapObjectID MethodType = "HeapProfiler.getObjectByHeapObjectId" + CommandHeapProfilerGetSamplingProfile MethodType = "HeapProfiler.getSamplingProfile" + CommandHeapProfilerStartSampling MethodType = "HeapProfiler.startSampling" + CommandHeapProfilerStartTrackingHeapObjects MethodType = "HeapProfiler.startTrackingHeapObjects" + CommandHeapProfilerStopSampling MethodType = "HeapProfiler.stopSampling" + CommandHeapProfilerStopTrackingHeapObjects MethodType = "HeapProfiler.stopTrackingHeapObjects" + CommandHeapProfilerTakeHeapSnapshot MethodType = "HeapProfiler.takeHeapSnapshot" + EventProfilerConsoleProfileFinished MethodType = "Profiler.consoleProfileFinished" + EventProfilerConsoleProfileStarted MethodType = "Profiler.consoleProfileStarted" + CommandProfilerDisable MethodType = "Profiler.disable" + CommandProfilerEnable MethodType = "Profiler.enable" + CommandProfilerGetBestEffortCoverage MethodType = "Profiler.getBestEffortCoverage" + CommandProfilerSetSamplingInterval MethodType = "Profiler.setSamplingInterval" + CommandProfilerStart MethodType = "Profiler.start" + CommandProfilerStartPreciseCoverage MethodType = "Profiler.startPreciseCoverage" + CommandProfilerStartTypeProfile MethodType = "Profiler.startTypeProfile" + CommandProfilerStop MethodType = "Profiler.stop" + CommandProfilerStopPreciseCoverage MethodType = "Profiler.stopPreciseCoverage" + CommandProfilerStopTypeProfile MethodType = "Profiler.stopTypeProfile" + CommandProfilerTakePreciseCoverage MethodType = "Profiler.takePreciseCoverage" + CommandProfilerTakeTypeProfile MethodType = "Profiler.takeTypeProfile" + EventRuntimeConsoleAPICalled MethodType = "Runtime.consoleAPICalled" + EventRuntimeExceptionRevoked MethodType = "Runtime.exceptionRevoked" + EventRuntimeExceptionThrown MethodType = "Runtime.exceptionThrown" + EventRuntimeExecutionContextCreated MethodType = "Runtime.executionContextCreated" + EventRuntimeExecutionContextDestroyed MethodType = "Runtime.executionContextDestroyed" + EventRuntimeExecutionContextsCleared MethodType = "Runtime.executionContextsCleared" + EventRuntimeInspectRequested MethodType = "Runtime.inspectRequested" + CommandRuntimeAwaitPromise MethodType = "Runtime.awaitPromise" + CommandRuntimeCallFunctionOn MethodType = "Runtime.callFunctionOn" + CommandRuntimeCompileScript MethodType = "Runtime.compileScript" + CommandRuntimeDisable MethodType = "Runtime.disable" + CommandRuntimeDiscardConsoleEntries MethodType = "Runtime.discardConsoleEntries" + CommandRuntimeEnable MethodType = "Runtime.enable" + CommandRuntimeEvaluate MethodType = "Runtime.evaluate" + CommandRuntimeGetProperties MethodType = "Runtime.getProperties" + CommandRuntimeGlobalLexicalScopeNames MethodType = "Runtime.globalLexicalScopeNames" + CommandRuntimeQueryObjects MethodType = "Runtime.queryObjects" + CommandRuntimeReleaseObject MethodType = "Runtime.releaseObject" + CommandRuntimeReleaseObjectGroup MethodType = "Runtime.releaseObjectGroup" + CommandRuntimeRunIfWaitingForDebugger MethodType = "Runtime.runIfWaitingForDebugger" + CommandRuntimeRunScript MethodType = "Runtime.runScript" + CommandRuntimeSetCustomObjectFormatterEnabled MethodType = "Runtime.setCustomObjectFormatterEnabled" +) + +// MarshalEasyJSON satisfies easyjson.Marshaler. +func (t MethodType) MarshalEasyJSON(out *jwriter.Writer) { + out.String(string(t)) +} + +// MarshalJSON satisfies json.Marshaler. +func (t MethodType) MarshalJSON() ([]byte, error) { + return easyjson.Marshal(t) +} + +// UnmarshalEasyJSON satisfies easyjson.Unmarshaler. +func (t *MethodType) UnmarshalEasyJSON(in *jlexer.Lexer) { + switch MethodType(in.String()) { + case CommandAccessibilityGetPartialAXTree: + *t = CommandAccessibilityGetPartialAXTree + case EventAnimationAnimationCanceled: + *t = EventAnimationAnimationCanceled + case EventAnimationAnimationCreated: + *t = EventAnimationAnimationCreated + case EventAnimationAnimationStarted: + *t = EventAnimationAnimationStarted + case CommandAnimationDisable: + *t = CommandAnimationDisable + case CommandAnimationEnable: + *t = CommandAnimationEnable + case CommandAnimationGetCurrentTime: + *t = CommandAnimationGetCurrentTime + case CommandAnimationGetPlaybackRate: + *t = CommandAnimationGetPlaybackRate + case CommandAnimationReleaseAnimations: + *t = CommandAnimationReleaseAnimations + case CommandAnimationResolveAnimation: + *t = CommandAnimationResolveAnimation + case CommandAnimationSeekAnimations: + *t = CommandAnimationSeekAnimations + case CommandAnimationSetPaused: + *t = CommandAnimationSetPaused + case CommandAnimationSetPlaybackRate: + *t = CommandAnimationSetPlaybackRate + case CommandAnimationSetTiming: + *t = CommandAnimationSetTiming + case EventApplicationCacheApplicationCacheStatusUpdated: + *t = EventApplicationCacheApplicationCacheStatusUpdated + case EventApplicationCacheNetworkStateUpdated: + *t = EventApplicationCacheNetworkStateUpdated + case CommandApplicationCacheEnable: + *t = CommandApplicationCacheEnable + case CommandApplicationCacheGetApplicationCacheForFrame: + *t = CommandApplicationCacheGetApplicationCacheForFrame + case CommandApplicationCacheGetFramesWithManifests: + *t = CommandApplicationCacheGetFramesWithManifests + case CommandApplicationCacheGetManifestForFrame: + *t = CommandApplicationCacheGetManifestForFrame + case CommandAuditsGetEncodedResponse: + *t = CommandAuditsGetEncodedResponse + case CommandBrowserClose: + *t = CommandBrowserClose + case CommandBrowserGetVersion: + *t = CommandBrowserGetVersion + case CommandBrowserGetWindowBounds: + *t = CommandBrowserGetWindowBounds + case CommandBrowserGetWindowForTarget: + *t = CommandBrowserGetWindowForTarget + case CommandBrowserSetWindowBounds: + *t = CommandBrowserSetWindowBounds + case EventCSSFontsUpdated: + *t = EventCSSFontsUpdated + case EventCSSMediaQueryResultChanged: + *t = EventCSSMediaQueryResultChanged + case EventCSSStyleSheetAdded: + *t = EventCSSStyleSheetAdded + case EventCSSStyleSheetChanged: + *t = EventCSSStyleSheetChanged + case EventCSSStyleSheetRemoved: + *t = EventCSSStyleSheetRemoved + case CommandCSSAddRule: + *t = CommandCSSAddRule + case CommandCSSCollectClassNames: + *t = CommandCSSCollectClassNames + case CommandCSSCreateStyleSheet: + *t = CommandCSSCreateStyleSheet + case CommandCSSDisable: + *t = CommandCSSDisable + case CommandCSSEnable: + *t = CommandCSSEnable + case CommandCSSForcePseudoState: + *t = CommandCSSForcePseudoState + case CommandCSSGetBackgroundColors: + *t = CommandCSSGetBackgroundColors + case CommandCSSGetComputedStyleForNode: + *t = CommandCSSGetComputedStyleForNode + case CommandCSSGetInlineStylesForNode: + *t = CommandCSSGetInlineStylesForNode + case CommandCSSGetMatchedStylesForNode: + *t = CommandCSSGetMatchedStylesForNode + case CommandCSSGetMediaQueries: + *t = CommandCSSGetMediaQueries + case CommandCSSGetPlatformFontsForNode: + *t = CommandCSSGetPlatformFontsForNode + case CommandCSSGetStyleSheetText: + *t = CommandCSSGetStyleSheetText + case CommandCSSSetEffectivePropertyValueForNode: + *t = CommandCSSSetEffectivePropertyValueForNode + case CommandCSSSetKeyframeKey: + *t = CommandCSSSetKeyframeKey + case CommandCSSSetMediaText: + *t = CommandCSSSetMediaText + case CommandCSSSetRuleSelector: + *t = CommandCSSSetRuleSelector + case CommandCSSSetStyleSheetText: + *t = CommandCSSSetStyleSheetText + case CommandCSSSetStyleTexts: + *t = CommandCSSSetStyleTexts + case CommandCSSStartRuleUsageTracking: + *t = CommandCSSStartRuleUsageTracking + case CommandCSSStopRuleUsageTracking: + *t = CommandCSSStopRuleUsageTracking + case CommandCSSTakeCoverageDelta: + *t = CommandCSSTakeCoverageDelta + case CommandCacheStorageDeleteCache: + *t = CommandCacheStorageDeleteCache + case CommandCacheStorageDeleteEntry: + *t = CommandCacheStorageDeleteEntry + case CommandCacheStorageRequestCacheNames: + *t = CommandCacheStorageRequestCacheNames + case CommandCacheStorageRequestCachedResponse: + *t = CommandCacheStorageRequestCachedResponse + case CommandCacheStorageRequestEntries: + *t = CommandCacheStorageRequestEntries + case EventDOMAttributeModified: + *t = EventDOMAttributeModified + case EventDOMAttributeRemoved: + *t = EventDOMAttributeRemoved + case EventDOMCharacterDataModified: + *t = EventDOMCharacterDataModified + case EventDOMChildNodeCountUpdated: + *t = EventDOMChildNodeCountUpdated + case EventDOMChildNodeInserted: + *t = EventDOMChildNodeInserted + case EventDOMChildNodeRemoved: + *t = EventDOMChildNodeRemoved + case EventDOMDistributedNodesUpdated: + *t = EventDOMDistributedNodesUpdated + case EventDOMDocumentUpdated: + *t = EventDOMDocumentUpdated + case EventDOMInlineStyleInvalidated: + *t = EventDOMInlineStyleInvalidated + case EventDOMPseudoElementAdded: + *t = EventDOMPseudoElementAdded + case EventDOMPseudoElementRemoved: + *t = EventDOMPseudoElementRemoved + case EventDOMSetChildNodes: + *t = EventDOMSetChildNodes + case EventDOMShadowRootPopped: + *t = EventDOMShadowRootPopped + case EventDOMShadowRootPushed: + *t = EventDOMShadowRootPushed + case CommandDOMCollectClassNamesFromSubtree: + *t = CommandDOMCollectClassNamesFromSubtree + case CommandDOMCopyTo: + *t = CommandDOMCopyTo + case CommandDOMDescribeNode: + *t = CommandDOMDescribeNode + case CommandDOMDisable: + *t = CommandDOMDisable + case CommandDOMDiscardSearchResults: + *t = CommandDOMDiscardSearchResults + case CommandDOMEnable: + *t = CommandDOMEnable + case CommandDOMFocus: + *t = CommandDOMFocus + case CommandDOMGetAttributes: + *t = CommandDOMGetAttributes + case CommandDOMGetBoxModel: + *t = CommandDOMGetBoxModel + case CommandDOMGetDocument: + *t = CommandDOMGetDocument + case CommandDOMGetFlattenedDocument: + *t = CommandDOMGetFlattenedDocument + case CommandDOMGetNodeForLocation: + *t = CommandDOMGetNodeForLocation + case CommandDOMGetOuterHTML: + *t = CommandDOMGetOuterHTML + case CommandDOMGetRelayoutBoundary: + *t = CommandDOMGetRelayoutBoundary + case CommandDOMGetSearchResults: + *t = CommandDOMGetSearchResults + case CommandDOMMarkUndoableState: + *t = CommandDOMMarkUndoableState + case CommandDOMMoveTo: + *t = CommandDOMMoveTo + case CommandDOMPerformSearch: + *t = CommandDOMPerformSearch + case CommandDOMPushNodeByPathToFrontend: + *t = CommandDOMPushNodeByPathToFrontend + case CommandDOMPushNodesByBackendIdsToFrontend: + *t = CommandDOMPushNodesByBackendIdsToFrontend + case CommandDOMQuerySelector: + *t = CommandDOMQuerySelector + case CommandDOMQuerySelectorAll: + *t = CommandDOMQuerySelectorAll + case CommandDOMRedo: + *t = CommandDOMRedo + case CommandDOMRemoveAttribute: + *t = CommandDOMRemoveAttribute + case CommandDOMRemoveNode: + *t = CommandDOMRemoveNode + case CommandDOMRequestChildNodes: + *t = CommandDOMRequestChildNodes + case CommandDOMRequestNode: + *t = CommandDOMRequestNode + case CommandDOMResolveNode: + *t = CommandDOMResolveNode + case CommandDOMSetAttributeValue: + *t = CommandDOMSetAttributeValue + case CommandDOMSetAttributesAsText: + *t = CommandDOMSetAttributesAsText + case CommandDOMSetFileInputFiles: + *t = CommandDOMSetFileInputFiles + case CommandDOMSetInspectedNode: + *t = CommandDOMSetInspectedNode + case CommandDOMSetNodeName: + *t = CommandDOMSetNodeName + case CommandDOMSetNodeValue: + *t = CommandDOMSetNodeValue + case CommandDOMSetOuterHTML: + *t = CommandDOMSetOuterHTML + case CommandDOMUndo: + *t = CommandDOMUndo + case CommandDOMDebuggerGetEventListeners: + *t = CommandDOMDebuggerGetEventListeners + case CommandDOMDebuggerRemoveDOMBreakpoint: + *t = CommandDOMDebuggerRemoveDOMBreakpoint + case CommandDOMDebuggerRemoveEventListenerBreakpoint: + *t = CommandDOMDebuggerRemoveEventListenerBreakpoint + case CommandDOMDebuggerRemoveInstrumentationBreakpoint: + *t = CommandDOMDebuggerRemoveInstrumentationBreakpoint + case CommandDOMDebuggerRemoveXHRBreakpoint: + *t = CommandDOMDebuggerRemoveXHRBreakpoint + case CommandDOMDebuggerSetDOMBreakpoint: + *t = CommandDOMDebuggerSetDOMBreakpoint + case CommandDOMDebuggerSetEventListenerBreakpoint: + *t = CommandDOMDebuggerSetEventListenerBreakpoint + case CommandDOMDebuggerSetInstrumentationBreakpoint: + *t = CommandDOMDebuggerSetInstrumentationBreakpoint + case CommandDOMDebuggerSetXHRBreakpoint: + *t = CommandDOMDebuggerSetXHRBreakpoint + case CommandDOMSnapshotGetSnapshot: + *t = CommandDOMSnapshotGetSnapshot + case EventDOMStorageDomStorageItemAdded: + *t = EventDOMStorageDomStorageItemAdded + case EventDOMStorageDomStorageItemRemoved: + *t = EventDOMStorageDomStorageItemRemoved + case EventDOMStorageDomStorageItemUpdated: + *t = EventDOMStorageDomStorageItemUpdated + case EventDOMStorageDomStorageItemsCleared: + *t = EventDOMStorageDomStorageItemsCleared + case CommandDOMStorageClear: + *t = CommandDOMStorageClear + case CommandDOMStorageDisable: + *t = CommandDOMStorageDisable + case CommandDOMStorageEnable: + *t = CommandDOMStorageEnable + case CommandDOMStorageGetDOMStorageItems: + *t = CommandDOMStorageGetDOMStorageItems + case CommandDOMStorageRemoveDOMStorageItem: + *t = CommandDOMStorageRemoveDOMStorageItem + case CommandDOMStorageSetDOMStorageItem: + *t = CommandDOMStorageSetDOMStorageItem + case EventDatabaseAddDatabase: + *t = EventDatabaseAddDatabase + case CommandDatabaseDisable: + *t = CommandDatabaseDisable + case CommandDatabaseEnable: + *t = CommandDatabaseEnable + case CommandDatabaseExecuteSQL: + *t = CommandDatabaseExecuteSQL + case CommandDatabaseGetDatabaseTableNames: + *t = CommandDatabaseGetDatabaseTableNames + case CommandDeviceOrientationClearDeviceOrientationOverride: + *t = CommandDeviceOrientationClearDeviceOrientationOverride + case CommandDeviceOrientationSetDeviceOrientationOverride: + *t = CommandDeviceOrientationSetDeviceOrientationOverride + case EventEmulationVirtualTimeAdvanced: + *t = EventEmulationVirtualTimeAdvanced + case EventEmulationVirtualTimeBudgetExpired: + *t = EventEmulationVirtualTimeBudgetExpired + case EventEmulationVirtualTimePaused: + *t = EventEmulationVirtualTimePaused + case CommandEmulationCanEmulate: + *t = CommandEmulationCanEmulate + case CommandEmulationClearDeviceMetricsOverride: + *t = CommandEmulationClearDeviceMetricsOverride + case CommandEmulationClearGeolocationOverride: + *t = CommandEmulationClearGeolocationOverride + case CommandEmulationResetPageScaleFactor: + *t = CommandEmulationResetPageScaleFactor + case CommandEmulationSetCPUThrottlingRate: + *t = CommandEmulationSetCPUThrottlingRate + case CommandEmulationSetDefaultBackgroundColorOverride: + *t = CommandEmulationSetDefaultBackgroundColorOverride + case CommandEmulationSetDeviceMetricsOverride: + *t = CommandEmulationSetDeviceMetricsOverride + case CommandEmulationSetEmitTouchEventsForMouse: + *t = CommandEmulationSetEmitTouchEventsForMouse + case CommandEmulationSetEmulatedMedia: + *t = CommandEmulationSetEmulatedMedia + case CommandEmulationSetGeolocationOverride: + *t = CommandEmulationSetGeolocationOverride + case CommandEmulationSetNavigatorOverrides: + *t = CommandEmulationSetNavigatorOverrides + case CommandEmulationSetPageScaleFactor: + *t = CommandEmulationSetPageScaleFactor + case CommandEmulationSetScriptExecutionDisabled: + *t = CommandEmulationSetScriptExecutionDisabled + case CommandEmulationSetTouchEmulationEnabled: + *t = CommandEmulationSetTouchEmulationEnabled + case CommandEmulationSetVirtualTimePolicy: + *t = CommandEmulationSetVirtualTimePolicy + case EventHeadlessExperimentalMainFrameReadyForScreenshots: + *t = EventHeadlessExperimentalMainFrameReadyForScreenshots + case EventHeadlessExperimentalNeedsBeginFramesChanged: + *t = EventHeadlessExperimentalNeedsBeginFramesChanged + case CommandHeadlessExperimentalBeginFrame: + *t = CommandHeadlessExperimentalBeginFrame + case CommandHeadlessExperimentalDisable: + *t = CommandHeadlessExperimentalDisable + case CommandHeadlessExperimentalEnable: + *t = CommandHeadlessExperimentalEnable + case CommandIOClose: + *t = CommandIOClose + case CommandIORead: + *t = CommandIORead + case CommandIOResolveBlob: + *t = CommandIOResolveBlob + case CommandIndexedDBClearObjectStore: + *t = CommandIndexedDBClearObjectStore + case CommandIndexedDBDeleteDatabase: + *t = CommandIndexedDBDeleteDatabase + case CommandIndexedDBDeleteObjectStoreEntries: + *t = CommandIndexedDBDeleteObjectStoreEntries + case CommandIndexedDBDisable: + *t = CommandIndexedDBDisable + case CommandIndexedDBEnable: + *t = CommandIndexedDBEnable + case CommandIndexedDBRequestData: + *t = CommandIndexedDBRequestData + case CommandIndexedDBRequestDatabase: + *t = CommandIndexedDBRequestDatabase + case CommandIndexedDBRequestDatabaseNames: + *t = CommandIndexedDBRequestDatabaseNames + case CommandInputDispatchKeyEvent: + *t = CommandInputDispatchKeyEvent + case CommandInputDispatchMouseEvent: + *t = CommandInputDispatchMouseEvent + case CommandInputDispatchTouchEvent: + *t = CommandInputDispatchTouchEvent + case CommandInputEmulateTouchFromMouseEvent: + *t = CommandInputEmulateTouchFromMouseEvent + case CommandInputSetIgnoreInputEvents: + *t = CommandInputSetIgnoreInputEvents + case CommandInputSynthesizePinchGesture: + *t = CommandInputSynthesizePinchGesture + case CommandInputSynthesizeScrollGesture: + *t = CommandInputSynthesizeScrollGesture + case CommandInputSynthesizeTapGesture: + *t = CommandInputSynthesizeTapGesture + case EventInspectorDetached: + *t = EventInspectorDetached + case EventInspectorTargetCrashed: + *t = EventInspectorTargetCrashed + case CommandInspectorDisable: + *t = CommandInspectorDisable + case CommandInspectorEnable: + *t = CommandInspectorEnable + case EventLayerTreeLayerPainted: + *t = EventLayerTreeLayerPainted + case EventLayerTreeLayerTreeDidChange: + *t = EventLayerTreeLayerTreeDidChange + case CommandLayerTreeCompositingReasons: + *t = CommandLayerTreeCompositingReasons + case CommandLayerTreeDisable: + *t = CommandLayerTreeDisable + case CommandLayerTreeEnable: + *t = CommandLayerTreeEnable + case CommandLayerTreeLoadSnapshot: + *t = CommandLayerTreeLoadSnapshot + case CommandLayerTreeMakeSnapshot: + *t = CommandLayerTreeMakeSnapshot + case CommandLayerTreeProfileSnapshot: + *t = CommandLayerTreeProfileSnapshot + case CommandLayerTreeReleaseSnapshot: + *t = CommandLayerTreeReleaseSnapshot + case CommandLayerTreeReplaySnapshot: + *t = CommandLayerTreeReplaySnapshot + case CommandLayerTreeSnapshotCommandLog: + *t = CommandLayerTreeSnapshotCommandLog + case EventLogEntryAdded: + *t = EventLogEntryAdded + case CommandLogClear: + *t = CommandLogClear + case CommandLogDisable: + *t = CommandLogDisable + case CommandLogEnable: + *t = CommandLogEnable + case CommandLogStartViolationsReport: + *t = CommandLogStartViolationsReport + case CommandLogStopViolationsReport: + *t = CommandLogStopViolationsReport + case CommandMemoryGetDOMCounters: + *t = CommandMemoryGetDOMCounters + case CommandMemoryPrepareForLeakDetection: + *t = CommandMemoryPrepareForLeakDetection + case CommandMemorySetPressureNotificationsSuppressed: + *t = CommandMemorySetPressureNotificationsSuppressed + case CommandMemorySimulatePressureNotification: + *t = CommandMemorySimulatePressureNotification + case EventNetworkDataReceived: + *t = EventNetworkDataReceived + case EventNetworkEventSourceMessageReceived: + *t = EventNetworkEventSourceMessageReceived + case EventNetworkLoadingFailed: + *t = EventNetworkLoadingFailed + case EventNetworkLoadingFinished: + *t = EventNetworkLoadingFinished + case EventNetworkRequestIntercepted: + *t = EventNetworkRequestIntercepted + case EventNetworkRequestServedFromCache: + *t = EventNetworkRequestServedFromCache + case EventNetworkRequestWillBeSent: + *t = EventNetworkRequestWillBeSent + case EventNetworkResourceChangedPriority: + *t = EventNetworkResourceChangedPriority + case EventNetworkResponseReceived: + *t = EventNetworkResponseReceived + case EventNetworkWebSocketClosed: + *t = EventNetworkWebSocketClosed + case EventNetworkWebSocketCreated: + *t = EventNetworkWebSocketCreated + case EventNetworkWebSocketFrameError: + *t = EventNetworkWebSocketFrameError + case EventNetworkWebSocketFrameReceived: + *t = EventNetworkWebSocketFrameReceived + case EventNetworkWebSocketFrameSent: + *t = EventNetworkWebSocketFrameSent + case EventNetworkWebSocketHandshakeResponseReceived: + *t = EventNetworkWebSocketHandshakeResponseReceived + case EventNetworkWebSocketWillSendHandshakeRequest: + *t = EventNetworkWebSocketWillSendHandshakeRequest + case CommandNetworkClearBrowserCache: + *t = CommandNetworkClearBrowserCache + case CommandNetworkClearBrowserCookies: + *t = CommandNetworkClearBrowserCookies + case CommandNetworkContinueInterceptedRequest: + *t = CommandNetworkContinueInterceptedRequest + case CommandNetworkDeleteCookies: + *t = CommandNetworkDeleteCookies + case CommandNetworkDisable: + *t = CommandNetworkDisable + case CommandNetworkEmulateNetworkConditions: + *t = CommandNetworkEmulateNetworkConditions + case CommandNetworkEnable: + *t = CommandNetworkEnable + case CommandNetworkGetAllCookies: + *t = CommandNetworkGetAllCookies + case CommandNetworkGetCertificate: + *t = CommandNetworkGetCertificate + case CommandNetworkGetCookies: + *t = CommandNetworkGetCookies + case CommandNetworkGetResponseBody: + *t = CommandNetworkGetResponseBody + case CommandNetworkGetResponseBodyForInterception: + *t = CommandNetworkGetResponseBodyForInterception + case CommandNetworkReplayXHR: + *t = CommandNetworkReplayXHR + case CommandNetworkSearchInResponseBody: + *t = CommandNetworkSearchInResponseBody + case CommandNetworkSetBlockedURLS: + *t = CommandNetworkSetBlockedURLS + case CommandNetworkSetBypassServiceWorker: + *t = CommandNetworkSetBypassServiceWorker + case CommandNetworkSetCacheDisabled: + *t = CommandNetworkSetCacheDisabled + case CommandNetworkSetCookie: + *t = CommandNetworkSetCookie + case CommandNetworkSetCookies: + *t = CommandNetworkSetCookies + case CommandNetworkSetDataSizeLimitsForTest: + *t = CommandNetworkSetDataSizeLimitsForTest + case CommandNetworkSetExtraHTTPHeaders: + *t = CommandNetworkSetExtraHTTPHeaders + case CommandNetworkSetRequestInterception: + *t = CommandNetworkSetRequestInterception + case CommandNetworkSetUserAgentOverride: + *t = CommandNetworkSetUserAgentOverride + case EventOverlayInspectNodeRequested: + *t = EventOverlayInspectNodeRequested + case EventOverlayNodeHighlightRequested: + *t = EventOverlayNodeHighlightRequested + case EventOverlayScreenshotRequested: + *t = EventOverlayScreenshotRequested + case CommandOverlayDisable: + *t = CommandOverlayDisable + case CommandOverlayEnable: + *t = CommandOverlayEnable + case CommandOverlayGetHighlightObjectForTest: + *t = CommandOverlayGetHighlightObjectForTest + case CommandOverlayHideHighlight: + *t = CommandOverlayHideHighlight + case CommandOverlayHighlightFrame: + *t = CommandOverlayHighlightFrame + case CommandOverlayHighlightNode: + *t = CommandOverlayHighlightNode + case CommandOverlayHighlightQuad: + *t = CommandOverlayHighlightQuad + case CommandOverlayHighlightRect: + *t = CommandOverlayHighlightRect + case CommandOverlaySetInspectMode: + *t = CommandOverlaySetInspectMode + case CommandOverlaySetPausedInDebuggerMessage: + *t = CommandOverlaySetPausedInDebuggerMessage + case CommandOverlaySetShowDebugBorders: + *t = CommandOverlaySetShowDebugBorders + case CommandOverlaySetShowFPSCounter: + *t = CommandOverlaySetShowFPSCounter + case CommandOverlaySetShowPaintRects: + *t = CommandOverlaySetShowPaintRects + case CommandOverlaySetShowScrollBottleneckRects: + *t = CommandOverlaySetShowScrollBottleneckRects + case CommandOverlaySetShowViewportSizeOnResize: + *t = CommandOverlaySetShowViewportSizeOnResize + case CommandOverlaySetSuspended: + *t = CommandOverlaySetSuspended + case EventPageDomContentEventFired: + *t = EventPageDomContentEventFired + case EventPageFrameAttached: + *t = EventPageFrameAttached + case EventPageFrameClearedScheduledNavigation: + *t = EventPageFrameClearedScheduledNavigation + case EventPageFrameDetached: + *t = EventPageFrameDetached + case EventPageFrameNavigated: + *t = EventPageFrameNavigated + case EventPageFrameResized: + *t = EventPageFrameResized + case EventPageFrameScheduledNavigation: + *t = EventPageFrameScheduledNavigation + case EventPageFrameStartedLoading: + *t = EventPageFrameStartedLoading + case EventPageFrameStoppedLoading: + *t = EventPageFrameStoppedLoading + case EventPageInterstitialHidden: + *t = EventPageInterstitialHidden + case EventPageInterstitialShown: + *t = EventPageInterstitialShown + case EventPageJavascriptDialogClosed: + *t = EventPageJavascriptDialogClosed + case EventPageJavascriptDialogOpening: + *t = EventPageJavascriptDialogOpening + case EventPageLifecycleEvent: + *t = EventPageLifecycleEvent + case EventPageLoadEventFired: + *t = EventPageLoadEventFired + case EventPageScreencastFrame: + *t = EventPageScreencastFrame + case EventPageScreencastVisibilityChanged: + *t = EventPageScreencastVisibilityChanged + case EventPageWindowOpen: + *t = EventPageWindowOpen + case CommandPageAddScriptToEvaluateOnNewDocument: + *t = CommandPageAddScriptToEvaluateOnNewDocument + case CommandPageBringToFront: + *t = CommandPageBringToFront + case CommandPageCaptureScreenshot: + *t = CommandPageCaptureScreenshot + case CommandPageCreateIsolatedWorld: + *t = CommandPageCreateIsolatedWorld + case CommandPageDisable: + *t = CommandPageDisable + case CommandPageEnable: + *t = CommandPageEnable + case CommandPageGetAppManifest: + *t = CommandPageGetAppManifest + case CommandPageGetFrameTree: + *t = CommandPageGetFrameTree + case CommandPageGetLayoutMetrics: + *t = CommandPageGetLayoutMetrics + case CommandPageGetNavigationHistory: + *t = CommandPageGetNavigationHistory + case CommandPageGetResourceContent: + *t = CommandPageGetResourceContent + case CommandPageGetResourceTree: + *t = CommandPageGetResourceTree + case CommandPageHandleJavaScriptDialog: + *t = CommandPageHandleJavaScriptDialog + case CommandPageNavigate: + *t = CommandPageNavigate + case CommandPageNavigateToHistoryEntry: + *t = CommandPageNavigateToHistoryEntry + case CommandPagePrintToPDF: + *t = CommandPagePrintToPDF + case CommandPageReload: + *t = CommandPageReload + case CommandPageRemoveScriptToEvaluateOnNewDocument: + *t = CommandPageRemoveScriptToEvaluateOnNewDocument + case CommandPageRequestAppBanner: + *t = CommandPageRequestAppBanner + case CommandPageScreencastFrameAck: + *t = CommandPageScreencastFrameAck + case CommandPageSearchInResource: + *t = CommandPageSearchInResource + case CommandPageSetAdBlockingEnabled: + *t = CommandPageSetAdBlockingEnabled + case CommandPageSetAutoAttachToCreatedPages: + *t = CommandPageSetAutoAttachToCreatedPages + case CommandPageSetDocumentContent: + *t = CommandPageSetDocumentContent + case CommandPageSetDownloadBehavior: + *t = CommandPageSetDownloadBehavior + case CommandPageSetLifecycleEventsEnabled: + *t = CommandPageSetLifecycleEventsEnabled + case CommandPageStartScreencast: + *t = CommandPageStartScreencast + case CommandPageStopLoading: + *t = CommandPageStopLoading + case CommandPageStopScreencast: + *t = CommandPageStopScreencast + case EventPerformanceMetrics: + *t = EventPerformanceMetrics + case CommandPerformanceDisable: + *t = CommandPerformanceDisable + case CommandPerformanceEnable: + *t = CommandPerformanceEnable + case CommandPerformanceGetMetrics: + *t = CommandPerformanceGetMetrics + case EventSecurityCertificateError: + *t = EventSecurityCertificateError + case EventSecuritySecurityStateChanged: + *t = EventSecuritySecurityStateChanged + case CommandSecurityDisable: + *t = CommandSecurityDisable + case CommandSecurityEnable: + *t = CommandSecurityEnable + case CommandSecurityHandleCertificateError: + *t = CommandSecurityHandleCertificateError + case CommandSecuritySetOverrideCertificateErrors: + *t = CommandSecuritySetOverrideCertificateErrors + case EventServiceWorkerWorkerErrorReported: + *t = EventServiceWorkerWorkerErrorReported + case EventServiceWorkerWorkerRegistrationUpdated: + *t = EventServiceWorkerWorkerRegistrationUpdated + case EventServiceWorkerWorkerVersionUpdated: + *t = EventServiceWorkerWorkerVersionUpdated + case CommandServiceWorkerDeliverPushMessage: + *t = CommandServiceWorkerDeliverPushMessage + case CommandServiceWorkerDisable: + *t = CommandServiceWorkerDisable + case CommandServiceWorkerDispatchSyncEvent: + *t = CommandServiceWorkerDispatchSyncEvent + case CommandServiceWorkerEnable: + *t = CommandServiceWorkerEnable + case CommandServiceWorkerInspectWorker: + *t = CommandServiceWorkerInspectWorker + case CommandServiceWorkerSetForceUpdateOnPageLoad: + *t = CommandServiceWorkerSetForceUpdateOnPageLoad + case CommandServiceWorkerSkipWaiting: + *t = CommandServiceWorkerSkipWaiting + case CommandServiceWorkerStartWorker: + *t = CommandServiceWorkerStartWorker + case CommandServiceWorkerStopAllWorkers: + *t = CommandServiceWorkerStopAllWorkers + case CommandServiceWorkerStopWorker: + *t = CommandServiceWorkerStopWorker + case CommandServiceWorkerUnregister: + *t = CommandServiceWorkerUnregister + case CommandServiceWorkerUpdateRegistration: + *t = CommandServiceWorkerUpdateRegistration + case EventStorageCacheStorageContentUpdated: + *t = EventStorageCacheStorageContentUpdated + case EventStorageCacheStorageListUpdated: + *t = EventStorageCacheStorageListUpdated + case EventStorageIndexedDBContentUpdated: + *t = EventStorageIndexedDBContentUpdated + case EventStorageIndexedDBListUpdated: + *t = EventStorageIndexedDBListUpdated + case CommandStorageClearDataForOrigin: + *t = CommandStorageClearDataForOrigin + case CommandStorageGetUsageAndQuota: + *t = CommandStorageGetUsageAndQuota + case CommandStorageTrackCacheStorageForOrigin: + *t = CommandStorageTrackCacheStorageForOrigin + case CommandStorageTrackIndexedDBForOrigin: + *t = CommandStorageTrackIndexedDBForOrigin + case CommandStorageUntrackCacheStorageForOrigin: + *t = CommandStorageUntrackCacheStorageForOrigin + case CommandStorageUntrackIndexedDBForOrigin: + *t = CommandStorageUntrackIndexedDBForOrigin + case CommandSystemInfoGetInfo: + *t = CommandSystemInfoGetInfo + case EventTargetAttachedToTarget: + *t = EventTargetAttachedToTarget + case EventTargetDetachedFromTarget: + *t = EventTargetDetachedFromTarget + case EventTargetReceivedMessageFromTarget: + *t = EventTargetReceivedMessageFromTarget + case EventTargetTargetCreated: + *t = EventTargetTargetCreated + case EventTargetTargetDestroyed: + *t = EventTargetTargetDestroyed + case EventTargetTargetInfoChanged: + *t = EventTargetTargetInfoChanged + case CommandTargetActivateTarget: + *t = CommandTargetActivateTarget + case CommandTargetAttachToTarget: + *t = CommandTargetAttachToTarget + case CommandTargetCloseTarget: + *t = CommandTargetCloseTarget + case CommandTargetCreateBrowserContext: + *t = CommandTargetCreateBrowserContext + case CommandTargetCreateTarget: + *t = CommandTargetCreateTarget + case CommandTargetDetachFromTarget: + *t = CommandTargetDetachFromTarget + case CommandTargetDisposeBrowserContext: + *t = CommandTargetDisposeBrowserContext + case CommandTargetGetTargetInfo: + *t = CommandTargetGetTargetInfo + case CommandTargetGetTargets: + *t = CommandTargetGetTargets + case CommandTargetSendMessageToTarget: + *t = CommandTargetSendMessageToTarget + case CommandTargetSetAttachToFrames: + *t = CommandTargetSetAttachToFrames + case CommandTargetSetAutoAttach: + *t = CommandTargetSetAutoAttach + case CommandTargetSetDiscoverTargets: + *t = CommandTargetSetDiscoverTargets + case CommandTargetSetRemoteLocations: + *t = CommandTargetSetRemoteLocations + case EventTetheringAccepted: + *t = EventTetheringAccepted + case CommandTetheringBind: + *t = CommandTetheringBind + case CommandTetheringUnbind: + *t = CommandTetheringUnbind + case EventTracingBufferUsage: + *t = EventTracingBufferUsage + case EventTracingDataCollected: + *t = EventTracingDataCollected + case EventTracingTracingComplete: + *t = EventTracingTracingComplete + case CommandTracingEnd: + *t = CommandTracingEnd + case CommandTracingGetCategories: + *t = CommandTracingGetCategories + case CommandTracingRecordClockSyncMarker: + *t = CommandTracingRecordClockSyncMarker + case CommandTracingRequestMemoryDump: + *t = CommandTracingRequestMemoryDump + case CommandTracingStart: + *t = CommandTracingStart + case EventDebuggerBreakpointResolved: + *t = EventDebuggerBreakpointResolved + case EventDebuggerPaused: + *t = EventDebuggerPaused + case EventDebuggerResumed: + *t = EventDebuggerResumed + case EventDebuggerScriptFailedToParse: + *t = EventDebuggerScriptFailedToParse + case EventDebuggerScriptParsed: + *t = EventDebuggerScriptParsed + case CommandDebuggerContinueToLocation: + *t = CommandDebuggerContinueToLocation + case CommandDebuggerDisable: + *t = CommandDebuggerDisable + case CommandDebuggerEnable: + *t = CommandDebuggerEnable + case CommandDebuggerEvaluateOnCallFrame: + *t = CommandDebuggerEvaluateOnCallFrame + case CommandDebuggerGetPossibleBreakpoints: + *t = CommandDebuggerGetPossibleBreakpoints + case CommandDebuggerGetScriptSource: + *t = CommandDebuggerGetScriptSource + case CommandDebuggerGetStackTrace: + *t = CommandDebuggerGetStackTrace + case CommandDebuggerPause: + *t = CommandDebuggerPause + case CommandDebuggerPauseOnAsyncCall: + *t = CommandDebuggerPauseOnAsyncCall + case CommandDebuggerRemoveBreakpoint: + *t = CommandDebuggerRemoveBreakpoint + case CommandDebuggerRestartFrame: + *t = CommandDebuggerRestartFrame + case CommandDebuggerResume: + *t = CommandDebuggerResume + case CommandDebuggerScheduleStepIntoAsync: + *t = CommandDebuggerScheduleStepIntoAsync + case CommandDebuggerSearchInContent: + *t = CommandDebuggerSearchInContent + case CommandDebuggerSetAsyncCallStackDepth: + *t = CommandDebuggerSetAsyncCallStackDepth + case CommandDebuggerSetBlackboxPatterns: + *t = CommandDebuggerSetBlackboxPatterns + case CommandDebuggerSetBlackboxedRanges: + *t = CommandDebuggerSetBlackboxedRanges + case CommandDebuggerSetBreakpoint: + *t = CommandDebuggerSetBreakpoint + case CommandDebuggerSetBreakpointByURL: + *t = CommandDebuggerSetBreakpointByURL + case CommandDebuggerSetBreakpointsActive: + *t = CommandDebuggerSetBreakpointsActive + case CommandDebuggerSetPauseOnExceptions: + *t = CommandDebuggerSetPauseOnExceptions + case CommandDebuggerSetReturnValue: + *t = CommandDebuggerSetReturnValue + case CommandDebuggerSetScriptSource: + *t = CommandDebuggerSetScriptSource + case CommandDebuggerSetSkipAllPauses: + *t = CommandDebuggerSetSkipAllPauses + case CommandDebuggerSetVariableValue: + *t = CommandDebuggerSetVariableValue + case CommandDebuggerStepInto: + *t = CommandDebuggerStepInto + case CommandDebuggerStepOut: + *t = CommandDebuggerStepOut + case CommandDebuggerStepOver: + *t = CommandDebuggerStepOver + case EventHeapProfilerAddHeapSnapshotChunk: + *t = EventHeapProfilerAddHeapSnapshotChunk + case EventHeapProfilerHeapStatsUpdate: + *t = EventHeapProfilerHeapStatsUpdate + case EventHeapProfilerLastSeenObjectID: + *t = EventHeapProfilerLastSeenObjectID + case EventHeapProfilerReportHeapSnapshotProgress: + *t = EventHeapProfilerReportHeapSnapshotProgress + case EventHeapProfilerResetProfiles: + *t = EventHeapProfilerResetProfiles + case CommandHeapProfilerAddInspectedHeapObject: + *t = CommandHeapProfilerAddInspectedHeapObject + case CommandHeapProfilerCollectGarbage: + *t = CommandHeapProfilerCollectGarbage + case CommandHeapProfilerDisable: + *t = CommandHeapProfilerDisable + case CommandHeapProfilerEnable: + *t = CommandHeapProfilerEnable + case CommandHeapProfilerGetHeapObjectID: + *t = CommandHeapProfilerGetHeapObjectID + case CommandHeapProfilerGetObjectByHeapObjectID: + *t = CommandHeapProfilerGetObjectByHeapObjectID + case CommandHeapProfilerGetSamplingProfile: + *t = CommandHeapProfilerGetSamplingProfile + case CommandHeapProfilerStartSampling: + *t = CommandHeapProfilerStartSampling + case CommandHeapProfilerStartTrackingHeapObjects: + *t = CommandHeapProfilerStartTrackingHeapObjects + case CommandHeapProfilerStopSampling: + *t = CommandHeapProfilerStopSampling + case CommandHeapProfilerStopTrackingHeapObjects: + *t = CommandHeapProfilerStopTrackingHeapObjects + case CommandHeapProfilerTakeHeapSnapshot: + *t = CommandHeapProfilerTakeHeapSnapshot + case EventProfilerConsoleProfileFinished: + *t = EventProfilerConsoleProfileFinished + case EventProfilerConsoleProfileStarted: + *t = EventProfilerConsoleProfileStarted + case CommandProfilerDisable: + *t = CommandProfilerDisable + case CommandProfilerEnable: + *t = CommandProfilerEnable + case CommandProfilerGetBestEffortCoverage: + *t = CommandProfilerGetBestEffortCoverage + case CommandProfilerSetSamplingInterval: + *t = CommandProfilerSetSamplingInterval + case CommandProfilerStart: + *t = CommandProfilerStart + case CommandProfilerStartPreciseCoverage: + *t = CommandProfilerStartPreciseCoverage + case CommandProfilerStartTypeProfile: + *t = CommandProfilerStartTypeProfile + case CommandProfilerStop: + *t = CommandProfilerStop + case CommandProfilerStopPreciseCoverage: + *t = CommandProfilerStopPreciseCoverage + case CommandProfilerStopTypeProfile: + *t = CommandProfilerStopTypeProfile + case CommandProfilerTakePreciseCoverage: + *t = CommandProfilerTakePreciseCoverage + case CommandProfilerTakeTypeProfile: + *t = CommandProfilerTakeTypeProfile + case EventRuntimeConsoleAPICalled: + *t = EventRuntimeConsoleAPICalled + case EventRuntimeExceptionRevoked: + *t = EventRuntimeExceptionRevoked + case EventRuntimeExceptionThrown: + *t = EventRuntimeExceptionThrown + case EventRuntimeExecutionContextCreated: + *t = EventRuntimeExecutionContextCreated + case EventRuntimeExecutionContextDestroyed: + *t = EventRuntimeExecutionContextDestroyed + case EventRuntimeExecutionContextsCleared: + *t = EventRuntimeExecutionContextsCleared + case EventRuntimeInspectRequested: + *t = EventRuntimeInspectRequested + case CommandRuntimeAwaitPromise: + *t = CommandRuntimeAwaitPromise + case CommandRuntimeCallFunctionOn: + *t = CommandRuntimeCallFunctionOn + case CommandRuntimeCompileScript: + *t = CommandRuntimeCompileScript + case CommandRuntimeDisable: + *t = CommandRuntimeDisable + case CommandRuntimeDiscardConsoleEntries: + *t = CommandRuntimeDiscardConsoleEntries + case CommandRuntimeEnable: + *t = CommandRuntimeEnable + case CommandRuntimeEvaluate: + *t = CommandRuntimeEvaluate + case CommandRuntimeGetProperties: + *t = CommandRuntimeGetProperties + case CommandRuntimeGlobalLexicalScopeNames: + *t = CommandRuntimeGlobalLexicalScopeNames + case CommandRuntimeQueryObjects: + *t = CommandRuntimeQueryObjects + case CommandRuntimeReleaseObject: + *t = CommandRuntimeReleaseObject + case CommandRuntimeReleaseObjectGroup: + *t = CommandRuntimeReleaseObjectGroup + case CommandRuntimeRunIfWaitingForDebugger: + *t = CommandRuntimeRunIfWaitingForDebugger + case CommandRuntimeRunScript: + *t = CommandRuntimeRunScript + case CommandRuntimeSetCustomObjectFormatterEnabled: + *t = CommandRuntimeSetCustomObjectFormatterEnabled + + default: + in.AddError(errors.New("unknown MethodType value")) + } +} + +// UnmarshalJSON satisfies json.Unmarshaler. +func (t *MethodType) UnmarshalJSON(buf []byte) error { + return easyjson.Unmarshal(buf, t) +} + +// Domain returns the Chrome Debugging Protocol domain of the event or command. +func (t MethodType) Domain() string { + return string(t[:strings.IndexByte(string(t), '.')]) +} + +// ErrorType error type. +type ErrorType string + +// String returns the ErrorType as string value. +func (t ErrorType) String() string { + return string(t) +} + +// ErrorType values. +const ( + ErrChannelClosed ErrorType = "channel closed" + ErrInvalidResult ErrorType = "invalid result" + ErrUnknownResult ErrorType = "unknown result" +) + +// MarshalEasyJSON satisfies easyjson.Marshaler. +func (t ErrorType) MarshalEasyJSON(out *jwriter.Writer) { + out.String(string(t)) +} + +// MarshalJSON satisfies json.Marshaler. +func (t ErrorType) MarshalJSON() ([]byte, error) { + return easyjson.Marshal(t) +} + +// UnmarshalEasyJSON satisfies easyjson.Unmarshaler. +func (t *ErrorType) UnmarshalEasyJSON(in *jlexer.Lexer) { + switch ErrorType(in.String()) { + case ErrChannelClosed: + *t = ErrChannelClosed + case ErrInvalidResult: + *t = ErrInvalidResult + case ErrUnknownResult: + *t = ErrUnknownResult + + default: + in.AddError(errors.New("unknown ErrorType value")) + } +} + +// UnmarshalJSON satisfies json.Unmarshaler. +func (t *ErrorType) UnmarshalJSON(buf []byte) error { + return easyjson.Unmarshal(buf, t) +} + +// Error satisfies the error interface. +func (t ErrorType) Error() string { + return string(t) +} + +// Handler is the common interface for a Chrome Debugging Protocol target. +type Handler interface { + // SetActive changes the top level frame id. + SetActive(context.Context, FrameID) error + + // GetRoot returns the root document node for the top level frame. + GetRoot(context.Context) (*Node, error) + + // WaitFrame waits for a frame to be available. + WaitFrame(context.Context, FrameID) (*Frame, error) + + // WaitNode waits for a node to be available. + WaitNode(context.Context, *Frame, NodeID) (*Node, error) + + // Execute executes the specified command using the supplied context and + // parameters. + Execute(context.Context, MethodType, easyjson.Marshaler, easyjson.Unmarshaler) error + + // Listen creates a channel that will receive an event for the types + // specified. + Listen(...MethodType) <-chan interface{} + + // Release releases a channel returned from Listen. + Release(<-chan interface{}) +} + +// LoaderID unique loader identifier. +type LoaderID string + +// String returns the LoaderID as string value. +func (t LoaderID) String() string { + return string(t) +} + +// TimeSinceEpoch uTC time in seconds, counted from January 1, 1970. +type TimeSinceEpoch time.Time + +// Time returns the TimeSinceEpoch as time.Time value. +func (t TimeSinceEpoch) Time() time.Time { + return time.Time(t) +} + +// MarshalEasyJSON satisfies easyjson.Marshaler. +func (t TimeSinceEpoch) MarshalEasyJSON(out *jwriter.Writer) { + v := float64(time.Time(t).UnixNano() / int64(time.Second)) + + out.Buffer.EnsureSpace(20) + out.Buffer.Buf = strconv.AppendFloat(out.Buffer.Buf, v, 'f', -1, 64) +} + +// MarshalJSON satisfies json.Marshaler. +func (t TimeSinceEpoch) MarshalJSON() ([]byte, error) { + return easyjson.Marshal(t) +} + +// UnmarshalEasyJSON satisfies easyjson.Unmarshaler. +func (t *TimeSinceEpoch) UnmarshalEasyJSON(in *jlexer.Lexer) { + *t = TimeSinceEpoch(time.Unix(0, int64(in.Float64()*float64(time.Second)))) +} + +// UnmarshalJSON satisfies json.Unmarshaler. +func (t *TimeSinceEpoch) UnmarshalJSON(buf []byte) error { + return easyjson.Unmarshal(buf, t) +} + +// MonotonicTime monotonically increasing time in seconds since an arbitrary +// point in the past. +type MonotonicTime time.Time + +// Time returns the MonotonicTime as time.Time value. +func (t MonotonicTime) Time() time.Time { + return time.Time(t) +} + +// MonotonicTimeEpoch is the MonotonicTime time epoch. +var MonotonicTimeEpoch *time.Time + +func init() { + // initialize epoch + bt := sysutil.BootTime() + MonotonicTimeEpoch = &bt +} + +// MarshalEasyJSON satisfies easyjson.Marshaler. +func (t MonotonicTime) MarshalEasyJSON(out *jwriter.Writer) { + v := float64(time.Time(t).Sub(*MonotonicTimeEpoch)) / float64(time.Second) + + out.Buffer.EnsureSpace(20) + out.Buffer.Buf = strconv.AppendFloat(out.Buffer.Buf, v, 'f', -1, 64) +} + +// MarshalJSON satisfies json.Marshaler. +func (t MonotonicTime) MarshalJSON() ([]byte, error) { + return easyjson.Marshal(t) +} + +// UnmarshalEasyJSON satisfies easyjson.Unmarshaler. +func (t *MonotonicTime) UnmarshalEasyJSON(in *jlexer.Lexer) { + *t = MonotonicTime(MonotonicTimeEpoch.Add(time.Duration(in.Float64() * float64(time.Second)))) +} + +// UnmarshalJSON satisfies json.Unmarshaler. +func (t *MonotonicTime) UnmarshalJSON(buf []byte) error { + return easyjson.Unmarshal(buf, t) +} + +// FrameID unique frame identifier. +type FrameID string + +// String returns the FrameID as string value. +func (t FrameID) String() string { + return string(t) +} + +// UnmarshalEasyJSON satisfies easyjson.Unmarshaler. +func (t *FrameID) UnmarshalEasyJSON(in *jlexer.Lexer) { + buf := in.Raw() + if l := len(buf); l > 2 && buf[0] == '"' && buf[l-1] == '"' { + buf = buf[1 : l-1] + } + + *t = FrameID(buf) +} + +// UnmarshalJSON satisfies json.Unmarshaler. +func (t *FrameID) UnmarshalJSON(buf []byte) error { + return easyjson.Unmarshal(buf, t) +} + +// Frame information about the Frame on the page. +type Frame struct { + ID FrameID `json:"id"` // Frame unique identifier. + ParentID FrameID `json:"parentId,omitempty"` // Parent frame identifier. + LoaderID LoaderID `json:"loaderId"` // Identifier of the loader associated with this frame. + Name string `json:"name,omitempty"` // Frame's name as specified in the tag. + URL string `json:"url"` // Frame document's URL. + SecurityOrigin string `json:"securityOrigin"` // Frame document's security origin. + MimeType string `json:"mimeType"` // Frame document's mimeType as determined by the browser. + UnreachableURL string `json:"unreachableUrl,omitempty"` // If the frame failed to load, this contains the URL that could not be loaded. + State FrameState `json:"-"` // Frame state. + Root *Node `json:"-"` // Frame document root. + Nodes map[NodeID]*Node `json:"-"` // Frame nodes. + sync.RWMutex `json:"-"` // Read write mutex. +} + +// FrameState is the state of a Frame. +type FrameState uint16 + +// FrameState enum values. +const ( + FrameDOMContentEventFired FrameState = 1 << (15 - iota) + FrameLoadEventFired + FrameAttached + FrameNavigated + FrameLoading + FrameScheduledNavigation +) + +// frameStateNames are the names of the frame states. +var frameStateNames = map[FrameState]string{ + FrameDOMContentEventFired: "DOMContentEventFired", + FrameLoadEventFired: "LoadEventFired", + FrameAttached: "Attached", + FrameNavigated: "Navigated", + FrameLoading: "Loading", + FrameScheduledNavigation: "ScheduledNavigation", +} + +// String satisfies stringer interface. +func (fs FrameState) String() string { + var s []string + for k, v := range frameStateNames { + if fs&k != 0 { + s = append(s, v) + } + } + return "[" + strings.Join(s, " ") + "]" +} + +// EmptyFrameID is the "non-existent" frame id. +const EmptyFrameID = FrameID("") diff --git a/cdp/cdputil/cdputil.go b/cdp/cdputil/cdputil.go index 3f8e542..be1ee38 100644 --- a/cdp/cdputil/cdputil.go +++ b/cdp/cdputil/cdputil.go @@ -52,590 +52,233 @@ var emptyVal = &empty{} func UnmarshalMessage(msg *cdp.Message) (interface{}, error) { var v easyjson.Unmarshaler switch msg.Method { - case cdp.CommandInspectorEnable: - return emptyVal, nil - - case cdp.CommandInspectorDisable: - return emptyVal, nil - - case cdp.EventInspectorDetached: - v = new(inspector.EventDetached) - - case cdp.EventInspectorTargetCrashed: - v = new(inspector.EventTargetCrashed) - - case cdp.CommandMemoryGetDOMCounters: - v = new(memory.GetDOMCountersReturns) - - case cdp.CommandMemoryPrepareForLeakDetection: - return emptyVal, nil - - case cdp.CommandMemorySetPressureNotificationsSuppressed: - return emptyVal, nil - - case cdp.CommandMemorySimulatePressureNotification: - return emptyVal, nil - - case cdp.CommandPerformanceEnable: - return emptyVal, nil - - case cdp.CommandPerformanceDisable: - return emptyVal, nil - - case cdp.CommandPerformanceGetMetrics: - v = new(performance.GetMetricsReturns) - - case cdp.EventPerformanceMetrics: - v = new(performance.EventMetrics) - - case cdp.CommandPageEnable: - return emptyVal, nil - - case cdp.CommandPageDisable: - return emptyVal, nil - - case cdp.CommandPageAddScriptToEvaluateOnNewDocument: - v = new(page.AddScriptToEvaluateOnNewDocumentReturns) - - case cdp.CommandPageRemoveScriptToEvaluateOnNewDocument: - return emptyVal, nil - - case cdp.CommandPageSetAutoAttachToCreatedPages: - return emptyVal, nil - - case cdp.CommandPageSetLifecycleEventsEnabled: - return emptyVal, nil - - case cdp.CommandPageReload: - return emptyVal, nil - - case cdp.CommandPageSetAdBlockingEnabled: - return emptyVal, nil - - case cdp.CommandPageNavigate: - v = new(page.NavigateReturns) - - case cdp.CommandPageStopLoading: - return emptyVal, nil - - case cdp.CommandPageGetNavigationHistory: - v = new(page.GetNavigationHistoryReturns) - - case cdp.CommandPageNavigateToHistoryEntry: - return emptyVal, nil - - case cdp.CommandPageGetResourceTree: - v = new(page.GetResourceTreeReturns) - - case cdp.CommandPageGetFrameTree: - v = new(page.GetFrameTreeReturns) - - case cdp.CommandPageGetResourceContent: - v = new(page.GetResourceContentReturns) - - case cdp.CommandPageSearchInResource: - v = new(page.SearchInResourceReturns) - - case cdp.CommandPageSetDocumentContent: - return emptyVal, nil - - case cdp.CommandPageCaptureScreenshot: - v = new(page.CaptureScreenshotReturns) - - case cdp.CommandPagePrintToPDF: - v = new(page.PrintToPDFReturns) - - case cdp.CommandPageStartScreencast: - return emptyVal, nil - - case cdp.CommandPageStopScreencast: - return emptyVal, nil - - case cdp.CommandPageScreencastFrameAck: - return emptyVal, nil - - case cdp.CommandPageHandleJavaScriptDialog: - return emptyVal, nil - - case cdp.CommandPageGetAppManifest: - v = new(page.GetAppManifestReturns) - - case cdp.CommandPageRequestAppBanner: - return emptyVal, nil - - case cdp.CommandPageGetLayoutMetrics: - v = new(page.GetLayoutMetricsReturns) - - case cdp.CommandPageCreateIsolatedWorld: - v = new(page.CreateIsolatedWorldReturns) - - case cdp.CommandPageBringToFront: - return emptyVal, nil - - case cdp.CommandPageSetDownloadBehavior: - return emptyVal, nil - - case cdp.EventPageDomContentEventFired: - v = new(page.EventDomContentEventFired) - - case cdp.EventPageLoadEventFired: - v = new(page.EventLoadEventFired) - - case cdp.EventPageLifecycleEvent: - v = new(page.EventLifecycleEvent) - - case cdp.EventPageFrameAttached: - v = new(page.EventFrameAttached) - - case cdp.EventPageFrameNavigated: - v = new(page.EventFrameNavigated) - - case cdp.EventPageFrameDetached: - v = new(page.EventFrameDetached) - - case cdp.EventPageFrameStartedLoading: - v = new(page.EventFrameStartedLoading) - - case cdp.EventPageFrameStoppedLoading: - v = new(page.EventFrameStoppedLoading) - - case cdp.EventPageFrameScheduledNavigation: - v = new(page.EventFrameScheduledNavigation) - - case cdp.EventPageFrameClearedScheduledNavigation: - v = new(page.EventFrameClearedScheduledNavigation) - - case cdp.EventPageFrameResized: - v = new(page.EventFrameResized) - - case cdp.EventPageJavascriptDialogOpening: - v = new(page.EventJavascriptDialogOpening) - - case cdp.EventPageJavascriptDialogClosed: - v = new(page.EventJavascriptDialogClosed) - - case cdp.EventPageScreencastFrame: - v = new(page.EventScreencastFrame) - - case cdp.EventPageScreencastVisibilityChanged: - v = new(page.EventScreencastVisibilityChanged) - - case cdp.EventPageInterstitialShown: - v = new(page.EventInterstitialShown) - - case cdp.EventPageInterstitialHidden: - v = new(page.EventInterstitialHidden) - - case cdp.EventPageWindowOpen: - v = new(page.EventWindowOpen) - - case cdp.CommandOverlayEnable: - return emptyVal, nil - - case cdp.CommandOverlayDisable: - return emptyVal, nil - - case cdp.CommandOverlaySetShowPaintRects: - return emptyVal, nil - - case cdp.CommandOverlaySetShowDebugBorders: - return emptyVal, nil - - case cdp.CommandOverlaySetShowFPSCounter: - return emptyVal, nil - - case cdp.CommandOverlaySetShowScrollBottleneckRects: - return emptyVal, nil - - case cdp.CommandOverlaySetShowViewportSizeOnResize: - return emptyVal, nil - - case cdp.CommandOverlaySetPausedInDebuggerMessage: - return emptyVal, nil - - case cdp.CommandOverlaySetSuspended: - return emptyVal, nil - - case cdp.CommandOverlaySetInspectMode: - return emptyVal, nil - - case cdp.CommandOverlayHighlightRect: - return emptyVal, nil - - case cdp.CommandOverlayHighlightQuad: - return emptyVal, nil - - case cdp.CommandOverlayHighlightNode: - return emptyVal, nil - - case cdp.CommandOverlayHighlightFrame: - return emptyVal, nil - - case cdp.CommandOverlayHideHighlight: - return emptyVal, nil - - case cdp.CommandOverlayGetHighlightObjectForTest: - v = new(overlay.GetHighlightObjectForTestReturns) - - case cdp.EventOverlayNodeHighlightRequested: - v = new(overlay.EventNodeHighlightRequested) - - case cdp.EventOverlayInspectNodeRequested: - v = new(overlay.EventInspectNodeRequested) - - case cdp.EventOverlayScreenshotRequested: - v = new(overlay.EventScreenshotRequested) - - case cdp.CommandEmulationSetDeviceMetricsOverride: - return emptyVal, nil - - case cdp.CommandEmulationClearDeviceMetricsOverride: - return emptyVal, nil - - case cdp.CommandEmulationResetPageScaleFactor: - return emptyVal, nil - - case cdp.CommandEmulationSetPageScaleFactor: - return emptyVal, nil - - case cdp.CommandEmulationSetScriptExecutionDisabled: - return emptyVal, nil - - case cdp.CommandEmulationSetGeolocationOverride: - return emptyVal, nil - - case cdp.CommandEmulationClearGeolocationOverride: - return emptyVal, nil - - case cdp.CommandEmulationSetTouchEmulationEnabled: - return emptyVal, nil + case cdp.CommandAccessibilityGetPartialAXTree: + v = new(accessibility.GetPartialAXTreeReturns) - case cdp.CommandEmulationSetEmitTouchEventsForMouse: + case cdp.CommandAnimationDisable: return emptyVal, nil - case cdp.CommandEmulationSetEmulatedMedia: + case cdp.CommandAnimationEnable: return emptyVal, nil - case cdp.CommandEmulationSetCPUThrottlingRate: - return emptyVal, nil - - case cdp.CommandEmulationCanEmulate: - v = new(emulation.CanEmulateReturns) + case cdp.CommandAnimationGetCurrentTime: + v = new(animation.GetCurrentTimeReturns) - case cdp.CommandEmulationSetVirtualTimePolicy: - v = new(emulation.SetVirtualTimePolicyReturns) - - case cdp.CommandEmulationSetNavigatorOverrides: - return emptyVal, nil + case cdp.CommandAnimationGetPlaybackRate: + v = new(animation.GetPlaybackRateReturns) - case cdp.CommandEmulationSetDefaultBackgroundColorOverride: + case cdp.CommandAnimationReleaseAnimations: return emptyVal, nil - case cdp.EventEmulationVirtualTimeBudgetExpired: - v = new(emulation.EventVirtualTimeBudgetExpired) - - case cdp.EventEmulationVirtualTimeAdvanced: - v = new(emulation.EventVirtualTimeAdvanced) - - case cdp.EventEmulationVirtualTimePaused: - v = new(emulation.EventVirtualTimePaused) - - case cdp.CommandSecurityEnable: - return emptyVal, nil + case cdp.CommandAnimationResolveAnimation: + v = new(animation.ResolveAnimationReturns) - case cdp.CommandSecurityDisable: + case cdp.CommandAnimationSeekAnimations: return emptyVal, nil - case cdp.CommandSecurityHandleCertificateError: - return emptyVal, nil - - case cdp.CommandSecuritySetOverrideCertificateErrors: - return emptyVal, nil - - case cdp.EventSecuritySecurityStateChanged: - v = new(security.EventSecurityStateChanged) - - case cdp.EventSecurityCertificateError: - v = new(security.EventCertificateError) - - case cdp.CommandAuditsGetEncodedResponse: - v = new(audits.GetEncodedResponseReturns) - - case cdp.CommandNetworkEnable: + case cdp.CommandAnimationSetPaused: return emptyVal, nil - case cdp.CommandNetworkDisable: + case cdp.CommandAnimationSetPlaybackRate: return emptyVal, nil - case cdp.CommandNetworkSetUserAgentOverride: + case cdp.CommandAnimationSetTiming: return emptyVal, nil - case cdp.CommandNetworkSearchInResponseBody: - v = new(network.SearchInResponseBodyReturns) - - case cdp.CommandNetworkSetExtraHTTPHeaders: - return emptyVal, nil - - case cdp.CommandNetworkGetResponseBody: - v = new(network.GetResponseBodyReturns) - - case cdp.CommandNetworkSetBlockedURLS: - return emptyVal, nil - - case cdp.CommandNetworkReplayXHR: - return emptyVal, nil - - case cdp.CommandNetworkClearBrowserCache: - return emptyVal, nil - - case cdp.CommandNetworkClearBrowserCookies: - return emptyVal, nil - - case cdp.CommandNetworkGetCookies: - v = new(network.GetCookiesReturns) - - case cdp.CommandNetworkGetAllCookies: - v = new(network.GetAllCookiesReturns) - - case cdp.CommandNetworkDeleteCookies: - return emptyVal, nil - - case cdp.CommandNetworkSetCookie: - v = new(network.SetCookieReturns) - - case cdp.CommandNetworkSetCookies: - return emptyVal, nil - - case cdp.CommandNetworkEmulateNetworkConditions: - return emptyVal, nil - - case cdp.CommandNetworkSetCacheDisabled: - return emptyVal, nil - - case cdp.CommandNetworkSetBypassServiceWorker: - return emptyVal, nil - - case cdp.CommandNetworkSetDataSizeLimitsForTest: - return emptyVal, nil - - case cdp.CommandNetworkGetCertificate: - v = new(network.GetCertificateReturns) - - case cdp.CommandNetworkSetRequestInterception: - return emptyVal, nil - - case cdp.CommandNetworkContinueInterceptedRequest: - return emptyVal, nil - - case cdp.CommandNetworkGetResponseBodyForInterception: - v = new(network.GetResponseBodyForInterceptionReturns) - - case cdp.EventNetworkResourceChangedPriority: - v = new(network.EventResourceChangedPriority) - - case cdp.EventNetworkRequestWillBeSent: - v = new(network.EventRequestWillBeSent) - - case cdp.EventNetworkRequestServedFromCache: - v = new(network.EventRequestServedFromCache) - - case cdp.EventNetworkResponseReceived: - v = new(network.EventResponseReceived) - - case cdp.EventNetworkDataReceived: - v = new(network.EventDataReceived) - - case cdp.EventNetworkLoadingFinished: - v = new(network.EventLoadingFinished) - - case cdp.EventNetworkLoadingFailed: - v = new(network.EventLoadingFailed) - - case cdp.EventNetworkWebSocketWillSendHandshakeRequest: - v = new(network.EventWebSocketWillSendHandshakeRequest) - - case cdp.EventNetworkWebSocketHandshakeResponseReceived: - v = new(network.EventWebSocketHandshakeResponseReceived) - - case cdp.EventNetworkWebSocketCreated: - v = new(network.EventWebSocketCreated) - - case cdp.EventNetworkWebSocketClosed: - v = new(network.EventWebSocketClosed) - - case cdp.EventNetworkWebSocketFrameReceived: - v = new(network.EventWebSocketFrameReceived) - - case cdp.EventNetworkWebSocketFrameError: - v = new(network.EventWebSocketFrameError) - - case cdp.EventNetworkWebSocketFrameSent: - v = new(network.EventWebSocketFrameSent) - - case cdp.EventNetworkEventSourceMessageReceived: - v = new(network.EventEventSourceMessageReceived) - - case cdp.EventNetworkRequestIntercepted: - v = new(network.EventRequestIntercepted) - - case cdp.CommandDatabaseEnable: - return emptyVal, nil - - case cdp.CommandDatabaseDisable: - return emptyVal, nil - - case cdp.CommandDatabaseGetDatabaseTableNames: - v = new(database.GetDatabaseTableNamesReturns) - - case cdp.CommandDatabaseExecuteSQL: - v = new(database.ExecuteSQLReturns) - - case cdp.EventDatabaseAddDatabase: - v = new(database.EventAddDatabase) - - case cdp.CommandIndexedDBEnable: - return emptyVal, nil - - case cdp.CommandIndexedDBDisable: - return emptyVal, nil - - case cdp.CommandIndexedDBRequestDatabaseNames: - v = new(indexeddb.RequestDatabaseNamesReturns) - - case cdp.CommandIndexedDBRequestDatabase: - v = new(indexeddb.RequestDatabaseReturns) - - case cdp.CommandIndexedDBRequestData: - v = new(indexeddb.RequestDataReturns) - - case cdp.CommandIndexedDBClearObjectStore: - return emptyVal, nil - - case cdp.CommandIndexedDBDeleteDatabase: - return emptyVal, nil - - case cdp.CommandCacheStorageRequestCacheNames: - v = new(cachestorage.RequestCacheNamesReturns) - - case cdp.CommandCacheStorageRequestEntries: - v = new(cachestorage.RequestEntriesReturns) - - case cdp.CommandCacheStorageDeleteCache: - return emptyVal, nil - - case cdp.CommandCacheStorageDeleteEntry: - return emptyVal, nil - - case cdp.CommandCacheStorageRequestCachedResponse: - v = new(cachestorage.RequestCachedResponseReturns) - - case cdp.CommandDOMStorageEnable: - return emptyVal, nil - - case cdp.CommandDOMStorageDisable: - return emptyVal, nil - - case cdp.CommandDOMStorageClear: - return emptyVal, nil - - case cdp.CommandDOMStorageGetDOMStorageItems: - v = new(domstorage.GetDOMStorageItemsReturns) - - case cdp.CommandDOMStorageSetDOMStorageItem: - return emptyVal, nil - - case cdp.CommandDOMStorageRemoveDOMStorageItem: - return emptyVal, nil - - case cdp.EventDOMStorageDomStorageItemsCleared: - v = new(domstorage.EventDomStorageItemsCleared) - - case cdp.EventDOMStorageDomStorageItemRemoved: - v = new(domstorage.EventDomStorageItemRemoved) - - case cdp.EventDOMStorageDomStorageItemAdded: - v = new(domstorage.EventDomStorageItemAdded) + case cdp.EventAnimationAnimationCanceled: + v = new(animation.EventAnimationCanceled) - case cdp.EventDOMStorageDomStorageItemUpdated: - v = new(domstorage.EventDomStorageItemUpdated) + case cdp.EventAnimationAnimationCreated: + v = new(animation.EventAnimationCreated) - case cdp.CommandApplicationCacheGetFramesWithManifests: - v = new(applicationcache.GetFramesWithManifestsReturns) + case cdp.EventAnimationAnimationStarted: + v = new(animation.EventAnimationStarted) case cdp.CommandApplicationCacheEnable: return emptyVal, nil - case cdp.CommandApplicationCacheGetManifestForFrame: - v = new(applicationcache.GetManifestForFrameReturns) - case cdp.CommandApplicationCacheGetApplicationCacheForFrame: v = new(applicationcache.GetApplicationCacheForFrameReturns) + case cdp.CommandApplicationCacheGetFramesWithManifests: + v = new(applicationcache.GetFramesWithManifestsReturns) + + case cdp.CommandApplicationCacheGetManifestForFrame: + v = new(applicationcache.GetManifestForFrameReturns) + case cdp.EventApplicationCacheApplicationCacheStatusUpdated: v = new(applicationcache.EventApplicationCacheStatusUpdated) case cdp.EventApplicationCacheNetworkStateUpdated: v = new(applicationcache.EventNetworkStateUpdated) - case cdp.CommandDOMEnable: + case cdp.CommandAuditsGetEncodedResponse: + v = new(audits.GetEncodedResponseReturns) + + case cdp.CommandBrowserClose: return emptyVal, nil + case cdp.CommandBrowserGetVersion: + v = new(browser.GetVersionReturns) + + case cdp.CommandBrowserGetWindowBounds: + v = new(browser.GetWindowBoundsReturns) + + case cdp.CommandBrowserGetWindowForTarget: + v = new(browser.GetWindowForTargetReturns) + + case cdp.CommandBrowserSetWindowBounds: + return emptyVal, nil + + case cdp.CommandCSSAddRule: + v = new(css.AddRuleReturns) + + case cdp.CommandCSSCollectClassNames: + v = new(css.CollectClassNamesReturns) + + case cdp.CommandCSSCreateStyleSheet: + v = new(css.CreateStyleSheetReturns) + + case cdp.CommandCSSDisable: + return emptyVal, nil + + case cdp.CommandCSSEnable: + return emptyVal, nil + + case cdp.CommandCSSForcePseudoState: + return emptyVal, nil + + case cdp.CommandCSSGetBackgroundColors: + v = new(css.GetBackgroundColorsReturns) + + case cdp.CommandCSSGetComputedStyleForNode: + v = new(css.GetComputedStyleForNodeReturns) + + case cdp.CommandCSSGetInlineStylesForNode: + v = new(css.GetInlineStylesForNodeReturns) + + case cdp.CommandCSSGetMatchedStylesForNode: + v = new(css.GetMatchedStylesForNodeReturns) + + case cdp.CommandCSSGetMediaQueries: + v = new(css.GetMediaQueriesReturns) + + case cdp.CommandCSSGetPlatformFontsForNode: + v = new(css.GetPlatformFontsForNodeReturns) + + case cdp.CommandCSSGetStyleSheetText: + v = new(css.GetStyleSheetTextReturns) + + case cdp.CommandCSSSetEffectivePropertyValueForNode: + return emptyVal, nil + + case cdp.CommandCSSSetKeyframeKey: + v = new(css.SetKeyframeKeyReturns) + + case cdp.CommandCSSSetMediaText: + v = new(css.SetMediaTextReturns) + + case cdp.CommandCSSSetRuleSelector: + v = new(css.SetRuleSelectorReturns) + + case cdp.CommandCSSSetStyleSheetText: + v = new(css.SetStyleSheetTextReturns) + + case cdp.CommandCSSSetStyleTexts: + v = new(css.SetStyleTextsReturns) + + case cdp.CommandCSSStartRuleUsageTracking: + return emptyVal, nil + + case cdp.CommandCSSStopRuleUsageTracking: + v = new(css.StopRuleUsageTrackingReturns) + + case cdp.CommandCSSTakeCoverageDelta: + v = new(css.TakeCoverageDeltaReturns) + + case cdp.EventCSSFontsUpdated: + v = new(css.EventFontsUpdated) + + case cdp.EventCSSMediaQueryResultChanged: + v = new(css.EventMediaQueryResultChanged) + + case cdp.EventCSSStyleSheetAdded: + v = new(css.EventStyleSheetAdded) + + case cdp.EventCSSStyleSheetChanged: + v = new(css.EventStyleSheetChanged) + + case cdp.EventCSSStyleSheetRemoved: + v = new(css.EventStyleSheetRemoved) + + case cdp.CommandCacheStorageDeleteCache: + return emptyVal, nil + + case cdp.CommandCacheStorageDeleteEntry: + return emptyVal, nil + + case cdp.CommandCacheStorageRequestCacheNames: + v = new(cachestorage.RequestCacheNamesReturns) + + case cdp.CommandCacheStorageRequestCachedResponse: + v = new(cachestorage.RequestCachedResponseReturns) + + case cdp.CommandCacheStorageRequestEntries: + v = new(cachestorage.RequestEntriesReturns) + + case cdp.CommandDOMCollectClassNamesFromSubtree: + v = new(dom.CollectClassNamesFromSubtreeReturns) + + case cdp.CommandDOMCopyTo: + v = new(dom.CopyToReturns) + + case cdp.CommandDOMDescribeNode: + v = new(dom.DescribeNodeReturns) + case cdp.CommandDOMDisable: return emptyVal, nil + case cdp.CommandDOMDiscardSearchResults: + return emptyVal, nil + + case cdp.CommandDOMEnable: + return emptyVal, nil + + case cdp.CommandDOMFocus: + return emptyVal, nil + + case cdp.CommandDOMGetAttributes: + v = new(dom.GetAttributesReturns) + + case cdp.CommandDOMGetBoxModel: + v = new(dom.GetBoxModelReturns) + case cdp.CommandDOMGetDocument: v = new(dom.GetDocumentReturns) case cdp.CommandDOMGetFlattenedDocument: v = new(dom.GetFlattenedDocumentReturns) - case cdp.CommandDOMCollectClassNamesFromSubtree: - v = new(dom.CollectClassNamesFromSubtreeReturns) - - case cdp.CommandDOMRequestChildNodes: - return emptyVal, nil - - case cdp.CommandDOMQuerySelector: - v = new(dom.QuerySelectorReturns) - - case cdp.CommandDOMQuerySelectorAll: - v = new(dom.QuerySelectorAllReturns) - - case cdp.CommandDOMSetNodeName: - v = new(dom.SetNodeNameReturns) - - case cdp.CommandDOMSetNodeValue: - return emptyVal, nil - - case cdp.CommandDOMRemoveNode: - return emptyVal, nil - - case cdp.CommandDOMSetAttributeValue: - return emptyVal, nil - - case cdp.CommandDOMSetAttributesAsText: - return emptyVal, nil - - case cdp.CommandDOMRemoveAttribute: - return emptyVal, nil + case cdp.CommandDOMGetNodeForLocation: + v = new(dom.GetNodeForLocationReturns) case cdp.CommandDOMGetOuterHTML: v = new(dom.GetOuterHTMLReturns) - case cdp.CommandDOMSetOuterHTML: - return emptyVal, nil - - case cdp.CommandDOMPerformSearch: - v = new(dom.PerformSearchReturns) + case cdp.CommandDOMGetRelayoutBoundary: + v = new(dom.GetRelayoutBoundaryReturns) case cdp.CommandDOMGetSearchResults: v = new(dom.GetSearchResultsReturns) - case cdp.CommandDOMDiscardSearchResults: + case cdp.CommandDOMMarkUndoableState: return emptyVal, nil - case cdp.CommandDOMRequestNode: - v = new(dom.RequestNodeReturns) + case cdp.CommandDOMMoveTo: + v = new(dom.MoveToReturns) + + case cdp.CommandDOMPerformSearch: + v = new(dom.PerformSearchReturns) case cdp.CommandDOMPushNodeByPathToFrontend: v = new(dom.PushNodeByPathToFrontendReturns) @@ -643,53 +286,53 @@ func UnmarshalMessage(msg *cdp.Message) (interface{}, error) { case cdp.CommandDOMPushNodesByBackendIdsToFrontend: v = new(dom.PushNodesByBackendIdsToFrontendReturns) - case cdp.CommandDOMSetInspectedNode: - return emptyVal, nil + case cdp.CommandDOMQuerySelector: + v = new(dom.QuerySelectorReturns) - case cdp.CommandDOMResolveNode: - v = new(dom.ResolveNodeReturns) - - case cdp.CommandDOMGetAttributes: - v = new(dom.GetAttributesReturns) - - case cdp.CommandDOMCopyTo: - v = new(dom.CopyToReturns) - - case cdp.CommandDOMMoveTo: - v = new(dom.MoveToReturns) - - case cdp.CommandDOMUndo: - return emptyVal, nil + case cdp.CommandDOMQuerySelectorAll: + v = new(dom.QuerySelectorAllReturns) case cdp.CommandDOMRedo: return emptyVal, nil - case cdp.CommandDOMMarkUndoableState: + case cdp.CommandDOMRemoveAttribute: return emptyVal, nil - case cdp.CommandDOMFocus: + case cdp.CommandDOMRemoveNode: + return emptyVal, nil + + case cdp.CommandDOMRequestChildNodes: + return emptyVal, nil + + case cdp.CommandDOMRequestNode: + v = new(dom.RequestNodeReturns) + + case cdp.CommandDOMResolveNode: + v = new(dom.ResolveNodeReturns) + + case cdp.CommandDOMSetAttributeValue: + return emptyVal, nil + + case cdp.CommandDOMSetAttributesAsText: return emptyVal, nil case cdp.CommandDOMSetFileInputFiles: return emptyVal, nil - case cdp.CommandDOMGetBoxModel: - v = new(dom.GetBoxModelReturns) + case cdp.CommandDOMSetInspectedNode: + return emptyVal, nil - case cdp.CommandDOMGetNodeForLocation: - v = new(dom.GetNodeForLocationReturns) + case cdp.CommandDOMSetNodeName: + v = new(dom.SetNodeNameReturns) - case cdp.CommandDOMGetRelayoutBoundary: - v = new(dom.GetRelayoutBoundaryReturns) + case cdp.CommandDOMSetNodeValue: + return emptyVal, nil - case cdp.CommandDOMDescribeNode: - v = new(dom.DescribeNodeReturns) + case cdp.CommandDOMSetOuterHTML: + return emptyVal, nil - case cdp.EventDOMDocumentUpdated: - v = new(dom.EventDocumentUpdated) - - case cdp.EventDOMSetChildNodes: - v = new(dom.EventSetChildNodes) + case cdp.CommandDOMUndo: + return emptyVal, nil case cdp.EventDOMAttributeModified: v = new(dom.EventAttributeModified) @@ -697,9 +340,6 @@ func UnmarshalMessage(msg *cdp.Message) (interface{}, error) { case cdp.EventDOMAttributeRemoved: v = new(dom.EventAttributeRemoved) - case cdp.EventDOMInlineStyleInvalidated: - v = new(dom.EventInlineStyleInvalidated) - case cdp.EventDOMCharacterDataModified: v = new(dom.EventCharacterDataModified) @@ -712,11 +352,14 @@ func UnmarshalMessage(msg *cdp.Message) (interface{}, error) { case cdp.EventDOMChildNodeRemoved: v = new(dom.EventChildNodeRemoved) - case cdp.EventDOMShadowRootPushed: - v = new(dom.EventShadowRootPushed) + case cdp.EventDOMDistributedNodesUpdated: + v = new(dom.EventDistributedNodesUpdated) - case cdp.EventDOMShadowRootPopped: - v = new(dom.EventShadowRootPopped) + case cdp.EventDOMDocumentUpdated: + v = new(dom.EventDocumentUpdated) + + case cdp.EventDOMInlineStyleInvalidated: + v = new(dom.EventInlineStyleInvalidated) case cdp.EventDOMPseudoElementAdded: v = new(dom.EventPseudoElementAdded) @@ -724,251 +367,197 @@ func UnmarshalMessage(msg *cdp.Message) (interface{}, error) { case cdp.EventDOMPseudoElementRemoved: v = new(dom.EventPseudoElementRemoved) - case cdp.EventDOMDistributedNodesUpdated: - v = new(dom.EventDistributedNodesUpdated) + case cdp.EventDOMSetChildNodes: + v = new(dom.EventSetChildNodes) - case cdp.CommandCSSEnable: - return emptyVal, nil + case cdp.EventDOMShadowRootPopped: + v = new(dom.EventShadowRootPopped) - case cdp.CommandCSSDisable: - return emptyVal, nil + case cdp.EventDOMShadowRootPushed: + v = new(dom.EventShadowRootPushed) - case cdp.CommandCSSGetMatchedStylesForNode: - v = new(css.GetMatchedStylesForNodeReturns) - - case cdp.CommandCSSGetInlineStylesForNode: - v = new(css.GetInlineStylesForNodeReturns) - - case cdp.CommandCSSGetComputedStyleForNode: - v = new(css.GetComputedStyleForNodeReturns) - - case cdp.CommandCSSGetPlatformFontsForNode: - v = new(css.GetPlatformFontsForNodeReturns) - - case cdp.CommandCSSGetStyleSheetText: - v = new(css.GetStyleSheetTextReturns) - - case cdp.CommandCSSCollectClassNames: - v = new(css.CollectClassNamesReturns) - - case cdp.CommandCSSSetStyleSheetText: - v = new(css.SetStyleSheetTextReturns) - - case cdp.CommandCSSSetRuleSelector: - v = new(css.SetRuleSelectorReturns) - - case cdp.CommandCSSSetKeyframeKey: - v = new(css.SetKeyframeKeyReturns) - - case cdp.CommandCSSSetStyleTexts: - v = new(css.SetStyleTextsReturns) - - case cdp.CommandCSSSetMediaText: - v = new(css.SetMediaTextReturns) - - case cdp.CommandCSSCreateStyleSheet: - v = new(css.CreateStyleSheetReturns) - - case cdp.CommandCSSAddRule: - v = new(css.AddRuleReturns) - - case cdp.CommandCSSForcePseudoState: - return emptyVal, nil - - case cdp.CommandCSSGetMediaQueries: - v = new(css.GetMediaQueriesReturns) - - case cdp.CommandCSSSetEffectivePropertyValueForNode: - return emptyVal, nil - - case cdp.CommandCSSGetBackgroundColors: - v = new(css.GetBackgroundColorsReturns) - - case cdp.CommandCSSStartRuleUsageTracking: - return emptyVal, nil - - case cdp.CommandCSSTakeCoverageDelta: - v = new(css.TakeCoverageDeltaReturns) - - case cdp.CommandCSSStopRuleUsageTracking: - v = new(css.StopRuleUsageTrackingReturns) - - case cdp.EventCSSMediaQueryResultChanged: - v = new(css.EventMediaQueryResultChanged) - - case cdp.EventCSSFontsUpdated: - v = new(css.EventFontsUpdated) - - case cdp.EventCSSStyleSheetChanged: - v = new(css.EventStyleSheetChanged) - - case cdp.EventCSSStyleSheetAdded: - v = new(css.EventStyleSheetAdded) - - case cdp.EventCSSStyleSheetRemoved: - v = new(css.EventStyleSheetRemoved) - - case cdp.CommandDOMSnapshotGetSnapshot: - v = new(domsnapshot.GetSnapshotReturns) - - case cdp.CommandIORead: - v = new(iodom.ReadReturns) - - case cdp.CommandIOClose: - return emptyVal, nil - - case cdp.CommandIOResolveBlob: - v = new(iodom.ResolveBlobReturns) - - case cdp.CommandDOMDebuggerSetDOMBreakpoint: - return emptyVal, nil + case cdp.CommandDOMDebuggerGetEventListeners: + v = new(domdebugger.GetEventListenersReturns) case cdp.CommandDOMDebuggerRemoveDOMBreakpoint: return emptyVal, nil - case cdp.CommandDOMDebuggerSetEventListenerBreakpoint: - return emptyVal, nil - case cdp.CommandDOMDebuggerRemoveEventListenerBreakpoint: return emptyVal, nil - case cdp.CommandDOMDebuggerSetInstrumentationBreakpoint: - return emptyVal, nil - case cdp.CommandDOMDebuggerRemoveInstrumentationBreakpoint: return emptyVal, nil - case cdp.CommandDOMDebuggerSetXHRBreakpoint: - return emptyVal, nil - case cdp.CommandDOMDebuggerRemoveXHRBreakpoint: return emptyVal, nil - case cdp.CommandDOMDebuggerGetEventListeners: - v = new(domdebugger.GetEventListenersReturns) - - case cdp.CommandTargetSetDiscoverTargets: + case cdp.CommandDOMDebuggerSetDOMBreakpoint: return emptyVal, nil - case cdp.CommandTargetSetAutoAttach: + case cdp.CommandDOMDebuggerSetEventListenerBreakpoint: return emptyVal, nil - case cdp.CommandTargetSetAttachToFrames: + case cdp.CommandDOMDebuggerSetInstrumentationBreakpoint: return emptyVal, nil - case cdp.CommandTargetSetRemoteLocations: + case cdp.CommandDOMDebuggerSetXHRBreakpoint: return emptyVal, nil - case cdp.CommandTargetSendMessageToTarget: + case cdp.CommandDOMSnapshotGetSnapshot: + v = new(domsnapshot.GetSnapshotReturns) + + case cdp.CommandDOMStorageClear: return emptyVal, nil - case cdp.CommandTargetGetTargetInfo: - v = new(target.GetTargetInfoReturns) - - case cdp.CommandTargetActivateTarget: + case cdp.CommandDOMStorageDisable: return emptyVal, nil - case cdp.CommandTargetCloseTarget: - v = new(target.CloseTargetReturns) - - case cdp.CommandTargetAttachToTarget: - v = new(target.AttachToTargetReturns) - - case cdp.CommandTargetDetachFromTarget: + case cdp.CommandDOMStorageEnable: return emptyVal, nil - case cdp.CommandTargetCreateBrowserContext: - v = new(target.CreateBrowserContextReturns) + case cdp.CommandDOMStorageGetDOMStorageItems: + v = new(domstorage.GetDOMStorageItemsReturns) - case cdp.CommandTargetDisposeBrowserContext: - v = new(target.DisposeBrowserContextReturns) - - case cdp.CommandTargetCreateTarget: - v = new(target.CreateTargetReturns) - - case cdp.CommandTargetGetTargets: - v = new(target.GetTargetsReturns) - - case cdp.EventTargetTargetCreated: - v = new(target.EventTargetCreated) - - case cdp.EventTargetTargetInfoChanged: - v = new(target.EventTargetInfoChanged) - - case cdp.EventTargetTargetDestroyed: - v = new(target.EventTargetDestroyed) - - case cdp.EventTargetAttachedToTarget: - v = new(target.EventAttachedToTarget) - - case cdp.EventTargetDetachedFromTarget: - v = new(target.EventDetachedFromTarget) - - case cdp.EventTargetReceivedMessageFromTarget: - v = new(target.EventReceivedMessageFromTarget) - - case cdp.CommandHeadlessExperimentalEnable: + case cdp.CommandDOMStorageRemoveDOMStorageItem: return emptyVal, nil - case cdp.CommandHeadlessExperimentalDisable: + case cdp.CommandDOMStorageSetDOMStorageItem: return emptyVal, nil + case cdp.EventDOMStorageDomStorageItemAdded: + v = new(domstorage.EventDomStorageItemAdded) + + case cdp.EventDOMStorageDomStorageItemRemoved: + v = new(domstorage.EventDomStorageItemRemoved) + + case cdp.EventDOMStorageDomStorageItemUpdated: + v = new(domstorage.EventDomStorageItemUpdated) + + case cdp.EventDOMStorageDomStorageItemsCleared: + v = new(domstorage.EventDomStorageItemsCleared) + + case cdp.CommandDatabaseDisable: + return emptyVal, nil + + case cdp.CommandDatabaseEnable: + return emptyVal, nil + + case cdp.CommandDatabaseExecuteSQL: + v = new(database.ExecuteSQLReturns) + + case cdp.CommandDatabaseGetDatabaseTableNames: + v = new(database.GetDatabaseTableNamesReturns) + + case cdp.EventDatabaseAddDatabase: + v = new(database.EventAddDatabase) + + case cdp.CommandDeviceOrientationClearDeviceOrientationOverride: + return emptyVal, nil + + case cdp.CommandDeviceOrientationSetDeviceOrientationOverride: + return emptyVal, nil + + case cdp.CommandEmulationCanEmulate: + v = new(emulation.CanEmulateReturns) + + case cdp.CommandEmulationClearDeviceMetricsOverride: + return emptyVal, nil + + case cdp.CommandEmulationClearGeolocationOverride: + return emptyVal, nil + + case cdp.CommandEmulationResetPageScaleFactor: + return emptyVal, nil + + case cdp.CommandEmulationSetCPUThrottlingRate: + return emptyVal, nil + + case cdp.CommandEmulationSetDefaultBackgroundColorOverride: + return emptyVal, nil + + case cdp.CommandEmulationSetDeviceMetricsOverride: + return emptyVal, nil + + case cdp.CommandEmulationSetEmitTouchEventsForMouse: + return emptyVal, nil + + case cdp.CommandEmulationSetEmulatedMedia: + return emptyVal, nil + + case cdp.CommandEmulationSetGeolocationOverride: + return emptyVal, nil + + case cdp.CommandEmulationSetNavigatorOverrides: + return emptyVal, nil + + case cdp.CommandEmulationSetPageScaleFactor: + return emptyVal, nil + + case cdp.CommandEmulationSetScriptExecutionDisabled: + return emptyVal, nil + + case cdp.CommandEmulationSetTouchEmulationEnabled: + return emptyVal, nil + + case cdp.CommandEmulationSetVirtualTimePolicy: + v = new(emulation.SetVirtualTimePolicyReturns) + + case cdp.EventEmulationVirtualTimeAdvanced: + v = new(emulation.EventVirtualTimeAdvanced) + + case cdp.EventEmulationVirtualTimeBudgetExpired: + v = new(emulation.EventVirtualTimeBudgetExpired) + + case cdp.EventEmulationVirtualTimePaused: + v = new(emulation.EventVirtualTimePaused) + case cdp.CommandHeadlessExperimentalBeginFrame: v = new(headlessexperimental.BeginFrameReturns) - case cdp.EventHeadlessExperimentalNeedsBeginFramesChanged: - v = new(headlessexperimental.EventNeedsBeginFramesChanged) + case cdp.CommandHeadlessExperimentalDisable: + return emptyVal, nil + + case cdp.CommandHeadlessExperimentalEnable: + return emptyVal, nil case cdp.EventHeadlessExperimentalMainFrameReadyForScreenshots: v = new(headlessexperimental.EventMainFrameReadyForScreenshots) - case cdp.CommandServiceWorkerEnable: + case cdp.EventHeadlessExperimentalNeedsBeginFramesChanged: + v = new(headlessexperimental.EventNeedsBeginFramesChanged) + + case cdp.CommandIOClose: return emptyVal, nil - case cdp.CommandServiceWorkerDisable: + case cdp.CommandIORead: + v = new(iodom.ReadReturns) + + case cdp.CommandIOResolveBlob: + v = new(iodom.ResolveBlobReturns) + + case cdp.CommandIndexedDBClearObjectStore: return emptyVal, nil - case cdp.CommandServiceWorkerUnregister: + case cdp.CommandIndexedDBDeleteDatabase: return emptyVal, nil - case cdp.CommandServiceWorkerUpdateRegistration: + case cdp.CommandIndexedDBDeleteObjectStoreEntries: return emptyVal, nil - case cdp.CommandServiceWorkerStartWorker: + case cdp.CommandIndexedDBDisable: return emptyVal, nil - case cdp.CommandServiceWorkerSkipWaiting: + case cdp.CommandIndexedDBEnable: return emptyVal, nil - case cdp.CommandServiceWorkerStopWorker: - return emptyVal, nil + case cdp.CommandIndexedDBRequestData: + v = new(indexeddb.RequestDataReturns) - case cdp.CommandServiceWorkerStopAllWorkers: - return emptyVal, nil + case cdp.CommandIndexedDBRequestDatabase: + v = new(indexeddb.RequestDatabaseReturns) - case cdp.CommandServiceWorkerInspectWorker: - return emptyVal, nil - - case cdp.CommandServiceWorkerSetForceUpdateOnPageLoad: - return emptyVal, nil - - case cdp.CommandServiceWorkerDeliverPushMessage: - return emptyVal, nil - - case cdp.CommandServiceWorkerDispatchSyncEvent: - return emptyVal, nil - - case cdp.EventServiceWorkerWorkerRegistrationUpdated: - v = new(serviceworker.EventWorkerRegistrationUpdated) - - case cdp.EventServiceWorkerWorkerVersionUpdated: - v = new(serviceworker.EventWorkerVersionUpdated) - - case cdp.EventServiceWorkerWorkerErrorReported: - v = new(serviceworker.EventWorkerErrorReported) - - case cdp.CommandInputSetIgnoreInputEvents: - return emptyVal, nil + case cdp.CommandIndexedDBRequestDatabaseNames: + v = new(indexeddb.RequestDatabaseNamesReturns) case cdp.CommandInputDispatchKeyEvent: return emptyVal, nil @@ -982,6 +571,9 @@ func UnmarshalMessage(msg *cdp.Message) (interface{}, error) { case cdp.CommandInputEmulateTouchFromMouseEvent: return emptyVal, nil + case cdp.CommandInputSetIgnoreInputEvents: + return emptyVal, nil + case cdp.CommandInputSynthesizePinchGesture: return emptyVal, nil @@ -991,148 +583,58 @@ func UnmarshalMessage(msg *cdp.Message) (interface{}, error) { case cdp.CommandInputSynthesizeTapGesture: return emptyVal, nil - case cdp.CommandLayerTreeEnable: + case cdp.CommandInspectorDisable: return emptyVal, nil - case cdp.CommandLayerTreeDisable: + case cdp.CommandInspectorEnable: return emptyVal, nil + case cdp.EventInspectorDetached: + v = new(inspector.EventDetached) + + case cdp.EventInspectorTargetCrashed: + v = new(inspector.EventTargetCrashed) + case cdp.CommandLayerTreeCompositingReasons: v = new(layertree.CompositingReasonsReturns) - case cdp.CommandLayerTreeMakeSnapshot: - v = new(layertree.MakeSnapshotReturns) + case cdp.CommandLayerTreeDisable: + return emptyVal, nil + + case cdp.CommandLayerTreeEnable: + return emptyVal, nil case cdp.CommandLayerTreeLoadSnapshot: v = new(layertree.LoadSnapshotReturns) - case cdp.CommandLayerTreeReleaseSnapshot: - return emptyVal, nil + case cdp.CommandLayerTreeMakeSnapshot: + v = new(layertree.MakeSnapshotReturns) case cdp.CommandLayerTreeProfileSnapshot: v = new(layertree.ProfileSnapshotReturns) + case cdp.CommandLayerTreeReleaseSnapshot: + return emptyVal, nil + case cdp.CommandLayerTreeReplaySnapshot: v = new(layertree.ReplaySnapshotReturns) case cdp.CommandLayerTreeSnapshotCommandLog: v = new(layertree.SnapshotCommandLogReturns) - case cdp.EventLayerTreeLayerTreeDidChange: - v = new(layertree.EventLayerTreeDidChange) - case cdp.EventLayerTreeLayerPainted: v = new(layertree.EventLayerPainted) - case cdp.CommandDeviceOrientationSetDeviceOrientationOverride: - return emptyVal, nil + case cdp.EventLayerTreeLayerTreeDidChange: + v = new(layertree.EventLayerTreeDidChange) - case cdp.CommandDeviceOrientationClearDeviceOrientationOverride: - return emptyVal, nil - - case cdp.CommandTracingStart: - return emptyVal, nil - - case cdp.CommandTracingEnd: - return emptyVal, nil - - case cdp.CommandTracingGetCategories: - v = new(tracing.GetCategoriesReturns) - - case cdp.CommandTracingRequestMemoryDump: - v = new(tracing.RequestMemoryDumpReturns) - - case cdp.CommandTracingRecordClockSyncMarker: - return emptyVal, nil - - case cdp.EventTracingDataCollected: - v = new(tracing.EventDataCollected) - - case cdp.EventTracingTracingComplete: - v = new(tracing.EventTracingComplete) - - case cdp.EventTracingBufferUsage: - v = new(tracing.EventBufferUsage) - - case cdp.CommandAnimationEnable: - return emptyVal, nil - - case cdp.CommandAnimationDisable: - return emptyVal, nil - - case cdp.CommandAnimationGetPlaybackRate: - v = new(animation.GetPlaybackRateReturns) - - case cdp.CommandAnimationSetPlaybackRate: - return emptyVal, nil - - case cdp.CommandAnimationGetCurrentTime: - v = new(animation.GetCurrentTimeReturns) - - case cdp.CommandAnimationSetPaused: - return emptyVal, nil - - case cdp.CommandAnimationSetTiming: - return emptyVal, nil - - case cdp.CommandAnimationSeekAnimations: - return emptyVal, nil - - case cdp.CommandAnimationReleaseAnimations: - return emptyVal, nil - - case cdp.CommandAnimationResolveAnimation: - v = new(animation.ResolveAnimationReturns) - - case cdp.EventAnimationAnimationCreated: - v = new(animation.EventAnimationCreated) - - case cdp.EventAnimationAnimationStarted: - v = new(animation.EventAnimationStarted) - - case cdp.EventAnimationAnimationCanceled: - v = new(animation.EventAnimationCanceled) - - case cdp.CommandAccessibilityGetPartialAXTree: - v = new(accessibility.GetPartialAXTreeReturns) - - case cdp.CommandStorageClearDataForOrigin: - return emptyVal, nil - - case cdp.CommandStorageGetUsageAndQuota: - v = new(storage.GetUsageAndQuotaReturns) - - case cdp.CommandStorageTrackCacheStorageForOrigin: - return emptyVal, nil - - case cdp.CommandStorageUntrackCacheStorageForOrigin: - return emptyVal, nil - - case cdp.CommandStorageTrackIndexedDBForOrigin: - return emptyVal, nil - - case cdp.CommandStorageUntrackIndexedDBForOrigin: - return emptyVal, nil - - case cdp.EventStorageCacheStorageListUpdated: - v = new(storage.EventCacheStorageListUpdated) - - case cdp.EventStorageCacheStorageContentUpdated: - v = new(storage.EventCacheStorageContentUpdated) - - case cdp.EventStorageIndexedDBListUpdated: - v = new(storage.EventIndexedDBListUpdated) - - case cdp.EventStorageIndexedDBContentUpdated: - v = new(storage.EventIndexedDBContentUpdated) - - case cdp.CommandLogEnable: + case cdp.CommandLogClear: return emptyVal, nil case cdp.CommandLogDisable: return emptyVal, nil - case cdp.CommandLogClear: + case cdp.CommandLogEnable: return emptyVal, nil case cdp.CommandLogStartViolationsReport: @@ -1144,9 +646,501 @@ func UnmarshalMessage(msg *cdp.Message) (interface{}, error) { case cdp.EventLogEntryAdded: v = new(logdom.EventEntryAdded) + case cdp.CommandMemoryGetDOMCounters: + v = new(memory.GetDOMCountersReturns) + + case cdp.CommandMemoryPrepareForLeakDetection: + return emptyVal, nil + + case cdp.CommandMemorySetPressureNotificationsSuppressed: + return emptyVal, nil + + case cdp.CommandMemorySimulatePressureNotification: + return emptyVal, nil + + case cdp.CommandNetworkClearBrowserCache: + return emptyVal, nil + + case cdp.CommandNetworkClearBrowserCookies: + return emptyVal, nil + + case cdp.CommandNetworkContinueInterceptedRequest: + return emptyVal, nil + + case cdp.CommandNetworkDeleteCookies: + return emptyVal, nil + + case cdp.CommandNetworkDisable: + return emptyVal, nil + + case cdp.CommandNetworkEmulateNetworkConditions: + return emptyVal, nil + + case cdp.CommandNetworkEnable: + return emptyVal, nil + + case cdp.CommandNetworkGetAllCookies: + v = new(network.GetAllCookiesReturns) + + case cdp.CommandNetworkGetCertificate: + v = new(network.GetCertificateReturns) + + case cdp.CommandNetworkGetCookies: + v = new(network.GetCookiesReturns) + + case cdp.CommandNetworkGetResponseBody: + v = new(network.GetResponseBodyReturns) + + case cdp.CommandNetworkGetResponseBodyForInterception: + v = new(network.GetResponseBodyForInterceptionReturns) + + case cdp.CommandNetworkReplayXHR: + return emptyVal, nil + + case cdp.CommandNetworkSearchInResponseBody: + v = new(network.SearchInResponseBodyReturns) + + case cdp.CommandNetworkSetBlockedURLS: + return emptyVal, nil + + case cdp.CommandNetworkSetBypassServiceWorker: + return emptyVal, nil + + case cdp.CommandNetworkSetCacheDisabled: + return emptyVal, nil + + case cdp.CommandNetworkSetCookie: + v = new(network.SetCookieReturns) + + case cdp.CommandNetworkSetCookies: + return emptyVal, nil + + case cdp.CommandNetworkSetDataSizeLimitsForTest: + return emptyVal, nil + + case cdp.CommandNetworkSetExtraHTTPHeaders: + return emptyVal, nil + + case cdp.CommandNetworkSetRequestInterception: + return emptyVal, nil + + case cdp.CommandNetworkSetUserAgentOverride: + return emptyVal, nil + + case cdp.EventNetworkDataReceived: + v = new(network.EventDataReceived) + + case cdp.EventNetworkEventSourceMessageReceived: + v = new(network.EventEventSourceMessageReceived) + + case cdp.EventNetworkLoadingFailed: + v = new(network.EventLoadingFailed) + + case cdp.EventNetworkLoadingFinished: + v = new(network.EventLoadingFinished) + + case cdp.EventNetworkRequestIntercepted: + v = new(network.EventRequestIntercepted) + + case cdp.EventNetworkRequestServedFromCache: + v = new(network.EventRequestServedFromCache) + + case cdp.EventNetworkRequestWillBeSent: + v = new(network.EventRequestWillBeSent) + + case cdp.EventNetworkResourceChangedPriority: + v = new(network.EventResourceChangedPriority) + + case cdp.EventNetworkResponseReceived: + v = new(network.EventResponseReceived) + + case cdp.EventNetworkWebSocketClosed: + v = new(network.EventWebSocketClosed) + + case cdp.EventNetworkWebSocketCreated: + v = new(network.EventWebSocketCreated) + + case cdp.EventNetworkWebSocketFrameError: + v = new(network.EventWebSocketFrameError) + + case cdp.EventNetworkWebSocketFrameReceived: + v = new(network.EventWebSocketFrameReceived) + + case cdp.EventNetworkWebSocketFrameSent: + v = new(network.EventWebSocketFrameSent) + + case cdp.EventNetworkWebSocketHandshakeResponseReceived: + v = new(network.EventWebSocketHandshakeResponseReceived) + + case cdp.EventNetworkWebSocketWillSendHandshakeRequest: + v = new(network.EventWebSocketWillSendHandshakeRequest) + + case cdp.CommandOverlayDisable: + return emptyVal, nil + + case cdp.CommandOverlayEnable: + return emptyVal, nil + + case cdp.CommandOverlayGetHighlightObjectForTest: + v = new(overlay.GetHighlightObjectForTestReturns) + + case cdp.CommandOverlayHideHighlight: + return emptyVal, nil + + case cdp.CommandOverlayHighlightFrame: + return emptyVal, nil + + case cdp.CommandOverlayHighlightNode: + return emptyVal, nil + + case cdp.CommandOverlayHighlightQuad: + return emptyVal, nil + + case cdp.CommandOverlayHighlightRect: + return emptyVal, nil + + case cdp.CommandOverlaySetInspectMode: + return emptyVal, nil + + case cdp.CommandOverlaySetPausedInDebuggerMessage: + return emptyVal, nil + + case cdp.CommandOverlaySetShowDebugBorders: + return emptyVal, nil + + case cdp.CommandOverlaySetShowFPSCounter: + return emptyVal, nil + + case cdp.CommandOverlaySetShowPaintRects: + return emptyVal, nil + + case cdp.CommandOverlaySetShowScrollBottleneckRects: + return emptyVal, nil + + case cdp.CommandOverlaySetShowViewportSizeOnResize: + return emptyVal, nil + + case cdp.CommandOverlaySetSuspended: + return emptyVal, nil + + case cdp.EventOverlayInspectNodeRequested: + v = new(overlay.EventInspectNodeRequested) + + case cdp.EventOverlayNodeHighlightRequested: + v = new(overlay.EventNodeHighlightRequested) + + case cdp.EventOverlayScreenshotRequested: + v = new(overlay.EventScreenshotRequested) + + case cdp.CommandPageAddScriptToEvaluateOnNewDocument: + v = new(page.AddScriptToEvaluateOnNewDocumentReturns) + + case cdp.CommandPageBringToFront: + return emptyVal, nil + + case cdp.CommandPageCaptureScreenshot: + v = new(page.CaptureScreenshotReturns) + + case cdp.CommandPageCreateIsolatedWorld: + v = new(page.CreateIsolatedWorldReturns) + + case cdp.CommandPageDisable: + return emptyVal, nil + + case cdp.CommandPageEnable: + return emptyVal, nil + + case cdp.CommandPageGetAppManifest: + v = new(page.GetAppManifestReturns) + + case cdp.CommandPageGetFrameTree: + v = new(page.GetFrameTreeReturns) + + case cdp.CommandPageGetLayoutMetrics: + v = new(page.GetLayoutMetricsReturns) + + case cdp.CommandPageGetNavigationHistory: + v = new(page.GetNavigationHistoryReturns) + + case cdp.CommandPageGetResourceContent: + v = new(page.GetResourceContentReturns) + + case cdp.CommandPageGetResourceTree: + v = new(page.GetResourceTreeReturns) + + case cdp.CommandPageHandleJavaScriptDialog: + return emptyVal, nil + + case cdp.CommandPageNavigate: + v = new(page.NavigateReturns) + + case cdp.CommandPageNavigateToHistoryEntry: + return emptyVal, nil + + case cdp.CommandPagePrintToPDF: + v = new(page.PrintToPDFReturns) + + case cdp.CommandPageReload: + return emptyVal, nil + + case cdp.CommandPageRemoveScriptToEvaluateOnNewDocument: + return emptyVal, nil + + case cdp.CommandPageRequestAppBanner: + return emptyVal, nil + + case cdp.CommandPageScreencastFrameAck: + return emptyVal, nil + + case cdp.CommandPageSearchInResource: + v = new(page.SearchInResourceReturns) + + case cdp.CommandPageSetAdBlockingEnabled: + return emptyVal, nil + + case cdp.CommandPageSetAutoAttachToCreatedPages: + return emptyVal, nil + + case cdp.CommandPageSetDocumentContent: + return emptyVal, nil + + case cdp.CommandPageSetDownloadBehavior: + return emptyVal, nil + + case cdp.CommandPageSetLifecycleEventsEnabled: + return emptyVal, nil + + case cdp.CommandPageStartScreencast: + return emptyVal, nil + + case cdp.CommandPageStopLoading: + return emptyVal, nil + + case cdp.CommandPageStopScreencast: + return emptyVal, nil + + case cdp.EventPageDomContentEventFired: + v = new(page.EventDomContentEventFired) + + case cdp.EventPageFrameAttached: + v = new(page.EventFrameAttached) + + case cdp.EventPageFrameClearedScheduledNavigation: + v = new(page.EventFrameClearedScheduledNavigation) + + case cdp.EventPageFrameDetached: + v = new(page.EventFrameDetached) + + case cdp.EventPageFrameNavigated: + v = new(page.EventFrameNavigated) + + case cdp.EventPageFrameResized: + v = new(page.EventFrameResized) + + case cdp.EventPageFrameScheduledNavigation: + v = new(page.EventFrameScheduledNavigation) + + case cdp.EventPageFrameStartedLoading: + v = new(page.EventFrameStartedLoading) + + case cdp.EventPageFrameStoppedLoading: + v = new(page.EventFrameStoppedLoading) + + case cdp.EventPageInterstitialHidden: + v = new(page.EventInterstitialHidden) + + case cdp.EventPageInterstitialShown: + v = new(page.EventInterstitialShown) + + case cdp.EventPageJavascriptDialogClosed: + v = new(page.EventJavascriptDialogClosed) + + case cdp.EventPageJavascriptDialogOpening: + v = new(page.EventJavascriptDialogOpening) + + case cdp.EventPageLifecycleEvent: + v = new(page.EventLifecycleEvent) + + case cdp.EventPageLoadEventFired: + v = new(page.EventLoadEventFired) + + case cdp.EventPageScreencastFrame: + v = new(page.EventScreencastFrame) + + case cdp.EventPageScreencastVisibilityChanged: + v = new(page.EventScreencastVisibilityChanged) + + case cdp.EventPageWindowOpen: + v = new(page.EventWindowOpen) + + case cdp.CommandPerformanceDisable: + return emptyVal, nil + + case cdp.CommandPerformanceEnable: + return emptyVal, nil + + case cdp.CommandPerformanceGetMetrics: + v = new(performance.GetMetricsReturns) + + case cdp.EventPerformanceMetrics: + v = new(performance.EventMetrics) + + case cdp.CommandSecurityDisable: + return emptyVal, nil + + case cdp.CommandSecurityEnable: + return emptyVal, nil + + case cdp.CommandSecurityHandleCertificateError: + return emptyVal, nil + + case cdp.CommandSecuritySetOverrideCertificateErrors: + return emptyVal, nil + + case cdp.EventSecurityCertificateError: + v = new(security.EventCertificateError) + + case cdp.EventSecuritySecurityStateChanged: + v = new(security.EventSecurityStateChanged) + + case cdp.CommandServiceWorkerDeliverPushMessage: + return emptyVal, nil + + case cdp.CommandServiceWorkerDisable: + return emptyVal, nil + + case cdp.CommandServiceWorkerDispatchSyncEvent: + return emptyVal, nil + + case cdp.CommandServiceWorkerEnable: + return emptyVal, nil + + case cdp.CommandServiceWorkerInspectWorker: + return emptyVal, nil + + case cdp.CommandServiceWorkerSetForceUpdateOnPageLoad: + return emptyVal, nil + + case cdp.CommandServiceWorkerSkipWaiting: + return emptyVal, nil + + case cdp.CommandServiceWorkerStartWorker: + return emptyVal, nil + + case cdp.CommandServiceWorkerStopAllWorkers: + return emptyVal, nil + + case cdp.CommandServiceWorkerStopWorker: + return emptyVal, nil + + case cdp.CommandServiceWorkerUnregister: + return emptyVal, nil + + case cdp.CommandServiceWorkerUpdateRegistration: + return emptyVal, nil + + case cdp.EventServiceWorkerWorkerErrorReported: + v = new(serviceworker.EventWorkerErrorReported) + + case cdp.EventServiceWorkerWorkerRegistrationUpdated: + v = new(serviceworker.EventWorkerRegistrationUpdated) + + case cdp.EventServiceWorkerWorkerVersionUpdated: + v = new(serviceworker.EventWorkerVersionUpdated) + + case cdp.CommandStorageClearDataForOrigin: + return emptyVal, nil + + case cdp.CommandStorageGetUsageAndQuota: + v = new(storage.GetUsageAndQuotaReturns) + + case cdp.CommandStorageTrackCacheStorageForOrigin: + return emptyVal, nil + + case cdp.CommandStorageTrackIndexedDBForOrigin: + return emptyVal, nil + + case cdp.CommandStorageUntrackCacheStorageForOrigin: + return emptyVal, nil + + case cdp.CommandStorageUntrackIndexedDBForOrigin: + return emptyVal, nil + + case cdp.EventStorageCacheStorageContentUpdated: + v = new(storage.EventCacheStorageContentUpdated) + + case cdp.EventStorageCacheStorageListUpdated: + v = new(storage.EventCacheStorageListUpdated) + + case cdp.EventStorageIndexedDBContentUpdated: + v = new(storage.EventIndexedDBContentUpdated) + + case cdp.EventStorageIndexedDBListUpdated: + v = new(storage.EventIndexedDBListUpdated) + case cdp.CommandSystemInfoGetInfo: v = new(systeminfo.GetInfoReturns) + case cdp.CommandTargetActivateTarget: + return emptyVal, nil + + case cdp.CommandTargetAttachToTarget: + v = new(target.AttachToTargetReturns) + + case cdp.CommandTargetCloseTarget: + v = new(target.CloseTargetReturns) + + case cdp.CommandTargetCreateBrowserContext: + v = new(target.CreateBrowserContextReturns) + + case cdp.CommandTargetCreateTarget: + v = new(target.CreateTargetReturns) + + case cdp.CommandTargetDetachFromTarget: + return emptyVal, nil + + case cdp.CommandTargetDisposeBrowserContext: + v = new(target.DisposeBrowserContextReturns) + + case cdp.CommandTargetGetTargetInfo: + v = new(target.GetTargetInfoReturns) + + case cdp.CommandTargetGetTargets: + v = new(target.GetTargetsReturns) + + case cdp.CommandTargetSendMessageToTarget: + return emptyVal, nil + + case cdp.CommandTargetSetAttachToFrames: + return emptyVal, nil + + case cdp.CommandTargetSetAutoAttach: + return emptyVal, nil + + case cdp.CommandTargetSetDiscoverTargets: + return emptyVal, nil + + case cdp.CommandTargetSetRemoteLocations: + return emptyVal, nil + + case cdp.EventTargetAttachedToTarget: + v = new(target.EventAttachedToTarget) + + case cdp.EventTargetDetachedFromTarget: + v = new(target.EventDetachedFromTarget) + + case cdp.EventTargetReceivedMessageFromTarget: + v = new(target.EventReceivedMessageFromTarget) + + case cdp.EventTargetTargetCreated: + v = new(target.EventTargetCreated) + + case cdp.EventTargetTargetDestroyed: + v = new(target.EventTargetDestroyed) + + case cdp.EventTargetTargetInfoChanged: + v = new(target.EventTargetInfoChanged) + case cdp.CommandTetheringBind: return emptyVal, nil @@ -1156,162 +1150,72 @@ func UnmarshalMessage(msg *cdp.Message) (interface{}, error) { case cdp.EventTetheringAccepted: v = new(tethering.EventAccepted) - case cdp.CommandBrowserClose: + case cdp.CommandTracingEnd: return emptyVal, nil - case cdp.CommandBrowserGetWindowForTarget: - v = new(browser.GetWindowForTargetReturns) + case cdp.CommandTracingGetCategories: + v = new(tracing.GetCategoriesReturns) - case cdp.CommandBrowserGetVersion: - v = new(browser.GetVersionReturns) - - case cdp.CommandBrowserSetWindowBounds: + case cdp.CommandTracingRecordClockSyncMarker: return emptyVal, nil - case cdp.CommandBrowserGetWindowBounds: - v = new(browser.GetWindowBoundsReturns) + case cdp.CommandTracingRequestMemoryDump: + v = new(tracing.RequestMemoryDumpReturns) - case cdp.CommandRuntimeEvaluate: - v = new(runtime.EvaluateReturns) - - case cdp.CommandRuntimeAwaitPromise: - v = new(runtime.AwaitPromiseReturns) - - case cdp.CommandRuntimeCallFunctionOn: - v = new(runtime.CallFunctionOnReturns) - - case cdp.CommandRuntimeGetProperties: - v = new(runtime.GetPropertiesReturns) - - case cdp.CommandRuntimeReleaseObject: + case cdp.CommandTracingStart: return emptyVal, nil - case cdp.CommandRuntimeReleaseObjectGroup: + case cdp.EventTracingBufferUsage: + v = new(tracing.EventBufferUsage) + + case cdp.EventTracingDataCollected: + v = new(tracing.EventDataCollected) + + case cdp.EventTracingTracingComplete: + v = new(tracing.EventTracingComplete) + + case cdp.CommandDebuggerContinueToLocation: return emptyVal, nil - case cdp.CommandRuntimeRunIfWaitingForDebugger: - return emptyVal, nil - - case cdp.CommandRuntimeEnable: - return emptyVal, nil - - case cdp.CommandRuntimeDisable: - return emptyVal, nil - - case cdp.CommandRuntimeDiscardConsoleEntries: - return emptyVal, nil - - case cdp.CommandRuntimeSetCustomObjectFormatterEnabled: - return emptyVal, nil - - case cdp.CommandRuntimeCompileScript: - v = new(runtime.CompileScriptReturns) - - case cdp.CommandRuntimeRunScript: - v = new(runtime.RunScriptReturns) - - case cdp.CommandRuntimeQueryObjects: - v = new(runtime.QueryObjectsReturns) - - case cdp.CommandRuntimeGlobalLexicalScopeNames: - v = new(runtime.GlobalLexicalScopeNamesReturns) - - case cdp.EventRuntimeExecutionContextCreated: - v = new(runtime.EventExecutionContextCreated) - - case cdp.EventRuntimeExecutionContextDestroyed: - v = new(runtime.EventExecutionContextDestroyed) - - case cdp.EventRuntimeExecutionContextsCleared: - v = new(runtime.EventExecutionContextsCleared) - - case cdp.EventRuntimeExceptionThrown: - v = new(runtime.EventExceptionThrown) - - case cdp.EventRuntimeExceptionRevoked: - v = new(runtime.EventExceptionRevoked) - - case cdp.EventRuntimeConsoleAPICalled: - v = new(runtime.EventConsoleAPICalled) - - case cdp.EventRuntimeInspectRequested: - v = new(runtime.EventInspectRequested) - - case cdp.CommandDebuggerEnable: - v = new(debugger.EnableReturns) - case cdp.CommandDebuggerDisable: return emptyVal, nil - case cdp.CommandDebuggerSetBreakpointsActive: - return emptyVal, nil + case cdp.CommandDebuggerEnable: + v = new(debugger.EnableReturns) - case cdp.CommandDebuggerSetSkipAllPauses: - return emptyVal, nil - - case cdp.CommandDebuggerSetBreakpointByURL: - v = new(debugger.SetBreakpointByURLReturns) - - case cdp.CommandDebuggerSetBreakpoint: - v = new(debugger.SetBreakpointReturns) - - case cdp.CommandDebuggerRemoveBreakpoint: - return emptyVal, nil + case cdp.CommandDebuggerEvaluateOnCallFrame: + v = new(debugger.EvaluateOnCallFrameReturns) case cdp.CommandDebuggerGetPossibleBreakpoints: v = new(debugger.GetPossibleBreakpointsReturns) - case cdp.CommandDebuggerContinueToLocation: + case cdp.CommandDebuggerGetScriptSource: + v = new(debugger.GetScriptSourceReturns) + + case cdp.CommandDebuggerGetStackTrace: + v = new(debugger.GetStackTraceReturns) + + case cdp.CommandDebuggerPause: return emptyVal, nil case cdp.CommandDebuggerPauseOnAsyncCall: return emptyVal, nil - case cdp.CommandDebuggerStepOver: + case cdp.CommandDebuggerRemoveBreakpoint: return emptyVal, nil - case cdp.CommandDebuggerStepInto: - return emptyVal, nil + case cdp.CommandDebuggerRestartFrame: + v = new(debugger.RestartFrameReturns) - case cdp.CommandDebuggerStepOut: - return emptyVal, nil - - case cdp.CommandDebuggerPause: + case cdp.CommandDebuggerResume: return emptyVal, nil case cdp.CommandDebuggerScheduleStepIntoAsync: return emptyVal, nil - case cdp.CommandDebuggerResume: - return emptyVal, nil - - case cdp.CommandDebuggerGetStackTrace: - v = new(debugger.GetStackTraceReturns) - case cdp.CommandDebuggerSearchInContent: v = new(debugger.SearchInContentReturns) - case cdp.CommandDebuggerSetScriptSource: - v = new(debugger.SetScriptSourceReturns) - - case cdp.CommandDebuggerRestartFrame: - v = new(debugger.RestartFrameReturns) - - case cdp.CommandDebuggerGetScriptSource: - v = new(debugger.GetScriptSourceReturns) - - case cdp.CommandDebuggerSetPauseOnExceptions: - return emptyVal, nil - - case cdp.CommandDebuggerEvaluateOnCallFrame: - v = new(debugger.EvaluateOnCallFrameReturns) - - case cdp.CommandDebuggerSetVariableValue: - return emptyVal, nil - - case cdp.CommandDebuggerSetReturnValue: - return emptyVal, nil - case cdp.CommandDebuggerSetAsyncCallStackDepth: return emptyVal, nil @@ -1321,11 +1225,38 @@ func UnmarshalMessage(msg *cdp.Message) (interface{}, error) { case cdp.CommandDebuggerSetBlackboxedRanges: return emptyVal, nil - case cdp.EventDebuggerScriptParsed: - v = new(debugger.EventScriptParsed) + case cdp.CommandDebuggerSetBreakpoint: + v = new(debugger.SetBreakpointReturns) - case cdp.EventDebuggerScriptFailedToParse: - v = new(debugger.EventScriptFailedToParse) + case cdp.CommandDebuggerSetBreakpointByURL: + v = new(debugger.SetBreakpointByURLReturns) + + case cdp.CommandDebuggerSetBreakpointsActive: + return emptyVal, nil + + case cdp.CommandDebuggerSetPauseOnExceptions: + return emptyVal, nil + + case cdp.CommandDebuggerSetReturnValue: + return emptyVal, nil + + case cdp.CommandDebuggerSetScriptSource: + v = new(debugger.SetScriptSourceReturns) + + case cdp.CommandDebuggerSetSkipAllPauses: + return emptyVal, nil + + case cdp.CommandDebuggerSetVariableValue: + return emptyVal, nil + + case cdp.CommandDebuggerStepInto: + return emptyVal, nil + + case cdp.CommandDebuggerStepOut: + return emptyVal, nil + + case cdp.CommandDebuggerStepOver: + return emptyVal, nil case cdp.EventDebuggerBreakpointResolved: v = new(debugger.EventBreakpointResolved) @@ -1336,98 +1267,170 @@ func UnmarshalMessage(msg *cdp.Message) (interface{}, error) { case cdp.EventDebuggerResumed: v = new(debugger.EventResumed) - case cdp.CommandProfilerEnable: + case cdp.EventDebuggerScriptFailedToParse: + v = new(debugger.EventScriptFailedToParse) + + case cdp.EventDebuggerScriptParsed: + v = new(debugger.EventScriptParsed) + + case cdp.CommandHeapProfilerAddInspectedHeapObject: return emptyVal, nil - case cdp.CommandProfilerDisable: - return emptyVal, nil - - case cdp.CommandProfilerSetSamplingInterval: - return emptyVal, nil - - case cdp.CommandProfilerStart: - return emptyVal, nil - - case cdp.CommandProfilerStop: - v = new(profiler.StopReturns) - - case cdp.CommandProfilerStartPreciseCoverage: - return emptyVal, nil - - case cdp.CommandProfilerStopPreciseCoverage: - return emptyVal, nil - - case cdp.CommandProfilerTakePreciseCoverage: - v = new(profiler.TakePreciseCoverageReturns) - - case cdp.CommandProfilerGetBestEffortCoverage: - v = new(profiler.GetBestEffortCoverageReturns) - - case cdp.CommandProfilerStartTypeProfile: - return emptyVal, nil - - case cdp.CommandProfilerStopTypeProfile: - return emptyVal, nil - - case cdp.CommandProfilerTakeTypeProfile: - v = new(profiler.TakeTypeProfileReturns) - - case cdp.EventProfilerConsoleProfileStarted: - v = new(profiler.EventConsoleProfileStarted) - - case cdp.EventProfilerConsoleProfileFinished: - v = new(profiler.EventConsoleProfileFinished) - - case cdp.CommandHeapProfilerEnable: + case cdp.CommandHeapProfilerCollectGarbage: return emptyVal, nil case cdp.CommandHeapProfilerDisable: return emptyVal, nil + case cdp.CommandHeapProfilerEnable: + return emptyVal, nil + + case cdp.CommandHeapProfilerGetHeapObjectID: + v = new(heapprofiler.GetHeapObjectIDReturns) + + case cdp.CommandHeapProfilerGetObjectByHeapObjectID: + v = new(heapprofiler.GetObjectByHeapObjectIDReturns) + + case cdp.CommandHeapProfilerGetSamplingProfile: + v = new(heapprofiler.GetSamplingProfileReturns) + + case cdp.CommandHeapProfilerStartSampling: + return emptyVal, nil + case cdp.CommandHeapProfilerStartTrackingHeapObjects: return emptyVal, nil + case cdp.CommandHeapProfilerStopSampling: + v = new(heapprofiler.StopSamplingReturns) + case cdp.CommandHeapProfilerStopTrackingHeapObjects: return emptyVal, nil case cdp.CommandHeapProfilerTakeHeapSnapshot: return emptyVal, nil - case cdp.CommandHeapProfilerCollectGarbage: - return emptyVal, nil - - case cdp.CommandHeapProfilerGetObjectByHeapObjectID: - v = new(heapprofiler.GetObjectByHeapObjectIDReturns) - - case cdp.CommandHeapProfilerAddInspectedHeapObject: - return emptyVal, nil - - case cdp.CommandHeapProfilerGetHeapObjectID: - v = new(heapprofiler.GetHeapObjectIDReturns) - - case cdp.CommandHeapProfilerStartSampling: - return emptyVal, nil - - case cdp.CommandHeapProfilerStopSampling: - v = new(heapprofiler.StopSamplingReturns) - - case cdp.CommandHeapProfilerGetSamplingProfile: - v = new(heapprofiler.GetSamplingProfileReturns) - case cdp.EventHeapProfilerAddHeapSnapshotChunk: v = new(heapprofiler.EventAddHeapSnapshotChunk) - case cdp.EventHeapProfilerResetProfiles: - v = new(heapprofiler.EventResetProfiles) - - case cdp.EventHeapProfilerReportHeapSnapshotProgress: - v = new(heapprofiler.EventReportHeapSnapshotProgress) + case cdp.EventHeapProfilerHeapStatsUpdate: + v = new(heapprofiler.EventHeapStatsUpdate) case cdp.EventHeapProfilerLastSeenObjectID: v = new(heapprofiler.EventLastSeenObjectID) - case cdp.EventHeapProfilerHeapStatsUpdate: - v = new(heapprofiler.EventHeapStatsUpdate) + case cdp.EventHeapProfilerReportHeapSnapshotProgress: + v = new(heapprofiler.EventReportHeapSnapshotProgress) + + case cdp.EventHeapProfilerResetProfiles: + v = new(heapprofiler.EventResetProfiles) + + case cdp.CommandProfilerDisable: + return emptyVal, nil + + case cdp.CommandProfilerEnable: + return emptyVal, nil + + case cdp.CommandProfilerGetBestEffortCoverage: + v = new(profiler.GetBestEffortCoverageReturns) + + case cdp.CommandProfilerSetSamplingInterval: + return emptyVal, nil + + case cdp.CommandProfilerStart: + return emptyVal, nil + + case cdp.CommandProfilerStartPreciseCoverage: + return emptyVal, nil + + case cdp.CommandProfilerStartTypeProfile: + return emptyVal, nil + + case cdp.CommandProfilerStop: + v = new(profiler.StopReturns) + + case cdp.CommandProfilerStopPreciseCoverage: + return emptyVal, nil + + case cdp.CommandProfilerStopTypeProfile: + return emptyVal, nil + + case cdp.CommandProfilerTakePreciseCoverage: + v = new(profiler.TakePreciseCoverageReturns) + + case cdp.CommandProfilerTakeTypeProfile: + v = new(profiler.TakeTypeProfileReturns) + + case cdp.EventProfilerConsoleProfileFinished: + v = new(profiler.EventConsoleProfileFinished) + + case cdp.EventProfilerConsoleProfileStarted: + v = new(profiler.EventConsoleProfileStarted) + + case cdp.CommandRuntimeAwaitPromise: + v = new(runtime.AwaitPromiseReturns) + + case cdp.CommandRuntimeCallFunctionOn: + v = new(runtime.CallFunctionOnReturns) + + case cdp.CommandRuntimeCompileScript: + v = new(runtime.CompileScriptReturns) + + case cdp.CommandRuntimeDisable: + return emptyVal, nil + + case cdp.CommandRuntimeDiscardConsoleEntries: + return emptyVal, nil + + case cdp.CommandRuntimeEnable: + return emptyVal, nil + + case cdp.CommandRuntimeEvaluate: + v = new(runtime.EvaluateReturns) + + case cdp.CommandRuntimeGetProperties: + v = new(runtime.GetPropertiesReturns) + + case cdp.CommandRuntimeGlobalLexicalScopeNames: + v = new(runtime.GlobalLexicalScopeNamesReturns) + + case cdp.CommandRuntimeQueryObjects: + v = new(runtime.QueryObjectsReturns) + + case cdp.CommandRuntimeReleaseObject: + return emptyVal, nil + + case cdp.CommandRuntimeReleaseObjectGroup: + return emptyVal, nil + + case cdp.CommandRuntimeRunIfWaitingForDebugger: + return emptyVal, nil + + case cdp.CommandRuntimeRunScript: + v = new(runtime.RunScriptReturns) + + case cdp.CommandRuntimeSetCustomObjectFormatterEnabled: + return emptyVal, nil + + case cdp.EventRuntimeConsoleAPICalled: + v = new(runtime.EventConsoleAPICalled) + + case cdp.EventRuntimeExceptionRevoked: + v = new(runtime.EventExceptionRevoked) + + case cdp.EventRuntimeExceptionThrown: + v = new(runtime.EventExceptionThrown) + + case cdp.EventRuntimeExecutionContextCreated: + v = new(runtime.EventExecutionContextCreated) + + case cdp.EventRuntimeExecutionContextDestroyed: + v = new(runtime.EventExecutionContextDestroyed) + + case cdp.EventRuntimeExecutionContextsCleared: + v = new(runtime.EventExecutionContextsCleared) + + case cdp.EventRuntimeInspectRequested: + v = new(runtime.EventInspectRequested) } var buf easyjson.RawMessage diff --git a/cdp/css/css.go b/cdp/css/css.go index 9062204..e127af2 100644 --- a/cdp/css/css.go +++ b/cdp/css/css.go @@ -21,6 +21,138 @@ import ( cdp "github.com/knq/chromedp/cdp" ) +// AddRuleParams inserts a new rule with the given ruleText in a stylesheet +// with given styleSheetId, at the position specified by location. +type AddRuleParams struct { + StyleSheetID StyleSheetID `json:"styleSheetId"` // The css style sheet identifier where a new rule should be inserted. + RuleText string `json:"ruleText"` // The text of a new rule. + Location *SourceRange `json:"location"` // Text position of a new rule in the target style sheet. +} + +// AddRule inserts a new rule with the given ruleText in a stylesheet with +// given styleSheetId, at the position specified by location. +// +// parameters: +// styleSheetID - The css style sheet identifier where a new rule should be inserted. +// ruleText - The text of a new rule. +// location - Text position of a new rule in the target style sheet. +func AddRule(styleSheetID StyleSheetID, ruleText string, location *SourceRange) *AddRuleParams { + return &AddRuleParams{ + StyleSheetID: styleSheetID, + RuleText: ruleText, + Location: location, + } +} + +// AddRuleReturns return values. +type AddRuleReturns struct { + Rule *Rule `json:"rule,omitempty"` // The newly created rule. +} + +// Do executes CSS.addRule against the provided context and +// target handler. +// +// returns: +// rule - The newly created rule. +func (p *AddRuleParams) Do(ctxt context.Context, h cdp.Handler) (rule *Rule, err error) { + // execute + var res AddRuleReturns + err = h.Execute(ctxt, cdp.CommandCSSAddRule, p, &res) + if err != nil { + return nil, err + } + + return res.Rule, nil +} + +// CollectClassNamesParams returns all class names from specified stylesheet. +type CollectClassNamesParams struct { + StyleSheetID StyleSheetID `json:"styleSheetId"` +} + +// CollectClassNames returns all class names from specified stylesheet. +// +// parameters: +// styleSheetID +func CollectClassNames(styleSheetID StyleSheetID) *CollectClassNamesParams { + return &CollectClassNamesParams{ + StyleSheetID: styleSheetID, + } +} + +// CollectClassNamesReturns return values. +type CollectClassNamesReturns struct { + ClassNames []string `json:"classNames,omitempty"` // Class name list. +} + +// Do executes CSS.collectClassNames against the provided context and +// target handler. +// +// returns: +// classNames - Class name list. +func (p *CollectClassNamesParams) Do(ctxt context.Context, h cdp.Handler) (classNames []string, err error) { + // execute + var res CollectClassNamesReturns + err = h.Execute(ctxt, cdp.CommandCSSCollectClassNames, p, &res) + if err != nil { + return nil, err + } + + return res.ClassNames, nil +} + +// CreateStyleSheetParams creates a new special "via-inspector" stylesheet in +// the frame with given frameId. +type CreateStyleSheetParams struct { + FrameID cdp.FrameID `json:"frameId"` // Identifier of the frame where "via-inspector" stylesheet should be created. +} + +// CreateStyleSheet creates a new special "via-inspector" stylesheet in the +// frame with given frameId. +// +// parameters: +// frameID - Identifier of the frame where "via-inspector" stylesheet should be created. +func CreateStyleSheet(frameID cdp.FrameID) *CreateStyleSheetParams { + return &CreateStyleSheetParams{ + FrameID: frameID, + } +} + +// CreateStyleSheetReturns return values. +type CreateStyleSheetReturns struct { + StyleSheetID StyleSheetID `json:"styleSheetId,omitempty"` // Identifier of the created "via-inspector" stylesheet. +} + +// Do executes CSS.createStyleSheet against the provided context and +// target handler. +// +// returns: +// styleSheetID - Identifier of the created "via-inspector" stylesheet. +func (p *CreateStyleSheetParams) Do(ctxt context.Context, h cdp.Handler) (styleSheetID StyleSheetID, err error) { + // execute + var res CreateStyleSheetReturns + err = h.Execute(ctxt, cdp.CommandCSSCreateStyleSheet, p, &res) + if err != nil { + return "", err + } + + return res.StyleSheetID, nil +} + +// DisableParams disables the CSS agent for the given page. +type DisableParams struct{} + +// Disable disables the CSS agent for the given page. +func Disable() *DisableParams { + return &DisableParams{} +} + +// Do executes CSS.disable against the provided context and +// target handler. +func (p *DisableParams) Do(ctxt context.Context, h cdp.Handler) (err error) { + return h.Execute(ctxt, cdp.CommandCSSDisable, nil, nil) +} + // EnableParams enables the CSS agent for the given page. Clients should not // assume that the CSS agent has been enabled until the result of this command // is received. @@ -39,18 +171,152 @@ func (p *EnableParams) Do(ctxt context.Context, h cdp.Handler) (err error) { return h.Execute(ctxt, cdp.CommandCSSEnable, nil, nil) } -// DisableParams disables the CSS agent for the given page. -type DisableParams struct{} - -// Disable disables the CSS agent for the given page. -func Disable() *DisableParams { - return &DisableParams{} +// ForcePseudoStateParams ensures that the given node will have specified +// pseudo-classes whenever its style is computed by the browser. +type ForcePseudoStateParams struct { + NodeID cdp.NodeID `json:"nodeId"` // The element id for which to force the pseudo state. + ForcedPseudoClasses []string `json:"forcedPseudoClasses"` // Element pseudo classes to force when computing the element's style. } -// Do executes CSS.disable against the provided context and +// ForcePseudoState ensures that the given node will have specified +// pseudo-classes whenever its style is computed by the browser. +// +// parameters: +// nodeID - The element id for which to force the pseudo state. +// forcedPseudoClasses - Element pseudo classes to force when computing the element's style. +func ForcePseudoState(nodeID cdp.NodeID, forcedPseudoClasses []string) *ForcePseudoStateParams { + return &ForcePseudoStateParams{ + NodeID: nodeID, + ForcedPseudoClasses: forcedPseudoClasses, + } +} + +// Do executes CSS.forcePseudoState against the provided context and // target handler. -func (p *DisableParams) Do(ctxt context.Context, h cdp.Handler) (err error) { - return h.Execute(ctxt, cdp.CommandCSSDisable, nil, nil) +func (p *ForcePseudoStateParams) Do(ctxt context.Context, h cdp.Handler) (err error) { + return h.Execute(ctxt, cdp.CommandCSSForcePseudoState, p, nil) +} + +// GetBackgroundColorsParams [no description]. +type GetBackgroundColorsParams struct { + NodeID cdp.NodeID `json:"nodeId"` // Id of the node to get background colors for. +} + +// GetBackgroundColors [no description]. +// +// parameters: +// nodeID - Id of the node to get background colors for. +func GetBackgroundColors(nodeID cdp.NodeID) *GetBackgroundColorsParams { + return &GetBackgroundColorsParams{ + NodeID: nodeID, + } +} + +// GetBackgroundColorsReturns return values. +type GetBackgroundColorsReturns struct { + BackgroundColors []string `json:"backgroundColors,omitempty"` // The range of background colors behind this element, if it contains any visible text. If no visible text is present, this will be undefined. In the case of a flat background color, this will consist of simply that color. In the case of a gradient, this will consist of each of the color stops. For anything more complicated, this will be an empty array. Images will be ignored (as if the image had failed to load). + ComputedFontSize string `json:"computedFontSize,omitempty"` // The computed font size for this node, as a CSS computed value string (e.g. '12px'). + ComputedFontWeight string `json:"computedFontWeight,omitempty"` // The computed font weight for this node, as a CSS computed value string (e.g. 'normal' or '100'). + ComputedBodyFontSize string `json:"computedBodyFontSize,omitempty"` // The computed font size for the document body, as a computed CSS value string (e.g. '16px'). +} + +// Do executes CSS.getBackgroundColors against the provided context and +// target handler. +// +// returns: +// backgroundColors - The range of background colors behind this element, if it contains any visible text. If no visible text is present, this will be undefined. In the case of a flat background color, this will consist of simply that color. In the case of a gradient, this will consist of each of the color stops. For anything more complicated, this will be an empty array. Images will be ignored (as if the image had failed to load). +// computedFontSize - The computed font size for this node, as a CSS computed value string (e.g. '12px'). +// computedFontWeight - The computed font weight for this node, as a CSS computed value string (e.g. 'normal' or '100'). +// computedBodyFontSize - The computed font size for the document body, as a computed CSS value string (e.g. '16px'). +func (p *GetBackgroundColorsParams) Do(ctxt context.Context, h cdp.Handler) (backgroundColors []string, computedFontSize string, computedFontWeight string, computedBodyFontSize string, err error) { + // execute + var res GetBackgroundColorsReturns + err = h.Execute(ctxt, cdp.CommandCSSGetBackgroundColors, p, &res) + if err != nil { + return nil, "", "", "", err + } + + return res.BackgroundColors, res.ComputedFontSize, res.ComputedFontWeight, res.ComputedBodyFontSize, nil +} + +// GetComputedStyleForNodeParams returns the computed style for a DOM node +// identified by nodeId. +type GetComputedStyleForNodeParams struct { + NodeID cdp.NodeID `json:"nodeId"` +} + +// GetComputedStyleForNode returns the computed style for a DOM node +// identified by nodeId. +// +// parameters: +// nodeID +func GetComputedStyleForNode(nodeID cdp.NodeID) *GetComputedStyleForNodeParams { + return &GetComputedStyleForNodeParams{ + NodeID: nodeID, + } +} + +// GetComputedStyleForNodeReturns return values. +type GetComputedStyleForNodeReturns struct { + ComputedStyle []*ComputedProperty `json:"computedStyle,omitempty"` // Computed style for the specified DOM node. +} + +// Do executes CSS.getComputedStyleForNode against the provided context and +// target handler. +// +// returns: +// computedStyle - Computed style for the specified DOM node. +func (p *GetComputedStyleForNodeParams) Do(ctxt context.Context, h cdp.Handler) (computedStyle []*ComputedProperty, err error) { + // execute + var res GetComputedStyleForNodeReturns + err = h.Execute(ctxt, cdp.CommandCSSGetComputedStyleForNode, p, &res) + if err != nil { + return nil, err + } + + return res.ComputedStyle, nil +} + +// GetInlineStylesForNodeParams returns the styles defined inline (explicitly +// in the "style" attribute and implicitly, using DOM attributes) for a DOM node +// identified by nodeId. +type GetInlineStylesForNodeParams struct { + NodeID cdp.NodeID `json:"nodeId"` +} + +// GetInlineStylesForNode returns the styles defined inline (explicitly in +// the "style" attribute and implicitly, using DOM attributes) for a DOM node +// identified by nodeId. +// +// parameters: +// nodeID +func GetInlineStylesForNode(nodeID cdp.NodeID) *GetInlineStylesForNodeParams { + return &GetInlineStylesForNodeParams{ + NodeID: nodeID, + } +} + +// GetInlineStylesForNodeReturns return values. +type GetInlineStylesForNodeReturns struct { + InlineStyle *Style `json:"inlineStyle,omitempty"` // Inline style for the specified DOM node. + AttributesStyle *Style `json:"attributesStyle,omitempty"` // Attribute-defined element style (e.g. resulting from "width=20 height=100%"). +} + +// Do executes CSS.getInlineStylesForNode against the provided context and +// target handler. +// +// returns: +// inlineStyle - Inline style for the specified DOM node. +// attributesStyle - Attribute-defined element style (e.g. resulting from "width=20 height=100%"). +func (p *GetInlineStylesForNodeParams) Do(ctxt context.Context, h cdp.Handler) (inlineStyle *Style, attributesStyle *Style, err error) { + // execute + var res GetInlineStylesForNodeReturns + err = h.Execute(ctxt, cdp.CommandCSSGetInlineStylesForNode, p, &res) + if err != nil { + return nil, nil, err + } + + return res.InlineStyle, res.AttributesStyle, nil } // GetMatchedStylesForNodeParams returns requested styles for a DOM node @@ -101,84 +367,34 @@ func (p *GetMatchedStylesForNodeParams) Do(ctxt context.Context, h cdp.Handler) return res.InlineStyle, res.AttributesStyle, res.MatchedCSSRules, res.PseudoElements, res.Inherited, res.CSSKeyframesRules, nil } -// GetInlineStylesForNodeParams returns the styles defined inline (explicitly -// in the "style" attribute and implicitly, using DOM attributes) for a DOM node -// identified by nodeId. -type GetInlineStylesForNodeParams struct { - NodeID cdp.NodeID `json:"nodeId"` +// GetMediaQueriesParams returns all media queries parsed by the rendering +// engine. +type GetMediaQueriesParams struct{} + +// GetMediaQueries returns all media queries parsed by the rendering engine. +func GetMediaQueries() *GetMediaQueriesParams { + return &GetMediaQueriesParams{} } -// GetInlineStylesForNode returns the styles defined inline (explicitly in -// the "style" attribute and implicitly, using DOM attributes) for a DOM node -// identified by nodeId. -// -// parameters: -// nodeID -func GetInlineStylesForNode(nodeID cdp.NodeID) *GetInlineStylesForNodeParams { - return &GetInlineStylesForNodeParams{ - NodeID: nodeID, - } +// GetMediaQueriesReturns return values. +type GetMediaQueriesReturns struct { + Medias []*Media `json:"medias,omitempty"` } -// GetInlineStylesForNodeReturns return values. -type GetInlineStylesForNodeReturns struct { - InlineStyle *Style `json:"inlineStyle,omitempty"` // Inline style for the specified DOM node. - AttributesStyle *Style `json:"attributesStyle,omitempty"` // Attribute-defined element style (e.g. resulting from "width=20 height=100%"). -} - -// Do executes CSS.getInlineStylesForNode against the provided context and +// Do executes CSS.getMediaQueries against the provided context and // target handler. // // returns: -// inlineStyle - Inline style for the specified DOM node. -// attributesStyle - Attribute-defined element style (e.g. resulting from "width=20 height=100%"). -func (p *GetInlineStylesForNodeParams) Do(ctxt context.Context, h cdp.Handler) (inlineStyle *Style, attributesStyle *Style, err error) { +// medias +func (p *GetMediaQueriesParams) Do(ctxt context.Context, h cdp.Handler) (medias []*Media, err error) { // execute - var res GetInlineStylesForNodeReturns - err = h.Execute(ctxt, cdp.CommandCSSGetInlineStylesForNode, p, &res) - if err != nil { - return nil, nil, err - } - - return res.InlineStyle, res.AttributesStyle, nil -} - -// GetComputedStyleForNodeParams returns the computed style for a DOM node -// identified by nodeId. -type GetComputedStyleForNodeParams struct { - NodeID cdp.NodeID `json:"nodeId"` -} - -// GetComputedStyleForNode returns the computed style for a DOM node -// identified by nodeId. -// -// parameters: -// nodeID -func GetComputedStyleForNode(nodeID cdp.NodeID) *GetComputedStyleForNodeParams { - return &GetComputedStyleForNodeParams{ - NodeID: nodeID, - } -} - -// GetComputedStyleForNodeReturns return values. -type GetComputedStyleForNodeReturns struct { - ComputedStyle []*ComputedProperty `json:"computedStyle,omitempty"` // Computed style for the specified DOM node. -} - -// Do executes CSS.getComputedStyleForNode against the provided context and -// target handler. -// -// returns: -// computedStyle - Computed style for the specified DOM node. -func (p *GetComputedStyleForNodeParams) Do(ctxt context.Context, h cdp.Handler) (computedStyle []*ComputedProperty, err error) { - // execute - var res GetComputedStyleForNodeReturns - err = h.Execute(ctxt, cdp.CommandCSSGetComputedStyleForNode, p, &res) + var res GetMediaQueriesReturns + err = h.Execute(ctxt, cdp.CommandCSSGetMediaQueries, nil, &res) if err != nil { return nil, err } - return res.ComputedStyle, nil + return res.Medias, nil } // GetPlatformFontsForNodeParams requests information about platform fonts @@ -257,121 +473,33 @@ func (p *GetStyleSheetTextParams) Do(ctxt context.Context, h cdp.Handler) (text return res.Text, nil } -// CollectClassNamesParams returns all class names from specified stylesheet. -type CollectClassNamesParams struct { - StyleSheetID StyleSheetID `json:"styleSheetId"` +// SetEffectivePropertyValueForNodeParams find a rule with the given active +// property for the given node and set the new value for this property. +type SetEffectivePropertyValueForNodeParams struct { + NodeID cdp.NodeID `json:"nodeId"` // The element id for which to set property. + PropertyName string `json:"propertyName"` + Value string `json:"value"` } -// CollectClassNames returns all class names from specified stylesheet. +// SetEffectivePropertyValueForNode find a rule with the given active +// property for the given node and set the new value for this property. // // parameters: -// styleSheetID -func CollectClassNames(styleSheetID StyleSheetID) *CollectClassNamesParams { - return &CollectClassNamesParams{ - StyleSheetID: styleSheetID, +// nodeID - The element id for which to set property. +// propertyName +// value +func SetEffectivePropertyValueForNode(nodeID cdp.NodeID, propertyName string, value string) *SetEffectivePropertyValueForNodeParams { + return &SetEffectivePropertyValueForNodeParams{ + NodeID: nodeID, + PropertyName: propertyName, + Value: value, } } -// CollectClassNamesReturns return values. -type CollectClassNamesReturns struct { - ClassNames []string `json:"classNames,omitempty"` // Class name list. -} - -// Do executes CSS.collectClassNames against the provided context and +// Do executes CSS.setEffectivePropertyValueForNode against the provided context and // target handler. -// -// returns: -// classNames - Class name list. -func (p *CollectClassNamesParams) Do(ctxt context.Context, h cdp.Handler) (classNames []string, err error) { - // execute - var res CollectClassNamesReturns - err = h.Execute(ctxt, cdp.CommandCSSCollectClassNames, p, &res) - if err != nil { - return nil, err - } - - return res.ClassNames, nil -} - -// SetStyleSheetTextParams sets the new stylesheet text. -type SetStyleSheetTextParams struct { - StyleSheetID StyleSheetID `json:"styleSheetId"` - Text string `json:"text"` -} - -// SetStyleSheetText sets the new stylesheet text. -// -// parameters: -// styleSheetID -// text -func SetStyleSheetText(styleSheetID StyleSheetID, text string) *SetStyleSheetTextParams { - return &SetStyleSheetTextParams{ - StyleSheetID: styleSheetID, - Text: text, - } -} - -// SetStyleSheetTextReturns return values. -type SetStyleSheetTextReturns struct { - SourceMapURL string `json:"sourceMapURL,omitempty"` // URL of source map associated with script (if any). -} - -// Do executes CSS.setStyleSheetText against the provided context and -// target handler. -// -// returns: -// sourceMapURL - URL of source map associated with script (if any). -func (p *SetStyleSheetTextParams) Do(ctxt context.Context, h cdp.Handler) (sourceMapURL string, err error) { - // execute - var res SetStyleSheetTextReturns - err = h.Execute(ctxt, cdp.CommandCSSSetStyleSheetText, p, &res) - if err != nil { - return "", err - } - - return res.SourceMapURL, nil -} - -// SetRuleSelectorParams modifies the rule selector. -type SetRuleSelectorParams struct { - StyleSheetID StyleSheetID `json:"styleSheetId"` - Range *SourceRange `json:"range"` - Selector string `json:"selector"` -} - -// SetRuleSelector modifies the rule selector. -// -// parameters: -// styleSheetID -// range -// selector -func SetRuleSelector(styleSheetID StyleSheetID, rangeVal *SourceRange, selector string) *SetRuleSelectorParams { - return &SetRuleSelectorParams{ - StyleSheetID: styleSheetID, - Range: rangeVal, - Selector: selector, - } -} - -// SetRuleSelectorReturns return values. -type SetRuleSelectorReturns struct { - SelectorList *SelectorList `json:"selectorList,omitempty"` // The resulting selector list after modification. -} - -// Do executes CSS.setRuleSelector against the provided context and -// target handler. -// -// returns: -// selectorList - The resulting selector list after modification. -func (p *SetRuleSelectorParams) Do(ctxt context.Context, h cdp.Handler) (selectorList *SelectorList, err error) { - // execute - var res SetRuleSelectorReturns - err = h.Execute(ctxt, cdp.CommandCSSSetRuleSelector, p, &res) - if err != nil { - return nil, err - } - - return res.SelectorList, nil +func (p *SetEffectivePropertyValueForNodeParams) Do(ctxt context.Context, h cdp.Handler) (err error) { + return h.Execute(ctxt, cdp.CommandCSSSetEffectivePropertyValueForNode, p, nil) } // SetKeyframeKeyParams modifies the keyframe rule key text. @@ -416,44 +544,6 @@ func (p *SetKeyframeKeyParams) Do(ctxt context.Context, h cdp.Handler) (keyText return res.KeyText, nil } -// SetStyleTextsParams applies specified style edits one after another in the -// given order. -type SetStyleTextsParams struct { - Edits []*StyleDeclarationEdit `json:"edits"` -} - -// SetStyleTexts applies specified style edits one after another in the given -// order. -// -// parameters: -// edits -func SetStyleTexts(edits []*StyleDeclarationEdit) *SetStyleTextsParams { - return &SetStyleTextsParams{ - Edits: edits, - } -} - -// SetStyleTextsReturns return values. -type SetStyleTextsReturns struct { - Styles []*Style `json:"styles,omitempty"` // The resulting styles after modification. -} - -// Do executes CSS.setStyleTexts against the provided context and -// target handler. -// -// returns: -// styles - The resulting styles after modification. -func (p *SetStyleTextsParams) Do(ctxt context.Context, h cdp.Handler) (styles []*Style, err error) { - // execute - var res SetStyleTextsReturns - err = h.Execute(ctxt, cdp.CommandCSSSetStyleTexts, p, &res) - if err != nil { - return nil, err - } - - return res.Styles, nil -} - // SetMediaTextParams modifies the rule selector. type SetMediaTextParams struct { StyleSheetID StyleSheetID `json:"styleSheetId"` @@ -496,213 +586,123 @@ func (p *SetMediaTextParams) Do(ctxt context.Context, h cdp.Handler) (media *Med return res.Media, nil } -// CreateStyleSheetParams creates a new special "via-inspector" stylesheet in -// the frame with given frameId. -type CreateStyleSheetParams struct { - FrameID cdp.FrameID `json:"frameId"` // Identifier of the frame where "via-inspector" stylesheet should be created. +// SetRuleSelectorParams modifies the rule selector. +type SetRuleSelectorParams struct { + StyleSheetID StyleSheetID `json:"styleSheetId"` + Range *SourceRange `json:"range"` + Selector string `json:"selector"` } -// CreateStyleSheet creates a new special "via-inspector" stylesheet in the -// frame with given frameId. +// SetRuleSelector modifies the rule selector. // // parameters: -// frameID - Identifier of the frame where "via-inspector" stylesheet should be created. -func CreateStyleSheet(frameID cdp.FrameID) *CreateStyleSheetParams { - return &CreateStyleSheetParams{ - FrameID: frameID, +// styleSheetID +// range +// selector +func SetRuleSelector(styleSheetID StyleSheetID, rangeVal *SourceRange, selector string) *SetRuleSelectorParams { + return &SetRuleSelectorParams{ + StyleSheetID: styleSheetID, + Range: rangeVal, + Selector: selector, } } -// CreateStyleSheetReturns return values. -type CreateStyleSheetReturns struct { - StyleSheetID StyleSheetID `json:"styleSheetId,omitempty"` // Identifier of the created "via-inspector" stylesheet. +// SetRuleSelectorReturns return values. +type SetRuleSelectorReturns struct { + SelectorList *SelectorList `json:"selectorList,omitempty"` // The resulting selector list after modification. } -// Do executes CSS.createStyleSheet against the provided context and +// Do executes CSS.setRuleSelector against the provided context and // target handler. // // returns: -// styleSheetID - Identifier of the created "via-inspector" stylesheet. -func (p *CreateStyleSheetParams) Do(ctxt context.Context, h cdp.Handler) (styleSheetID StyleSheetID, err error) { +// selectorList - The resulting selector list after modification. +func (p *SetRuleSelectorParams) Do(ctxt context.Context, h cdp.Handler) (selectorList *SelectorList, err error) { // execute - var res CreateStyleSheetReturns - err = h.Execute(ctxt, cdp.CommandCSSCreateStyleSheet, p, &res) + var res SetRuleSelectorReturns + err = h.Execute(ctxt, cdp.CommandCSSSetRuleSelector, p, &res) + if err != nil { + return nil, err + } + + return res.SelectorList, nil +} + +// SetStyleSheetTextParams sets the new stylesheet text. +type SetStyleSheetTextParams struct { + StyleSheetID StyleSheetID `json:"styleSheetId"` + Text string `json:"text"` +} + +// SetStyleSheetText sets the new stylesheet text. +// +// parameters: +// styleSheetID +// text +func SetStyleSheetText(styleSheetID StyleSheetID, text string) *SetStyleSheetTextParams { + return &SetStyleSheetTextParams{ + StyleSheetID: styleSheetID, + Text: text, + } +} + +// SetStyleSheetTextReturns return values. +type SetStyleSheetTextReturns struct { + SourceMapURL string `json:"sourceMapURL,omitempty"` // URL of source map associated with script (if any). +} + +// Do executes CSS.setStyleSheetText against the provided context and +// target handler. +// +// returns: +// sourceMapURL - URL of source map associated with script (if any). +func (p *SetStyleSheetTextParams) Do(ctxt context.Context, h cdp.Handler) (sourceMapURL string, err error) { + // execute + var res SetStyleSheetTextReturns + err = h.Execute(ctxt, cdp.CommandCSSSetStyleSheetText, p, &res) if err != nil { return "", err } - return res.StyleSheetID, nil + return res.SourceMapURL, nil } -// AddRuleParams inserts a new rule with the given ruleText in a stylesheet -// with given styleSheetId, at the position specified by location. -type AddRuleParams struct { - StyleSheetID StyleSheetID `json:"styleSheetId"` // The css style sheet identifier where a new rule should be inserted. - RuleText string `json:"ruleText"` // The text of a new rule. - Location *SourceRange `json:"location"` // Text position of a new rule in the target style sheet. +// SetStyleTextsParams applies specified style edits one after another in the +// given order. +type SetStyleTextsParams struct { + Edits []*StyleDeclarationEdit `json:"edits"` } -// AddRule inserts a new rule with the given ruleText in a stylesheet with -// given styleSheetId, at the position specified by location. +// SetStyleTexts applies specified style edits one after another in the given +// order. // // parameters: -// styleSheetID - The css style sheet identifier where a new rule should be inserted. -// ruleText - The text of a new rule. -// location - Text position of a new rule in the target style sheet. -func AddRule(styleSheetID StyleSheetID, ruleText string, location *SourceRange) *AddRuleParams { - return &AddRuleParams{ - StyleSheetID: styleSheetID, - RuleText: ruleText, - Location: location, +// edits +func SetStyleTexts(edits []*StyleDeclarationEdit) *SetStyleTextsParams { + return &SetStyleTextsParams{ + Edits: edits, } } -// AddRuleReturns return values. -type AddRuleReturns struct { - Rule *Rule `json:"rule,omitempty"` // The newly created rule. +// SetStyleTextsReturns return values. +type SetStyleTextsReturns struct { + Styles []*Style `json:"styles,omitempty"` // The resulting styles after modification. } -// Do executes CSS.addRule against the provided context and +// Do executes CSS.setStyleTexts against the provided context and // target handler. // // returns: -// rule - The newly created rule. -func (p *AddRuleParams) Do(ctxt context.Context, h cdp.Handler) (rule *Rule, err error) { +// styles - The resulting styles after modification. +func (p *SetStyleTextsParams) Do(ctxt context.Context, h cdp.Handler) (styles []*Style, err error) { // execute - var res AddRuleReturns - err = h.Execute(ctxt, cdp.CommandCSSAddRule, p, &res) + var res SetStyleTextsReturns + err = h.Execute(ctxt, cdp.CommandCSSSetStyleTexts, p, &res) if err != nil { return nil, err } - return res.Rule, nil -} - -// ForcePseudoStateParams ensures that the given node will have specified -// pseudo-classes whenever its style is computed by the browser. -type ForcePseudoStateParams struct { - NodeID cdp.NodeID `json:"nodeId"` // The element id for which to force the pseudo state. - ForcedPseudoClasses []PseudoClass `json:"forcedPseudoClasses"` // Element pseudo classes to force when computing the element's style. -} - -// ForcePseudoState ensures that the given node will have specified -// pseudo-classes whenever its style is computed by the browser. -// -// parameters: -// nodeID - The element id for which to force the pseudo state. -// forcedPseudoClasses - Element pseudo classes to force when computing the element's style. -func ForcePseudoState(nodeID cdp.NodeID, forcedPseudoClasses []PseudoClass) *ForcePseudoStateParams { - return &ForcePseudoStateParams{ - NodeID: nodeID, - ForcedPseudoClasses: forcedPseudoClasses, - } -} - -// Do executes CSS.forcePseudoState against the provided context and -// target handler. -func (p *ForcePseudoStateParams) Do(ctxt context.Context, h cdp.Handler) (err error) { - return h.Execute(ctxt, cdp.CommandCSSForcePseudoState, p, nil) -} - -// GetMediaQueriesParams returns all media queries parsed by the rendering -// engine. -type GetMediaQueriesParams struct{} - -// GetMediaQueries returns all media queries parsed by the rendering engine. -func GetMediaQueries() *GetMediaQueriesParams { - return &GetMediaQueriesParams{} -} - -// GetMediaQueriesReturns return values. -type GetMediaQueriesReturns struct { - Medias []*Media `json:"medias,omitempty"` -} - -// Do executes CSS.getMediaQueries against the provided context and -// target handler. -// -// returns: -// medias -func (p *GetMediaQueriesParams) Do(ctxt context.Context, h cdp.Handler) (medias []*Media, err error) { - // execute - var res GetMediaQueriesReturns - err = h.Execute(ctxt, cdp.CommandCSSGetMediaQueries, nil, &res) - if err != nil { - return nil, err - } - - return res.Medias, nil -} - -// SetEffectivePropertyValueForNodeParams find a rule with the given active -// property for the given node and set the new value for this property. -type SetEffectivePropertyValueForNodeParams struct { - NodeID cdp.NodeID `json:"nodeId"` // The element id for which to set property. - PropertyName string `json:"propertyName"` - Value string `json:"value"` -} - -// SetEffectivePropertyValueForNode find a rule with the given active -// property for the given node and set the new value for this property. -// -// parameters: -// nodeID - The element id for which to set property. -// propertyName -// value -func SetEffectivePropertyValueForNode(nodeID cdp.NodeID, propertyName string, value string) *SetEffectivePropertyValueForNodeParams { - return &SetEffectivePropertyValueForNodeParams{ - NodeID: nodeID, - PropertyName: propertyName, - Value: value, - } -} - -// Do executes CSS.setEffectivePropertyValueForNode against the provided context and -// target handler. -func (p *SetEffectivePropertyValueForNodeParams) Do(ctxt context.Context, h cdp.Handler) (err error) { - return h.Execute(ctxt, cdp.CommandCSSSetEffectivePropertyValueForNode, p, nil) -} - -// GetBackgroundColorsParams [no description]. -type GetBackgroundColorsParams struct { - NodeID cdp.NodeID `json:"nodeId"` // Id of the node to get background colors for. -} - -// GetBackgroundColors [no description]. -// -// parameters: -// nodeID - Id of the node to get background colors for. -func GetBackgroundColors(nodeID cdp.NodeID) *GetBackgroundColorsParams { - return &GetBackgroundColorsParams{ - NodeID: nodeID, - } -} - -// GetBackgroundColorsReturns return values. -type GetBackgroundColorsReturns struct { - BackgroundColors []string `json:"backgroundColors,omitempty"` // The range of background colors behind this element, if it contains any visible text. If no visible text is present, this will be undefined. In the case of a flat background color, this will consist of simply that color. In the case of a gradient, this will consist of each of the color stops. For anything more complicated, this will be an empty array. Images will be ignored (as if the image had failed to load). - ComputedFontSize string `json:"computedFontSize,omitempty"` // The computed font size for this node, as a CSS computed value string (e.g. '12px'). - ComputedFontWeight string `json:"computedFontWeight,omitempty"` // The computed font weight for this node, as a CSS computed value string (e.g. 'normal' or '100'). - ComputedBodyFontSize string `json:"computedBodyFontSize,omitempty"` // The computed font size for the document body, as a computed CSS value string (e.g. '16px'). -} - -// Do executes CSS.getBackgroundColors against the provided context and -// target handler. -// -// returns: -// backgroundColors - The range of background colors behind this element, if it contains any visible text. If no visible text is present, this will be undefined. In the case of a flat background color, this will consist of simply that color. In the case of a gradient, this will consist of each of the color stops. For anything more complicated, this will be an empty array. Images will be ignored (as if the image had failed to load). -// computedFontSize - The computed font size for this node, as a CSS computed value string (e.g. '12px'). -// computedFontWeight - The computed font weight for this node, as a CSS computed value string (e.g. 'normal' or '100'). -// computedBodyFontSize - The computed font size for the document body, as a computed CSS value string (e.g. '16px'). -func (p *GetBackgroundColorsParams) Do(ctxt context.Context, h cdp.Handler) (backgroundColors []string, computedFontSize string, computedFontWeight string, computedBodyFontSize string, err error) { - // execute - var res GetBackgroundColorsReturns - err = h.Execute(ctxt, cdp.CommandCSSGetBackgroundColors, p, &res) - if err != nil { - return nil, "", "", "", err - } - - return res.BackgroundColors, res.ComputedFontSize, res.ComputedFontWeight, res.ComputedBodyFontSize, nil + return res.Styles, nil } // StartRuleUsageTrackingParams enables the selector recording. @@ -719,37 +719,6 @@ func (p *StartRuleUsageTrackingParams) Do(ctxt context.Context, h cdp.Handler) ( return h.Execute(ctxt, cdp.CommandCSSStartRuleUsageTracking, nil, nil) } -// TakeCoverageDeltaParams obtain list of rules that became used since last -// call to this method (or since start of coverage instrumentation). -type TakeCoverageDeltaParams struct{} - -// TakeCoverageDelta obtain list of rules that became used since last call to -// this method (or since start of coverage instrumentation). -func TakeCoverageDelta() *TakeCoverageDeltaParams { - return &TakeCoverageDeltaParams{} -} - -// TakeCoverageDeltaReturns return values. -type TakeCoverageDeltaReturns struct { - Coverage []*RuleUsage `json:"coverage,omitempty"` -} - -// Do executes CSS.takeCoverageDelta against the provided context and -// target handler. -// -// returns: -// coverage -func (p *TakeCoverageDeltaParams) Do(ctxt context.Context, h cdp.Handler) (coverage []*RuleUsage, err error) { - // execute - var res TakeCoverageDeltaReturns - err = h.Execute(ctxt, cdp.CommandCSSTakeCoverageDelta, nil, &res) - if err != nil { - return nil, err - } - - return res.Coverage, nil -} - // StopRuleUsageTrackingParams the list of rules with an indication of // whether these were used. type StopRuleUsageTrackingParams struct{} @@ -780,3 +749,34 @@ func (p *StopRuleUsageTrackingParams) Do(ctxt context.Context, h cdp.Handler) (r return res.RuleUsage, nil } + +// TakeCoverageDeltaParams obtain list of rules that became used since last +// call to this method (or since start of coverage instrumentation). +type TakeCoverageDeltaParams struct{} + +// TakeCoverageDelta obtain list of rules that became used since last call to +// this method (or since start of coverage instrumentation). +func TakeCoverageDelta() *TakeCoverageDeltaParams { + return &TakeCoverageDeltaParams{} +} + +// TakeCoverageDeltaReturns return values. +type TakeCoverageDeltaReturns struct { + Coverage []*RuleUsage `json:"coverage,omitempty"` +} + +// Do executes CSS.takeCoverageDelta against the provided context and +// target handler. +// +// returns: +// coverage +func (p *TakeCoverageDeltaParams) Do(ctxt context.Context, h cdp.Handler) (coverage []*RuleUsage, err error) { + // execute + var res TakeCoverageDeltaReturns + err = h.Execute(ctxt, cdp.CommandCSSTakeCoverageDelta, nil, &res) + if err != nil { + return nil, err + } + + return res.Coverage, nil +} diff --git a/cdp/css/easyjson.go b/cdp/css/easyjson.go index 165fcd4..f71ff47 100644 --- a/cdp/css/easyjson.go +++ b/cdp/css/easyjson.go @@ -5531,16 +5531,16 @@ func easyjsonC5a4559bDecodeGithubComKnqChromedpCdpCss49(in *jlexer.Lexer, out *F in.Delim('[') if out.ForcedPseudoClasses == nil { if !in.IsDelim(']') { - out.ForcedPseudoClasses = make([]PseudoClass, 0, 4) + out.ForcedPseudoClasses = make([]string, 0, 4) } else { - out.ForcedPseudoClasses = []PseudoClass{} + out.ForcedPseudoClasses = []string{} } } else { out.ForcedPseudoClasses = (out.ForcedPseudoClasses)[:0] } for !in.IsDelim(']') { - var v67 PseudoClass - (v67).UnmarshalEasyJSON(in) + var v67 string + v67 = string(in.String()) out.ForcedPseudoClasses = append(out.ForcedPseudoClasses, v67) in.WantComma() } @@ -5586,7 +5586,7 @@ func easyjsonC5a4559bEncodeGithubComKnqChromedpCdpCss49(out *jwriter.Writer, in if v68 > 0 { out.RawByte(',') } - (v69).MarshalEasyJSON(out) + out.String(string(v69)) } out.RawByte(']') } diff --git a/cdp/css/events.go b/cdp/css/events.go index afc1b6b..ee5c63a 100644 --- a/cdp/css/events.go +++ b/cdp/css/events.go @@ -6,13 +6,19 @@ import ( cdp "github.com/knq/chromedp/cdp" ) +// EventFontsUpdated fires whenever a web font gets loaded. +type EventFontsUpdated struct{} + // EventMediaQueryResultChanged fires whenever a MediaQuery result changes // (for example, after a browser window has been resized.) The current // implementation considers only viewport-dependent media features. type EventMediaQueryResultChanged struct{} -// EventFontsUpdated fires whenever a web font gets loaded. -type EventFontsUpdated struct{} +// EventStyleSheetAdded fired whenever an active document stylesheet is +// added. +type EventStyleSheetAdded struct { + Header *StyleSheetHeader `json:"header"` // Added stylesheet metainfo. +} // EventStyleSheetChanged fired whenever a stylesheet is changed as a result // of the client operation. @@ -20,12 +26,6 @@ type EventStyleSheetChanged struct { StyleSheetID StyleSheetID `json:"styleSheetId"` } -// EventStyleSheetAdded fired whenever an active document stylesheet is -// added. -type EventStyleSheetAdded struct { - Header *StyleSheetHeader `json:"header"` // Added stylesheet metainfo. -} - // EventStyleSheetRemoved fired whenever an active document stylesheet is // removed. type EventStyleSheetRemoved struct { @@ -34,9 +34,9 @@ type EventStyleSheetRemoved struct { // EventTypes all event types in the domain. var EventTypes = []cdp.MethodType{ - cdp.EventCSSMediaQueryResultChanged, cdp.EventCSSFontsUpdated, - cdp.EventCSSStyleSheetChanged, + cdp.EventCSSMediaQueryResultChanged, cdp.EventCSSStyleSheetAdded, + cdp.EventCSSStyleSheetChanged, cdp.EventCSSStyleSheetRemoved, } diff --git a/cdp/css/types.go b/cdp/css/types.go index c23e6a3..386114b 100644 --- a/cdp/css/types.go +++ b/cdp/css/types.go @@ -283,51 +283,3 @@ func (t *MediaSource) UnmarshalEasyJSON(in *jlexer.Lexer) { func (t *MediaSource) UnmarshalJSON(buf []byte) error { return easyjson.Unmarshal(buf, t) } - -// PseudoClass [no description]. -type PseudoClass string - -// String returns the PseudoClass as string value. -func (t PseudoClass) String() string { - return string(t) -} - -// PseudoClass values. -const ( - PseudoClassActive PseudoClass = "active" - PseudoClassFocus PseudoClass = "focus" - PseudoClassHover PseudoClass = "hover" - PseudoClassVisited PseudoClass = "visited" -) - -// MarshalEasyJSON satisfies easyjson.Marshaler. -func (t PseudoClass) MarshalEasyJSON(out *jwriter.Writer) { - out.String(string(t)) -} - -// MarshalJSON satisfies json.Marshaler. -func (t PseudoClass) MarshalJSON() ([]byte, error) { - return easyjson.Marshal(t) -} - -// UnmarshalEasyJSON satisfies easyjson.Unmarshaler. -func (t *PseudoClass) UnmarshalEasyJSON(in *jlexer.Lexer) { - switch PseudoClass(in.String()) { - case PseudoClassActive: - *t = PseudoClassActive - case PseudoClassFocus: - *t = PseudoClassFocus - case PseudoClassHover: - *t = PseudoClassHover - case PseudoClassVisited: - *t = PseudoClassVisited - - default: - in.AddError(errors.New("unknown PseudoClass value")) - } -} - -// UnmarshalJSON satisfies json.Unmarshaler. -func (t *PseudoClass) UnmarshalJSON(buf []byte) error { - return easyjson.Unmarshal(buf, t) -} diff --git a/cdp/database/database.go b/cdp/database/database.go index 6156491..b7480f2 100644 --- a/cdp/database/database.go +++ b/cdp/database/database.go @@ -13,22 +13,6 @@ import ( "github.com/mailru/easyjson" ) -// EnableParams enables database tracking, database events will now be -// delivered to the client. -type EnableParams struct{} - -// Enable enables database tracking, database events will now be delivered to -// the client. -func Enable() *EnableParams { - return &EnableParams{} -} - -// Do executes Database.enable against the provided context and -// target handler. -func (p *EnableParams) Do(ctxt context.Context, h cdp.Handler) (err error) { - return h.Execute(ctxt, cdp.CommandDatabaseEnable, nil, nil) -} - // DisableParams disables database tracking, prevents database events from // being sent to the client. type DisableParams struct{} @@ -45,40 +29,20 @@ func (p *DisableParams) Do(ctxt context.Context, h cdp.Handler) (err error) { return h.Execute(ctxt, cdp.CommandDatabaseDisable, nil, nil) } -// GetDatabaseTableNamesParams [no description]. -type GetDatabaseTableNamesParams struct { - DatabaseID ID `json:"databaseId"` +// EnableParams enables database tracking, database events will now be +// delivered to the client. +type EnableParams struct{} + +// Enable enables database tracking, database events will now be delivered to +// the client. +func Enable() *EnableParams { + return &EnableParams{} } -// GetDatabaseTableNames [no description]. -// -// parameters: -// databaseID -func GetDatabaseTableNames(databaseID ID) *GetDatabaseTableNamesParams { - return &GetDatabaseTableNamesParams{ - DatabaseID: databaseID, - } -} - -// GetDatabaseTableNamesReturns return values. -type GetDatabaseTableNamesReturns struct { - TableNames []string `json:"tableNames,omitempty"` -} - -// Do executes Database.getDatabaseTableNames against the provided context and +// Do executes Database.enable against the provided context and // target handler. -// -// returns: -// tableNames -func (p *GetDatabaseTableNamesParams) Do(ctxt context.Context, h cdp.Handler) (tableNames []string, err error) { - // execute - var res GetDatabaseTableNamesReturns - err = h.Execute(ctxt, cdp.CommandDatabaseGetDatabaseTableNames, p, &res) - if err != nil { - return nil, err - } - - return res.TableNames, nil +func (p *EnableParams) Do(ctxt context.Context, h cdp.Handler) (err error) { + return h.Execute(ctxt, cdp.CommandDatabaseEnable, nil, nil) } // ExecuteSQLParams [no description]. @@ -123,3 +87,39 @@ func (p *ExecuteSQLParams) Do(ctxt context.Context, h cdp.Handler) (columnNames return res.ColumnNames, res.Values, res.SQLError, nil } + +// GetDatabaseTableNamesParams [no description]. +type GetDatabaseTableNamesParams struct { + DatabaseID ID `json:"databaseId"` +} + +// GetDatabaseTableNames [no description]. +// +// parameters: +// databaseID +func GetDatabaseTableNames(databaseID ID) *GetDatabaseTableNamesParams { + return &GetDatabaseTableNamesParams{ + DatabaseID: databaseID, + } +} + +// GetDatabaseTableNamesReturns return values. +type GetDatabaseTableNamesReturns struct { + TableNames []string `json:"tableNames,omitempty"` +} + +// Do executes Database.getDatabaseTableNames against the provided context and +// target handler. +// +// returns: +// tableNames +func (p *GetDatabaseTableNamesParams) Do(ctxt context.Context, h cdp.Handler) (tableNames []string, err error) { + // execute + var res GetDatabaseTableNamesReturns + err = h.Execute(ctxt, cdp.CommandDatabaseGetDatabaseTableNames, p, &res) + if err != nil { + return nil, err + } + + return res.TableNames, nil +} diff --git a/cdp/debugger/debugger.go b/cdp/debugger/debugger.go index b067f27..c9c2a69 100644 --- a/cdp/debugger/debugger.go +++ b/cdp/debugger/debugger.go @@ -17,6 +17,49 @@ import ( "github.com/knq/chromedp/cdp/runtime" ) +// ContinueToLocationParams continues execution until specific location is +// reached. +type ContinueToLocationParams struct { + Location *Location `json:"location"` // Location to continue to. + TargetCallFrames ContinueToLocationTargetCallFrames `json:"targetCallFrames,omitempty"` +} + +// ContinueToLocation continues execution until specific location is reached. +// +// parameters: +// location - Location to continue to. +func ContinueToLocation(location *Location) *ContinueToLocationParams { + return &ContinueToLocationParams{ + Location: location, + } +} + +// WithTargetCallFrames [no description]. +func (p ContinueToLocationParams) WithTargetCallFrames(targetCallFrames ContinueToLocationTargetCallFrames) *ContinueToLocationParams { + p.TargetCallFrames = targetCallFrames + return &p +} + +// Do executes Debugger.continueToLocation against the provided context and +// target handler. +func (p *ContinueToLocationParams) Do(ctxt context.Context, h cdp.Handler) (err error) { + return h.Execute(ctxt, cdp.CommandDebuggerContinueToLocation, p, nil) +} + +// DisableParams disables debugger for given page. +type DisableParams struct{} + +// Disable disables debugger for given page. +func Disable() *DisableParams { + return &DisableParams{} +} + +// Do executes Debugger.disable against the provided context and +// target handler. +func (p *DisableParams) Do(ctxt context.Context, h cdp.Handler) (err error) { + return h.Execute(ctxt, cdp.CommandDebuggerDisable, nil, nil) +} + // EnableParams enables debugger for the given page. Clients should not // assume that the debugging has been enabled until the result for this command // is received. @@ -49,670 +92,6 @@ func (p *EnableParams) Do(ctxt context.Context, h cdp.Handler) (debuggerID runti return res.DebuggerID, nil } -// DisableParams disables debugger for given page. -type DisableParams struct{} - -// Disable disables debugger for given page. -func Disable() *DisableParams { - return &DisableParams{} -} - -// Do executes Debugger.disable against the provided context and -// target handler. -func (p *DisableParams) Do(ctxt context.Context, h cdp.Handler) (err error) { - return h.Execute(ctxt, cdp.CommandDebuggerDisable, nil, nil) -} - -// SetBreakpointsActiveParams activates / deactivates all breakpoints on the -// page. -type SetBreakpointsActiveParams struct { - Active bool `json:"active"` // New value for breakpoints active state. -} - -// SetBreakpointsActive activates / deactivates all breakpoints on the page. -// -// parameters: -// active - New value for breakpoints active state. -func SetBreakpointsActive(active bool) *SetBreakpointsActiveParams { - return &SetBreakpointsActiveParams{ - Active: active, - } -} - -// Do executes Debugger.setBreakpointsActive against the provided context and -// target handler. -func (p *SetBreakpointsActiveParams) Do(ctxt context.Context, h cdp.Handler) (err error) { - return h.Execute(ctxt, cdp.CommandDebuggerSetBreakpointsActive, p, nil) -} - -// SetSkipAllPausesParams makes page not interrupt on any pauses (breakpoint, -// exception, dom exception etc). -type SetSkipAllPausesParams struct { - Skip bool `json:"skip"` // New value for skip pauses state. -} - -// SetSkipAllPauses makes page not interrupt on any pauses (breakpoint, -// exception, dom exception etc). -// -// parameters: -// skip - New value for skip pauses state. -func SetSkipAllPauses(skip bool) *SetSkipAllPausesParams { - return &SetSkipAllPausesParams{ - Skip: skip, - } -} - -// Do executes Debugger.setSkipAllPauses against the provided context and -// target handler. -func (p *SetSkipAllPausesParams) Do(ctxt context.Context, h cdp.Handler) (err error) { - return h.Execute(ctxt, cdp.CommandDebuggerSetSkipAllPauses, p, nil) -} - -// SetBreakpointByURLParams sets JavaScript breakpoint at given location -// specified either by URL or URL regex. Once this command is issued, all -// existing parsed scripts will have breakpoints resolved and returned in -// locations property. Further matching script parsing will result in subsequent -// breakpointResolved events issued. This logical breakpoint will survive page -// reloads. -type SetBreakpointByURLParams struct { - LineNumber int64 `json:"lineNumber"` // Line number to set breakpoint at. - URL string `json:"url,omitempty"` // URL of the resources to set breakpoint on. - URLRegex string `json:"urlRegex,omitempty"` // Regex pattern for the URLs of the resources to set breakpoints on. Either url or urlRegex must be specified. - ScriptHash string `json:"scriptHash,omitempty"` // Script hash of the resources to set breakpoint on. - ColumnNumber int64 `json:"columnNumber,omitempty"` // Offset in the line to set breakpoint at. - Condition string `json:"condition,omitempty"` // Expression to use as a breakpoint condition. When specified, debugger will only stop on the breakpoint if this expression evaluates to true. -} - -// SetBreakpointByURL sets JavaScript breakpoint at given location specified -// either by URL or URL regex. Once this command is issued, all existing parsed -// scripts will have breakpoints resolved and returned in locations property. -// Further matching script parsing will result in subsequent breakpointResolved -// events issued. This logical breakpoint will survive page reloads. -// -// parameters: -// lineNumber - Line number to set breakpoint at. -func SetBreakpointByURL(lineNumber int64) *SetBreakpointByURLParams { - return &SetBreakpointByURLParams{ - LineNumber: lineNumber, - } -} - -// WithURL URL of the resources to set breakpoint on. -func (p SetBreakpointByURLParams) WithURL(url string) *SetBreakpointByURLParams { - p.URL = url - return &p -} - -// WithURLRegex regex pattern for the URLs of the resources to set -// breakpoints on. Either url or urlRegex must be specified. -func (p SetBreakpointByURLParams) WithURLRegex(urlRegex string) *SetBreakpointByURLParams { - p.URLRegex = urlRegex - return &p -} - -// WithScriptHash script hash of the resources to set breakpoint on. -func (p SetBreakpointByURLParams) WithScriptHash(scriptHash string) *SetBreakpointByURLParams { - p.ScriptHash = scriptHash - return &p -} - -// WithColumnNumber offset in the line to set breakpoint at. -func (p SetBreakpointByURLParams) WithColumnNumber(columnNumber int64) *SetBreakpointByURLParams { - p.ColumnNumber = columnNumber - return &p -} - -// WithCondition expression to use as a breakpoint condition. When specified, -// debugger will only stop on the breakpoint if this expression evaluates to -// true. -func (p SetBreakpointByURLParams) WithCondition(condition string) *SetBreakpointByURLParams { - p.Condition = condition - return &p -} - -// SetBreakpointByURLReturns return values. -type SetBreakpointByURLReturns struct { - BreakpointID BreakpointID `json:"breakpointId,omitempty"` // Id of the created breakpoint for further reference. - Locations []*Location `json:"locations,omitempty"` // List of the locations this breakpoint resolved into upon addition. -} - -// Do executes Debugger.setBreakpointByUrl against the provided context and -// target handler. -// -// returns: -// breakpointID - Id of the created breakpoint for further reference. -// locations - List of the locations this breakpoint resolved into upon addition. -func (p *SetBreakpointByURLParams) Do(ctxt context.Context, h cdp.Handler) (breakpointID BreakpointID, locations []*Location, err error) { - // execute - var res SetBreakpointByURLReturns - err = h.Execute(ctxt, cdp.CommandDebuggerSetBreakpointByURL, p, &res) - if err != nil { - return "", nil, err - } - - return res.BreakpointID, res.Locations, nil -} - -// SetBreakpointParams sets JavaScript breakpoint at a given location. -type SetBreakpointParams struct { - Location *Location `json:"location"` // Location to set breakpoint in. - Condition string `json:"condition,omitempty"` // Expression to use as a breakpoint condition. When specified, debugger will only stop on the breakpoint if this expression evaluates to true. -} - -// SetBreakpoint sets JavaScript breakpoint at a given location. -// -// parameters: -// location - Location to set breakpoint in. -func SetBreakpoint(location *Location) *SetBreakpointParams { - return &SetBreakpointParams{ - Location: location, - } -} - -// WithCondition expression to use as a breakpoint condition. When specified, -// debugger will only stop on the breakpoint if this expression evaluates to -// true. -func (p SetBreakpointParams) WithCondition(condition string) *SetBreakpointParams { - p.Condition = condition - return &p -} - -// SetBreakpointReturns return values. -type SetBreakpointReturns struct { - BreakpointID BreakpointID `json:"breakpointId,omitempty"` // Id of the created breakpoint for further reference. - ActualLocation *Location `json:"actualLocation,omitempty"` // Location this breakpoint resolved into. -} - -// Do executes Debugger.setBreakpoint against the provided context and -// target handler. -// -// returns: -// breakpointID - Id of the created breakpoint for further reference. -// actualLocation - Location this breakpoint resolved into. -func (p *SetBreakpointParams) Do(ctxt context.Context, h cdp.Handler) (breakpointID BreakpointID, actualLocation *Location, err error) { - // execute - var res SetBreakpointReturns - err = h.Execute(ctxt, cdp.CommandDebuggerSetBreakpoint, p, &res) - if err != nil { - return "", nil, err - } - - return res.BreakpointID, res.ActualLocation, nil -} - -// RemoveBreakpointParams removes JavaScript breakpoint. -type RemoveBreakpointParams struct { - BreakpointID BreakpointID `json:"breakpointId"` -} - -// RemoveBreakpoint removes JavaScript breakpoint. -// -// parameters: -// breakpointID -func RemoveBreakpoint(breakpointID BreakpointID) *RemoveBreakpointParams { - return &RemoveBreakpointParams{ - BreakpointID: breakpointID, - } -} - -// Do executes Debugger.removeBreakpoint against the provided context and -// target handler. -func (p *RemoveBreakpointParams) Do(ctxt context.Context, h cdp.Handler) (err error) { - return h.Execute(ctxt, cdp.CommandDebuggerRemoveBreakpoint, p, nil) -} - -// GetPossibleBreakpointsParams returns possible locations for breakpoint. -// scriptId in start and end range locations should be the same. -type GetPossibleBreakpointsParams struct { - Start *Location `json:"start"` // Start of range to search possible breakpoint locations in. - End *Location `json:"end,omitempty"` // End of range to search possible breakpoint locations in (excluding). When not specified, end of scripts is used as end of range. - RestrictToFunction bool `json:"restrictToFunction,omitempty"` // Only consider locations which are in the same (non-nested) function as start. -} - -// GetPossibleBreakpoints returns possible locations for breakpoint. scriptId -// in start and end range locations should be the same. -// -// parameters: -// start - Start of range to search possible breakpoint locations in. -func GetPossibleBreakpoints(start *Location) *GetPossibleBreakpointsParams { - return &GetPossibleBreakpointsParams{ - Start: start, - } -} - -// WithEnd end of range to search possible breakpoint locations in -// (excluding). When not specified, end of scripts is used as end of range. -func (p GetPossibleBreakpointsParams) WithEnd(end *Location) *GetPossibleBreakpointsParams { - p.End = end - return &p -} - -// WithRestrictToFunction only consider locations which are in the same -// (non-nested) function as start. -func (p GetPossibleBreakpointsParams) WithRestrictToFunction(restrictToFunction bool) *GetPossibleBreakpointsParams { - p.RestrictToFunction = restrictToFunction - return &p -} - -// GetPossibleBreakpointsReturns return values. -type GetPossibleBreakpointsReturns struct { - Locations []*BreakLocation `json:"locations,omitempty"` // List of the possible breakpoint locations. -} - -// Do executes Debugger.getPossibleBreakpoints against the provided context and -// target handler. -// -// returns: -// locations - List of the possible breakpoint locations. -func (p *GetPossibleBreakpointsParams) Do(ctxt context.Context, h cdp.Handler) (locations []*BreakLocation, err error) { - // execute - var res GetPossibleBreakpointsReturns - err = h.Execute(ctxt, cdp.CommandDebuggerGetPossibleBreakpoints, p, &res) - if err != nil { - return nil, err - } - - return res.Locations, nil -} - -// ContinueToLocationParams continues execution until specific location is -// reached. -type ContinueToLocationParams struct { - Location *Location `json:"location"` // Location to continue to. - TargetCallFrames ContinueToLocationTargetCallFrames `json:"targetCallFrames,omitempty"` -} - -// ContinueToLocation continues execution until specific location is reached. -// -// parameters: -// location - Location to continue to. -func ContinueToLocation(location *Location) *ContinueToLocationParams { - return &ContinueToLocationParams{ - Location: location, - } -} - -// WithTargetCallFrames [no description]. -func (p ContinueToLocationParams) WithTargetCallFrames(targetCallFrames ContinueToLocationTargetCallFrames) *ContinueToLocationParams { - p.TargetCallFrames = targetCallFrames - return &p -} - -// Do executes Debugger.continueToLocation against the provided context and -// target handler. -func (p *ContinueToLocationParams) Do(ctxt context.Context, h cdp.Handler) (err error) { - return h.Execute(ctxt, cdp.CommandDebuggerContinueToLocation, p, nil) -} - -// PauseOnAsyncCallParams [no description]. -type PauseOnAsyncCallParams struct { - ParentStackTraceID *runtime.StackTraceID `json:"parentStackTraceId"` // Debugger will pause when async call with given stack trace is started. -} - -// PauseOnAsyncCall [no description]. -// -// parameters: -// parentStackTraceID - Debugger will pause when async call with given stack trace is started. -func PauseOnAsyncCall(parentStackTraceID *runtime.StackTraceID) *PauseOnAsyncCallParams { - return &PauseOnAsyncCallParams{ - ParentStackTraceID: parentStackTraceID, - } -} - -// Do executes Debugger.pauseOnAsyncCall against the provided context and -// target handler. -func (p *PauseOnAsyncCallParams) Do(ctxt context.Context, h cdp.Handler) (err error) { - return h.Execute(ctxt, cdp.CommandDebuggerPauseOnAsyncCall, p, nil) -} - -// StepOverParams steps over the statement. -type StepOverParams struct{} - -// StepOver steps over the statement. -func StepOver() *StepOverParams { - return &StepOverParams{} -} - -// Do executes Debugger.stepOver against the provided context and -// target handler. -func (p *StepOverParams) Do(ctxt context.Context, h cdp.Handler) (err error) { - return h.Execute(ctxt, cdp.CommandDebuggerStepOver, nil, nil) -} - -// StepIntoParams steps into the function call. -type StepIntoParams struct { - BreakOnAsyncCall bool `json:"breakOnAsyncCall,omitempty"` // Debugger will issue additional Debugger.paused notification if any async task is scheduled before next pause. -} - -// StepInto steps into the function call. -// -// parameters: -func StepInto() *StepIntoParams { - return &StepIntoParams{} -} - -// WithBreakOnAsyncCall debugger will issue additional Debugger.paused -// notification if any async task is scheduled before next pause. -func (p StepIntoParams) WithBreakOnAsyncCall(breakOnAsyncCall bool) *StepIntoParams { - p.BreakOnAsyncCall = breakOnAsyncCall - return &p -} - -// Do executes Debugger.stepInto against the provided context and -// target handler. -func (p *StepIntoParams) Do(ctxt context.Context, h cdp.Handler) (err error) { - return h.Execute(ctxt, cdp.CommandDebuggerStepInto, p, nil) -} - -// StepOutParams steps out of the function call. -type StepOutParams struct{} - -// StepOut steps out of the function call. -func StepOut() *StepOutParams { - return &StepOutParams{} -} - -// Do executes Debugger.stepOut against the provided context and -// target handler. -func (p *StepOutParams) Do(ctxt context.Context, h cdp.Handler) (err error) { - return h.Execute(ctxt, cdp.CommandDebuggerStepOut, nil, nil) -} - -// PauseParams stops on the next JavaScript statement. -type PauseParams struct{} - -// Pause stops on the next JavaScript statement. -func Pause() *PauseParams { - return &PauseParams{} -} - -// Do executes Debugger.pause against the provided context and -// target handler. -func (p *PauseParams) Do(ctxt context.Context, h cdp.Handler) (err error) { - return h.Execute(ctxt, cdp.CommandDebuggerPause, nil, nil) -} - -// ScheduleStepIntoAsyncParams this method is deprecated - use -// Debugger.stepInto with breakOnAsyncCall and Debugger.pauseOnAsyncTask -// instead. Steps into next scheduled async task if any is scheduled before next -// pause. Returns success when async task is actually scheduled, returns error -// if no task were scheduled or another scheduleStepIntoAsync was called. -type ScheduleStepIntoAsyncParams struct{} - -// ScheduleStepIntoAsync this method is deprecated - use Debugger.stepInto -// with breakOnAsyncCall and Debugger.pauseOnAsyncTask instead. Steps into next -// scheduled async task if any is scheduled before next pause. Returns success -// when async task is actually scheduled, returns error if no task were -// scheduled or another scheduleStepIntoAsync was called. -func ScheduleStepIntoAsync() *ScheduleStepIntoAsyncParams { - return &ScheduleStepIntoAsyncParams{} -} - -// Do executes Debugger.scheduleStepIntoAsync against the provided context and -// target handler. -func (p *ScheduleStepIntoAsyncParams) Do(ctxt context.Context, h cdp.Handler) (err error) { - return h.Execute(ctxt, cdp.CommandDebuggerScheduleStepIntoAsync, nil, nil) -} - -// ResumeParams resumes JavaScript execution. -type ResumeParams struct{} - -// Resume resumes JavaScript execution. -func Resume() *ResumeParams { - return &ResumeParams{} -} - -// Do executes Debugger.resume against the provided context and -// target handler. -func (p *ResumeParams) Do(ctxt context.Context, h cdp.Handler) (err error) { - return h.Execute(ctxt, cdp.CommandDebuggerResume, nil, nil) -} - -// GetStackTraceParams returns stack trace with given stackTraceId. -type GetStackTraceParams struct { - StackTraceID *runtime.StackTraceID `json:"stackTraceId"` -} - -// GetStackTrace returns stack trace with given stackTraceId. -// -// parameters: -// stackTraceID -func GetStackTrace(stackTraceID *runtime.StackTraceID) *GetStackTraceParams { - return &GetStackTraceParams{ - StackTraceID: stackTraceID, - } -} - -// GetStackTraceReturns return values. -type GetStackTraceReturns struct { - StackTrace *runtime.StackTrace `json:"stackTrace,omitempty"` -} - -// Do executes Debugger.getStackTrace against the provided context and -// target handler. -// -// returns: -// stackTrace -func (p *GetStackTraceParams) Do(ctxt context.Context, h cdp.Handler) (stackTrace *runtime.StackTrace, err error) { - // execute - var res GetStackTraceReturns - err = h.Execute(ctxt, cdp.CommandDebuggerGetStackTrace, p, &res) - if err != nil { - return nil, err - } - - return res.StackTrace, nil -} - -// SearchInContentParams searches for given string in script content. -type SearchInContentParams struct { - ScriptID runtime.ScriptID `json:"scriptId"` // Id of the script to search in. - Query string `json:"query"` // String to search for. - CaseSensitive bool `json:"caseSensitive,omitempty"` // If true, search is case sensitive. - IsRegex bool `json:"isRegex,omitempty"` // If true, treats string parameter as regex. -} - -// SearchInContent searches for given string in script content. -// -// parameters: -// scriptID - Id of the script to search in. -// query - String to search for. -func SearchInContent(scriptID runtime.ScriptID, query string) *SearchInContentParams { - return &SearchInContentParams{ - ScriptID: scriptID, - Query: query, - } -} - -// WithCaseSensitive if true, search is case sensitive. -func (p SearchInContentParams) WithCaseSensitive(caseSensitive bool) *SearchInContentParams { - p.CaseSensitive = caseSensitive - return &p -} - -// WithIsRegex if true, treats string parameter as regex. -func (p SearchInContentParams) WithIsRegex(isRegex bool) *SearchInContentParams { - p.IsRegex = isRegex - return &p -} - -// SearchInContentReturns return values. -type SearchInContentReturns struct { - Result []*SearchMatch `json:"result,omitempty"` // List of search matches. -} - -// Do executes Debugger.searchInContent against the provided context and -// target handler. -// -// returns: -// result - List of search matches. -func (p *SearchInContentParams) Do(ctxt context.Context, h cdp.Handler) (result []*SearchMatch, err error) { - // execute - var res SearchInContentReturns - err = h.Execute(ctxt, cdp.CommandDebuggerSearchInContent, p, &res) - if err != nil { - return nil, err - } - - return res.Result, nil -} - -// SetScriptSourceParams edits JavaScript source live. -type SetScriptSourceParams struct { - ScriptID runtime.ScriptID `json:"scriptId"` // Id of the script to edit. - ScriptSource string `json:"scriptSource"` // New content of the script. - DryRun bool `json:"dryRun,omitempty"` // If true the change will not actually be applied. Dry run may be used to get result description without actually modifying the code. -} - -// SetScriptSource edits JavaScript source live. -// -// parameters: -// scriptID - Id of the script to edit. -// scriptSource - New content of the script. -func SetScriptSource(scriptID runtime.ScriptID, scriptSource string) *SetScriptSourceParams { - return &SetScriptSourceParams{ - ScriptID: scriptID, - ScriptSource: scriptSource, - } -} - -// WithDryRun if true the change will not actually be applied. Dry run may be -// used to get result description without actually modifying the code. -func (p SetScriptSourceParams) WithDryRun(dryRun bool) *SetScriptSourceParams { - p.DryRun = dryRun - return &p -} - -// SetScriptSourceReturns return values. -type SetScriptSourceReturns struct { - CallFrames []*CallFrame `json:"callFrames,omitempty"` // New stack trace in case editing has happened while VM was stopped. - StackChanged bool `json:"stackChanged,omitempty"` // Whether current call stack was modified after applying the changes. - AsyncStackTrace *runtime.StackTrace `json:"asyncStackTrace,omitempty"` // Async stack trace, if any. - AsyncStackTraceID *runtime.StackTraceID `json:"asyncStackTraceId,omitempty"` // Async stack trace, if any. - ExceptionDetails *runtime.ExceptionDetails `json:"exceptionDetails,omitempty"` // Exception details if any. -} - -// Do executes Debugger.setScriptSource against the provided context and -// target handler. -// -// returns: -// callFrames - New stack trace in case editing has happened while VM was stopped. -// stackChanged - Whether current call stack was modified after applying the changes. -// asyncStackTrace - Async stack trace, if any. -// asyncStackTraceID - Async stack trace, if any. -// exceptionDetails - Exception details if any. -func (p *SetScriptSourceParams) Do(ctxt context.Context, h cdp.Handler) (callFrames []*CallFrame, stackChanged bool, asyncStackTrace *runtime.StackTrace, asyncStackTraceID *runtime.StackTraceID, exceptionDetails *runtime.ExceptionDetails, err error) { - // execute - var res SetScriptSourceReturns - err = h.Execute(ctxt, cdp.CommandDebuggerSetScriptSource, p, &res) - if err != nil { - return nil, false, nil, nil, nil, err - } - - return res.CallFrames, res.StackChanged, res.AsyncStackTrace, res.AsyncStackTraceID, res.ExceptionDetails, nil -} - -// RestartFrameParams restarts particular call frame from the beginning. -type RestartFrameParams struct { - CallFrameID CallFrameID `json:"callFrameId"` // Call frame identifier to evaluate on. -} - -// RestartFrame restarts particular call frame from the beginning. -// -// parameters: -// callFrameID - Call frame identifier to evaluate on. -func RestartFrame(callFrameID CallFrameID) *RestartFrameParams { - return &RestartFrameParams{ - CallFrameID: callFrameID, - } -} - -// RestartFrameReturns return values. -type RestartFrameReturns struct { - CallFrames []*CallFrame `json:"callFrames,omitempty"` // New stack trace. - AsyncStackTrace *runtime.StackTrace `json:"asyncStackTrace,omitempty"` // Async stack trace, if any. - AsyncStackTraceID *runtime.StackTraceID `json:"asyncStackTraceId,omitempty"` // Async stack trace, if any. -} - -// Do executes Debugger.restartFrame against the provided context and -// target handler. -// -// returns: -// callFrames - New stack trace. -// asyncStackTrace - Async stack trace, if any. -// asyncStackTraceID - Async stack trace, if any. -func (p *RestartFrameParams) Do(ctxt context.Context, h cdp.Handler) (callFrames []*CallFrame, asyncStackTrace *runtime.StackTrace, asyncStackTraceID *runtime.StackTraceID, err error) { - // execute - var res RestartFrameReturns - err = h.Execute(ctxt, cdp.CommandDebuggerRestartFrame, p, &res) - if err != nil { - return nil, nil, nil, err - } - - return res.CallFrames, res.AsyncStackTrace, res.AsyncStackTraceID, nil -} - -// GetScriptSourceParams returns source for the script with given id. -type GetScriptSourceParams struct { - ScriptID runtime.ScriptID `json:"scriptId"` // Id of the script to get source for. -} - -// GetScriptSource returns source for the script with given id. -// -// parameters: -// scriptID - Id of the script to get source for. -func GetScriptSource(scriptID runtime.ScriptID) *GetScriptSourceParams { - return &GetScriptSourceParams{ - ScriptID: scriptID, - } -} - -// GetScriptSourceReturns return values. -type GetScriptSourceReturns struct { - ScriptSource string `json:"scriptSource,omitempty"` // Script source. -} - -// Do executes Debugger.getScriptSource against the provided context and -// target handler. -// -// returns: -// scriptSource - Script source. -func (p *GetScriptSourceParams) Do(ctxt context.Context, h cdp.Handler) (scriptSource string, err error) { - // execute - var res GetScriptSourceReturns - err = h.Execute(ctxt, cdp.CommandDebuggerGetScriptSource, p, &res) - if err != nil { - return "", err - } - - return res.ScriptSource, nil -} - -// SetPauseOnExceptionsParams defines pause on exceptions state. Can be set -// to stop on all exceptions, uncaught exceptions or no exceptions. Initial -// pause on exceptions state is none. -type SetPauseOnExceptionsParams struct { - State ExceptionsState `json:"state"` // Pause on exceptions mode. -} - -// SetPauseOnExceptions defines pause on exceptions state. Can be set to stop -// on all exceptions, uncaught exceptions or no exceptions. Initial pause on -// exceptions state is none. -// -// parameters: -// state - Pause on exceptions mode. -func SetPauseOnExceptions(state ExceptionsState) *SetPauseOnExceptionsParams { - return &SetPauseOnExceptionsParams{ - State: state, - } -} - -// Do executes Debugger.setPauseOnExceptions against the provided context and -// target handler. -func (p *SetPauseOnExceptionsParams) Do(ctxt context.Context, h cdp.Handler) (err error) { - return h.Execute(ctxt, cdp.CommandDebuggerSetPauseOnExceptions, p, nil) -} - // EvaluateOnCallFrameParams evaluates expression on a given call frame. type EvaluateOnCallFrameParams struct { CallFrameID CallFrameID `json:"callFrameId"` // Call frame identifier to evaluate on. @@ -801,59 +180,315 @@ func (p *EvaluateOnCallFrameParams) Do(ctxt context.Context, h cdp.Handler) (res return res.Result, res.ExceptionDetails, nil } -// SetVariableValueParams changes value of variable in a callframe. -// Object-based scopes are not supported and must be mutated manually. -type SetVariableValueParams struct { - ScopeNumber int64 `json:"scopeNumber"` // 0-based number of scope as was listed in scope chain. Only 'local', 'closure' and 'catch' scope types are allowed. Other scopes could be manipulated manually. - VariableName string `json:"variableName"` // Variable name. - NewValue *runtime.CallArgument `json:"newValue"` // New variable value. - CallFrameID CallFrameID `json:"callFrameId"` // Id of callframe that holds variable. +// GetPossibleBreakpointsParams returns possible locations for breakpoint. +// scriptId in start and end range locations should be the same. +type GetPossibleBreakpointsParams struct { + Start *Location `json:"start"` // Start of range to search possible breakpoint locations in. + End *Location `json:"end,omitempty"` // End of range to search possible breakpoint locations in (excluding). When not specified, end of scripts is used as end of range. + RestrictToFunction bool `json:"restrictToFunction,omitempty"` // Only consider locations which are in the same (non-nested) function as start. } -// SetVariableValue changes value of variable in a callframe. Object-based -// scopes are not supported and must be mutated manually. +// GetPossibleBreakpoints returns possible locations for breakpoint. scriptId +// in start and end range locations should be the same. // // parameters: -// scopeNumber - 0-based number of scope as was listed in scope chain. Only 'local', 'closure' and 'catch' scope types are allowed. Other scopes could be manipulated manually. -// variableName - Variable name. -// newValue - New variable value. -// callFrameID - Id of callframe that holds variable. -func SetVariableValue(scopeNumber int64, variableName string, newValue *runtime.CallArgument, callFrameID CallFrameID) *SetVariableValueParams { - return &SetVariableValueParams{ - ScopeNumber: scopeNumber, - VariableName: variableName, - NewValue: newValue, - CallFrameID: callFrameID, +// start - Start of range to search possible breakpoint locations in. +func GetPossibleBreakpoints(start *Location) *GetPossibleBreakpointsParams { + return &GetPossibleBreakpointsParams{ + Start: start, } } -// Do executes Debugger.setVariableValue against the provided context and +// WithEnd end of range to search possible breakpoint locations in +// (excluding). When not specified, end of scripts is used as end of range. +func (p GetPossibleBreakpointsParams) WithEnd(end *Location) *GetPossibleBreakpointsParams { + p.End = end + return &p +} + +// WithRestrictToFunction only consider locations which are in the same +// (non-nested) function as start. +func (p GetPossibleBreakpointsParams) WithRestrictToFunction(restrictToFunction bool) *GetPossibleBreakpointsParams { + p.RestrictToFunction = restrictToFunction + return &p +} + +// GetPossibleBreakpointsReturns return values. +type GetPossibleBreakpointsReturns struct { + Locations []*BreakLocation `json:"locations,omitempty"` // List of the possible breakpoint locations. +} + +// Do executes Debugger.getPossibleBreakpoints against the provided context and // target handler. -func (p *SetVariableValueParams) Do(ctxt context.Context, h cdp.Handler) (err error) { - return h.Execute(ctxt, cdp.CommandDebuggerSetVariableValue, p, nil) +// +// returns: +// locations - List of the possible breakpoint locations. +func (p *GetPossibleBreakpointsParams) Do(ctxt context.Context, h cdp.Handler) (locations []*BreakLocation, err error) { + // execute + var res GetPossibleBreakpointsReturns + err = h.Execute(ctxt, cdp.CommandDebuggerGetPossibleBreakpoints, p, &res) + if err != nil { + return nil, err + } + + return res.Locations, nil } -// SetReturnValueParams changes return value in top frame. Available only at -// return break position. -type SetReturnValueParams struct { - NewValue *runtime.CallArgument `json:"newValue"` // New return value. +// GetScriptSourceParams returns source for the script with given id. +type GetScriptSourceParams struct { + ScriptID runtime.ScriptID `json:"scriptId"` // Id of the script to get source for. } -// SetReturnValue changes return value in top frame. Available only at return -// break position. +// GetScriptSource returns source for the script with given id. // // parameters: -// newValue - New return value. -func SetReturnValue(newValue *runtime.CallArgument) *SetReturnValueParams { - return &SetReturnValueParams{ - NewValue: newValue, +// scriptID - Id of the script to get source for. +func GetScriptSource(scriptID runtime.ScriptID) *GetScriptSourceParams { + return &GetScriptSourceParams{ + ScriptID: scriptID, } } -// Do executes Debugger.setReturnValue against the provided context and +// GetScriptSourceReturns return values. +type GetScriptSourceReturns struct { + ScriptSource string `json:"scriptSource,omitempty"` // Script source. +} + +// Do executes Debugger.getScriptSource against the provided context and // target handler. -func (p *SetReturnValueParams) Do(ctxt context.Context, h cdp.Handler) (err error) { - return h.Execute(ctxt, cdp.CommandDebuggerSetReturnValue, p, nil) +// +// returns: +// scriptSource - Script source. +func (p *GetScriptSourceParams) Do(ctxt context.Context, h cdp.Handler) (scriptSource string, err error) { + // execute + var res GetScriptSourceReturns + err = h.Execute(ctxt, cdp.CommandDebuggerGetScriptSource, p, &res) + if err != nil { + return "", err + } + + return res.ScriptSource, nil +} + +// GetStackTraceParams returns stack trace with given stackTraceId. +type GetStackTraceParams struct { + StackTraceID *runtime.StackTraceID `json:"stackTraceId"` +} + +// GetStackTrace returns stack trace with given stackTraceId. +// +// parameters: +// stackTraceID +func GetStackTrace(stackTraceID *runtime.StackTraceID) *GetStackTraceParams { + return &GetStackTraceParams{ + StackTraceID: stackTraceID, + } +} + +// GetStackTraceReturns return values. +type GetStackTraceReturns struct { + StackTrace *runtime.StackTrace `json:"stackTrace,omitempty"` +} + +// Do executes Debugger.getStackTrace against the provided context and +// target handler. +// +// returns: +// stackTrace +func (p *GetStackTraceParams) Do(ctxt context.Context, h cdp.Handler) (stackTrace *runtime.StackTrace, err error) { + // execute + var res GetStackTraceReturns + err = h.Execute(ctxt, cdp.CommandDebuggerGetStackTrace, p, &res) + if err != nil { + return nil, err + } + + return res.StackTrace, nil +} + +// PauseParams stops on the next JavaScript statement. +type PauseParams struct{} + +// Pause stops on the next JavaScript statement. +func Pause() *PauseParams { + return &PauseParams{} +} + +// Do executes Debugger.pause against the provided context and +// target handler. +func (p *PauseParams) Do(ctxt context.Context, h cdp.Handler) (err error) { + return h.Execute(ctxt, cdp.CommandDebuggerPause, nil, nil) +} + +// PauseOnAsyncCallParams [no description]. +type PauseOnAsyncCallParams struct { + ParentStackTraceID *runtime.StackTraceID `json:"parentStackTraceId"` // Debugger will pause when async call with given stack trace is started. +} + +// PauseOnAsyncCall [no description]. +// +// parameters: +// parentStackTraceID - Debugger will pause when async call with given stack trace is started. +func PauseOnAsyncCall(parentStackTraceID *runtime.StackTraceID) *PauseOnAsyncCallParams { + return &PauseOnAsyncCallParams{ + ParentStackTraceID: parentStackTraceID, + } +} + +// Do executes Debugger.pauseOnAsyncCall against the provided context and +// target handler. +func (p *PauseOnAsyncCallParams) Do(ctxt context.Context, h cdp.Handler) (err error) { + return h.Execute(ctxt, cdp.CommandDebuggerPauseOnAsyncCall, p, nil) +} + +// RemoveBreakpointParams removes JavaScript breakpoint. +type RemoveBreakpointParams struct { + BreakpointID BreakpointID `json:"breakpointId"` +} + +// RemoveBreakpoint removes JavaScript breakpoint. +// +// parameters: +// breakpointID +func RemoveBreakpoint(breakpointID BreakpointID) *RemoveBreakpointParams { + return &RemoveBreakpointParams{ + BreakpointID: breakpointID, + } +} + +// Do executes Debugger.removeBreakpoint against the provided context and +// target handler. +func (p *RemoveBreakpointParams) Do(ctxt context.Context, h cdp.Handler) (err error) { + return h.Execute(ctxt, cdp.CommandDebuggerRemoveBreakpoint, p, nil) +} + +// RestartFrameParams restarts particular call frame from the beginning. +type RestartFrameParams struct { + CallFrameID CallFrameID `json:"callFrameId"` // Call frame identifier to evaluate on. +} + +// RestartFrame restarts particular call frame from the beginning. +// +// parameters: +// callFrameID - Call frame identifier to evaluate on. +func RestartFrame(callFrameID CallFrameID) *RestartFrameParams { + return &RestartFrameParams{ + CallFrameID: callFrameID, + } +} + +// RestartFrameReturns return values. +type RestartFrameReturns struct { + CallFrames []*CallFrame `json:"callFrames,omitempty"` // New stack trace. + AsyncStackTrace *runtime.StackTrace `json:"asyncStackTrace,omitempty"` // Async stack trace, if any. + AsyncStackTraceID *runtime.StackTraceID `json:"asyncStackTraceId,omitempty"` // Async stack trace, if any. +} + +// Do executes Debugger.restartFrame against the provided context and +// target handler. +// +// returns: +// callFrames - New stack trace. +// asyncStackTrace - Async stack trace, if any. +// asyncStackTraceID - Async stack trace, if any. +func (p *RestartFrameParams) Do(ctxt context.Context, h cdp.Handler) (callFrames []*CallFrame, asyncStackTrace *runtime.StackTrace, asyncStackTraceID *runtime.StackTraceID, err error) { + // execute + var res RestartFrameReturns + err = h.Execute(ctxt, cdp.CommandDebuggerRestartFrame, p, &res) + if err != nil { + return nil, nil, nil, err + } + + return res.CallFrames, res.AsyncStackTrace, res.AsyncStackTraceID, nil +} + +// ResumeParams resumes JavaScript execution. +type ResumeParams struct{} + +// Resume resumes JavaScript execution. +func Resume() *ResumeParams { + return &ResumeParams{} +} + +// Do executes Debugger.resume against the provided context and +// target handler. +func (p *ResumeParams) Do(ctxt context.Context, h cdp.Handler) (err error) { + return h.Execute(ctxt, cdp.CommandDebuggerResume, nil, nil) +} + +// ScheduleStepIntoAsyncParams this method is deprecated - use +// Debugger.stepInto with breakOnAsyncCall and Debugger.pauseOnAsyncTask +// instead. Steps into next scheduled async task if any is scheduled before next +// pause. Returns success when async task is actually scheduled, returns error +// if no task were scheduled or another scheduleStepIntoAsync was called. +type ScheduleStepIntoAsyncParams struct{} + +// ScheduleStepIntoAsync this method is deprecated - use Debugger.stepInto +// with breakOnAsyncCall and Debugger.pauseOnAsyncTask instead. Steps into next +// scheduled async task if any is scheduled before next pause. Returns success +// when async task is actually scheduled, returns error if no task were +// scheduled or another scheduleStepIntoAsync was called. +func ScheduleStepIntoAsync() *ScheduleStepIntoAsyncParams { + return &ScheduleStepIntoAsyncParams{} +} + +// Do executes Debugger.scheduleStepIntoAsync against the provided context and +// target handler. +func (p *ScheduleStepIntoAsyncParams) Do(ctxt context.Context, h cdp.Handler) (err error) { + return h.Execute(ctxt, cdp.CommandDebuggerScheduleStepIntoAsync, nil, nil) +} + +// SearchInContentParams searches for given string in script content. +type SearchInContentParams struct { + ScriptID runtime.ScriptID `json:"scriptId"` // Id of the script to search in. + Query string `json:"query"` // String to search for. + CaseSensitive bool `json:"caseSensitive,omitempty"` // If true, search is case sensitive. + IsRegex bool `json:"isRegex,omitempty"` // If true, treats string parameter as regex. +} + +// SearchInContent searches for given string in script content. +// +// parameters: +// scriptID - Id of the script to search in. +// query - String to search for. +func SearchInContent(scriptID runtime.ScriptID, query string) *SearchInContentParams { + return &SearchInContentParams{ + ScriptID: scriptID, + Query: query, + } +} + +// WithCaseSensitive if true, search is case sensitive. +func (p SearchInContentParams) WithCaseSensitive(caseSensitive bool) *SearchInContentParams { + p.CaseSensitive = caseSensitive + return &p +} + +// WithIsRegex if true, treats string parameter as regex. +func (p SearchInContentParams) WithIsRegex(isRegex bool) *SearchInContentParams { + p.IsRegex = isRegex + return &p +} + +// SearchInContentReturns return values. +type SearchInContentReturns struct { + Result []*SearchMatch `json:"result,omitempty"` // List of search matches. +} + +// Do executes Debugger.searchInContent against the provided context and +// target handler. +// +// returns: +// result - List of search matches. +func (p *SearchInContentParams) Do(ctxt context.Context, h cdp.Handler) (result []*SearchMatch, err error) { + // execute + var res SearchInContentReturns + err = h.Execute(ctxt, cdp.CommandDebuggerSearchInContent, p, &res) + if err != nil { + return nil, err + } + + return res.Result, nil } // SetAsyncCallStackDepthParams enables or disables async call stacks @@ -936,3 +571,368 @@ func SetBlackboxedRanges(scriptID runtime.ScriptID, positions []*ScriptPosition) func (p *SetBlackboxedRangesParams) Do(ctxt context.Context, h cdp.Handler) (err error) { return h.Execute(ctxt, cdp.CommandDebuggerSetBlackboxedRanges, p, nil) } + +// SetBreakpointParams sets JavaScript breakpoint at a given location. +type SetBreakpointParams struct { + Location *Location `json:"location"` // Location to set breakpoint in. + Condition string `json:"condition,omitempty"` // Expression to use as a breakpoint condition. When specified, debugger will only stop on the breakpoint if this expression evaluates to true. +} + +// SetBreakpoint sets JavaScript breakpoint at a given location. +// +// parameters: +// location - Location to set breakpoint in. +func SetBreakpoint(location *Location) *SetBreakpointParams { + return &SetBreakpointParams{ + Location: location, + } +} + +// WithCondition expression to use as a breakpoint condition. When specified, +// debugger will only stop on the breakpoint if this expression evaluates to +// true. +func (p SetBreakpointParams) WithCondition(condition string) *SetBreakpointParams { + p.Condition = condition + return &p +} + +// SetBreakpointReturns return values. +type SetBreakpointReturns struct { + BreakpointID BreakpointID `json:"breakpointId,omitempty"` // Id of the created breakpoint for further reference. + ActualLocation *Location `json:"actualLocation,omitempty"` // Location this breakpoint resolved into. +} + +// Do executes Debugger.setBreakpoint against the provided context and +// target handler. +// +// returns: +// breakpointID - Id of the created breakpoint for further reference. +// actualLocation - Location this breakpoint resolved into. +func (p *SetBreakpointParams) Do(ctxt context.Context, h cdp.Handler) (breakpointID BreakpointID, actualLocation *Location, err error) { + // execute + var res SetBreakpointReturns + err = h.Execute(ctxt, cdp.CommandDebuggerSetBreakpoint, p, &res) + if err != nil { + return "", nil, err + } + + return res.BreakpointID, res.ActualLocation, nil +} + +// SetBreakpointByURLParams sets JavaScript breakpoint at given location +// specified either by URL or URL regex. Once this command is issued, all +// existing parsed scripts will have breakpoints resolved and returned in +// locations property. Further matching script parsing will result in subsequent +// breakpointResolved events issued. This logical breakpoint will survive page +// reloads. +type SetBreakpointByURLParams struct { + LineNumber int64 `json:"lineNumber"` // Line number to set breakpoint at. + URL string `json:"url,omitempty"` // URL of the resources to set breakpoint on. + URLRegex string `json:"urlRegex,omitempty"` // Regex pattern for the URLs of the resources to set breakpoints on. Either url or urlRegex must be specified. + ScriptHash string `json:"scriptHash,omitempty"` // Script hash of the resources to set breakpoint on. + ColumnNumber int64 `json:"columnNumber,omitempty"` // Offset in the line to set breakpoint at. + Condition string `json:"condition,omitempty"` // Expression to use as a breakpoint condition. When specified, debugger will only stop on the breakpoint if this expression evaluates to true. +} + +// SetBreakpointByURL sets JavaScript breakpoint at given location specified +// either by URL or URL regex. Once this command is issued, all existing parsed +// scripts will have breakpoints resolved and returned in locations property. +// Further matching script parsing will result in subsequent breakpointResolved +// events issued. This logical breakpoint will survive page reloads. +// +// parameters: +// lineNumber - Line number to set breakpoint at. +func SetBreakpointByURL(lineNumber int64) *SetBreakpointByURLParams { + return &SetBreakpointByURLParams{ + LineNumber: lineNumber, + } +} + +// WithURL URL of the resources to set breakpoint on. +func (p SetBreakpointByURLParams) WithURL(url string) *SetBreakpointByURLParams { + p.URL = url + return &p +} + +// WithURLRegex regex pattern for the URLs of the resources to set +// breakpoints on. Either url or urlRegex must be specified. +func (p SetBreakpointByURLParams) WithURLRegex(urlRegex string) *SetBreakpointByURLParams { + p.URLRegex = urlRegex + return &p +} + +// WithScriptHash script hash of the resources to set breakpoint on. +func (p SetBreakpointByURLParams) WithScriptHash(scriptHash string) *SetBreakpointByURLParams { + p.ScriptHash = scriptHash + return &p +} + +// WithColumnNumber offset in the line to set breakpoint at. +func (p SetBreakpointByURLParams) WithColumnNumber(columnNumber int64) *SetBreakpointByURLParams { + p.ColumnNumber = columnNumber + return &p +} + +// WithCondition expression to use as a breakpoint condition. When specified, +// debugger will only stop on the breakpoint if this expression evaluates to +// true. +func (p SetBreakpointByURLParams) WithCondition(condition string) *SetBreakpointByURLParams { + p.Condition = condition + return &p +} + +// SetBreakpointByURLReturns return values. +type SetBreakpointByURLReturns struct { + BreakpointID BreakpointID `json:"breakpointId,omitempty"` // Id of the created breakpoint for further reference. + Locations []*Location `json:"locations,omitempty"` // List of the locations this breakpoint resolved into upon addition. +} + +// Do executes Debugger.setBreakpointByUrl against the provided context and +// target handler. +// +// returns: +// breakpointID - Id of the created breakpoint for further reference. +// locations - List of the locations this breakpoint resolved into upon addition. +func (p *SetBreakpointByURLParams) Do(ctxt context.Context, h cdp.Handler) (breakpointID BreakpointID, locations []*Location, err error) { + // execute + var res SetBreakpointByURLReturns + err = h.Execute(ctxt, cdp.CommandDebuggerSetBreakpointByURL, p, &res) + if err != nil { + return "", nil, err + } + + return res.BreakpointID, res.Locations, nil +} + +// SetBreakpointsActiveParams activates / deactivates all breakpoints on the +// page. +type SetBreakpointsActiveParams struct { + Active bool `json:"active"` // New value for breakpoints active state. +} + +// SetBreakpointsActive activates / deactivates all breakpoints on the page. +// +// parameters: +// active - New value for breakpoints active state. +func SetBreakpointsActive(active bool) *SetBreakpointsActiveParams { + return &SetBreakpointsActiveParams{ + Active: active, + } +} + +// Do executes Debugger.setBreakpointsActive against the provided context and +// target handler. +func (p *SetBreakpointsActiveParams) Do(ctxt context.Context, h cdp.Handler) (err error) { + return h.Execute(ctxt, cdp.CommandDebuggerSetBreakpointsActive, p, nil) +} + +// SetPauseOnExceptionsParams defines pause on exceptions state. Can be set +// to stop on all exceptions, uncaught exceptions or no exceptions. Initial +// pause on exceptions state is none. +type SetPauseOnExceptionsParams struct { + State ExceptionsState `json:"state"` // Pause on exceptions mode. +} + +// SetPauseOnExceptions defines pause on exceptions state. Can be set to stop +// on all exceptions, uncaught exceptions or no exceptions. Initial pause on +// exceptions state is none. +// +// parameters: +// state - Pause on exceptions mode. +func SetPauseOnExceptions(state ExceptionsState) *SetPauseOnExceptionsParams { + return &SetPauseOnExceptionsParams{ + State: state, + } +} + +// Do executes Debugger.setPauseOnExceptions against the provided context and +// target handler. +func (p *SetPauseOnExceptionsParams) Do(ctxt context.Context, h cdp.Handler) (err error) { + return h.Execute(ctxt, cdp.CommandDebuggerSetPauseOnExceptions, p, nil) +} + +// SetReturnValueParams changes return value in top frame. Available only at +// return break position. +type SetReturnValueParams struct { + NewValue *runtime.CallArgument `json:"newValue"` // New return value. +} + +// SetReturnValue changes return value in top frame. Available only at return +// break position. +// +// parameters: +// newValue - New return value. +func SetReturnValue(newValue *runtime.CallArgument) *SetReturnValueParams { + return &SetReturnValueParams{ + NewValue: newValue, + } +} + +// Do executes Debugger.setReturnValue against the provided context and +// target handler. +func (p *SetReturnValueParams) Do(ctxt context.Context, h cdp.Handler) (err error) { + return h.Execute(ctxt, cdp.CommandDebuggerSetReturnValue, p, nil) +} + +// SetScriptSourceParams edits JavaScript source live. +type SetScriptSourceParams struct { + ScriptID runtime.ScriptID `json:"scriptId"` // Id of the script to edit. + ScriptSource string `json:"scriptSource"` // New content of the script. + DryRun bool `json:"dryRun,omitempty"` // If true the change will not actually be applied. Dry run may be used to get result description without actually modifying the code. +} + +// SetScriptSource edits JavaScript source live. +// +// parameters: +// scriptID - Id of the script to edit. +// scriptSource - New content of the script. +func SetScriptSource(scriptID runtime.ScriptID, scriptSource string) *SetScriptSourceParams { + return &SetScriptSourceParams{ + ScriptID: scriptID, + ScriptSource: scriptSource, + } +} + +// WithDryRun if true the change will not actually be applied. Dry run may be +// used to get result description without actually modifying the code. +func (p SetScriptSourceParams) WithDryRun(dryRun bool) *SetScriptSourceParams { + p.DryRun = dryRun + return &p +} + +// SetScriptSourceReturns return values. +type SetScriptSourceReturns struct { + CallFrames []*CallFrame `json:"callFrames,omitempty"` // New stack trace in case editing has happened while VM was stopped. + StackChanged bool `json:"stackChanged,omitempty"` // Whether current call stack was modified after applying the changes. + AsyncStackTrace *runtime.StackTrace `json:"asyncStackTrace,omitempty"` // Async stack trace, if any. + AsyncStackTraceID *runtime.StackTraceID `json:"asyncStackTraceId,omitempty"` // Async stack trace, if any. + ExceptionDetails *runtime.ExceptionDetails `json:"exceptionDetails,omitempty"` // Exception details if any. +} + +// Do executes Debugger.setScriptSource against the provided context and +// target handler. +// +// returns: +// callFrames - New stack trace in case editing has happened while VM was stopped. +// stackChanged - Whether current call stack was modified after applying the changes. +// asyncStackTrace - Async stack trace, if any. +// asyncStackTraceID - Async stack trace, if any. +// exceptionDetails - Exception details if any. +func (p *SetScriptSourceParams) Do(ctxt context.Context, h cdp.Handler) (callFrames []*CallFrame, stackChanged bool, asyncStackTrace *runtime.StackTrace, asyncStackTraceID *runtime.StackTraceID, exceptionDetails *runtime.ExceptionDetails, err error) { + // execute + var res SetScriptSourceReturns + err = h.Execute(ctxt, cdp.CommandDebuggerSetScriptSource, p, &res) + if err != nil { + return nil, false, nil, nil, nil, err + } + + return res.CallFrames, res.StackChanged, res.AsyncStackTrace, res.AsyncStackTraceID, res.ExceptionDetails, nil +} + +// SetSkipAllPausesParams makes page not interrupt on any pauses (breakpoint, +// exception, dom exception etc). +type SetSkipAllPausesParams struct { + Skip bool `json:"skip"` // New value for skip pauses state. +} + +// SetSkipAllPauses makes page not interrupt on any pauses (breakpoint, +// exception, dom exception etc). +// +// parameters: +// skip - New value for skip pauses state. +func SetSkipAllPauses(skip bool) *SetSkipAllPausesParams { + return &SetSkipAllPausesParams{ + Skip: skip, + } +} + +// Do executes Debugger.setSkipAllPauses against the provided context and +// target handler. +func (p *SetSkipAllPausesParams) Do(ctxt context.Context, h cdp.Handler) (err error) { + return h.Execute(ctxt, cdp.CommandDebuggerSetSkipAllPauses, p, nil) +} + +// SetVariableValueParams changes value of variable in a callframe. +// Object-based scopes are not supported and must be mutated manually. +type SetVariableValueParams struct { + ScopeNumber int64 `json:"scopeNumber"` // 0-based number of scope as was listed in scope chain. Only 'local', 'closure' and 'catch' scope types are allowed. Other scopes could be manipulated manually. + VariableName string `json:"variableName"` // Variable name. + NewValue *runtime.CallArgument `json:"newValue"` // New variable value. + CallFrameID CallFrameID `json:"callFrameId"` // Id of callframe that holds variable. +} + +// SetVariableValue changes value of variable in a callframe. Object-based +// scopes are not supported and must be mutated manually. +// +// parameters: +// scopeNumber - 0-based number of scope as was listed in scope chain. Only 'local', 'closure' and 'catch' scope types are allowed. Other scopes could be manipulated manually. +// variableName - Variable name. +// newValue - New variable value. +// callFrameID - Id of callframe that holds variable. +func SetVariableValue(scopeNumber int64, variableName string, newValue *runtime.CallArgument, callFrameID CallFrameID) *SetVariableValueParams { + return &SetVariableValueParams{ + ScopeNumber: scopeNumber, + VariableName: variableName, + NewValue: newValue, + CallFrameID: callFrameID, + } +} + +// Do executes Debugger.setVariableValue against the provided context and +// target handler. +func (p *SetVariableValueParams) Do(ctxt context.Context, h cdp.Handler) (err error) { + return h.Execute(ctxt, cdp.CommandDebuggerSetVariableValue, p, nil) +} + +// StepIntoParams steps into the function call. +type StepIntoParams struct { + BreakOnAsyncCall bool `json:"breakOnAsyncCall,omitempty"` // Debugger will issue additional Debugger.paused notification if any async task is scheduled before next pause. +} + +// StepInto steps into the function call. +// +// parameters: +func StepInto() *StepIntoParams { + return &StepIntoParams{} +} + +// WithBreakOnAsyncCall debugger will issue additional Debugger.paused +// notification if any async task is scheduled before next pause. +func (p StepIntoParams) WithBreakOnAsyncCall(breakOnAsyncCall bool) *StepIntoParams { + p.BreakOnAsyncCall = breakOnAsyncCall + return &p +} + +// Do executes Debugger.stepInto against the provided context and +// target handler. +func (p *StepIntoParams) Do(ctxt context.Context, h cdp.Handler) (err error) { + return h.Execute(ctxt, cdp.CommandDebuggerStepInto, p, nil) +} + +// StepOutParams steps out of the function call. +type StepOutParams struct{} + +// StepOut steps out of the function call. +func StepOut() *StepOutParams { + return &StepOutParams{} +} + +// Do executes Debugger.stepOut against the provided context and +// target handler. +func (p *StepOutParams) Do(ctxt context.Context, h cdp.Handler) (err error) { + return h.Execute(ctxt, cdp.CommandDebuggerStepOut, nil, nil) +} + +// StepOverParams steps over the statement. +type StepOverParams struct{} + +// StepOver steps over the statement. +func StepOver() *StepOverParams { + return &StepOverParams{} +} + +// Do executes Debugger.stepOver against the provided context and +// target handler. +func (p *StepOverParams) Do(ctxt context.Context, h cdp.Handler) (err error) { + return h.Execute(ctxt, cdp.CommandDebuggerStepOver, nil, nil) +} diff --git a/cdp/debugger/events.go b/cdp/debugger/events.go index 1674d80..3f675ef 100644 --- a/cdp/debugger/events.go +++ b/cdp/debugger/events.go @@ -8,45 +8,6 @@ import ( "github.com/mailru/easyjson" ) -// EventScriptParsed fired when virtual machine parses script. This event is -// also fired for all known and uncollected scripts upon enabling debugger. -type EventScriptParsed struct { - ScriptID runtime.ScriptID `json:"scriptId"` // Identifier of the script parsed. - URL string `json:"url"` // URL or name of the script parsed (if any). - StartLine int64 `json:"startLine"` // Line offset of the script within the resource with given URL (for script tags). - StartColumn int64 `json:"startColumn"` // Column offset of the script within the resource with given URL. - EndLine int64 `json:"endLine"` // Last line of the script. - EndColumn int64 `json:"endColumn"` // Length of the last line of the script. - ExecutionContextID runtime.ExecutionContextID `json:"executionContextId"` // Specifies script creation context. - Hash string `json:"hash"` // Content hash of the script. - ExecutionContextAuxData easyjson.RawMessage `json:"executionContextAuxData,omitempty"` - IsLiveEdit bool `json:"isLiveEdit,omitempty"` // True, if this script is generated as a result of the live edit operation. - SourceMapURL string `json:"sourceMapURL,omitempty"` // URL of source map associated with script (if any). - HasSourceURL bool `json:"hasSourceURL,omitempty"` // True, if this script has sourceURL. - IsModule bool `json:"isModule,omitempty"` // True, if this script is ES6 module. - Length int64 `json:"length,omitempty"` // This script length. - StackTrace *runtime.StackTrace `json:"stackTrace,omitempty"` // JavaScript top stack frame of where the script parsed event was triggered if available. -} - -// EventScriptFailedToParse fired when virtual machine fails to parse the -// script. -type EventScriptFailedToParse struct { - ScriptID runtime.ScriptID `json:"scriptId"` // Identifier of the script parsed. - URL string `json:"url"` // URL or name of the script parsed (if any). - StartLine int64 `json:"startLine"` // Line offset of the script within the resource with given URL (for script tags). - StartColumn int64 `json:"startColumn"` // Column offset of the script within the resource with given URL. - EndLine int64 `json:"endLine"` // Last line of the script. - EndColumn int64 `json:"endColumn"` // Length of the last line of the script. - ExecutionContextID runtime.ExecutionContextID `json:"executionContextId"` // Specifies script creation context. - Hash string `json:"hash"` // Content hash of the script. - ExecutionContextAuxData easyjson.RawMessage `json:"executionContextAuxData,omitempty"` - SourceMapURL string `json:"sourceMapURL,omitempty"` // URL of source map associated with script (if any). - HasSourceURL bool `json:"hasSourceURL,omitempty"` // True, if this script has sourceURL. - IsModule bool `json:"isModule,omitempty"` // True, if this script is ES6 module. - Length int64 `json:"length,omitempty"` // This script length. - StackTrace *runtime.StackTrace `json:"stackTrace,omitempty"` // JavaScript top stack frame of where the script parsed event was triggered if available. -} - // EventBreakpointResolved fired when breakpoint is resolved to an actual // script and location. type EventBreakpointResolved struct { @@ -69,11 +30,50 @@ type EventPaused struct { // EventResumed fired when the virtual machine resumed execution. type EventResumed struct{} +// EventScriptFailedToParse fired when virtual machine fails to parse the +// script. +type EventScriptFailedToParse struct { + ScriptID runtime.ScriptID `json:"scriptId"` // Identifier of the script parsed. + URL string `json:"url"` // URL or name of the script parsed (if any). + StartLine int64 `json:"startLine"` // Line offset of the script within the resource with given URL (for script tags). + StartColumn int64 `json:"startColumn"` // Column offset of the script within the resource with given URL. + EndLine int64 `json:"endLine"` // Last line of the script. + EndColumn int64 `json:"endColumn"` // Length of the last line of the script. + ExecutionContextID runtime.ExecutionContextID `json:"executionContextId"` // Specifies script creation context. + Hash string `json:"hash"` // Content hash of the script. + ExecutionContextAuxData easyjson.RawMessage `json:"executionContextAuxData,omitempty"` + SourceMapURL string `json:"sourceMapURL,omitempty"` // URL of source map associated with script (if any). + HasSourceURL bool `json:"hasSourceURL,omitempty"` // True, if this script has sourceURL. + IsModule bool `json:"isModule,omitempty"` // True, if this script is ES6 module. + Length int64 `json:"length,omitempty"` // This script length. + StackTrace *runtime.StackTrace `json:"stackTrace,omitempty"` // JavaScript top stack frame of where the script parsed event was triggered if available. +} + +// EventScriptParsed fired when virtual machine parses script. This event is +// also fired for all known and uncollected scripts upon enabling debugger. +type EventScriptParsed struct { + ScriptID runtime.ScriptID `json:"scriptId"` // Identifier of the script parsed. + URL string `json:"url"` // URL or name of the script parsed (if any). + StartLine int64 `json:"startLine"` // Line offset of the script within the resource with given URL (for script tags). + StartColumn int64 `json:"startColumn"` // Column offset of the script within the resource with given URL. + EndLine int64 `json:"endLine"` // Last line of the script. + EndColumn int64 `json:"endColumn"` // Length of the last line of the script. + ExecutionContextID runtime.ExecutionContextID `json:"executionContextId"` // Specifies script creation context. + Hash string `json:"hash"` // Content hash of the script. + ExecutionContextAuxData easyjson.RawMessage `json:"executionContextAuxData,omitempty"` + IsLiveEdit bool `json:"isLiveEdit,omitempty"` // True, if this script is generated as a result of the live edit operation. + SourceMapURL string `json:"sourceMapURL,omitempty"` // URL of source map associated with script (if any). + HasSourceURL bool `json:"hasSourceURL,omitempty"` // True, if this script has sourceURL. + IsModule bool `json:"isModule,omitempty"` // True, if this script is ES6 module. + Length int64 `json:"length,omitempty"` // This script length. + StackTrace *runtime.StackTrace `json:"stackTrace,omitempty"` // JavaScript top stack frame of where the script parsed event was triggered if available. +} + // EventTypes all event types in the domain. var EventTypes = []cdp.MethodType{ - cdp.EventDebuggerScriptParsed, - cdp.EventDebuggerScriptFailedToParse, cdp.EventDebuggerBreakpointResolved, cdp.EventDebuggerPaused, cdp.EventDebuggerResumed, + cdp.EventDebuggerScriptFailedToParse, + cdp.EventDebuggerScriptParsed, } diff --git a/cdp/deviceorientation/deviceorientation.go b/cdp/deviceorientation/deviceorientation.go index a3ed876..febb6ac 100644 --- a/cdp/deviceorientation/deviceorientation.go +++ b/cdp/deviceorientation/deviceorientation.go @@ -12,6 +12,21 @@ import ( cdp "github.com/knq/chromedp/cdp" ) +// ClearDeviceOrientationOverrideParams clears the overridden Device +// Orientation. +type ClearDeviceOrientationOverrideParams struct{} + +// ClearDeviceOrientationOverride clears the overridden Device Orientation. +func ClearDeviceOrientationOverride() *ClearDeviceOrientationOverrideParams { + return &ClearDeviceOrientationOverrideParams{} +} + +// Do executes DeviceOrientation.clearDeviceOrientationOverride against the provided context and +// target handler. +func (p *ClearDeviceOrientationOverrideParams) Do(ctxt context.Context, h cdp.Handler) (err error) { + return h.Execute(ctxt, cdp.CommandDeviceOrientationClearDeviceOrientationOverride, nil, nil) +} + // SetDeviceOrientationOverrideParams overrides the Device Orientation. type SetDeviceOrientationOverrideParams struct { Alpha float64 `json:"alpha"` // Mock alpha @@ -38,18 +53,3 @@ func SetDeviceOrientationOverride(alpha float64, beta float64, gamma float64) *S func (p *SetDeviceOrientationOverrideParams) Do(ctxt context.Context, h cdp.Handler) (err error) { return h.Execute(ctxt, cdp.CommandDeviceOrientationSetDeviceOrientationOverride, p, nil) } - -// ClearDeviceOrientationOverrideParams clears the overridden Device -// Orientation. -type ClearDeviceOrientationOverrideParams struct{} - -// ClearDeviceOrientationOverride clears the overridden Device Orientation. -func ClearDeviceOrientationOverride() *ClearDeviceOrientationOverrideParams { - return &ClearDeviceOrientationOverrideParams{} -} - -// Do executes DeviceOrientation.clearDeviceOrientationOverride against the provided context and -// target handler. -func (p *ClearDeviceOrientationOverrideParams) Do(ctxt context.Context, h cdp.Handler) (err error) { - return h.Execute(ctxt, cdp.CommandDeviceOrientationClearDeviceOrientationOverride, nil, nil) -} diff --git a/cdp/dom/dom.go b/cdp/dom/dom.go index e8d87bc..8b9532f 100644 --- a/cdp/dom/dom.go +++ b/cdp/dom/dom.go @@ -23,18 +23,163 @@ import ( "github.com/knq/chromedp/cdp/runtime" ) -// EnableParams enables DOM agent for the given page. -type EnableParams struct{} - -// Enable enables DOM agent for the given page. -func Enable() *EnableParams { - return &EnableParams{} +// CollectClassNamesFromSubtreeParams collects class names for the node with +// given id and all of it's child nodes. +type CollectClassNamesFromSubtreeParams struct { + NodeID cdp.NodeID `json:"nodeId"` // Id of the node to collect class names. } -// Do executes DOM.enable against the provided context and +// CollectClassNamesFromSubtree collects class names for the node with given +// id and all of it's child nodes. +// +// parameters: +// nodeID - Id of the node to collect class names. +func CollectClassNamesFromSubtree(nodeID cdp.NodeID) *CollectClassNamesFromSubtreeParams { + return &CollectClassNamesFromSubtreeParams{ + NodeID: nodeID, + } +} + +// CollectClassNamesFromSubtreeReturns return values. +type CollectClassNamesFromSubtreeReturns struct { + ClassNames []string `json:"classNames,omitempty"` // Class name list. +} + +// Do executes DOM.collectClassNamesFromSubtree against the provided context and // target handler. -func (p *EnableParams) Do(ctxt context.Context, h cdp.Handler) (err error) { - return h.Execute(ctxt, cdp.CommandDOMEnable, nil, nil) +// +// returns: +// classNames - Class name list. +func (p *CollectClassNamesFromSubtreeParams) Do(ctxt context.Context, h cdp.Handler) (classNames []string, err error) { + // execute + var res CollectClassNamesFromSubtreeReturns + err = h.Execute(ctxt, cdp.CommandDOMCollectClassNamesFromSubtree, p, &res) + if err != nil { + return nil, err + } + + return res.ClassNames, nil +} + +// CopyToParams creates a deep copy of the specified node and places it into +// the target container before the given anchor. +type CopyToParams struct { + NodeID cdp.NodeID `json:"nodeId"` // Id of the node to copy. + TargetNodeID cdp.NodeID `json:"targetNodeId"` // Id of the element to drop the copy into. + InsertBeforeNodeID cdp.NodeID `json:"insertBeforeNodeId,omitempty"` // Drop the copy before this node (if absent, the copy becomes the last child of targetNodeId). +} + +// CopyTo creates a deep copy of the specified node and places it into the +// target container before the given anchor. +// +// parameters: +// nodeID - Id of the node to copy. +// targetNodeID - Id of the element to drop the copy into. +func CopyTo(nodeID cdp.NodeID, targetNodeID cdp.NodeID) *CopyToParams { + return &CopyToParams{ + NodeID: nodeID, + TargetNodeID: targetNodeID, + } +} + +// WithInsertBeforeNodeID drop the copy before this node (if absent, the copy +// becomes the last child of targetNodeId). +func (p CopyToParams) WithInsertBeforeNodeID(insertBeforeNodeID cdp.NodeID) *CopyToParams { + p.InsertBeforeNodeID = insertBeforeNodeID + return &p +} + +// CopyToReturns return values. +type CopyToReturns struct { + NodeID cdp.NodeID `json:"nodeId,omitempty"` // Id of the node clone. +} + +// Do executes DOM.copyTo against the provided context and +// target handler. +// +// returns: +// nodeID - Id of the node clone. +func (p *CopyToParams) Do(ctxt context.Context, h cdp.Handler) (nodeID cdp.NodeID, err error) { + // execute + var res CopyToReturns + err = h.Execute(ctxt, cdp.CommandDOMCopyTo, p, &res) + if err != nil { + return 0, err + } + + return res.NodeID, nil +} + +// DescribeNodeParams describes node given its id, does not require domain to +// be enabled. Does not start tracking any objects, can be used for automation. +type DescribeNodeParams struct { + NodeID cdp.NodeID `json:"nodeId,omitempty"` // Identifier of the node. + BackendNodeID cdp.BackendNodeID `json:"backendNodeId,omitempty"` // Identifier of the backend node. + ObjectID runtime.RemoteObjectID `json:"objectId,omitempty"` // JavaScript object id of the node wrapper. + Depth int64 `json:"depth,omitempty"` // The maximum depth at which children should be retrieved, defaults to 1. Use -1 for the entire subtree or provide an integer larger than 0. + Pierce bool `json:"pierce,omitempty"` // Whether or not iframes and shadow roots should be traversed when returning the subtree (default is false). +} + +// DescribeNode describes node given its id, does not require domain to be +// enabled. Does not start tracking any objects, can be used for automation. +// +// parameters: +func DescribeNode() *DescribeNodeParams { + return &DescribeNodeParams{} +} + +// WithNodeID identifier of the node. +func (p DescribeNodeParams) WithNodeID(nodeID cdp.NodeID) *DescribeNodeParams { + p.NodeID = nodeID + return &p +} + +// WithBackendNodeID identifier of the backend node. +func (p DescribeNodeParams) WithBackendNodeID(backendNodeID cdp.BackendNodeID) *DescribeNodeParams { + p.BackendNodeID = backendNodeID + return &p +} + +// WithObjectID JavaScript object id of the node wrapper. +func (p DescribeNodeParams) WithObjectID(objectID runtime.RemoteObjectID) *DescribeNodeParams { + p.ObjectID = objectID + return &p +} + +// WithDepth the maximum depth at which children should be retrieved, +// defaults to 1. Use -1 for the entire subtree or provide an integer larger +// than 0. +func (p DescribeNodeParams) WithDepth(depth int64) *DescribeNodeParams { + p.Depth = depth + return &p +} + +// WithPierce whether or not iframes and shadow roots should be traversed +// when returning the subtree (default is false). +func (p DescribeNodeParams) WithPierce(pierce bool) *DescribeNodeParams { + p.Pierce = pierce + return &p +} + +// DescribeNodeReturns return values. +type DescribeNodeReturns struct { + Node *cdp.Node `json:"node,omitempty"` // Node description. +} + +// Do executes DOM.describeNode against the provided context and +// target handler. +// +// returns: +// node - Node description. +func (p *DescribeNodeParams) Do(ctxt context.Context, h cdp.Handler) (node *cdp.Node, err error) { + // execute + var res DescribeNodeReturns + err = h.Execute(ctxt, cdp.CommandDOMDescribeNode, p, &res) + if err != nil { + return nil, err + } + + return res.Node, nil } // DisableParams disables DOM agent for the given page. @@ -51,6 +196,170 @@ func (p *DisableParams) Do(ctxt context.Context, h cdp.Handler) (err error) { return h.Execute(ctxt, cdp.CommandDOMDisable, nil, nil) } +// DiscardSearchResultsParams discards search results from the session with +// the given id. getSearchResults should no longer be called for that search. +type DiscardSearchResultsParams struct { + SearchID string `json:"searchId"` // Unique search session identifier. +} + +// DiscardSearchResults discards search results from the session with the +// given id. getSearchResults should no longer be called for that search. +// +// parameters: +// searchID - Unique search session identifier. +func DiscardSearchResults(searchID string) *DiscardSearchResultsParams { + return &DiscardSearchResultsParams{ + SearchID: searchID, + } +} + +// Do executes DOM.discardSearchResults against the provided context and +// target handler. +func (p *DiscardSearchResultsParams) Do(ctxt context.Context, h cdp.Handler) (err error) { + return h.Execute(ctxt, cdp.CommandDOMDiscardSearchResults, p, nil) +} + +// EnableParams enables DOM agent for the given page. +type EnableParams struct{} + +// Enable enables DOM agent for the given page. +func Enable() *EnableParams { + return &EnableParams{} +} + +// Do executes DOM.enable against the provided context and +// target handler. +func (p *EnableParams) Do(ctxt context.Context, h cdp.Handler) (err error) { + return h.Execute(ctxt, cdp.CommandDOMEnable, nil, nil) +} + +// FocusParams focuses the given element. +type FocusParams struct { + NodeID cdp.NodeID `json:"nodeId,omitempty"` // Identifier of the node. + BackendNodeID cdp.BackendNodeID `json:"backendNodeId,omitempty"` // Identifier of the backend node. + ObjectID runtime.RemoteObjectID `json:"objectId,omitempty"` // JavaScript object id of the node wrapper. +} + +// Focus focuses the given element. +// +// parameters: +func Focus() *FocusParams { + return &FocusParams{} +} + +// WithNodeID identifier of the node. +func (p FocusParams) WithNodeID(nodeID cdp.NodeID) *FocusParams { + p.NodeID = nodeID + return &p +} + +// WithBackendNodeID identifier of the backend node. +func (p FocusParams) WithBackendNodeID(backendNodeID cdp.BackendNodeID) *FocusParams { + p.BackendNodeID = backendNodeID + return &p +} + +// WithObjectID JavaScript object id of the node wrapper. +func (p FocusParams) WithObjectID(objectID runtime.RemoteObjectID) *FocusParams { + p.ObjectID = objectID + return &p +} + +// Do executes DOM.focus against the provided context and +// target handler. +func (p *FocusParams) Do(ctxt context.Context, h cdp.Handler) (err error) { + return h.Execute(ctxt, cdp.CommandDOMFocus, p, nil) +} + +// GetAttributesParams returns attributes for the specified node. +type GetAttributesParams struct { + NodeID cdp.NodeID `json:"nodeId"` // Id of the node to retrieve attibutes for. +} + +// GetAttributes returns attributes for the specified node. +// +// parameters: +// nodeID - Id of the node to retrieve attibutes for. +func GetAttributes(nodeID cdp.NodeID) *GetAttributesParams { + return &GetAttributesParams{ + NodeID: nodeID, + } +} + +// GetAttributesReturns return values. +type GetAttributesReturns struct { + Attributes []string `json:"attributes,omitempty"` // An interleaved array of node attribute names and values. +} + +// Do executes DOM.getAttributes against the provided context and +// target handler. +// +// returns: +// attributes - An interleaved array of node attribute names and values. +func (p *GetAttributesParams) Do(ctxt context.Context, h cdp.Handler) (attributes []string, err error) { + // execute + var res GetAttributesReturns + err = h.Execute(ctxt, cdp.CommandDOMGetAttributes, p, &res) + if err != nil { + return nil, err + } + + return res.Attributes, nil +} + +// GetBoxModelParams returns boxes for the given node. +type GetBoxModelParams struct { + NodeID cdp.NodeID `json:"nodeId,omitempty"` // Identifier of the node. + BackendNodeID cdp.BackendNodeID `json:"backendNodeId,omitempty"` // Identifier of the backend node. + ObjectID runtime.RemoteObjectID `json:"objectId,omitempty"` // JavaScript object id of the node wrapper. +} + +// GetBoxModel returns boxes for the given node. +// +// parameters: +func GetBoxModel() *GetBoxModelParams { + return &GetBoxModelParams{} +} + +// WithNodeID identifier of the node. +func (p GetBoxModelParams) WithNodeID(nodeID cdp.NodeID) *GetBoxModelParams { + p.NodeID = nodeID + return &p +} + +// WithBackendNodeID identifier of the backend node. +func (p GetBoxModelParams) WithBackendNodeID(backendNodeID cdp.BackendNodeID) *GetBoxModelParams { + p.BackendNodeID = backendNodeID + return &p +} + +// WithObjectID JavaScript object id of the node wrapper. +func (p GetBoxModelParams) WithObjectID(objectID runtime.RemoteObjectID) *GetBoxModelParams { + p.ObjectID = objectID + return &p +} + +// GetBoxModelReturns return values. +type GetBoxModelReturns struct { + Model *BoxModel `json:"model,omitempty"` // Box model for the node. +} + +// Do executes DOM.getBoxModel against the provided context and +// target handler. +// +// returns: +// model - Box model for the node. +func (p *GetBoxModelParams) Do(ctxt context.Context, h cdp.Handler) (model *BoxModel, err error) { + // execute + var res GetBoxModelReturns + err = h.Execute(ctxt, cdp.CommandDOMGetBoxModel, p, &res) + if err != nil { + return nil, err + } + + return res.Model, nil +} + // GetDocumentParams returns the root DOM node (and optionally the subtree) // to the caller. type GetDocumentParams struct { @@ -153,86 +462,374 @@ func (p *GetFlattenedDocumentParams) Do(ctxt context.Context, h cdp.Handler) (no return res.Nodes, nil } -// CollectClassNamesFromSubtreeParams collects class names for the node with -// given id and all of it's child nodes. -type CollectClassNamesFromSubtreeParams struct { - NodeID cdp.NodeID `json:"nodeId"` // Id of the node to collect class names. +// GetNodeForLocationParams returns node id at given location. +type GetNodeForLocationParams struct { + X int64 `json:"x"` // X coordinate. + Y int64 `json:"y"` // Y coordinate. + IncludeUserAgentShadowDOM bool `json:"includeUserAgentShadowDOM,omitempty"` // False to skip to the nearest non-UA shadow root ancestor (default: false). } -// CollectClassNamesFromSubtree collects class names for the node with given -// id and all of it's child nodes. +// GetNodeForLocation returns node id at given location. // // parameters: -// nodeID - Id of the node to collect class names. -func CollectClassNamesFromSubtree(nodeID cdp.NodeID) *CollectClassNamesFromSubtreeParams { - return &CollectClassNamesFromSubtreeParams{ +// x - X coordinate. +// y - Y coordinate. +func GetNodeForLocation(x int64, y int64) *GetNodeForLocationParams { + return &GetNodeForLocationParams{ + X: x, + Y: y, + } +} + +// WithIncludeUserAgentShadowDOM false to skip to the nearest non-UA shadow +// root ancestor (default: false). +func (p GetNodeForLocationParams) WithIncludeUserAgentShadowDOM(includeUserAgentShadowDOM bool) *GetNodeForLocationParams { + p.IncludeUserAgentShadowDOM = includeUserAgentShadowDOM + return &p +} + +// GetNodeForLocationReturns return values. +type GetNodeForLocationReturns struct { + NodeID cdp.NodeID `json:"nodeId,omitempty"` // Id of the node at given coordinates. +} + +// Do executes DOM.getNodeForLocation against the provided context and +// target handler. +// +// returns: +// nodeID - Id of the node at given coordinates. +func (p *GetNodeForLocationParams) Do(ctxt context.Context, h cdp.Handler) (nodeID cdp.NodeID, err error) { + // execute + var res GetNodeForLocationReturns + err = h.Execute(ctxt, cdp.CommandDOMGetNodeForLocation, p, &res) + if err != nil { + return 0, err + } + + return res.NodeID, nil +} + +// GetOuterHTMLParams returns node's HTML markup. +type GetOuterHTMLParams struct { + NodeID cdp.NodeID `json:"nodeId,omitempty"` // Identifier of the node. + BackendNodeID cdp.BackendNodeID `json:"backendNodeId,omitempty"` // Identifier of the backend node. + ObjectID runtime.RemoteObjectID `json:"objectId,omitempty"` // JavaScript object id of the node wrapper. +} + +// GetOuterHTML returns node's HTML markup. +// +// parameters: +func GetOuterHTML() *GetOuterHTMLParams { + return &GetOuterHTMLParams{} +} + +// WithNodeID identifier of the node. +func (p GetOuterHTMLParams) WithNodeID(nodeID cdp.NodeID) *GetOuterHTMLParams { + p.NodeID = nodeID + return &p +} + +// WithBackendNodeID identifier of the backend node. +func (p GetOuterHTMLParams) WithBackendNodeID(backendNodeID cdp.BackendNodeID) *GetOuterHTMLParams { + p.BackendNodeID = backendNodeID + return &p +} + +// WithObjectID JavaScript object id of the node wrapper. +func (p GetOuterHTMLParams) WithObjectID(objectID runtime.RemoteObjectID) *GetOuterHTMLParams { + p.ObjectID = objectID + return &p +} + +// GetOuterHTMLReturns return values. +type GetOuterHTMLReturns struct { + OuterHTML string `json:"outerHTML,omitempty"` // Outer HTML markup. +} + +// Do executes DOM.getOuterHTML against the provided context and +// target handler. +// +// returns: +// outerHTML - Outer HTML markup. +func (p *GetOuterHTMLParams) Do(ctxt context.Context, h cdp.Handler) (outerHTML string, err error) { + // execute + var res GetOuterHTMLReturns + err = h.Execute(ctxt, cdp.CommandDOMGetOuterHTML, p, &res) + if err != nil { + return "", err + } + + return res.OuterHTML, nil +} + +// GetRelayoutBoundaryParams returns the id of the nearest ancestor that is a +// relayout boundary. +type GetRelayoutBoundaryParams struct { + NodeID cdp.NodeID `json:"nodeId"` // Id of the node. +} + +// GetRelayoutBoundary returns the id of the nearest ancestor that is a +// relayout boundary. +// +// parameters: +// nodeID - Id of the node. +func GetRelayoutBoundary(nodeID cdp.NodeID) *GetRelayoutBoundaryParams { + return &GetRelayoutBoundaryParams{ NodeID: nodeID, } } -// CollectClassNamesFromSubtreeReturns return values. -type CollectClassNamesFromSubtreeReturns struct { - ClassNames []string `json:"classNames,omitempty"` // Class name list. +// GetRelayoutBoundaryReturns return values. +type GetRelayoutBoundaryReturns struct { + NodeID cdp.NodeID `json:"nodeId,omitempty"` // Relayout boundary node id for the given node. } -// Do executes DOM.collectClassNamesFromSubtree against the provided context and +// Do executes DOM.getRelayoutBoundary against the provided context and // target handler. // // returns: -// classNames - Class name list. -func (p *CollectClassNamesFromSubtreeParams) Do(ctxt context.Context, h cdp.Handler) (classNames []string, err error) { +// nodeID - Relayout boundary node id for the given node. +func (p *GetRelayoutBoundaryParams) Do(ctxt context.Context, h cdp.Handler) (nodeID cdp.NodeID, err error) { // execute - var res CollectClassNamesFromSubtreeReturns - err = h.Execute(ctxt, cdp.CommandDOMCollectClassNamesFromSubtree, p, &res) + var res GetRelayoutBoundaryReturns + err = h.Execute(ctxt, cdp.CommandDOMGetRelayoutBoundary, p, &res) + if err != nil { + return 0, err + } + + return res.NodeID, nil +} + +// GetSearchResultsParams returns search results from given fromIndex to +// given toIndex from the search with the given identifier. +type GetSearchResultsParams struct { + SearchID string `json:"searchId"` // Unique search session identifier. + FromIndex int64 `json:"fromIndex"` // Start index of the search result to be returned. + ToIndex int64 `json:"toIndex"` // End index of the search result to be returned. +} + +// GetSearchResults returns search results from given fromIndex to given +// toIndex from the search with the given identifier. +// +// parameters: +// searchID - Unique search session identifier. +// fromIndex - Start index of the search result to be returned. +// toIndex - End index of the search result to be returned. +func GetSearchResults(searchID string, fromIndex int64, toIndex int64) *GetSearchResultsParams { + return &GetSearchResultsParams{ + SearchID: searchID, + FromIndex: fromIndex, + ToIndex: toIndex, + } +} + +// GetSearchResultsReturns return values. +type GetSearchResultsReturns struct { + NodeIds []cdp.NodeID `json:"nodeIds,omitempty"` // Ids of the search result nodes. +} + +// Do executes DOM.getSearchResults against the provided context and +// target handler. +// +// returns: +// nodeIds - Ids of the search result nodes. +func (p *GetSearchResultsParams) Do(ctxt context.Context, h cdp.Handler) (nodeIds []cdp.NodeID, err error) { + // execute + var res GetSearchResultsReturns + err = h.Execute(ctxt, cdp.CommandDOMGetSearchResults, p, &res) if err != nil { return nil, err } - return res.ClassNames, nil + return res.NodeIds, nil } -// RequestChildNodesParams requests that children of the node with given id -// are returned to the caller in form of setChildNodes events where not only -// immediate children are retrieved, but all children down to the specified -// depth. -type RequestChildNodesParams struct { - NodeID cdp.NodeID `json:"nodeId"` // Id of the node to get children for. - Depth int64 `json:"depth,omitempty"` // The maximum depth at which children should be retrieved, defaults to 1. Use -1 for the entire subtree or provide an integer larger than 0. - Pierce bool `json:"pierce,omitempty"` // Whether or not iframes and shadow roots should be traversed when returning the sub-tree (default is false). +// MarkUndoableStateParams marks last undoable state. +type MarkUndoableStateParams struct{} + +// MarkUndoableState marks last undoable state. +func MarkUndoableState() *MarkUndoableStateParams { + return &MarkUndoableStateParams{} } -// RequestChildNodes requests that children of the node with given id are -// returned to the caller in form of setChildNodes events where not only -// immediate children are retrieved, but all children down to the specified -// depth. +// Do executes DOM.markUndoableState against the provided context and +// target handler. +func (p *MarkUndoableStateParams) Do(ctxt context.Context, h cdp.Handler) (err error) { + return h.Execute(ctxt, cdp.CommandDOMMarkUndoableState, nil, nil) +} + +// MoveToParams moves node into the new container, places it before the given +// anchor. +type MoveToParams struct { + NodeID cdp.NodeID `json:"nodeId"` // Id of the node to move. + TargetNodeID cdp.NodeID `json:"targetNodeId"` // Id of the element to drop the moved node into. + InsertBeforeNodeID cdp.NodeID `json:"insertBeforeNodeId,omitempty"` // Drop node before this one (if absent, the moved node becomes the last child of targetNodeId). +} + +// MoveTo moves node into the new container, places it before the given +// anchor. // // parameters: -// nodeID - Id of the node to get children for. -func RequestChildNodes(nodeID cdp.NodeID) *RequestChildNodesParams { - return &RequestChildNodesParams{ - NodeID: nodeID, +// nodeID - Id of the node to move. +// targetNodeID - Id of the element to drop the moved node into. +func MoveTo(nodeID cdp.NodeID, targetNodeID cdp.NodeID) *MoveToParams { + return &MoveToParams{ + NodeID: nodeID, + TargetNodeID: targetNodeID, } } -// WithDepth the maximum depth at which children should be retrieved, -// defaults to 1. Use -1 for the entire subtree or provide an integer larger -// than 0. -func (p RequestChildNodesParams) WithDepth(depth int64) *RequestChildNodesParams { - p.Depth = depth +// WithInsertBeforeNodeID drop node before this one (if absent, the moved +// node becomes the last child of targetNodeId). +func (p MoveToParams) WithInsertBeforeNodeID(insertBeforeNodeID cdp.NodeID) *MoveToParams { + p.InsertBeforeNodeID = insertBeforeNodeID return &p } -// WithPierce whether or not iframes and shadow roots should be traversed -// when returning the sub-tree (default is false). -func (p RequestChildNodesParams) WithPierce(pierce bool) *RequestChildNodesParams { - p.Pierce = pierce - return &p +// MoveToReturns return values. +type MoveToReturns struct { + NodeID cdp.NodeID `json:"nodeId,omitempty"` // New id of the moved node. } -// Do executes DOM.requestChildNodes against the provided context and +// Do executes DOM.moveTo against the provided context and // target handler. -func (p *RequestChildNodesParams) Do(ctxt context.Context, h cdp.Handler) (err error) { - return h.Execute(ctxt, cdp.CommandDOMRequestChildNodes, p, nil) +// +// returns: +// nodeID - New id of the moved node. +func (p *MoveToParams) Do(ctxt context.Context, h cdp.Handler) (nodeID cdp.NodeID, err error) { + // execute + var res MoveToReturns + err = h.Execute(ctxt, cdp.CommandDOMMoveTo, p, &res) + if err != nil { + return 0, err + } + + return res.NodeID, nil +} + +// PerformSearchParams searches for a given string in the DOM tree. Use +// getSearchResults to access search results or cancelSearch to end this search +// session. +type PerformSearchParams struct { + Query string `json:"query"` // Plain text or query selector or XPath search query. + IncludeUserAgentShadowDOM bool `json:"includeUserAgentShadowDOM,omitempty"` // True to search in user agent shadow DOM. +} + +// PerformSearch searches for a given string in the DOM tree. Use +// getSearchResults to access search results or cancelSearch to end this search +// session. +// +// parameters: +// query - Plain text or query selector or XPath search query. +func PerformSearch(query string) *PerformSearchParams { + return &PerformSearchParams{ + Query: query, + } +} + +// WithIncludeUserAgentShadowDOM true to search in user agent shadow DOM. +func (p PerformSearchParams) WithIncludeUserAgentShadowDOM(includeUserAgentShadowDOM bool) *PerformSearchParams { + p.IncludeUserAgentShadowDOM = includeUserAgentShadowDOM + return &p +} + +// PerformSearchReturns return values. +type PerformSearchReturns struct { + SearchID string `json:"searchId,omitempty"` // Unique search session identifier. + ResultCount int64 `json:"resultCount,omitempty"` // Number of search results. +} + +// Do executes DOM.performSearch against the provided context and +// target handler. +// +// returns: +// searchID - Unique search session identifier. +// resultCount - Number of search results. +func (p *PerformSearchParams) Do(ctxt context.Context, h cdp.Handler) (searchID string, resultCount int64, err error) { + // execute + var res PerformSearchReturns + err = h.Execute(ctxt, cdp.CommandDOMPerformSearch, p, &res) + if err != nil { + return "", 0, err + } + + return res.SearchID, res.ResultCount, nil +} + +// PushNodeByPathToFrontendParams requests that the node is sent to the +// caller given its path. // FIXME, use XPath. +type PushNodeByPathToFrontendParams struct { + Path string `json:"path"` // Path to node in the proprietary format. +} + +// PushNodeByPathToFrontend requests that the node is sent to the caller +// given its path. // FIXME, use XPath. +// +// parameters: +// path - Path to node in the proprietary format. +func PushNodeByPathToFrontend(path string) *PushNodeByPathToFrontendParams { + return &PushNodeByPathToFrontendParams{ + Path: path, + } +} + +// PushNodeByPathToFrontendReturns return values. +type PushNodeByPathToFrontendReturns struct { + NodeID cdp.NodeID `json:"nodeId,omitempty"` // Id of the node for given path. +} + +// Do executes DOM.pushNodeByPathToFrontend against the provided context and +// target handler. +// +// returns: +// nodeID - Id of the node for given path. +func (p *PushNodeByPathToFrontendParams) Do(ctxt context.Context, h cdp.Handler) (nodeID cdp.NodeID, err error) { + // execute + var res PushNodeByPathToFrontendReturns + err = h.Execute(ctxt, cdp.CommandDOMPushNodeByPathToFrontend, p, &res) + if err != nil { + return 0, err + } + + return res.NodeID, nil +} + +// PushNodesByBackendIdsToFrontendParams requests that a batch of nodes is +// sent to the caller given their backend node ids. +type PushNodesByBackendIdsToFrontendParams struct { + BackendNodeIds []cdp.BackendNodeID `json:"backendNodeIds"` // The array of backend node ids. +} + +// PushNodesByBackendIdsToFrontend requests that a batch of nodes is sent to +// the caller given their backend node ids. +// +// parameters: +// backendNodeIds - The array of backend node ids. +func PushNodesByBackendIdsToFrontend(backendNodeIds []cdp.BackendNodeID) *PushNodesByBackendIdsToFrontendParams { + return &PushNodesByBackendIdsToFrontendParams{ + BackendNodeIds: backendNodeIds, + } +} + +// PushNodesByBackendIdsToFrontendReturns return values. +type PushNodesByBackendIdsToFrontendReturns struct { + NodeIds []cdp.NodeID `json:"nodeIds,omitempty"` // The array of ids of pushed nodes that correspond to the backend ids specified in backendNodeIds. +} + +// Do executes DOM.pushNodesByBackendIdsToFrontend against the provided context and +// target handler. +// +// returns: +// nodeIds - The array of ids of pushed nodes that correspond to the backend ids specified in backendNodeIds. +func (p *PushNodesByBackendIdsToFrontendParams) Do(ctxt context.Context, h cdp.Handler) (nodeIds []cdp.NodeID, err error) { + // execute + var res PushNodesByBackendIdsToFrontendReturns + err = h.Execute(ctxt, cdp.CommandDOMPushNodesByBackendIdsToFrontend, p, &res) + if err != nil { + return nil, err + } + + return res.NodeIds, nil } // QuerySelectorParams executes querySelector on a given node. @@ -313,67 +910,44 @@ func (p *QuerySelectorAllParams) Do(ctxt context.Context, h cdp.Handler) (nodeId return res.NodeIds, nil } -// SetNodeNameParams sets node name for a node with given id. -type SetNodeNameParams struct { - NodeID cdp.NodeID `json:"nodeId"` // Id of the node to set name for. - Name string `json:"name"` // New node's name. +// RedoParams re-does the last undone action. +type RedoParams struct{} + +// Redo re-does the last undone action. +func Redo() *RedoParams { + return &RedoParams{} } -// SetNodeName sets node name for a node with given id. +// Do executes DOM.redo against the provided context and +// target handler. +func (p *RedoParams) Do(ctxt context.Context, h cdp.Handler) (err error) { + return h.Execute(ctxt, cdp.CommandDOMRedo, nil, nil) +} + +// RemoveAttributeParams removes attribute with given name from an element +// with given id. +type RemoveAttributeParams struct { + NodeID cdp.NodeID `json:"nodeId"` // Id of the element to remove attribute from. + Name string `json:"name"` // Name of the attribute to remove. +} + +// RemoveAttribute removes attribute with given name from an element with +// given id. // // parameters: -// nodeID - Id of the node to set name for. -// name - New node's name. -func SetNodeName(nodeID cdp.NodeID, name string) *SetNodeNameParams { - return &SetNodeNameParams{ +// nodeID - Id of the element to remove attribute from. +// name - Name of the attribute to remove. +func RemoveAttribute(nodeID cdp.NodeID, name string) *RemoveAttributeParams { + return &RemoveAttributeParams{ NodeID: nodeID, Name: name, } } -// SetNodeNameReturns return values. -type SetNodeNameReturns struct { - NodeID cdp.NodeID `json:"nodeId,omitempty"` // New node's id. -} - -// Do executes DOM.setNodeName against the provided context and +// Do executes DOM.removeAttribute against the provided context and // target handler. -// -// returns: -// nodeID - New node's id. -func (p *SetNodeNameParams) Do(ctxt context.Context, h cdp.Handler) (nodeID cdp.NodeID, err error) { - // execute - var res SetNodeNameReturns - err = h.Execute(ctxt, cdp.CommandDOMSetNodeName, p, &res) - if err != nil { - return 0, err - } - - return res.NodeID, nil -} - -// SetNodeValueParams sets node value for a node with given id. -type SetNodeValueParams struct { - NodeID cdp.NodeID `json:"nodeId"` // Id of the node to set value for. - Value string `json:"value"` // New node's value. -} - -// SetNodeValue sets node value for a node with given id. -// -// parameters: -// nodeID - Id of the node to set value for. -// value - New node's value. -func SetNodeValue(nodeID cdp.NodeID, value string) *SetNodeValueParams { - return &SetNodeValueParams{ - NodeID: nodeID, - Value: value, - } -} - -// Do executes DOM.setNodeValue against the provided context and -// target handler. -func (p *SetNodeValueParams) Do(ctxt context.Context, h cdp.Handler) (err error) { - return h.Execute(ctxt, cdp.CommandDOMSetNodeValue, p, nil) +func (p *RemoveAttributeParams) Do(ctxt context.Context, h cdp.Handler) (err error) { + return h.Execute(ctxt, cdp.CommandDOMRemoveAttribute, p, nil) } // RemoveNodeParams removes node with given id. @@ -397,6 +971,148 @@ func (p *RemoveNodeParams) Do(ctxt context.Context, h cdp.Handler) (err error) { return h.Execute(ctxt, cdp.CommandDOMRemoveNode, p, nil) } +// RequestChildNodesParams requests that children of the node with given id +// are returned to the caller in form of setChildNodes events where not only +// immediate children are retrieved, but all children down to the specified +// depth. +type RequestChildNodesParams struct { + NodeID cdp.NodeID `json:"nodeId"` // Id of the node to get children for. + Depth int64 `json:"depth,omitempty"` // The maximum depth at which children should be retrieved, defaults to 1. Use -1 for the entire subtree or provide an integer larger than 0. + Pierce bool `json:"pierce,omitempty"` // Whether or not iframes and shadow roots should be traversed when returning the sub-tree (default is false). +} + +// RequestChildNodes requests that children of the node with given id are +// returned to the caller in form of setChildNodes events where not only +// immediate children are retrieved, but all children down to the specified +// depth. +// +// parameters: +// nodeID - Id of the node to get children for. +func RequestChildNodes(nodeID cdp.NodeID) *RequestChildNodesParams { + return &RequestChildNodesParams{ + NodeID: nodeID, + } +} + +// WithDepth the maximum depth at which children should be retrieved, +// defaults to 1. Use -1 for the entire subtree or provide an integer larger +// than 0. +func (p RequestChildNodesParams) WithDepth(depth int64) *RequestChildNodesParams { + p.Depth = depth + return &p +} + +// WithPierce whether or not iframes and shadow roots should be traversed +// when returning the sub-tree (default is false). +func (p RequestChildNodesParams) WithPierce(pierce bool) *RequestChildNodesParams { + p.Pierce = pierce + return &p +} + +// Do executes DOM.requestChildNodes against the provided context and +// target handler. +func (p *RequestChildNodesParams) Do(ctxt context.Context, h cdp.Handler) (err error) { + return h.Execute(ctxt, cdp.CommandDOMRequestChildNodes, p, nil) +} + +// RequestNodeParams requests that the node is sent to the caller given the +// JavaScript node object reference. All nodes that form the path from the node +// to the root are also sent to the client as a series of setChildNodes +// notifications. +type RequestNodeParams struct { + ObjectID runtime.RemoteObjectID `json:"objectId"` // JavaScript object id to convert into node. +} + +// RequestNode requests that the node is sent to the caller given the +// JavaScript node object reference. All nodes that form the path from the node +// to the root are also sent to the client as a series of setChildNodes +// notifications. +// +// parameters: +// objectID - JavaScript object id to convert into node. +func RequestNode(objectID runtime.RemoteObjectID) *RequestNodeParams { + return &RequestNodeParams{ + ObjectID: objectID, + } +} + +// RequestNodeReturns return values. +type RequestNodeReturns struct { + NodeID cdp.NodeID `json:"nodeId,omitempty"` // Node id for given object. +} + +// Do executes DOM.requestNode against the provided context and +// target handler. +// +// returns: +// nodeID - Node id for given object. +func (p *RequestNodeParams) Do(ctxt context.Context, h cdp.Handler) (nodeID cdp.NodeID, err error) { + // execute + var res RequestNodeReturns + err = h.Execute(ctxt, cdp.CommandDOMRequestNode, p, &res) + if err != nil { + return 0, err + } + + return res.NodeID, nil +} + +// ResolveNodeParams resolves the JavaScript node object for a given NodeId +// or BackendNodeId. +type ResolveNodeParams struct { + NodeID cdp.NodeID `json:"nodeId,omitempty"` // Id of the node to resolve. + BackendNodeID cdp.BackendNodeID `json:"backendNodeId,omitempty"` // Backend identifier of the node to resolve. + ObjectGroup string `json:"objectGroup,omitempty"` // Symbolic group name that can be used to release multiple objects. +} + +// ResolveNode resolves the JavaScript node object for a given NodeId or +// BackendNodeId. +// +// parameters: +func ResolveNode() *ResolveNodeParams { + return &ResolveNodeParams{} +} + +// WithNodeID ID of the node to resolve. +func (p ResolveNodeParams) WithNodeID(nodeID cdp.NodeID) *ResolveNodeParams { + p.NodeID = nodeID + return &p +} + +// WithBackendNodeID backend identifier of the node to resolve. +func (p ResolveNodeParams) WithBackendNodeID(backendNodeID cdp.BackendNodeID) *ResolveNodeParams { + p.BackendNodeID = backendNodeID + return &p +} + +// WithObjectGroup symbolic group name that can be used to release multiple +// objects. +func (p ResolveNodeParams) WithObjectGroup(objectGroup string) *ResolveNodeParams { + p.ObjectGroup = objectGroup + return &p +} + +// ResolveNodeReturns return values. +type ResolveNodeReturns struct { + Object *runtime.RemoteObject `json:"object,omitempty"` // JavaScript object wrapper for given node. +} + +// Do executes DOM.resolveNode against the provided context and +// target handler. +// +// returns: +// object - JavaScript object wrapper for given node. +func (p *ResolveNodeParams) Do(ctxt context.Context, h cdp.Handler) (object *runtime.RemoteObject, err error) { + // execute + var res ResolveNodeReturns + err = h.Execute(ctxt, cdp.CommandDOMResolveNode, p, &res) + if err != nil { + return nil, err + } + + return res.Object, nil +} + // SetAttributeValueParams sets attribute for an element with given id. type SetAttributeValueParams struct { NodeID cdp.NodeID `json:"nodeId"` // Id of the element to set attribute for. @@ -460,636 +1176,6 @@ func (p *SetAttributesAsTextParams) Do(ctxt context.Context, h cdp.Handler) (err return h.Execute(ctxt, cdp.CommandDOMSetAttributesAsText, p, nil) } -// RemoveAttributeParams removes attribute with given name from an element -// with given id. -type RemoveAttributeParams struct { - NodeID cdp.NodeID `json:"nodeId"` // Id of the element to remove attribute from. - Name string `json:"name"` // Name of the attribute to remove. -} - -// RemoveAttribute removes attribute with given name from an element with -// given id. -// -// parameters: -// nodeID - Id of the element to remove attribute from. -// name - Name of the attribute to remove. -func RemoveAttribute(nodeID cdp.NodeID, name string) *RemoveAttributeParams { - return &RemoveAttributeParams{ - NodeID: nodeID, - Name: name, - } -} - -// Do executes DOM.removeAttribute against the provided context and -// target handler. -func (p *RemoveAttributeParams) Do(ctxt context.Context, h cdp.Handler) (err error) { - return h.Execute(ctxt, cdp.CommandDOMRemoveAttribute, p, nil) -} - -// GetOuterHTMLParams returns node's HTML markup. -type GetOuterHTMLParams struct { - NodeID cdp.NodeID `json:"nodeId,omitempty"` // Identifier of the node. - BackendNodeID cdp.BackendNodeID `json:"backendNodeId,omitempty"` // Identifier of the backend node. - ObjectID runtime.RemoteObjectID `json:"objectId,omitempty"` // JavaScript object id of the node wrapper. -} - -// GetOuterHTML returns node's HTML markup. -// -// parameters: -func GetOuterHTML() *GetOuterHTMLParams { - return &GetOuterHTMLParams{} -} - -// WithNodeID identifier of the node. -func (p GetOuterHTMLParams) WithNodeID(nodeID cdp.NodeID) *GetOuterHTMLParams { - p.NodeID = nodeID - return &p -} - -// WithBackendNodeID identifier of the backend node. -func (p GetOuterHTMLParams) WithBackendNodeID(backendNodeID cdp.BackendNodeID) *GetOuterHTMLParams { - p.BackendNodeID = backendNodeID - return &p -} - -// WithObjectID JavaScript object id of the node wrapper. -func (p GetOuterHTMLParams) WithObjectID(objectID runtime.RemoteObjectID) *GetOuterHTMLParams { - p.ObjectID = objectID - return &p -} - -// GetOuterHTMLReturns return values. -type GetOuterHTMLReturns struct { - OuterHTML string `json:"outerHTML,omitempty"` // Outer HTML markup. -} - -// Do executes DOM.getOuterHTML against the provided context and -// target handler. -// -// returns: -// outerHTML - Outer HTML markup. -func (p *GetOuterHTMLParams) Do(ctxt context.Context, h cdp.Handler) (outerHTML string, err error) { - // execute - var res GetOuterHTMLReturns - err = h.Execute(ctxt, cdp.CommandDOMGetOuterHTML, p, &res) - if err != nil { - return "", err - } - - return res.OuterHTML, nil -} - -// SetOuterHTMLParams sets node HTML markup, returns new node id. -type SetOuterHTMLParams struct { - NodeID cdp.NodeID `json:"nodeId"` // Id of the node to set markup for. - OuterHTML string `json:"outerHTML"` // Outer HTML markup to set. -} - -// SetOuterHTML sets node HTML markup, returns new node id. -// -// parameters: -// nodeID - Id of the node to set markup for. -// outerHTML - Outer HTML markup to set. -func SetOuterHTML(nodeID cdp.NodeID, outerHTML string) *SetOuterHTMLParams { - return &SetOuterHTMLParams{ - NodeID: nodeID, - OuterHTML: outerHTML, - } -} - -// Do executes DOM.setOuterHTML against the provided context and -// target handler. -func (p *SetOuterHTMLParams) Do(ctxt context.Context, h cdp.Handler) (err error) { - return h.Execute(ctxt, cdp.CommandDOMSetOuterHTML, p, nil) -} - -// PerformSearchParams searches for a given string in the DOM tree. Use -// getSearchResults to access search results or cancelSearch to end this search -// session. -type PerformSearchParams struct { - Query string `json:"query"` // Plain text or query selector or XPath search query. - IncludeUserAgentShadowDOM bool `json:"includeUserAgentShadowDOM,omitempty"` // True to search in user agent shadow DOM. -} - -// PerformSearch searches for a given string in the DOM tree. Use -// getSearchResults to access search results or cancelSearch to end this search -// session. -// -// parameters: -// query - Plain text or query selector or XPath search query. -func PerformSearch(query string) *PerformSearchParams { - return &PerformSearchParams{ - Query: query, - } -} - -// WithIncludeUserAgentShadowDOM true to search in user agent shadow DOM. -func (p PerformSearchParams) WithIncludeUserAgentShadowDOM(includeUserAgentShadowDOM bool) *PerformSearchParams { - p.IncludeUserAgentShadowDOM = includeUserAgentShadowDOM - return &p -} - -// PerformSearchReturns return values. -type PerformSearchReturns struct { - SearchID string `json:"searchId,omitempty"` // Unique search session identifier. - ResultCount int64 `json:"resultCount,omitempty"` // Number of search results. -} - -// Do executes DOM.performSearch against the provided context and -// target handler. -// -// returns: -// searchID - Unique search session identifier. -// resultCount - Number of search results. -func (p *PerformSearchParams) Do(ctxt context.Context, h cdp.Handler) (searchID string, resultCount int64, err error) { - // execute - var res PerformSearchReturns - err = h.Execute(ctxt, cdp.CommandDOMPerformSearch, p, &res) - if err != nil { - return "", 0, err - } - - return res.SearchID, res.ResultCount, nil -} - -// GetSearchResultsParams returns search results from given fromIndex to -// given toIndex from the search with the given identifier. -type GetSearchResultsParams struct { - SearchID string `json:"searchId"` // Unique search session identifier. - FromIndex int64 `json:"fromIndex"` // Start index of the search result to be returned. - ToIndex int64 `json:"toIndex"` // End index of the search result to be returned. -} - -// GetSearchResults returns search results from given fromIndex to given -// toIndex from the search with the given identifier. -// -// parameters: -// searchID - Unique search session identifier. -// fromIndex - Start index of the search result to be returned. -// toIndex - End index of the search result to be returned. -func GetSearchResults(searchID string, fromIndex int64, toIndex int64) *GetSearchResultsParams { - return &GetSearchResultsParams{ - SearchID: searchID, - FromIndex: fromIndex, - ToIndex: toIndex, - } -} - -// GetSearchResultsReturns return values. -type GetSearchResultsReturns struct { - NodeIds []cdp.NodeID `json:"nodeIds,omitempty"` // Ids of the search result nodes. -} - -// Do executes DOM.getSearchResults against the provided context and -// target handler. -// -// returns: -// nodeIds - Ids of the search result nodes. -func (p *GetSearchResultsParams) Do(ctxt context.Context, h cdp.Handler) (nodeIds []cdp.NodeID, err error) { - // execute - var res GetSearchResultsReturns - err = h.Execute(ctxt, cdp.CommandDOMGetSearchResults, p, &res) - if err != nil { - return nil, err - } - - return res.NodeIds, nil -} - -// DiscardSearchResultsParams discards search results from the session with -// the given id. getSearchResults should no longer be called for that search. -type DiscardSearchResultsParams struct { - SearchID string `json:"searchId"` // Unique search session identifier. -} - -// DiscardSearchResults discards search results from the session with the -// given id. getSearchResults should no longer be called for that search. -// -// parameters: -// searchID - Unique search session identifier. -func DiscardSearchResults(searchID string) *DiscardSearchResultsParams { - return &DiscardSearchResultsParams{ - SearchID: searchID, - } -} - -// Do executes DOM.discardSearchResults against the provided context and -// target handler. -func (p *DiscardSearchResultsParams) Do(ctxt context.Context, h cdp.Handler) (err error) { - return h.Execute(ctxt, cdp.CommandDOMDiscardSearchResults, p, nil) -} - -// RequestNodeParams requests that the node is sent to the caller given the -// JavaScript node object reference. All nodes that form the path from the node -// to the root are also sent to the client as a series of setChildNodes -// notifications. -type RequestNodeParams struct { - ObjectID runtime.RemoteObjectID `json:"objectId"` // JavaScript object id to convert into node. -} - -// RequestNode requests that the node is sent to the caller given the -// JavaScript node object reference. All nodes that form the path from the node -// to the root are also sent to the client as a series of setChildNodes -// notifications. -// -// parameters: -// objectID - JavaScript object id to convert into node. -func RequestNode(objectID runtime.RemoteObjectID) *RequestNodeParams { - return &RequestNodeParams{ - ObjectID: objectID, - } -} - -// RequestNodeReturns return values. -type RequestNodeReturns struct { - NodeID cdp.NodeID `json:"nodeId,omitempty"` // Node id for given object. -} - -// Do executes DOM.requestNode against the provided context and -// target handler. -// -// returns: -// nodeID - Node id for given object. -func (p *RequestNodeParams) Do(ctxt context.Context, h cdp.Handler) (nodeID cdp.NodeID, err error) { - // execute - var res RequestNodeReturns - err = h.Execute(ctxt, cdp.CommandDOMRequestNode, p, &res) - if err != nil { - return 0, err - } - - return res.NodeID, nil -} - -// PushNodeByPathToFrontendParams requests that the node is sent to the -// caller given its path. // FIXME, use XPath. -type PushNodeByPathToFrontendParams struct { - Path string `json:"path"` // Path to node in the proprietary format. -} - -// PushNodeByPathToFrontend requests that the node is sent to the caller -// given its path. // FIXME, use XPath. -// -// parameters: -// path - Path to node in the proprietary format. -func PushNodeByPathToFrontend(path string) *PushNodeByPathToFrontendParams { - return &PushNodeByPathToFrontendParams{ - Path: path, - } -} - -// PushNodeByPathToFrontendReturns return values. -type PushNodeByPathToFrontendReturns struct { - NodeID cdp.NodeID `json:"nodeId,omitempty"` // Id of the node for given path. -} - -// Do executes DOM.pushNodeByPathToFrontend against the provided context and -// target handler. -// -// returns: -// nodeID - Id of the node for given path. -func (p *PushNodeByPathToFrontendParams) Do(ctxt context.Context, h cdp.Handler) (nodeID cdp.NodeID, err error) { - // execute - var res PushNodeByPathToFrontendReturns - err = h.Execute(ctxt, cdp.CommandDOMPushNodeByPathToFrontend, p, &res) - if err != nil { - return 0, err - } - - return res.NodeID, nil -} - -// PushNodesByBackendIdsToFrontendParams requests that a batch of nodes is -// sent to the caller given their backend node ids. -type PushNodesByBackendIdsToFrontendParams struct { - BackendNodeIds []cdp.BackendNodeID `json:"backendNodeIds"` // The array of backend node ids. -} - -// PushNodesByBackendIdsToFrontend requests that a batch of nodes is sent to -// the caller given their backend node ids. -// -// parameters: -// backendNodeIds - The array of backend node ids. -func PushNodesByBackendIdsToFrontend(backendNodeIds []cdp.BackendNodeID) *PushNodesByBackendIdsToFrontendParams { - return &PushNodesByBackendIdsToFrontendParams{ - BackendNodeIds: backendNodeIds, - } -} - -// PushNodesByBackendIdsToFrontendReturns return values. -type PushNodesByBackendIdsToFrontendReturns struct { - NodeIds []cdp.NodeID `json:"nodeIds,omitempty"` // The array of ids of pushed nodes that correspond to the backend ids specified in backendNodeIds. -} - -// Do executes DOM.pushNodesByBackendIdsToFrontend against the provided context and -// target handler. -// -// returns: -// nodeIds - The array of ids of pushed nodes that correspond to the backend ids specified in backendNodeIds. -func (p *PushNodesByBackendIdsToFrontendParams) Do(ctxt context.Context, h cdp.Handler) (nodeIds []cdp.NodeID, err error) { - // execute - var res PushNodesByBackendIdsToFrontendReturns - err = h.Execute(ctxt, cdp.CommandDOMPushNodesByBackendIdsToFrontend, p, &res) - if err != nil { - return nil, err - } - - return res.NodeIds, nil -} - -// SetInspectedNodeParams enables console to refer to the node with given id -// via $x (see Command Line API for more details $x functions). -type SetInspectedNodeParams struct { - NodeID cdp.NodeID `json:"nodeId"` // DOM node id to be accessible by means of $x command line API. -} - -// SetInspectedNode enables console to refer to the node with given id via $x -// (see Command Line API for more details $x functions). -// -// parameters: -// nodeID - DOM node id to be accessible by means of $x command line API. -func SetInspectedNode(nodeID cdp.NodeID) *SetInspectedNodeParams { - return &SetInspectedNodeParams{ - NodeID: nodeID, - } -} - -// Do executes DOM.setInspectedNode against the provided context and -// target handler. -func (p *SetInspectedNodeParams) Do(ctxt context.Context, h cdp.Handler) (err error) { - return h.Execute(ctxt, cdp.CommandDOMSetInspectedNode, p, nil) -} - -// ResolveNodeParams resolves the JavaScript node object for a given NodeId -// or BackendNodeId. -type ResolveNodeParams struct { - NodeID cdp.NodeID `json:"nodeId,omitempty"` // Id of the node to resolve. - BackendNodeID cdp.BackendNodeID `json:"backendNodeId,omitempty"` // Backend identifier of the node to resolve. - ObjectGroup string `json:"objectGroup,omitempty"` // Symbolic group name that can be used to release multiple objects. -} - -// ResolveNode resolves the JavaScript node object for a given NodeId or -// BackendNodeId. -// -// parameters: -func ResolveNode() *ResolveNodeParams { - return &ResolveNodeParams{} -} - -// WithNodeID ID of the node to resolve. -func (p ResolveNodeParams) WithNodeID(nodeID cdp.NodeID) *ResolveNodeParams { - p.NodeID = nodeID - return &p -} - -// WithBackendNodeID backend identifier of the node to resolve. -func (p ResolveNodeParams) WithBackendNodeID(backendNodeID cdp.BackendNodeID) *ResolveNodeParams { - p.BackendNodeID = backendNodeID - return &p -} - -// WithObjectGroup symbolic group name that can be used to release multiple -// objects. -func (p ResolveNodeParams) WithObjectGroup(objectGroup string) *ResolveNodeParams { - p.ObjectGroup = objectGroup - return &p -} - -// ResolveNodeReturns return values. -type ResolveNodeReturns struct { - Object *runtime.RemoteObject `json:"object,omitempty"` // JavaScript object wrapper for given node. -} - -// Do executes DOM.resolveNode against the provided context and -// target handler. -// -// returns: -// object - JavaScript object wrapper for given node. -func (p *ResolveNodeParams) Do(ctxt context.Context, h cdp.Handler) (object *runtime.RemoteObject, err error) { - // execute - var res ResolveNodeReturns - err = h.Execute(ctxt, cdp.CommandDOMResolveNode, p, &res) - if err != nil { - return nil, err - } - - return res.Object, nil -} - -// GetAttributesParams returns attributes for the specified node. -type GetAttributesParams struct { - NodeID cdp.NodeID `json:"nodeId"` // Id of the node to retrieve attibutes for. -} - -// GetAttributes returns attributes for the specified node. -// -// parameters: -// nodeID - Id of the node to retrieve attibutes for. -func GetAttributes(nodeID cdp.NodeID) *GetAttributesParams { - return &GetAttributesParams{ - NodeID: nodeID, - } -} - -// GetAttributesReturns return values. -type GetAttributesReturns struct { - Attributes []string `json:"attributes,omitempty"` // An interleaved array of node attribute names and values. -} - -// Do executes DOM.getAttributes against the provided context and -// target handler. -// -// returns: -// attributes - An interleaved array of node attribute names and values. -func (p *GetAttributesParams) Do(ctxt context.Context, h cdp.Handler) (attributes []string, err error) { - // execute - var res GetAttributesReturns - err = h.Execute(ctxt, cdp.CommandDOMGetAttributes, p, &res) - if err != nil { - return nil, err - } - - return res.Attributes, nil -} - -// CopyToParams creates a deep copy of the specified node and places it into -// the target container before the given anchor. -type CopyToParams struct { - NodeID cdp.NodeID `json:"nodeId"` // Id of the node to copy. - TargetNodeID cdp.NodeID `json:"targetNodeId"` // Id of the element to drop the copy into. - InsertBeforeNodeID cdp.NodeID `json:"insertBeforeNodeId,omitempty"` // Drop the copy before this node (if absent, the copy becomes the last child of targetNodeId). -} - -// CopyTo creates a deep copy of the specified node and places it into the -// target container before the given anchor. -// -// parameters: -// nodeID - Id of the node to copy. -// targetNodeID - Id of the element to drop the copy into. -func CopyTo(nodeID cdp.NodeID, targetNodeID cdp.NodeID) *CopyToParams { - return &CopyToParams{ - NodeID: nodeID, - TargetNodeID: targetNodeID, - } -} - -// WithInsertBeforeNodeID drop the copy before this node (if absent, the copy -// becomes the last child of targetNodeId). -func (p CopyToParams) WithInsertBeforeNodeID(insertBeforeNodeID cdp.NodeID) *CopyToParams { - p.InsertBeforeNodeID = insertBeforeNodeID - return &p -} - -// CopyToReturns return values. -type CopyToReturns struct { - NodeID cdp.NodeID `json:"nodeId,omitempty"` // Id of the node clone. -} - -// Do executes DOM.copyTo against the provided context and -// target handler. -// -// returns: -// nodeID - Id of the node clone. -func (p *CopyToParams) Do(ctxt context.Context, h cdp.Handler) (nodeID cdp.NodeID, err error) { - // execute - var res CopyToReturns - err = h.Execute(ctxt, cdp.CommandDOMCopyTo, p, &res) - if err != nil { - return 0, err - } - - return res.NodeID, nil -} - -// MoveToParams moves node into the new container, places it before the given -// anchor. -type MoveToParams struct { - NodeID cdp.NodeID `json:"nodeId"` // Id of the node to move. - TargetNodeID cdp.NodeID `json:"targetNodeId"` // Id of the element to drop the moved node into. - InsertBeforeNodeID cdp.NodeID `json:"insertBeforeNodeId,omitempty"` // Drop node before this one (if absent, the moved node becomes the last child of targetNodeId). -} - -// MoveTo moves node into the new container, places it before the given -// anchor. -// -// parameters: -// nodeID - Id of the node to move. -// targetNodeID - Id of the element to drop the moved node into. -func MoveTo(nodeID cdp.NodeID, targetNodeID cdp.NodeID) *MoveToParams { - return &MoveToParams{ - NodeID: nodeID, - TargetNodeID: targetNodeID, - } -} - -// WithInsertBeforeNodeID drop node before this one (if absent, the moved -// node becomes the last child of targetNodeId). -func (p MoveToParams) WithInsertBeforeNodeID(insertBeforeNodeID cdp.NodeID) *MoveToParams { - p.InsertBeforeNodeID = insertBeforeNodeID - return &p -} - -// MoveToReturns return values. -type MoveToReturns struct { - NodeID cdp.NodeID `json:"nodeId,omitempty"` // New id of the moved node. -} - -// Do executes DOM.moveTo against the provided context and -// target handler. -// -// returns: -// nodeID - New id of the moved node. -func (p *MoveToParams) Do(ctxt context.Context, h cdp.Handler) (nodeID cdp.NodeID, err error) { - // execute - var res MoveToReturns - err = h.Execute(ctxt, cdp.CommandDOMMoveTo, p, &res) - if err != nil { - return 0, err - } - - return res.NodeID, nil -} - -// UndoParams undoes the last performed action. -type UndoParams struct{} - -// Undo undoes the last performed action. -func Undo() *UndoParams { - return &UndoParams{} -} - -// Do executes DOM.undo against the provided context and -// target handler. -func (p *UndoParams) Do(ctxt context.Context, h cdp.Handler) (err error) { - return h.Execute(ctxt, cdp.CommandDOMUndo, nil, nil) -} - -// RedoParams re-does the last undone action. -type RedoParams struct{} - -// Redo re-does the last undone action. -func Redo() *RedoParams { - return &RedoParams{} -} - -// Do executes DOM.redo against the provided context and -// target handler. -func (p *RedoParams) Do(ctxt context.Context, h cdp.Handler) (err error) { - return h.Execute(ctxt, cdp.CommandDOMRedo, nil, nil) -} - -// MarkUndoableStateParams marks last undoable state. -type MarkUndoableStateParams struct{} - -// MarkUndoableState marks last undoable state. -func MarkUndoableState() *MarkUndoableStateParams { - return &MarkUndoableStateParams{} -} - -// Do executes DOM.markUndoableState against the provided context and -// target handler. -func (p *MarkUndoableStateParams) Do(ctxt context.Context, h cdp.Handler) (err error) { - return h.Execute(ctxt, cdp.CommandDOMMarkUndoableState, nil, nil) -} - -// FocusParams focuses the given element. -type FocusParams struct { - NodeID cdp.NodeID `json:"nodeId,omitempty"` // Identifier of the node. - BackendNodeID cdp.BackendNodeID `json:"backendNodeId,omitempty"` // Identifier of the backend node. - ObjectID runtime.RemoteObjectID `json:"objectId,omitempty"` // JavaScript object id of the node wrapper. -} - -// Focus focuses the given element. -// -// parameters: -func Focus() *FocusParams { - return &FocusParams{} -} - -// WithNodeID identifier of the node. -func (p FocusParams) WithNodeID(nodeID cdp.NodeID) *FocusParams { - p.NodeID = nodeID - return &p -} - -// WithBackendNodeID identifier of the backend node. -func (p FocusParams) WithBackendNodeID(backendNodeID cdp.BackendNodeID) *FocusParams { - p.BackendNodeID = backendNodeID - return &p -} - -// WithObjectID JavaScript object id of the node wrapper. -func (p FocusParams) WithObjectID(objectID runtime.RemoteObjectID) *FocusParams { - p.ObjectID = objectID - return &p -} - -// Do executes DOM.focus against the provided context and -// target handler. -func (p *FocusParams) Do(ctxt context.Context, h cdp.Handler) (err error) { - return h.Execute(ctxt, cdp.CommandDOMFocus, p, nil) -} - // SetFileInputFilesParams sets files for the given file input element. type SetFileInputFilesParams struct { Files []string `json:"files"` // Array of file paths to set. @@ -1132,137 +1218,61 @@ func (p *SetFileInputFilesParams) Do(ctxt context.Context, h cdp.Handler) (err e return h.Execute(ctxt, cdp.CommandDOMSetFileInputFiles, p, nil) } -// GetBoxModelParams returns boxes for the given node. -type GetBoxModelParams struct { - NodeID cdp.NodeID `json:"nodeId,omitempty"` // Identifier of the node. - BackendNodeID cdp.BackendNodeID `json:"backendNodeId,omitempty"` // Identifier of the backend node. - ObjectID runtime.RemoteObjectID `json:"objectId,omitempty"` // JavaScript object id of the node wrapper. +// SetInspectedNodeParams enables console to refer to the node with given id +// via $x (see Command Line API for more details $x functions). +type SetInspectedNodeParams struct { + NodeID cdp.NodeID `json:"nodeId"` // DOM node id to be accessible by means of $x command line API. } -// GetBoxModel returns boxes for the given node. +// SetInspectedNode enables console to refer to the node with given id via $x +// (see Command Line API for more details $x functions). // // parameters: -func GetBoxModel() *GetBoxModelParams { - return &GetBoxModelParams{} -} - -// WithNodeID identifier of the node. -func (p GetBoxModelParams) WithNodeID(nodeID cdp.NodeID) *GetBoxModelParams { - p.NodeID = nodeID - return &p -} - -// WithBackendNodeID identifier of the backend node. -func (p GetBoxModelParams) WithBackendNodeID(backendNodeID cdp.BackendNodeID) *GetBoxModelParams { - p.BackendNodeID = backendNodeID - return &p -} - -// WithObjectID JavaScript object id of the node wrapper. -func (p GetBoxModelParams) WithObjectID(objectID runtime.RemoteObjectID) *GetBoxModelParams { - p.ObjectID = objectID - return &p -} - -// GetBoxModelReturns return values. -type GetBoxModelReturns struct { - Model *BoxModel `json:"model,omitempty"` // Box model for the node. -} - -// Do executes DOM.getBoxModel against the provided context and -// target handler. -// -// returns: -// model - Box model for the node. -func (p *GetBoxModelParams) Do(ctxt context.Context, h cdp.Handler) (model *BoxModel, err error) { - // execute - var res GetBoxModelReturns - err = h.Execute(ctxt, cdp.CommandDOMGetBoxModel, p, &res) - if err != nil { - return nil, err - } - - return res.Model, nil -} - -// GetNodeForLocationParams returns node id at given location. -type GetNodeForLocationParams struct { - X int64 `json:"x"` // X coordinate. - Y int64 `json:"y"` // Y coordinate. - IncludeUserAgentShadowDOM bool `json:"includeUserAgentShadowDOM,omitempty"` // False to skip to the nearest non-UA shadow root ancestor (default: false). -} - -// GetNodeForLocation returns node id at given location. -// -// parameters: -// x - X coordinate. -// y - Y coordinate. -func GetNodeForLocation(x int64, y int64) *GetNodeForLocationParams { - return &GetNodeForLocationParams{ - X: x, - Y: y, - } -} - -// WithIncludeUserAgentShadowDOM false to skip to the nearest non-UA shadow -// root ancestor (default: false). -func (p GetNodeForLocationParams) WithIncludeUserAgentShadowDOM(includeUserAgentShadowDOM bool) *GetNodeForLocationParams { - p.IncludeUserAgentShadowDOM = includeUserAgentShadowDOM - return &p -} - -// GetNodeForLocationReturns return values. -type GetNodeForLocationReturns struct { - NodeID cdp.NodeID `json:"nodeId,omitempty"` // Id of the node at given coordinates. -} - -// Do executes DOM.getNodeForLocation against the provided context and -// target handler. -// -// returns: -// nodeID - Id of the node at given coordinates. -func (p *GetNodeForLocationParams) Do(ctxt context.Context, h cdp.Handler) (nodeID cdp.NodeID, err error) { - // execute - var res GetNodeForLocationReturns - err = h.Execute(ctxt, cdp.CommandDOMGetNodeForLocation, p, &res) - if err != nil { - return 0, err - } - - return res.NodeID, nil -} - -// GetRelayoutBoundaryParams returns the id of the nearest ancestor that is a -// relayout boundary. -type GetRelayoutBoundaryParams struct { - NodeID cdp.NodeID `json:"nodeId"` // Id of the node. -} - -// GetRelayoutBoundary returns the id of the nearest ancestor that is a -// relayout boundary. -// -// parameters: -// nodeID - Id of the node. -func GetRelayoutBoundary(nodeID cdp.NodeID) *GetRelayoutBoundaryParams { - return &GetRelayoutBoundaryParams{ +// nodeID - DOM node id to be accessible by means of $x command line API. +func SetInspectedNode(nodeID cdp.NodeID) *SetInspectedNodeParams { + return &SetInspectedNodeParams{ NodeID: nodeID, } } -// GetRelayoutBoundaryReturns return values. -type GetRelayoutBoundaryReturns struct { - NodeID cdp.NodeID `json:"nodeId,omitempty"` // Relayout boundary node id for the given node. +// Do executes DOM.setInspectedNode against the provided context and +// target handler. +func (p *SetInspectedNodeParams) Do(ctxt context.Context, h cdp.Handler) (err error) { + return h.Execute(ctxt, cdp.CommandDOMSetInspectedNode, p, nil) } -// Do executes DOM.getRelayoutBoundary against the provided context and +// SetNodeNameParams sets node name for a node with given id. +type SetNodeNameParams struct { + NodeID cdp.NodeID `json:"nodeId"` // Id of the node to set name for. + Name string `json:"name"` // New node's name. +} + +// SetNodeName sets node name for a node with given id. +// +// parameters: +// nodeID - Id of the node to set name for. +// name - New node's name. +func SetNodeName(nodeID cdp.NodeID, name string) *SetNodeNameParams { + return &SetNodeNameParams{ + NodeID: nodeID, + Name: name, + } +} + +// SetNodeNameReturns return values. +type SetNodeNameReturns struct { + NodeID cdp.NodeID `json:"nodeId,omitempty"` // New node's id. +} + +// Do executes DOM.setNodeName against the provided context and // target handler. // // returns: -// nodeID - Relayout boundary node id for the given node. -func (p *GetRelayoutBoundaryParams) Do(ctxt context.Context, h cdp.Handler) (nodeID cdp.NodeID, err error) { +// nodeID - New node's id. +func (p *SetNodeNameParams) Do(ctxt context.Context, h cdp.Handler) (nodeID cdp.NodeID, err error) { // execute - var res GetRelayoutBoundaryReturns - err = h.Execute(ctxt, cdp.CommandDOMGetRelayoutBoundary, p, &res) + var res SetNodeNameReturns + err = h.Execute(ctxt, cdp.CommandDOMSetNodeName, p, &res) if err != nil { return 0, err } @@ -1270,74 +1280,64 @@ func (p *GetRelayoutBoundaryParams) Do(ctxt context.Context, h cdp.Handler) (nod return res.NodeID, nil } -// DescribeNodeParams describes node given its id, does not require domain to -// be enabled. Does not start tracking any objects, can be used for automation. -type DescribeNodeParams struct { - NodeID cdp.NodeID `json:"nodeId,omitempty"` // Identifier of the node. - BackendNodeID cdp.BackendNodeID `json:"backendNodeId,omitempty"` // Identifier of the backend node. - ObjectID runtime.RemoteObjectID `json:"objectId,omitempty"` // JavaScript object id of the node wrapper. - Depth int64 `json:"depth,omitempty"` // The maximum depth at which children should be retrieved, defaults to 1. Use -1 for the entire subtree or provide an integer larger than 0. - Pierce bool `json:"pierce,omitempty"` // Whether or not iframes and shadow roots should be traversed when returning the subtree (default is false). +// SetNodeValueParams sets node value for a node with given id. +type SetNodeValueParams struct { + NodeID cdp.NodeID `json:"nodeId"` // Id of the node to set value for. + Value string `json:"value"` // New node's value. } -// DescribeNode describes node given its id, does not require domain to be -// enabled. Does not start tracking any objects, can be used for automation. +// SetNodeValue sets node value for a node with given id. // // parameters: -func DescribeNode() *DescribeNodeParams { - return &DescribeNodeParams{} -} - -// WithNodeID identifier of the node. -func (p DescribeNodeParams) WithNodeID(nodeID cdp.NodeID) *DescribeNodeParams { - p.NodeID = nodeID - return &p -} - -// WithBackendNodeID identifier of the backend node. -func (p DescribeNodeParams) WithBackendNodeID(backendNodeID cdp.BackendNodeID) *DescribeNodeParams { - p.BackendNodeID = backendNodeID - return &p -} - -// WithObjectID JavaScript object id of the node wrapper. -func (p DescribeNodeParams) WithObjectID(objectID runtime.RemoteObjectID) *DescribeNodeParams { - p.ObjectID = objectID - return &p -} - -// WithDepth the maximum depth at which children should be retrieved, -// defaults to 1. Use -1 for the entire subtree or provide an integer larger -// than 0. -func (p DescribeNodeParams) WithDepth(depth int64) *DescribeNodeParams { - p.Depth = depth - return &p -} - -// WithPierce whether or not iframes and shadow roots should be traversed -// when returning the subtree (default is false). -func (p DescribeNodeParams) WithPierce(pierce bool) *DescribeNodeParams { - p.Pierce = pierce - return &p -} - -// DescribeNodeReturns return values. -type DescribeNodeReturns struct { - Node *cdp.Node `json:"node,omitempty"` // Node description. -} - -// Do executes DOM.describeNode against the provided context and -// target handler. -// -// returns: -// node - Node description. -func (p *DescribeNodeParams) Do(ctxt context.Context, h cdp.Handler) (node *cdp.Node, err error) { - // execute - var res DescribeNodeReturns - err = h.Execute(ctxt, cdp.CommandDOMDescribeNode, p, &res) - if err != nil { - return nil, err +// nodeID - Id of the node to set value for. +// value - New node's value. +func SetNodeValue(nodeID cdp.NodeID, value string) *SetNodeValueParams { + return &SetNodeValueParams{ + NodeID: nodeID, + Value: value, } - - return res.Node, nil +} + +// Do executes DOM.setNodeValue against the provided context and +// target handler. +func (p *SetNodeValueParams) Do(ctxt context.Context, h cdp.Handler) (err error) { + return h.Execute(ctxt, cdp.CommandDOMSetNodeValue, p, nil) +} + +// SetOuterHTMLParams sets node HTML markup, returns new node id. +type SetOuterHTMLParams struct { + NodeID cdp.NodeID `json:"nodeId"` // Id of the node to set markup for. + OuterHTML string `json:"outerHTML"` // Outer HTML markup to set. +} + +// SetOuterHTML sets node HTML markup, returns new node id. +// +// parameters: +// nodeID - Id of the node to set markup for. +// outerHTML - Outer HTML markup to set. +func SetOuterHTML(nodeID cdp.NodeID, outerHTML string) *SetOuterHTMLParams { + return &SetOuterHTMLParams{ + NodeID: nodeID, + OuterHTML: outerHTML, + } +} + +// Do executes DOM.setOuterHTML against the provided context and +// target handler. +func (p *SetOuterHTMLParams) Do(ctxt context.Context, h cdp.Handler) (err error) { + return h.Execute(ctxt, cdp.CommandDOMSetOuterHTML, p, nil) +} + +// UndoParams undoes the last performed action. +type UndoParams struct{} + +// Undo undoes the last performed action. +func Undo() *UndoParams { + return &UndoParams{} +} + +// Do executes DOM.undo against the provided context and +// target handler. +func (p *UndoParams) Do(ctxt context.Context, h cdp.Handler) (err error) { + return h.Execute(ctxt, cdp.CommandDOMUndo, nil, nil) } diff --git a/cdp/dom/events.go b/cdp/dom/events.go index 8ffb465..0994be4 100644 --- a/cdp/dom/events.go +++ b/cdp/dom/events.go @@ -6,18 +6,6 @@ import ( cdp "github.com/knq/chromedp/cdp" ) -// EventDocumentUpdated fired when Document has been totally updated. Node -// ids are no longer valid. -type EventDocumentUpdated struct{} - -// EventSetChildNodes fired when backend wants to provide client with the -// missing DOM structure. This happens upon most of the calls requesting node -// ids. -type EventSetChildNodes struct { - ParentID cdp.NodeID `json:"parentId"` // Parent node id to populate with children. - Nodes []*cdp.Node `json:"nodes"` // Child nodes array. -} - // EventAttributeModified fired when Element's attribute is modified. type EventAttributeModified struct { NodeID cdp.NodeID `json:"nodeId"` // Id of the node that has changed. @@ -31,12 +19,6 @@ type EventAttributeRemoved struct { Name string `json:"name"` // A ttribute name. } -// EventInlineStyleInvalidated fired when Element's inline style is modified -// via a CSS property modification. -type EventInlineStyleInvalidated struct { - NodeIds []cdp.NodeID `json:"nodeIds"` // Ids of the nodes for which the inline styles have been invalidated. -} - // EventCharacterDataModified mirrors DOMCharacterDataModified event. type EventCharacterDataModified struct { NodeID cdp.NodeID `json:"nodeId"` // Id of the node that has changed. @@ -63,16 +45,20 @@ type EventChildNodeRemoved struct { NodeID cdp.NodeID `json:"nodeId"` // Id of the node that has been removed. } -// EventShadowRootPushed called when shadow root is pushed into the element. -type EventShadowRootPushed struct { - HostID cdp.NodeID `json:"hostId"` // Host element id. - Root *cdp.Node `json:"root"` // Shadow root. +// EventDistributedNodesUpdated called when distribution is changed. +type EventDistributedNodesUpdated struct { + InsertionPointID cdp.NodeID `json:"insertionPointId"` // Insertion point where distributed nodes were updated. + DistributedNodes []*cdp.BackendNode `json:"distributedNodes"` // Distributed nodes for given insertion point. } -// EventShadowRootPopped called when shadow root is popped from the element. -type EventShadowRootPopped struct { - HostID cdp.NodeID `json:"hostId"` // Host element id. - RootID cdp.NodeID `json:"rootId"` // Shadow root id. +// EventDocumentUpdated fired when Document has been totally updated. Node +// ids are no longer valid. +type EventDocumentUpdated struct{} + +// EventInlineStyleInvalidated fired when Element's inline style is modified +// via a CSS property modification. +type EventInlineStyleInvalidated struct { + NodeIds []cdp.NodeID `json:"nodeIds"` // Ids of the nodes for which the inline styles have been invalidated. } // EventPseudoElementAdded called when a pseudo element is added to an @@ -89,26 +75,40 @@ type EventPseudoElementRemoved struct { PseudoElementID cdp.NodeID `json:"pseudoElementId"` // The removed pseudo element id. } -// EventDistributedNodesUpdated called when distribution is changed. -type EventDistributedNodesUpdated struct { - InsertionPointID cdp.NodeID `json:"insertionPointId"` // Insertion point where distributed nodes were updated. - DistributedNodes []*cdp.BackendNode `json:"distributedNodes"` // Distributed nodes for given insertion point. +// EventSetChildNodes fired when backend wants to provide client with the +// missing DOM structure. This happens upon most of the calls requesting node +// ids. +type EventSetChildNodes struct { + ParentID cdp.NodeID `json:"parentId"` // Parent node id to populate with children. + Nodes []*cdp.Node `json:"nodes"` // Child nodes array. +} + +// EventShadowRootPopped called when shadow root is popped from the element. +type EventShadowRootPopped struct { + HostID cdp.NodeID `json:"hostId"` // Host element id. + RootID cdp.NodeID `json:"rootId"` // Shadow root id. +} + +// EventShadowRootPushed called when shadow root is pushed into the element. +type EventShadowRootPushed struct { + HostID cdp.NodeID `json:"hostId"` // Host element id. + Root *cdp.Node `json:"root"` // Shadow root. } // EventTypes all event types in the domain. var EventTypes = []cdp.MethodType{ - cdp.EventDOMDocumentUpdated, - cdp.EventDOMSetChildNodes, cdp.EventDOMAttributeModified, cdp.EventDOMAttributeRemoved, - cdp.EventDOMInlineStyleInvalidated, cdp.EventDOMCharacterDataModified, cdp.EventDOMChildNodeCountUpdated, cdp.EventDOMChildNodeInserted, cdp.EventDOMChildNodeRemoved, - cdp.EventDOMShadowRootPushed, - cdp.EventDOMShadowRootPopped, + cdp.EventDOMDistributedNodesUpdated, + cdp.EventDOMDocumentUpdated, + cdp.EventDOMInlineStyleInvalidated, cdp.EventDOMPseudoElementAdded, cdp.EventDOMPseudoElementRemoved, - cdp.EventDOMDistributedNodesUpdated, + cdp.EventDOMSetChildNodes, + cdp.EventDOMShadowRootPopped, + cdp.EventDOMShadowRootPushed, } diff --git a/cdp/domdebugger/domdebugger.go b/cdp/domdebugger/domdebugger.go index c6a3a54..f813408 100644 --- a/cdp/domdebugger/domdebugger.go +++ b/cdp/domdebugger/domdebugger.go @@ -17,201 +17,6 @@ import ( "github.com/knq/chromedp/cdp/runtime" ) -// SetDOMBreakpointParams sets breakpoint on particular operation with DOM. -type SetDOMBreakpointParams struct { - NodeID cdp.NodeID `json:"nodeId"` // Identifier of the node to set breakpoint on. - Type DOMBreakpointType `json:"type"` // Type of the operation to stop upon. -} - -// SetDOMBreakpoint sets breakpoint on particular operation with DOM. -// -// parameters: -// nodeID - Identifier of the node to set breakpoint on. -// type - Type of the operation to stop upon. -func SetDOMBreakpoint(nodeID cdp.NodeID, typeVal DOMBreakpointType) *SetDOMBreakpointParams { - return &SetDOMBreakpointParams{ - NodeID: nodeID, - Type: typeVal, - } -} - -// Do executes DOMDebugger.setDOMBreakpoint against the provided context and -// target handler. -func (p *SetDOMBreakpointParams) Do(ctxt context.Context, h cdp.Handler) (err error) { - return h.Execute(ctxt, cdp.CommandDOMDebuggerSetDOMBreakpoint, p, nil) -} - -// RemoveDOMBreakpointParams removes DOM breakpoint that was set using -// setDOMBreakpoint. -type RemoveDOMBreakpointParams struct { - NodeID cdp.NodeID `json:"nodeId"` // Identifier of the node to remove breakpoint from. - Type DOMBreakpointType `json:"type"` // Type of the breakpoint to remove. -} - -// RemoveDOMBreakpoint removes DOM breakpoint that was set using -// setDOMBreakpoint. -// -// parameters: -// nodeID - Identifier of the node to remove breakpoint from. -// type - Type of the breakpoint to remove. -func RemoveDOMBreakpoint(nodeID cdp.NodeID, typeVal DOMBreakpointType) *RemoveDOMBreakpointParams { - return &RemoveDOMBreakpointParams{ - NodeID: nodeID, - Type: typeVal, - } -} - -// Do executes DOMDebugger.removeDOMBreakpoint against the provided context and -// target handler. -func (p *RemoveDOMBreakpointParams) Do(ctxt context.Context, h cdp.Handler) (err error) { - return h.Execute(ctxt, cdp.CommandDOMDebuggerRemoveDOMBreakpoint, p, nil) -} - -// SetEventListenerBreakpointParams sets breakpoint on particular DOM event. -type SetEventListenerBreakpointParams struct { - EventName string `json:"eventName"` // DOM Event name to stop on (any DOM event will do). - TargetName string `json:"targetName,omitempty"` // EventTarget interface name to stop on. If equal to "*" or not provided, will stop on any EventTarget. -} - -// SetEventListenerBreakpoint sets breakpoint on particular DOM event. -// -// parameters: -// eventName - DOM Event name to stop on (any DOM event will do). -func SetEventListenerBreakpoint(eventName string) *SetEventListenerBreakpointParams { - return &SetEventListenerBreakpointParams{ - EventName: eventName, - } -} - -// WithTargetName eventTarget interface name to stop on. If equal to "*" or -// not provided, will stop on any EventTarget. -func (p SetEventListenerBreakpointParams) WithTargetName(targetName string) *SetEventListenerBreakpointParams { - p.TargetName = targetName - return &p -} - -// Do executes DOMDebugger.setEventListenerBreakpoint against the provided context and -// target handler. -func (p *SetEventListenerBreakpointParams) Do(ctxt context.Context, h cdp.Handler) (err error) { - return h.Execute(ctxt, cdp.CommandDOMDebuggerSetEventListenerBreakpoint, p, nil) -} - -// RemoveEventListenerBreakpointParams removes breakpoint on particular DOM -// event. -type RemoveEventListenerBreakpointParams struct { - EventName string `json:"eventName"` // Event name. - TargetName string `json:"targetName,omitempty"` // EventTarget interface name. -} - -// RemoveEventListenerBreakpoint removes breakpoint on particular DOM event. -// -// parameters: -// eventName - Event name. -func RemoveEventListenerBreakpoint(eventName string) *RemoveEventListenerBreakpointParams { - return &RemoveEventListenerBreakpointParams{ - EventName: eventName, - } -} - -// WithTargetName eventTarget interface name. -func (p RemoveEventListenerBreakpointParams) WithTargetName(targetName string) *RemoveEventListenerBreakpointParams { - p.TargetName = targetName - return &p -} - -// Do executes DOMDebugger.removeEventListenerBreakpoint against the provided context and -// target handler. -func (p *RemoveEventListenerBreakpointParams) Do(ctxt context.Context, h cdp.Handler) (err error) { - return h.Execute(ctxt, cdp.CommandDOMDebuggerRemoveEventListenerBreakpoint, p, nil) -} - -// SetInstrumentationBreakpointParams sets breakpoint on particular native -// event. -type SetInstrumentationBreakpointParams struct { - EventName string `json:"eventName"` // Instrumentation name to stop on. -} - -// SetInstrumentationBreakpoint sets breakpoint on particular native event. -// -// parameters: -// eventName - Instrumentation name to stop on. -func SetInstrumentationBreakpoint(eventName string) *SetInstrumentationBreakpointParams { - return &SetInstrumentationBreakpointParams{ - EventName: eventName, - } -} - -// Do executes DOMDebugger.setInstrumentationBreakpoint against the provided context and -// target handler. -func (p *SetInstrumentationBreakpointParams) Do(ctxt context.Context, h cdp.Handler) (err error) { - return h.Execute(ctxt, cdp.CommandDOMDebuggerSetInstrumentationBreakpoint, p, nil) -} - -// RemoveInstrumentationBreakpointParams removes breakpoint on particular -// native event. -type RemoveInstrumentationBreakpointParams struct { - EventName string `json:"eventName"` // Instrumentation name to stop on. -} - -// RemoveInstrumentationBreakpoint removes breakpoint on particular native -// event. -// -// parameters: -// eventName - Instrumentation name to stop on. -func RemoveInstrumentationBreakpoint(eventName string) *RemoveInstrumentationBreakpointParams { - return &RemoveInstrumentationBreakpointParams{ - EventName: eventName, - } -} - -// Do executes DOMDebugger.removeInstrumentationBreakpoint against the provided context and -// target handler. -func (p *RemoveInstrumentationBreakpointParams) Do(ctxt context.Context, h cdp.Handler) (err error) { - return h.Execute(ctxt, cdp.CommandDOMDebuggerRemoveInstrumentationBreakpoint, p, nil) -} - -// SetXHRBreakpointParams sets breakpoint on XMLHttpRequest. -type SetXHRBreakpointParams struct { - URL string `json:"url"` // Resource URL substring. All XHRs having this substring in the URL will get stopped upon. -} - -// SetXHRBreakpoint sets breakpoint on XMLHttpRequest. -// -// parameters: -// url - Resource URL substring. All XHRs having this substring in the URL will get stopped upon. -func SetXHRBreakpoint(url string) *SetXHRBreakpointParams { - return &SetXHRBreakpointParams{ - URL: url, - } -} - -// Do executes DOMDebugger.setXHRBreakpoint against the provided context and -// target handler. -func (p *SetXHRBreakpointParams) Do(ctxt context.Context, h cdp.Handler) (err error) { - return h.Execute(ctxt, cdp.CommandDOMDebuggerSetXHRBreakpoint, p, nil) -} - -// RemoveXHRBreakpointParams removes breakpoint from XMLHttpRequest. -type RemoveXHRBreakpointParams struct { - URL string `json:"url"` // Resource URL substring. -} - -// RemoveXHRBreakpoint removes breakpoint from XMLHttpRequest. -// -// parameters: -// url - Resource URL substring. -func RemoveXHRBreakpoint(url string) *RemoveXHRBreakpointParams { - return &RemoveXHRBreakpointParams{ - URL: url, - } -} - -// Do executes DOMDebugger.removeXHRBreakpoint against the provided context and -// target handler. -func (p *RemoveXHRBreakpointParams) Do(ctxt context.Context, h cdp.Handler) (err error) { - return h.Execute(ctxt, cdp.CommandDOMDebuggerRemoveXHRBreakpoint, p, nil) -} - // GetEventListenersParams returns event listeners of the given object. type GetEventListenersParams struct { ObjectID runtime.RemoteObjectID `json:"objectId"` // Identifier of the object to return listeners for. @@ -265,3 +70,198 @@ func (p *GetEventListenersParams) Do(ctxt context.Context, h cdp.Handler) (liste return res.Listeners, nil } + +// RemoveDOMBreakpointParams removes DOM breakpoint that was set using +// setDOMBreakpoint. +type RemoveDOMBreakpointParams struct { + NodeID cdp.NodeID `json:"nodeId"` // Identifier of the node to remove breakpoint from. + Type DOMBreakpointType `json:"type"` // Type of the breakpoint to remove. +} + +// RemoveDOMBreakpoint removes DOM breakpoint that was set using +// setDOMBreakpoint. +// +// parameters: +// nodeID - Identifier of the node to remove breakpoint from. +// type - Type of the breakpoint to remove. +func RemoveDOMBreakpoint(nodeID cdp.NodeID, typeVal DOMBreakpointType) *RemoveDOMBreakpointParams { + return &RemoveDOMBreakpointParams{ + NodeID: nodeID, + Type: typeVal, + } +} + +// Do executes DOMDebugger.removeDOMBreakpoint against the provided context and +// target handler. +func (p *RemoveDOMBreakpointParams) Do(ctxt context.Context, h cdp.Handler) (err error) { + return h.Execute(ctxt, cdp.CommandDOMDebuggerRemoveDOMBreakpoint, p, nil) +} + +// RemoveEventListenerBreakpointParams removes breakpoint on particular DOM +// event. +type RemoveEventListenerBreakpointParams struct { + EventName string `json:"eventName"` // Event name. + TargetName string `json:"targetName,omitempty"` // EventTarget interface name. +} + +// RemoveEventListenerBreakpoint removes breakpoint on particular DOM event. +// +// parameters: +// eventName - Event name. +func RemoveEventListenerBreakpoint(eventName string) *RemoveEventListenerBreakpointParams { + return &RemoveEventListenerBreakpointParams{ + EventName: eventName, + } +} + +// WithTargetName eventTarget interface name. +func (p RemoveEventListenerBreakpointParams) WithTargetName(targetName string) *RemoveEventListenerBreakpointParams { + p.TargetName = targetName + return &p +} + +// Do executes DOMDebugger.removeEventListenerBreakpoint against the provided context and +// target handler. +func (p *RemoveEventListenerBreakpointParams) Do(ctxt context.Context, h cdp.Handler) (err error) { + return h.Execute(ctxt, cdp.CommandDOMDebuggerRemoveEventListenerBreakpoint, p, nil) +} + +// RemoveInstrumentationBreakpointParams removes breakpoint on particular +// native event. +type RemoveInstrumentationBreakpointParams struct { + EventName string `json:"eventName"` // Instrumentation name to stop on. +} + +// RemoveInstrumentationBreakpoint removes breakpoint on particular native +// event. +// +// parameters: +// eventName - Instrumentation name to stop on. +func RemoveInstrumentationBreakpoint(eventName string) *RemoveInstrumentationBreakpointParams { + return &RemoveInstrumentationBreakpointParams{ + EventName: eventName, + } +} + +// Do executes DOMDebugger.removeInstrumentationBreakpoint against the provided context and +// target handler. +func (p *RemoveInstrumentationBreakpointParams) Do(ctxt context.Context, h cdp.Handler) (err error) { + return h.Execute(ctxt, cdp.CommandDOMDebuggerRemoveInstrumentationBreakpoint, p, nil) +} + +// RemoveXHRBreakpointParams removes breakpoint from XMLHttpRequest. +type RemoveXHRBreakpointParams struct { + URL string `json:"url"` // Resource URL substring. +} + +// RemoveXHRBreakpoint removes breakpoint from XMLHttpRequest. +// +// parameters: +// url - Resource URL substring. +func RemoveXHRBreakpoint(url string) *RemoveXHRBreakpointParams { + return &RemoveXHRBreakpointParams{ + URL: url, + } +} + +// Do executes DOMDebugger.removeXHRBreakpoint against the provided context and +// target handler. +func (p *RemoveXHRBreakpointParams) Do(ctxt context.Context, h cdp.Handler) (err error) { + return h.Execute(ctxt, cdp.CommandDOMDebuggerRemoveXHRBreakpoint, p, nil) +} + +// SetDOMBreakpointParams sets breakpoint on particular operation with DOM. +type SetDOMBreakpointParams struct { + NodeID cdp.NodeID `json:"nodeId"` // Identifier of the node to set breakpoint on. + Type DOMBreakpointType `json:"type"` // Type of the operation to stop upon. +} + +// SetDOMBreakpoint sets breakpoint on particular operation with DOM. +// +// parameters: +// nodeID - Identifier of the node to set breakpoint on. +// type - Type of the operation to stop upon. +func SetDOMBreakpoint(nodeID cdp.NodeID, typeVal DOMBreakpointType) *SetDOMBreakpointParams { + return &SetDOMBreakpointParams{ + NodeID: nodeID, + Type: typeVal, + } +} + +// Do executes DOMDebugger.setDOMBreakpoint against the provided context and +// target handler. +func (p *SetDOMBreakpointParams) Do(ctxt context.Context, h cdp.Handler) (err error) { + return h.Execute(ctxt, cdp.CommandDOMDebuggerSetDOMBreakpoint, p, nil) +} + +// SetEventListenerBreakpointParams sets breakpoint on particular DOM event. +type SetEventListenerBreakpointParams struct { + EventName string `json:"eventName"` // DOM Event name to stop on (any DOM event will do). + TargetName string `json:"targetName,omitempty"` // EventTarget interface name to stop on. If equal to "*" or not provided, will stop on any EventTarget. +} + +// SetEventListenerBreakpoint sets breakpoint on particular DOM event. +// +// parameters: +// eventName - DOM Event name to stop on (any DOM event will do). +func SetEventListenerBreakpoint(eventName string) *SetEventListenerBreakpointParams { + return &SetEventListenerBreakpointParams{ + EventName: eventName, + } +} + +// WithTargetName eventTarget interface name to stop on. If equal to "*" or +// not provided, will stop on any EventTarget. +func (p SetEventListenerBreakpointParams) WithTargetName(targetName string) *SetEventListenerBreakpointParams { + p.TargetName = targetName + return &p +} + +// Do executes DOMDebugger.setEventListenerBreakpoint against the provided context and +// target handler. +func (p *SetEventListenerBreakpointParams) Do(ctxt context.Context, h cdp.Handler) (err error) { + return h.Execute(ctxt, cdp.CommandDOMDebuggerSetEventListenerBreakpoint, p, nil) +} + +// SetInstrumentationBreakpointParams sets breakpoint on particular native +// event. +type SetInstrumentationBreakpointParams struct { + EventName string `json:"eventName"` // Instrumentation name to stop on. +} + +// SetInstrumentationBreakpoint sets breakpoint on particular native event. +// +// parameters: +// eventName - Instrumentation name to stop on. +func SetInstrumentationBreakpoint(eventName string) *SetInstrumentationBreakpointParams { + return &SetInstrumentationBreakpointParams{ + EventName: eventName, + } +} + +// Do executes DOMDebugger.setInstrumentationBreakpoint against the provided context and +// target handler. +func (p *SetInstrumentationBreakpointParams) Do(ctxt context.Context, h cdp.Handler) (err error) { + return h.Execute(ctxt, cdp.CommandDOMDebuggerSetInstrumentationBreakpoint, p, nil) +} + +// SetXHRBreakpointParams sets breakpoint on XMLHttpRequest. +type SetXHRBreakpointParams struct { + URL string `json:"url"` // Resource URL substring. All XHRs having this substring in the URL will get stopped upon. +} + +// SetXHRBreakpoint sets breakpoint on XMLHttpRequest. +// +// parameters: +// url - Resource URL substring. All XHRs having this substring in the URL will get stopped upon. +func SetXHRBreakpoint(url string) *SetXHRBreakpointParams { + return &SetXHRBreakpointParams{ + URL: url, + } +} + +// Do executes DOMDebugger.setXHRBreakpoint against the provided context and +// target handler. +func (p *SetXHRBreakpointParams) Do(ctxt context.Context, h cdp.Handler) (err error) { + return h.Execute(ctxt, cdp.CommandDOMDebuggerSetXHRBreakpoint, p, nil) +} diff --git a/cdp/domstorage/domstorage.go b/cdp/domstorage/domstorage.go index 9bea2d0..ff8ae38 100644 --- a/cdp/domstorage/domstorage.go +++ b/cdp/domstorage/domstorage.go @@ -14,38 +14,6 @@ import ( cdp "github.com/knq/chromedp/cdp" ) -// EnableParams enables storage tracking, storage events will now be -// delivered to the client. -type EnableParams struct{} - -// Enable enables storage tracking, storage events will now be delivered to -// the client. -func Enable() *EnableParams { - return &EnableParams{} -} - -// Do executes DOMStorage.enable against the provided context and -// target handler. -func (p *EnableParams) Do(ctxt context.Context, h cdp.Handler) (err error) { - return h.Execute(ctxt, cdp.CommandDOMStorageEnable, nil, nil) -} - -// DisableParams disables storage tracking, prevents storage events from -// being sent to the client. -type DisableParams struct{} - -// Disable disables storage tracking, prevents storage events from being sent -// to the client. -func Disable() *DisableParams { - return &DisableParams{} -} - -// Do executes DOMStorage.disable against the provided context and -// target handler. -func (p *DisableParams) Do(ctxt context.Context, h cdp.Handler) (err error) { - return h.Execute(ctxt, cdp.CommandDOMStorageDisable, nil, nil) -} - // ClearParams [no description]. type ClearParams struct { StorageID *StorageID `json:"storageId"` @@ -67,6 +35,38 @@ func (p *ClearParams) Do(ctxt context.Context, h cdp.Handler) (err error) { return h.Execute(ctxt, cdp.CommandDOMStorageClear, p, nil) } +// DisableParams disables storage tracking, prevents storage events from +// being sent to the client. +type DisableParams struct{} + +// Disable disables storage tracking, prevents storage events from being sent +// to the client. +func Disable() *DisableParams { + return &DisableParams{} +} + +// Do executes DOMStorage.disable against the provided context and +// target handler. +func (p *DisableParams) Do(ctxt context.Context, h cdp.Handler) (err error) { + return h.Execute(ctxt, cdp.CommandDOMStorageDisable, nil, nil) +} + +// EnableParams enables storage tracking, storage events will now be +// delivered to the client. +type EnableParams struct{} + +// Enable enables storage tracking, storage events will now be delivered to +// the client. +func Enable() *EnableParams { + return &EnableParams{} +} + +// Do executes DOMStorage.enable against the provided context and +// target handler. +func (p *EnableParams) Do(ctxt context.Context, h cdp.Handler) (err error) { + return h.Execute(ctxt, cdp.CommandDOMStorageEnable, nil, nil) +} + // GetDOMStorageItemsParams [no description]. type GetDOMStorageItemsParams struct { StorageID *StorageID `json:"storageId"` @@ -103,6 +103,30 @@ func (p *GetDOMStorageItemsParams) Do(ctxt context.Context, h cdp.Handler) (entr return res.Entries, nil } +// RemoveDOMStorageItemParams [no description]. +type RemoveDOMStorageItemParams struct { + StorageID *StorageID `json:"storageId"` + Key string `json:"key"` +} + +// RemoveDOMStorageItem [no description]. +// +// parameters: +// storageID +// key +func RemoveDOMStorageItem(storageID *StorageID, key string) *RemoveDOMStorageItemParams { + return &RemoveDOMStorageItemParams{ + StorageID: storageID, + Key: key, + } +} + +// Do executes DOMStorage.removeDOMStorageItem against the provided context and +// target handler. +func (p *RemoveDOMStorageItemParams) Do(ctxt context.Context, h cdp.Handler) (err error) { + return h.Execute(ctxt, cdp.CommandDOMStorageRemoveDOMStorageItem, p, nil) +} + // SetDOMStorageItemParams [no description]. type SetDOMStorageItemParams struct { StorageID *StorageID `json:"storageId"` @@ -129,27 +153,3 @@ func SetDOMStorageItem(storageID *StorageID, key string, value string) *SetDOMSt func (p *SetDOMStorageItemParams) Do(ctxt context.Context, h cdp.Handler) (err error) { return h.Execute(ctxt, cdp.CommandDOMStorageSetDOMStorageItem, p, nil) } - -// RemoveDOMStorageItemParams [no description]. -type RemoveDOMStorageItemParams struct { - StorageID *StorageID `json:"storageId"` - Key string `json:"key"` -} - -// RemoveDOMStorageItem [no description]. -// -// parameters: -// storageID -// key -func RemoveDOMStorageItem(storageID *StorageID, key string) *RemoveDOMStorageItemParams { - return &RemoveDOMStorageItemParams{ - StorageID: storageID, - Key: key, - } -} - -// Do executes DOMStorage.removeDOMStorageItem against the provided context and -// target handler. -func (p *RemoveDOMStorageItemParams) Do(ctxt context.Context, h cdp.Handler) (err error) { - return h.Execute(ctxt, cdp.CommandDOMStorageRemoveDOMStorageItem, p, nil) -} diff --git a/cdp/domstorage/events.go b/cdp/domstorage/events.go index 6b82f71..abd979e 100644 --- a/cdp/domstorage/events.go +++ b/cdp/domstorage/events.go @@ -6,9 +6,11 @@ import ( cdp "github.com/knq/chromedp/cdp" ) -// EventDomStorageItemsCleared [no description]. -type EventDomStorageItemsCleared struct { +// EventDomStorageItemAdded [no description]. +type EventDomStorageItemAdded struct { StorageID *StorageID `json:"storageId"` + Key string `json:"key"` + NewValue string `json:"newValue"` } // EventDomStorageItemRemoved [no description]. @@ -17,13 +19,6 @@ type EventDomStorageItemRemoved struct { Key string `json:"key"` } -// EventDomStorageItemAdded [no description]. -type EventDomStorageItemAdded struct { - StorageID *StorageID `json:"storageId"` - Key string `json:"key"` - NewValue string `json:"newValue"` -} - // EventDomStorageItemUpdated [no description]. type EventDomStorageItemUpdated struct { StorageID *StorageID `json:"storageId"` @@ -32,10 +27,15 @@ type EventDomStorageItemUpdated struct { NewValue string `json:"newValue"` } +// EventDomStorageItemsCleared [no description]. +type EventDomStorageItemsCleared struct { + StorageID *StorageID `json:"storageId"` +} + // EventTypes all event types in the domain. var EventTypes = []cdp.MethodType{ - cdp.EventDOMStorageDomStorageItemsCleared, - cdp.EventDOMStorageDomStorageItemRemoved, cdp.EventDOMStorageDomStorageItemAdded, + cdp.EventDOMStorageDomStorageItemRemoved, cdp.EventDOMStorageDomStorageItemUpdated, + cdp.EventDOMStorageDomStorageItemsCleared, } diff --git a/cdp/emulation/emulation.go b/cdp/emulation/emulation.go index 44832bd..7b0ca4d 100644 --- a/cdp/emulation/emulation.go +++ b/cdp/emulation/emulation.go @@ -16,6 +16,131 @@ import ( "github.com/knq/chromedp/cdp/runtime" ) +// CanEmulateParams tells whether emulation is supported. +type CanEmulateParams struct{} + +// CanEmulate tells whether emulation is supported. +func CanEmulate() *CanEmulateParams { + return &CanEmulateParams{} +} + +// CanEmulateReturns return values. +type CanEmulateReturns struct { + Result bool `json:"result,omitempty"` // True if emulation is supported. +} + +// Do executes Emulation.canEmulate against the provided context and +// target handler. +// +// returns: +// result - True if emulation is supported. +func (p *CanEmulateParams) Do(ctxt context.Context, h cdp.Handler) (result bool, err error) { + // execute + var res CanEmulateReturns + err = h.Execute(ctxt, cdp.CommandEmulationCanEmulate, nil, &res) + if err != nil { + return false, err + } + + return res.Result, nil +} + +// ClearDeviceMetricsOverrideParams clears the overridden device metrics. +type ClearDeviceMetricsOverrideParams struct{} + +// ClearDeviceMetricsOverride clears the overridden device metrics. +func ClearDeviceMetricsOverride() *ClearDeviceMetricsOverrideParams { + return &ClearDeviceMetricsOverrideParams{} +} + +// Do executes Emulation.clearDeviceMetricsOverride against the provided context and +// target handler. +func (p *ClearDeviceMetricsOverrideParams) Do(ctxt context.Context, h cdp.Handler) (err error) { + return h.Execute(ctxt, cdp.CommandEmulationClearDeviceMetricsOverride, nil, nil) +} + +// ClearGeolocationOverrideParams clears the overridden Geolocation Position +// and Error. +type ClearGeolocationOverrideParams struct{} + +// ClearGeolocationOverride clears the overridden Geolocation Position and +// Error. +func ClearGeolocationOverride() *ClearGeolocationOverrideParams { + return &ClearGeolocationOverrideParams{} +} + +// Do executes Emulation.clearGeolocationOverride against the provided context and +// target handler. +func (p *ClearGeolocationOverrideParams) Do(ctxt context.Context, h cdp.Handler) (err error) { + return h.Execute(ctxt, cdp.CommandEmulationClearGeolocationOverride, nil, nil) +} + +// ResetPageScaleFactorParams requests that page scale factor is reset to +// initial values. +type ResetPageScaleFactorParams struct{} + +// ResetPageScaleFactor requests that page scale factor is reset to initial +// values. +func ResetPageScaleFactor() *ResetPageScaleFactorParams { + return &ResetPageScaleFactorParams{} +} + +// Do executes Emulation.resetPageScaleFactor against the provided context and +// target handler. +func (p *ResetPageScaleFactorParams) Do(ctxt context.Context, h cdp.Handler) (err error) { + return h.Execute(ctxt, cdp.CommandEmulationResetPageScaleFactor, nil, nil) +} + +// SetCPUThrottlingRateParams enables CPU throttling to emulate slow CPUs. +type SetCPUThrottlingRateParams struct { + Rate float64 `json:"rate"` // Throttling rate as a slowdown factor (1 is no throttle, 2 is 2x slowdown, etc). +} + +// SetCPUThrottlingRate enables CPU throttling to emulate slow CPUs. +// +// parameters: +// rate - Throttling rate as a slowdown factor (1 is no throttle, 2 is 2x slowdown, etc). +func SetCPUThrottlingRate(rate float64) *SetCPUThrottlingRateParams { + return &SetCPUThrottlingRateParams{ + Rate: rate, + } +} + +// Do executes Emulation.setCPUThrottlingRate against the provided context and +// target handler. +func (p *SetCPUThrottlingRateParams) Do(ctxt context.Context, h cdp.Handler) (err error) { + return h.Execute(ctxt, cdp.CommandEmulationSetCPUThrottlingRate, p, nil) +} + +// SetDefaultBackgroundColorOverrideParams sets or clears an override of the +// default background color of the frame. This override is used if the content +// does not specify one. +type SetDefaultBackgroundColorOverrideParams struct { + Color *cdp.RGBA `json:"color,omitempty"` // RGBA of the default background color. If not specified, any existing override will be cleared. +} + +// SetDefaultBackgroundColorOverride sets or clears an override of the +// default background color of the frame. This override is used if the content +// does not specify one. +// +// parameters: +func SetDefaultBackgroundColorOverride() *SetDefaultBackgroundColorOverrideParams { + return &SetDefaultBackgroundColorOverrideParams{} +} + +// WithColor rGBA of the default background color. If not specified, any +// existing override will be cleared. +func (p SetDefaultBackgroundColorOverrideParams) WithColor(color *cdp.RGBA) *SetDefaultBackgroundColorOverrideParams { + p.Color = color + return &p +} + +// Do executes Emulation.setDefaultBackgroundColorOverride against the provided context and +// target handler. +func (p *SetDefaultBackgroundColorOverrideParams) Do(ctxt context.Context, h cdp.Handler) (err error) { + return h.Execute(ctxt, cdp.CommandEmulationSetDefaultBackgroundColorOverride, p, nil) +} + // SetDeviceMetricsOverrideParams overrides the values of device screen // dimensions (window.screen.width, window.screen.height, window.innerWidth, // window.innerHeight, and "device-width"/"device-height"-related CSS media @@ -115,164 +240,6 @@ func (p *SetDeviceMetricsOverrideParams) Do(ctxt context.Context, h cdp.Handler) return h.Execute(ctxt, cdp.CommandEmulationSetDeviceMetricsOverride, p, nil) } -// ClearDeviceMetricsOverrideParams clears the overridden device metrics. -type ClearDeviceMetricsOverrideParams struct{} - -// ClearDeviceMetricsOverride clears the overridden device metrics. -func ClearDeviceMetricsOverride() *ClearDeviceMetricsOverrideParams { - return &ClearDeviceMetricsOverrideParams{} -} - -// Do executes Emulation.clearDeviceMetricsOverride against the provided context and -// target handler. -func (p *ClearDeviceMetricsOverrideParams) Do(ctxt context.Context, h cdp.Handler) (err error) { - return h.Execute(ctxt, cdp.CommandEmulationClearDeviceMetricsOverride, nil, nil) -} - -// ResetPageScaleFactorParams requests that page scale factor is reset to -// initial values. -type ResetPageScaleFactorParams struct{} - -// ResetPageScaleFactor requests that page scale factor is reset to initial -// values. -func ResetPageScaleFactor() *ResetPageScaleFactorParams { - return &ResetPageScaleFactorParams{} -} - -// Do executes Emulation.resetPageScaleFactor against the provided context and -// target handler. -func (p *ResetPageScaleFactorParams) Do(ctxt context.Context, h cdp.Handler) (err error) { - return h.Execute(ctxt, cdp.CommandEmulationResetPageScaleFactor, nil, nil) -} - -// SetPageScaleFactorParams sets a specified page scale factor. -type SetPageScaleFactorParams struct { - PageScaleFactor float64 `json:"pageScaleFactor"` // Page scale factor. -} - -// SetPageScaleFactor sets a specified page scale factor. -// -// parameters: -// pageScaleFactor - Page scale factor. -func SetPageScaleFactor(pageScaleFactor float64) *SetPageScaleFactorParams { - return &SetPageScaleFactorParams{ - PageScaleFactor: pageScaleFactor, - } -} - -// Do executes Emulation.setPageScaleFactor against the provided context and -// target handler. -func (p *SetPageScaleFactorParams) Do(ctxt context.Context, h cdp.Handler) (err error) { - return h.Execute(ctxt, cdp.CommandEmulationSetPageScaleFactor, p, nil) -} - -// SetScriptExecutionDisabledParams switches script execution in the page. -type SetScriptExecutionDisabledParams struct { - Value bool `json:"value"` // Whether script execution should be disabled in the page. -} - -// SetScriptExecutionDisabled switches script execution in the page. -// -// parameters: -// value - Whether script execution should be disabled in the page. -func SetScriptExecutionDisabled(value bool) *SetScriptExecutionDisabledParams { - return &SetScriptExecutionDisabledParams{ - Value: value, - } -} - -// Do executes Emulation.setScriptExecutionDisabled against the provided context and -// target handler. -func (p *SetScriptExecutionDisabledParams) Do(ctxt context.Context, h cdp.Handler) (err error) { - return h.Execute(ctxt, cdp.CommandEmulationSetScriptExecutionDisabled, p, nil) -} - -// SetGeolocationOverrideParams overrides the Geolocation Position or Error. -// Omitting any of the parameters emulates position unavailable. -type SetGeolocationOverrideParams struct { - Latitude float64 `json:"latitude,omitempty"` // Mock latitude - Longitude float64 `json:"longitude,omitempty"` // Mock longitude - Accuracy float64 `json:"accuracy,omitempty"` // Mock accuracy -} - -// SetGeolocationOverride overrides the Geolocation Position or Error. -// Omitting any of the parameters emulates position unavailable. -// -// parameters: -func SetGeolocationOverride() *SetGeolocationOverrideParams { - return &SetGeolocationOverrideParams{} -} - -// WithLatitude mock latitude. -func (p SetGeolocationOverrideParams) WithLatitude(latitude float64) *SetGeolocationOverrideParams { - p.Latitude = latitude - return &p -} - -// WithLongitude mock longitude. -func (p SetGeolocationOverrideParams) WithLongitude(longitude float64) *SetGeolocationOverrideParams { - p.Longitude = longitude - return &p -} - -// WithAccuracy mock accuracy. -func (p SetGeolocationOverrideParams) WithAccuracy(accuracy float64) *SetGeolocationOverrideParams { - p.Accuracy = accuracy - return &p -} - -// Do executes Emulation.setGeolocationOverride against the provided context and -// target handler. -func (p *SetGeolocationOverrideParams) Do(ctxt context.Context, h cdp.Handler) (err error) { - return h.Execute(ctxt, cdp.CommandEmulationSetGeolocationOverride, p, nil) -} - -// ClearGeolocationOverrideParams clears the overridden Geolocation Position -// and Error. -type ClearGeolocationOverrideParams struct{} - -// ClearGeolocationOverride clears the overridden Geolocation Position and -// Error. -func ClearGeolocationOverride() *ClearGeolocationOverrideParams { - return &ClearGeolocationOverrideParams{} -} - -// Do executes Emulation.clearGeolocationOverride against the provided context and -// target handler. -func (p *ClearGeolocationOverrideParams) Do(ctxt context.Context, h cdp.Handler) (err error) { - return h.Execute(ctxt, cdp.CommandEmulationClearGeolocationOverride, nil, nil) -} - -// SetTouchEmulationEnabledParams enables touch on platforms which do not -// support them. -type SetTouchEmulationEnabledParams struct { - Enabled bool `json:"enabled"` // Whether the touch event emulation should be enabled. - MaxTouchPoints int64 `json:"maxTouchPoints,omitempty"` // Maximum touch points supported. Defaults to one. -} - -// SetTouchEmulationEnabled enables touch on platforms which do not support -// them. -// -// parameters: -// enabled - Whether the touch event emulation should be enabled. -func SetTouchEmulationEnabled(enabled bool) *SetTouchEmulationEnabledParams { - return &SetTouchEmulationEnabledParams{ - Enabled: enabled, - } -} - -// WithMaxTouchPoints maximum touch points supported. Defaults to one. -func (p SetTouchEmulationEnabledParams) WithMaxTouchPoints(maxTouchPoints int64) *SetTouchEmulationEnabledParams { - p.MaxTouchPoints = maxTouchPoints - return &p -} - -// Do executes Emulation.setTouchEmulationEnabled against the provided context and -// target handler. -func (p *SetTouchEmulationEnabledParams) Do(ctxt context.Context, h cdp.Handler) (err error) { - return h.Execute(ctxt, cdp.CommandEmulationSetTouchEmulationEnabled, p, nil) -} - // SetEmitTouchEventsForMouseParams [no description]. type SetEmitTouchEventsForMouseParams struct { Enabled bool `json:"enabled"` // Whether touch emulation based on mouse input should be enabled. @@ -323,54 +290,139 @@ func (p *SetEmulatedMediaParams) Do(ctxt context.Context, h cdp.Handler) (err er return h.Execute(ctxt, cdp.CommandEmulationSetEmulatedMedia, p, nil) } -// SetCPUThrottlingRateParams enables CPU throttling to emulate slow CPUs. -type SetCPUThrottlingRateParams struct { - Rate float64 `json:"rate"` // Throttling rate as a slowdown factor (1 is no throttle, 2 is 2x slowdown, etc). +// SetGeolocationOverrideParams overrides the Geolocation Position or Error. +// Omitting any of the parameters emulates position unavailable. +type SetGeolocationOverrideParams struct { + Latitude float64 `json:"latitude,omitempty"` // Mock latitude + Longitude float64 `json:"longitude,omitempty"` // Mock longitude + Accuracy float64 `json:"accuracy,omitempty"` // Mock accuracy } -// SetCPUThrottlingRate enables CPU throttling to emulate slow CPUs. +// SetGeolocationOverride overrides the Geolocation Position or Error. +// Omitting any of the parameters emulates position unavailable. // // parameters: -// rate - Throttling rate as a slowdown factor (1 is no throttle, 2 is 2x slowdown, etc). -func SetCPUThrottlingRate(rate float64) *SetCPUThrottlingRateParams { - return &SetCPUThrottlingRateParams{ - Rate: rate, - } +func SetGeolocationOverride() *SetGeolocationOverrideParams { + return &SetGeolocationOverrideParams{} } -// Do executes Emulation.setCPUThrottlingRate against the provided context and +// WithLatitude mock latitude. +func (p SetGeolocationOverrideParams) WithLatitude(latitude float64) *SetGeolocationOverrideParams { + p.Latitude = latitude + return &p +} + +// WithLongitude mock longitude. +func (p SetGeolocationOverrideParams) WithLongitude(longitude float64) *SetGeolocationOverrideParams { + p.Longitude = longitude + return &p +} + +// WithAccuracy mock accuracy. +func (p SetGeolocationOverrideParams) WithAccuracy(accuracy float64) *SetGeolocationOverrideParams { + p.Accuracy = accuracy + return &p +} + +// Do executes Emulation.setGeolocationOverride against the provided context and // target handler. -func (p *SetCPUThrottlingRateParams) Do(ctxt context.Context, h cdp.Handler) (err error) { - return h.Execute(ctxt, cdp.CommandEmulationSetCPUThrottlingRate, p, nil) +func (p *SetGeolocationOverrideParams) Do(ctxt context.Context, h cdp.Handler) (err error) { + return h.Execute(ctxt, cdp.CommandEmulationSetGeolocationOverride, p, nil) } -// CanEmulateParams tells whether emulation is supported. -type CanEmulateParams struct{} - -// CanEmulate tells whether emulation is supported. -func CanEmulate() *CanEmulateParams { - return &CanEmulateParams{} +// SetNavigatorOverridesParams overrides value returned by the javascript +// navigator object. +type SetNavigatorOverridesParams struct { + Platform string `json:"platform"` // The platform navigator.platform should return. } -// CanEmulateReturns return values. -type CanEmulateReturns struct { - Result bool `json:"result,omitempty"` // True if emulation is supported. -} - -// Do executes Emulation.canEmulate against the provided context and -// target handler. +// SetNavigatorOverrides overrides value returned by the javascript navigator +// object. // -// returns: -// result - True if emulation is supported. -func (p *CanEmulateParams) Do(ctxt context.Context, h cdp.Handler) (result bool, err error) { - // execute - var res CanEmulateReturns - err = h.Execute(ctxt, cdp.CommandEmulationCanEmulate, nil, &res) - if err != nil { - return false, err +// parameters: +// platform - The platform navigator.platform should return. +func SetNavigatorOverrides(platform string) *SetNavigatorOverridesParams { + return &SetNavigatorOverridesParams{ + Platform: platform, } +} - return res.Result, nil +// Do executes Emulation.setNavigatorOverrides against the provided context and +// target handler. +func (p *SetNavigatorOverridesParams) Do(ctxt context.Context, h cdp.Handler) (err error) { + return h.Execute(ctxt, cdp.CommandEmulationSetNavigatorOverrides, p, nil) +} + +// SetPageScaleFactorParams sets a specified page scale factor. +type SetPageScaleFactorParams struct { + PageScaleFactor float64 `json:"pageScaleFactor"` // Page scale factor. +} + +// SetPageScaleFactor sets a specified page scale factor. +// +// parameters: +// pageScaleFactor - Page scale factor. +func SetPageScaleFactor(pageScaleFactor float64) *SetPageScaleFactorParams { + return &SetPageScaleFactorParams{ + PageScaleFactor: pageScaleFactor, + } +} + +// Do executes Emulation.setPageScaleFactor against the provided context and +// target handler. +func (p *SetPageScaleFactorParams) Do(ctxt context.Context, h cdp.Handler) (err error) { + return h.Execute(ctxt, cdp.CommandEmulationSetPageScaleFactor, p, nil) +} + +// SetScriptExecutionDisabledParams switches script execution in the page. +type SetScriptExecutionDisabledParams struct { + Value bool `json:"value"` // Whether script execution should be disabled in the page. +} + +// SetScriptExecutionDisabled switches script execution in the page. +// +// parameters: +// value - Whether script execution should be disabled in the page. +func SetScriptExecutionDisabled(value bool) *SetScriptExecutionDisabledParams { + return &SetScriptExecutionDisabledParams{ + Value: value, + } +} + +// Do executes Emulation.setScriptExecutionDisabled against the provided context and +// target handler. +func (p *SetScriptExecutionDisabledParams) Do(ctxt context.Context, h cdp.Handler) (err error) { + return h.Execute(ctxt, cdp.CommandEmulationSetScriptExecutionDisabled, p, nil) +} + +// SetTouchEmulationEnabledParams enables touch on platforms which do not +// support them. +type SetTouchEmulationEnabledParams struct { + Enabled bool `json:"enabled"` // Whether the touch event emulation should be enabled. + MaxTouchPoints int64 `json:"maxTouchPoints,omitempty"` // Maximum touch points supported. Defaults to one. +} + +// SetTouchEmulationEnabled enables touch on platforms which do not support +// them. +// +// parameters: +// enabled - Whether the touch event emulation should be enabled. +func SetTouchEmulationEnabled(enabled bool) *SetTouchEmulationEnabledParams { + return &SetTouchEmulationEnabledParams{ + Enabled: enabled, + } +} + +// WithMaxTouchPoints maximum touch points supported. Defaults to one. +func (p SetTouchEmulationEnabledParams) WithMaxTouchPoints(maxTouchPoints int64) *SetTouchEmulationEnabledParams { + p.MaxTouchPoints = maxTouchPoints + return &p +} + +// Do executes Emulation.setTouchEmulationEnabled against the provided context and +// target handler. +func (p *SetTouchEmulationEnabledParams) Do(ctxt context.Context, h cdp.Handler) (err error) { + return h.Execute(ctxt, cdp.CommandEmulationSetTouchEmulationEnabled, p, nil) } // SetVirtualTimePolicyParams turns on virtual time for all frames (replacing @@ -429,55 +481,3 @@ func (p *SetVirtualTimePolicyParams) Do(ctxt context.Context, h cdp.Handler) (vi return res.VirtualTimeBase, nil } - -// SetNavigatorOverridesParams overrides value returned by the javascript -// navigator object. -type SetNavigatorOverridesParams struct { - Platform string `json:"platform"` // The platform navigator.platform should return. -} - -// SetNavigatorOverrides overrides value returned by the javascript navigator -// object. -// -// parameters: -// platform - The platform navigator.platform should return. -func SetNavigatorOverrides(platform string) *SetNavigatorOverridesParams { - return &SetNavigatorOverridesParams{ - Platform: platform, - } -} - -// Do executes Emulation.setNavigatorOverrides against the provided context and -// target handler. -func (p *SetNavigatorOverridesParams) Do(ctxt context.Context, h cdp.Handler) (err error) { - return h.Execute(ctxt, cdp.CommandEmulationSetNavigatorOverrides, p, nil) -} - -// SetDefaultBackgroundColorOverrideParams sets or clears an override of the -// default background color of the frame. This override is used if the content -// does not specify one. -type SetDefaultBackgroundColorOverrideParams struct { - Color *cdp.RGBA `json:"color,omitempty"` // RGBA of the default background color. If not specified, any existing override will be cleared. -} - -// SetDefaultBackgroundColorOverride sets or clears an override of the -// default background color of the frame. This override is used if the content -// does not specify one. -// -// parameters: -func SetDefaultBackgroundColorOverride() *SetDefaultBackgroundColorOverrideParams { - return &SetDefaultBackgroundColorOverrideParams{} -} - -// WithColor rGBA of the default background color. If not specified, any -// existing override will be cleared. -func (p SetDefaultBackgroundColorOverrideParams) WithColor(color *cdp.RGBA) *SetDefaultBackgroundColorOverrideParams { - p.Color = color - return &p -} - -// Do executes Emulation.setDefaultBackgroundColorOverride against the provided context and -// target handler. -func (p *SetDefaultBackgroundColorOverrideParams) Do(ctxt context.Context, h cdp.Handler) (err error) { - return h.Execute(ctxt, cdp.CommandEmulationSetDefaultBackgroundColorOverride, p, nil) -} diff --git a/cdp/emulation/events.go b/cdp/emulation/events.go index 259246b..42c4ab6 100644 --- a/cdp/emulation/events.go +++ b/cdp/emulation/events.go @@ -6,16 +6,16 @@ import ( cdp "github.com/knq/chromedp/cdp" ) -// EventVirtualTimeBudgetExpired notification sent after the virtual time -// budget for the current VirtualTimePolicy has run out. -type EventVirtualTimeBudgetExpired struct{} - // EventVirtualTimeAdvanced notification sent after the virtual time has // advanced. type EventVirtualTimeAdvanced struct { VirtualTimeElapsed float64 `json:"virtualTimeElapsed"` // The amount of virtual time that has elapsed in milliseconds since virtual time was first enabled. } +// EventVirtualTimeBudgetExpired notification sent after the virtual time +// budget for the current VirtualTimePolicy has run out. +type EventVirtualTimeBudgetExpired struct{} + // EventVirtualTimePaused notification sent after the virtual time has // paused. type EventVirtualTimePaused struct { @@ -24,7 +24,7 @@ type EventVirtualTimePaused struct { // EventTypes all event types in the domain. var EventTypes = []cdp.MethodType{ - cdp.EventEmulationVirtualTimeBudgetExpired, cdp.EventEmulationVirtualTimeAdvanced, + cdp.EventEmulationVirtualTimeBudgetExpired, cdp.EventEmulationVirtualTimePaused, } diff --git a/cdp/headlessexperimental/events.go b/cdp/headlessexperimental/events.go index 02a46dd..e68a007 100644 --- a/cdp/headlessexperimental/events.go +++ b/cdp/headlessexperimental/events.go @@ -6,19 +6,19 @@ import ( cdp "github.com/knq/chromedp/cdp" ) +// EventMainFrameReadyForScreenshots issued when the main frame has first +// submitted a frame to the browser. May only be fired while a BeginFrame is in +// flight. Before this event, screenshotting requests may fail. +type EventMainFrameReadyForScreenshots struct{} + // EventNeedsBeginFramesChanged issued when the target starts or stops // needing BeginFrames. type EventNeedsBeginFramesChanged struct { NeedsBeginFrames bool `json:"needsBeginFrames"` // True if BeginFrames are needed, false otherwise. } -// EventMainFrameReadyForScreenshots issued when the main frame has first -// submitted a frame to the browser. May only be fired while a BeginFrame is in -// flight. Before this event, screenshotting requests may fail. -type EventMainFrameReadyForScreenshots struct{} - // EventTypes all event types in the domain. var EventTypes = []cdp.MethodType{ - cdp.EventHeadlessExperimentalNeedsBeginFramesChanged, cdp.EventHeadlessExperimentalMainFrameReadyForScreenshots, + cdp.EventHeadlessExperimentalNeedsBeginFramesChanged, } diff --git a/cdp/headlessexperimental/headlessexperimental.go b/cdp/headlessexperimental/headlessexperimental.go index a29441b..b3b9b75 100644 --- a/cdp/headlessexperimental/headlessexperimental.go +++ b/cdp/headlessexperimental/headlessexperimental.go @@ -17,34 +17,6 @@ import ( "github.com/knq/chromedp/cdp/runtime" ) -// EnableParams enables headless events for the target. -type EnableParams struct{} - -// Enable enables headless events for the target. -func Enable() *EnableParams { - return &EnableParams{} -} - -// Do executes HeadlessExperimental.enable against the provided context and -// target handler. -func (p *EnableParams) Do(ctxt context.Context, h cdp.Handler) (err error) { - return h.Execute(ctxt, cdp.CommandHeadlessExperimentalEnable, nil, nil) -} - -// DisableParams disables headless events for the target. -type DisableParams struct{} - -// Disable disables headless events for the target. -func Disable() *DisableParams { - return &DisableParams{} -} - -// Do executes HeadlessExperimental.disable against the provided context and -// target handler. -func (p *DisableParams) Do(ctxt context.Context, h cdp.Handler) (err error) { - return h.Execute(ctxt, cdp.CommandHeadlessExperimentalDisable, nil, nil) -} - // BeginFrameParams sends a BeginFrame to the target and returns when the // frame was completed. Optionally captures a screenshot from the resulting // frame. Requires that the target was created with enabled BeginFrameControl. @@ -123,3 +95,31 @@ func (p *BeginFrameParams) Do(ctxt context.Context, h cdp.Handler) (hasDamage bo } return res.HasDamage, res.MainFrameContentUpdated, dec, nil } + +// DisableParams disables headless events for the target. +type DisableParams struct{} + +// Disable disables headless events for the target. +func Disable() *DisableParams { + return &DisableParams{} +} + +// Do executes HeadlessExperimental.disable against the provided context and +// target handler. +func (p *DisableParams) Do(ctxt context.Context, h cdp.Handler) (err error) { + return h.Execute(ctxt, cdp.CommandHeadlessExperimentalDisable, nil, nil) +} + +// EnableParams enables headless events for the target. +type EnableParams struct{} + +// Enable enables headless events for the target. +func Enable() *EnableParams { + return &EnableParams{} +} + +// Do executes HeadlessExperimental.enable against the provided context and +// target handler. +func (p *EnableParams) Do(ctxt context.Context, h cdp.Handler) (err error) { + return h.Execute(ctxt, cdp.CommandHeadlessExperimentalEnable, nil, nil) +} diff --git a/cdp/heapprofiler/events.go b/cdp/heapprofiler/events.go index 1d87378..c3b089c 100644 --- a/cdp/heapprofiler/events.go +++ b/cdp/heapprofiler/events.go @@ -11,14 +11,10 @@ type EventAddHeapSnapshotChunk struct { Chunk string `json:"chunk"` } -// EventResetProfiles [no description]. -type EventResetProfiles struct{} - -// EventReportHeapSnapshotProgress [no description]. -type EventReportHeapSnapshotProgress struct { - Done int64 `json:"done"` - Total int64 `json:"total"` - Finished bool `json:"finished,omitempty"` +// EventHeapStatsUpdate if heap objects tracking has been started then +// backend may send update for one or more fragments. +type EventHeapStatsUpdate struct { + StatsUpdate []int64 `json:"statsUpdate"` // An array of triplets. Each triplet describes a fragment. The first integer is the fragment index, the second integer is a total count of objects for the fragment, the third integer is a total size of the objects for the fragment. } // EventLastSeenObjectID if heap objects tracking has been started then @@ -31,17 +27,21 @@ type EventLastSeenObjectID struct { Timestamp float64 `json:"timestamp"` } -// EventHeapStatsUpdate if heap objects tracking has been started then -// backend may send update for one or more fragments. -type EventHeapStatsUpdate struct { - StatsUpdate []int64 `json:"statsUpdate"` // An array of triplets. Each triplet describes a fragment. The first integer is the fragment index, the second integer is a total count of objects for the fragment, the third integer is a total size of the objects for the fragment. +// EventReportHeapSnapshotProgress [no description]. +type EventReportHeapSnapshotProgress struct { + Done int64 `json:"done"` + Total int64 `json:"total"` + Finished bool `json:"finished,omitempty"` } +// EventResetProfiles [no description]. +type EventResetProfiles struct{} + // EventTypes all event types in the domain. var EventTypes = []cdp.MethodType{ cdp.EventHeapProfilerAddHeapSnapshotChunk, - cdp.EventHeapProfilerResetProfiles, - cdp.EventHeapProfilerReportHeapSnapshotProgress, - cdp.EventHeapProfilerLastSeenObjectID, cdp.EventHeapProfilerHeapStatsUpdate, + cdp.EventHeapProfilerLastSeenObjectID, + cdp.EventHeapProfilerReportHeapSnapshotProgress, + cdp.EventHeapProfilerResetProfiles, } diff --git a/cdp/heapprofiler/heapprofiler.go b/cdp/heapprofiler/heapprofiler.go index 22fcd83..509ab97 100644 --- a/cdp/heapprofiler/heapprofiler.go +++ b/cdp/heapprofiler/heapprofiler.go @@ -13,18 +13,41 @@ import ( "github.com/knq/chromedp/cdp/runtime" ) -// EnableParams [no description]. -type EnableParams struct{} - -// Enable [no description]. -func Enable() *EnableParams { - return &EnableParams{} +// AddInspectedHeapObjectParams enables console to refer to the node with +// given id via $x (see Command Line API for more details $x functions). +type AddInspectedHeapObjectParams struct { + HeapObjectID HeapSnapshotObjectID `json:"heapObjectId"` // Heap snapshot object id to be accessible by means of $x command line API. } -// Do executes HeapProfiler.enable against the provided context and +// AddInspectedHeapObject enables console to refer to the node with given id +// via $x (see Command Line API for more details $x functions). +// +// parameters: +// heapObjectID - Heap snapshot object id to be accessible by means of $x command line API. +func AddInspectedHeapObject(heapObjectID HeapSnapshotObjectID) *AddInspectedHeapObjectParams { + return &AddInspectedHeapObjectParams{ + HeapObjectID: heapObjectID, + } +} + +// Do executes HeapProfiler.addInspectedHeapObject against the provided context and // target handler. -func (p *EnableParams) Do(ctxt context.Context, h cdp.Handler) (err error) { - return h.Execute(ctxt, cdp.CommandHeapProfilerEnable, nil, nil) +func (p *AddInspectedHeapObjectParams) Do(ctxt context.Context, h cdp.Handler) (err error) { + return h.Execute(ctxt, cdp.CommandHeapProfilerAddInspectedHeapObject, p, nil) +} + +// CollectGarbageParams [no description]. +type CollectGarbageParams struct{} + +// CollectGarbage [no description]. +func CollectGarbage() *CollectGarbageParams { + return &CollectGarbageParams{} +} + +// Do executes HeapProfiler.collectGarbage against the provided context and +// target handler. +func (p *CollectGarbageParams) Do(ctxt context.Context, h cdp.Handler) (err error) { + return h.Execute(ctxt, cdp.CommandHeapProfilerCollectGarbage, nil, nil) } // DisableParams [no description]. @@ -41,6 +64,154 @@ func (p *DisableParams) Do(ctxt context.Context, h cdp.Handler) (err error) { return h.Execute(ctxt, cdp.CommandHeapProfilerDisable, nil, nil) } +// EnableParams [no description]. +type EnableParams struct{} + +// Enable [no description]. +func Enable() *EnableParams { + return &EnableParams{} +} + +// Do executes HeapProfiler.enable against the provided context and +// target handler. +func (p *EnableParams) Do(ctxt context.Context, h cdp.Handler) (err error) { + return h.Execute(ctxt, cdp.CommandHeapProfilerEnable, nil, nil) +} + +// GetHeapObjectIDParams [no description]. +type GetHeapObjectIDParams struct { + ObjectID runtime.RemoteObjectID `json:"objectId"` // Identifier of the object to get heap object id for. +} + +// GetHeapObjectID [no description]. +// +// parameters: +// objectID - Identifier of the object to get heap object id for. +func GetHeapObjectID(objectID runtime.RemoteObjectID) *GetHeapObjectIDParams { + return &GetHeapObjectIDParams{ + ObjectID: objectID, + } +} + +// GetHeapObjectIDReturns return values. +type GetHeapObjectIDReturns struct { + HeapSnapshotObjectID HeapSnapshotObjectID `json:"heapSnapshotObjectId,omitempty"` // Id of the heap snapshot object corresponding to the passed remote object id. +} + +// Do executes HeapProfiler.getHeapObjectId against the provided context and +// target handler. +// +// returns: +// heapSnapshotObjectID - Id of the heap snapshot object corresponding to the passed remote object id. +func (p *GetHeapObjectIDParams) Do(ctxt context.Context, h cdp.Handler) (heapSnapshotObjectID HeapSnapshotObjectID, err error) { + // execute + var res GetHeapObjectIDReturns + err = h.Execute(ctxt, cdp.CommandHeapProfilerGetHeapObjectID, p, &res) + if err != nil { + return "", err + } + + return res.HeapSnapshotObjectID, nil +} + +// GetObjectByHeapObjectIDParams [no description]. +type GetObjectByHeapObjectIDParams struct { + ObjectID HeapSnapshotObjectID `json:"objectId"` + ObjectGroup string `json:"objectGroup,omitempty"` // Symbolic group name that can be used to release multiple objects. +} + +// GetObjectByHeapObjectID [no description]. +// +// parameters: +// objectID +func GetObjectByHeapObjectID(objectID HeapSnapshotObjectID) *GetObjectByHeapObjectIDParams { + return &GetObjectByHeapObjectIDParams{ + ObjectID: objectID, + } +} + +// WithObjectGroup symbolic group name that can be used to release multiple +// objects. +func (p GetObjectByHeapObjectIDParams) WithObjectGroup(objectGroup string) *GetObjectByHeapObjectIDParams { + p.ObjectGroup = objectGroup + return &p +} + +// GetObjectByHeapObjectIDReturns return values. +type GetObjectByHeapObjectIDReturns struct { + Result *runtime.RemoteObject `json:"result,omitempty"` // Evaluation result. +} + +// Do executes HeapProfiler.getObjectByHeapObjectId against the provided context and +// target handler. +// +// returns: +// result - Evaluation result. +func (p *GetObjectByHeapObjectIDParams) Do(ctxt context.Context, h cdp.Handler) (result *runtime.RemoteObject, err error) { + // execute + var res GetObjectByHeapObjectIDReturns + err = h.Execute(ctxt, cdp.CommandHeapProfilerGetObjectByHeapObjectID, p, &res) + if err != nil { + return nil, err + } + + return res.Result, nil +} + +// GetSamplingProfileParams [no description]. +type GetSamplingProfileParams struct{} + +// GetSamplingProfile [no description]. +func GetSamplingProfile() *GetSamplingProfileParams { + return &GetSamplingProfileParams{} +} + +// GetSamplingProfileReturns return values. +type GetSamplingProfileReturns struct { + Profile *SamplingHeapProfile `json:"profile,omitempty"` // Return the sampling profile being collected. +} + +// Do executes HeapProfiler.getSamplingProfile against the provided context and +// target handler. +// +// returns: +// profile - Return the sampling profile being collected. +func (p *GetSamplingProfileParams) Do(ctxt context.Context, h cdp.Handler) (profile *SamplingHeapProfile, err error) { + // execute + var res GetSamplingProfileReturns + err = h.Execute(ctxt, cdp.CommandHeapProfilerGetSamplingProfile, nil, &res) + if err != nil { + return nil, err + } + + return res.Profile, nil +} + +// StartSamplingParams [no description]. +type StartSamplingParams struct { + SamplingInterval float64 `json:"samplingInterval,omitempty"` // Average sample interval in bytes. Poisson distribution is used for the intervals. The default value is 32768 bytes. +} + +// StartSampling [no description]. +// +// parameters: +func StartSampling() *StartSamplingParams { + return &StartSamplingParams{} +} + +// WithSamplingInterval average sample interval in bytes. Poisson +// distribution is used for the intervals. The default value is 32768 bytes. +func (p StartSamplingParams) WithSamplingInterval(samplingInterval float64) *StartSamplingParams { + p.SamplingInterval = samplingInterval + return &p +} + +// Do executes HeapProfiler.startSampling against the provided context and +// target handler. +func (p *StartSamplingParams) Do(ctxt context.Context, h cdp.Handler) (err error) { + return h.Execute(ctxt, cdp.CommandHeapProfilerStartSampling, p, nil) +} + // StartTrackingHeapObjectsParams [no description]. type StartTrackingHeapObjectsParams struct { TrackAllocations bool `json:"trackAllocations,omitempty"` @@ -65,6 +236,35 @@ func (p *StartTrackingHeapObjectsParams) Do(ctxt context.Context, h cdp.Handler) return h.Execute(ctxt, cdp.CommandHeapProfilerStartTrackingHeapObjects, p, nil) } +// StopSamplingParams [no description]. +type StopSamplingParams struct{} + +// StopSampling [no description]. +func StopSampling() *StopSamplingParams { + return &StopSamplingParams{} +} + +// StopSamplingReturns return values. +type StopSamplingReturns struct { + Profile *SamplingHeapProfile `json:"profile,omitempty"` // Recorded sampling heap profile. +} + +// Do executes HeapProfiler.stopSampling against the provided context and +// target handler. +// +// returns: +// profile - Recorded sampling heap profile. +func (p *StopSamplingParams) Do(ctxt context.Context, h cdp.Handler) (profile *SamplingHeapProfile, err error) { + // execute + var res StopSamplingReturns + err = h.Execute(ctxt, cdp.CommandHeapProfilerStopSampling, nil, &res) + if err != nil { + return nil, err + } + + return res.Profile, nil +} + // StopTrackingHeapObjectsParams [no description]. type StopTrackingHeapObjectsParams struct { ReportProgress bool `json:"reportProgress,omitempty"` // If true 'reportHeapSnapshotProgress' events will be generated while snapshot is being taken when the tracking is stopped. @@ -114,203 +314,3 @@ func (p TakeHeapSnapshotParams) WithReportProgress(reportProgress bool) *TakeHea func (p *TakeHeapSnapshotParams) Do(ctxt context.Context, h cdp.Handler) (err error) { return h.Execute(ctxt, cdp.CommandHeapProfilerTakeHeapSnapshot, p, nil) } - -// CollectGarbageParams [no description]. -type CollectGarbageParams struct{} - -// CollectGarbage [no description]. -func CollectGarbage() *CollectGarbageParams { - return &CollectGarbageParams{} -} - -// Do executes HeapProfiler.collectGarbage against the provided context and -// target handler. -func (p *CollectGarbageParams) Do(ctxt context.Context, h cdp.Handler) (err error) { - return h.Execute(ctxt, cdp.CommandHeapProfilerCollectGarbage, nil, nil) -} - -// GetObjectByHeapObjectIDParams [no description]. -type GetObjectByHeapObjectIDParams struct { - ObjectID HeapSnapshotObjectID `json:"objectId"` - ObjectGroup string `json:"objectGroup,omitempty"` // Symbolic group name that can be used to release multiple objects. -} - -// GetObjectByHeapObjectID [no description]. -// -// parameters: -// objectID -func GetObjectByHeapObjectID(objectID HeapSnapshotObjectID) *GetObjectByHeapObjectIDParams { - return &GetObjectByHeapObjectIDParams{ - ObjectID: objectID, - } -} - -// WithObjectGroup symbolic group name that can be used to release multiple -// objects. -func (p GetObjectByHeapObjectIDParams) WithObjectGroup(objectGroup string) *GetObjectByHeapObjectIDParams { - p.ObjectGroup = objectGroup - return &p -} - -// GetObjectByHeapObjectIDReturns return values. -type GetObjectByHeapObjectIDReturns struct { - Result *runtime.RemoteObject `json:"result,omitempty"` // Evaluation result. -} - -// Do executes HeapProfiler.getObjectByHeapObjectId against the provided context and -// target handler. -// -// returns: -// result - Evaluation result. -func (p *GetObjectByHeapObjectIDParams) Do(ctxt context.Context, h cdp.Handler) (result *runtime.RemoteObject, err error) { - // execute - var res GetObjectByHeapObjectIDReturns - err = h.Execute(ctxt, cdp.CommandHeapProfilerGetObjectByHeapObjectID, p, &res) - if err != nil { - return nil, err - } - - return res.Result, nil -} - -// AddInspectedHeapObjectParams enables console to refer to the node with -// given id via $x (see Command Line API for more details $x functions). -type AddInspectedHeapObjectParams struct { - HeapObjectID HeapSnapshotObjectID `json:"heapObjectId"` // Heap snapshot object id to be accessible by means of $x command line API. -} - -// AddInspectedHeapObject enables console to refer to the node with given id -// via $x (see Command Line API for more details $x functions). -// -// parameters: -// heapObjectID - Heap snapshot object id to be accessible by means of $x command line API. -func AddInspectedHeapObject(heapObjectID HeapSnapshotObjectID) *AddInspectedHeapObjectParams { - return &AddInspectedHeapObjectParams{ - HeapObjectID: heapObjectID, - } -} - -// Do executes HeapProfiler.addInspectedHeapObject against the provided context and -// target handler. -func (p *AddInspectedHeapObjectParams) Do(ctxt context.Context, h cdp.Handler) (err error) { - return h.Execute(ctxt, cdp.CommandHeapProfilerAddInspectedHeapObject, p, nil) -} - -// GetHeapObjectIDParams [no description]. -type GetHeapObjectIDParams struct { - ObjectID runtime.RemoteObjectID `json:"objectId"` // Identifier of the object to get heap object id for. -} - -// GetHeapObjectID [no description]. -// -// parameters: -// objectID - Identifier of the object to get heap object id for. -func GetHeapObjectID(objectID runtime.RemoteObjectID) *GetHeapObjectIDParams { - return &GetHeapObjectIDParams{ - ObjectID: objectID, - } -} - -// GetHeapObjectIDReturns return values. -type GetHeapObjectIDReturns struct { - HeapSnapshotObjectID HeapSnapshotObjectID `json:"heapSnapshotObjectId,omitempty"` // Id of the heap snapshot object corresponding to the passed remote object id. -} - -// Do executes HeapProfiler.getHeapObjectId against the provided context and -// target handler. -// -// returns: -// heapSnapshotObjectID - Id of the heap snapshot object corresponding to the passed remote object id. -func (p *GetHeapObjectIDParams) Do(ctxt context.Context, h cdp.Handler) (heapSnapshotObjectID HeapSnapshotObjectID, err error) { - // execute - var res GetHeapObjectIDReturns - err = h.Execute(ctxt, cdp.CommandHeapProfilerGetHeapObjectID, p, &res) - if err != nil { - return "", err - } - - return res.HeapSnapshotObjectID, nil -} - -// StartSamplingParams [no description]. -type StartSamplingParams struct { - SamplingInterval float64 `json:"samplingInterval,omitempty"` // Average sample interval in bytes. Poisson distribution is used for the intervals. The default value is 32768 bytes. -} - -// StartSampling [no description]. -// -// parameters: -func StartSampling() *StartSamplingParams { - return &StartSamplingParams{} -} - -// WithSamplingInterval average sample interval in bytes. Poisson -// distribution is used for the intervals. The default value is 32768 bytes. -func (p StartSamplingParams) WithSamplingInterval(samplingInterval float64) *StartSamplingParams { - p.SamplingInterval = samplingInterval - return &p -} - -// Do executes HeapProfiler.startSampling against the provided context and -// target handler. -func (p *StartSamplingParams) Do(ctxt context.Context, h cdp.Handler) (err error) { - return h.Execute(ctxt, cdp.CommandHeapProfilerStartSampling, p, nil) -} - -// StopSamplingParams [no description]. -type StopSamplingParams struct{} - -// StopSampling [no description]. -func StopSampling() *StopSamplingParams { - return &StopSamplingParams{} -} - -// StopSamplingReturns return values. -type StopSamplingReturns struct { - Profile *SamplingHeapProfile `json:"profile,omitempty"` // Recorded sampling heap profile. -} - -// Do executes HeapProfiler.stopSampling against the provided context and -// target handler. -// -// returns: -// profile - Recorded sampling heap profile. -func (p *StopSamplingParams) Do(ctxt context.Context, h cdp.Handler) (profile *SamplingHeapProfile, err error) { - // execute - var res StopSamplingReturns - err = h.Execute(ctxt, cdp.CommandHeapProfilerStopSampling, nil, &res) - if err != nil { - return nil, err - } - - return res.Profile, nil -} - -// GetSamplingProfileParams [no description]. -type GetSamplingProfileParams struct{} - -// GetSamplingProfile [no description]. -func GetSamplingProfile() *GetSamplingProfileParams { - return &GetSamplingProfileParams{} -} - -// GetSamplingProfileReturns return values. -type GetSamplingProfileReturns struct { - Profile *SamplingHeapProfile `json:"profile,omitempty"` // Return the sampling profile being collected. -} - -// Do executes HeapProfiler.getSamplingProfile against the provided context and -// target handler. -// -// returns: -// profile - Return the sampling profile being collected. -func (p *GetSamplingProfileParams) Do(ctxt context.Context, h cdp.Handler) (profile *SamplingHeapProfile, err error) { - // execute - var res GetSamplingProfileReturns - err = h.Execute(ctxt, cdp.CommandHeapProfilerGetSamplingProfile, nil, &res) - if err != nil { - return nil, err - } - - return res.Profile, nil -} diff --git a/cdp/indexeddb/easyjson.go b/cdp/indexeddb/easyjson.go index 40688ea..45ddc61 100644 --- a/cdp/indexeddb/easyjson.go +++ b/cdp/indexeddb/easyjson.go @@ -1437,7 +1437,126 @@ func (v *DisableParams) UnmarshalJSON(data []byte) error { func (v *DisableParams) UnmarshalEasyJSON(l *jlexer.Lexer) { easyjsonC5a4559bDecodeGithubComKnqChromedpCdpIndexeddb12(l, v) } -func easyjsonC5a4559bDecodeGithubComKnqChromedpCdpIndexeddb13(in *jlexer.Lexer, out *DeleteDatabaseParams) { +func easyjsonC5a4559bDecodeGithubComKnqChromedpCdpIndexeddb13(in *jlexer.Lexer, out *DeleteObjectStoreEntriesParams) { + isTopLevel := in.IsStart() + if in.IsNull() { + if isTopLevel { + in.Consumed() + } + in.Skip() + return + } + in.Delim('{') + for !in.IsDelim('}') { + key := in.UnsafeString() + in.WantColon() + if in.IsNull() { + in.Skip() + in.WantComma() + continue + } + switch key { + case "securityOrigin": + out.SecurityOrigin = string(in.String()) + case "databaseName": + out.DatabaseName = string(in.String()) + case "objectStoreName": + out.ObjectStoreName = string(in.String()) + case "keyRange": + if in.IsNull() { + in.Skip() + out.KeyRange = nil + } else { + if out.KeyRange == nil { + out.KeyRange = new(KeyRange) + } + (*out.KeyRange).UnmarshalEasyJSON(in) + } + default: + in.SkipRecursive() + } + in.WantComma() + } + in.Delim('}') + if isTopLevel { + in.Consumed() + } +} +func easyjsonC5a4559bEncodeGithubComKnqChromedpCdpIndexeddb13(out *jwriter.Writer, in DeleteObjectStoreEntriesParams) { + out.RawByte('{') + first := true + _ = first + { + const prefix string = ",\"securityOrigin\":" + if first { + first = false + out.RawString(prefix[1:]) + } else { + out.RawString(prefix) + } + out.String(string(in.SecurityOrigin)) + } + { + const prefix string = ",\"databaseName\":" + if first { + first = false + out.RawString(prefix[1:]) + } else { + out.RawString(prefix) + } + out.String(string(in.DatabaseName)) + } + { + const prefix string = ",\"objectStoreName\":" + if first { + first = false + out.RawString(prefix[1:]) + } else { + out.RawString(prefix) + } + out.String(string(in.ObjectStoreName)) + } + { + const prefix string = ",\"keyRange\":" + if first { + first = false + out.RawString(prefix[1:]) + } else { + out.RawString(prefix) + } + if in.KeyRange == nil { + out.RawString("null") + } else { + (*in.KeyRange).MarshalEasyJSON(out) + } + } + out.RawByte('}') +} + +// MarshalJSON supports json.Marshaler interface +func (v DeleteObjectStoreEntriesParams) MarshalJSON() ([]byte, error) { + w := jwriter.Writer{} + easyjsonC5a4559bEncodeGithubComKnqChromedpCdpIndexeddb13(&w, v) + return w.Buffer.BuildBytes(), w.Error +} + +// MarshalEasyJSON supports easyjson.Marshaler interface +func (v DeleteObjectStoreEntriesParams) MarshalEasyJSON(w *jwriter.Writer) { + easyjsonC5a4559bEncodeGithubComKnqChromedpCdpIndexeddb13(w, v) +} + +// UnmarshalJSON supports json.Unmarshaler interface +func (v *DeleteObjectStoreEntriesParams) UnmarshalJSON(data []byte) error { + r := jlexer.Lexer{Data: data} + easyjsonC5a4559bDecodeGithubComKnqChromedpCdpIndexeddb13(&r, v) + return r.Error() +} + +// UnmarshalEasyJSON supports easyjson.Unmarshaler interface +func (v *DeleteObjectStoreEntriesParams) UnmarshalEasyJSON(l *jlexer.Lexer) { + easyjsonC5a4559bDecodeGithubComKnqChromedpCdpIndexeddb13(l, v) +} +func easyjsonC5a4559bDecodeGithubComKnqChromedpCdpIndexeddb14(in *jlexer.Lexer, out *DeleteDatabaseParams) { isTopLevel := in.IsStart() if in.IsNull() { if isTopLevel { @@ -1470,7 +1589,7 @@ func easyjsonC5a4559bDecodeGithubComKnqChromedpCdpIndexeddb13(in *jlexer.Lexer, in.Consumed() } } -func easyjsonC5a4559bEncodeGithubComKnqChromedpCdpIndexeddb13(out *jwriter.Writer, in DeleteDatabaseParams) { +func easyjsonC5a4559bEncodeGithubComKnqChromedpCdpIndexeddb14(out *jwriter.Writer, in DeleteDatabaseParams) { out.RawByte('{') first := true _ = first @@ -1500,27 +1619,27 @@ func easyjsonC5a4559bEncodeGithubComKnqChromedpCdpIndexeddb13(out *jwriter.Write // MarshalJSON supports json.Marshaler interface func (v DeleteDatabaseParams) MarshalJSON() ([]byte, error) { w := jwriter.Writer{} - easyjsonC5a4559bEncodeGithubComKnqChromedpCdpIndexeddb13(&w, v) + easyjsonC5a4559bEncodeGithubComKnqChromedpCdpIndexeddb14(&w, v) return w.Buffer.BuildBytes(), w.Error } // MarshalEasyJSON supports easyjson.Marshaler interface func (v DeleteDatabaseParams) MarshalEasyJSON(w *jwriter.Writer) { - easyjsonC5a4559bEncodeGithubComKnqChromedpCdpIndexeddb13(w, v) + easyjsonC5a4559bEncodeGithubComKnqChromedpCdpIndexeddb14(w, v) } // UnmarshalJSON supports json.Unmarshaler interface func (v *DeleteDatabaseParams) UnmarshalJSON(data []byte) error { r := jlexer.Lexer{Data: data} - easyjsonC5a4559bDecodeGithubComKnqChromedpCdpIndexeddb13(&r, v) + easyjsonC5a4559bDecodeGithubComKnqChromedpCdpIndexeddb14(&r, v) return r.Error() } // UnmarshalEasyJSON supports easyjson.Unmarshaler interface func (v *DeleteDatabaseParams) UnmarshalEasyJSON(l *jlexer.Lexer) { - easyjsonC5a4559bDecodeGithubComKnqChromedpCdpIndexeddb13(l, v) + easyjsonC5a4559bDecodeGithubComKnqChromedpCdpIndexeddb14(l, v) } -func easyjsonC5a4559bDecodeGithubComKnqChromedpCdpIndexeddb14(in *jlexer.Lexer, out *DatabaseWithObjectStores) { +func easyjsonC5a4559bDecodeGithubComKnqChromedpCdpIndexeddb15(in *jlexer.Lexer, out *DatabaseWithObjectStores) { isTopLevel := in.IsStart() if in.IsNull() { if isTopLevel { @@ -1584,7 +1703,7 @@ func easyjsonC5a4559bDecodeGithubComKnqChromedpCdpIndexeddb14(in *jlexer.Lexer, in.Consumed() } } -func easyjsonC5a4559bEncodeGithubComKnqChromedpCdpIndexeddb14(out *jwriter.Writer, in DatabaseWithObjectStores) { +func easyjsonC5a4559bEncodeGithubComKnqChromedpCdpIndexeddb15(out *jwriter.Writer, in DatabaseWithObjectStores) { out.RawByte('{') first := true _ = first @@ -1639,27 +1758,27 @@ func easyjsonC5a4559bEncodeGithubComKnqChromedpCdpIndexeddb14(out *jwriter.Write // MarshalJSON supports json.Marshaler interface func (v DatabaseWithObjectStores) MarshalJSON() ([]byte, error) { w := jwriter.Writer{} - easyjsonC5a4559bEncodeGithubComKnqChromedpCdpIndexeddb14(&w, v) + easyjsonC5a4559bEncodeGithubComKnqChromedpCdpIndexeddb15(&w, v) return w.Buffer.BuildBytes(), w.Error } // MarshalEasyJSON supports easyjson.Marshaler interface func (v DatabaseWithObjectStores) MarshalEasyJSON(w *jwriter.Writer) { - easyjsonC5a4559bEncodeGithubComKnqChromedpCdpIndexeddb14(w, v) + easyjsonC5a4559bEncodeGithubComKnqChromedpCdpIndexeddb15(w, v) } // UnmarshalJSON supports json.Unmarshaler interface func (v *DatabaseWithObjectStores) UnmarshalJSON(data []byte) error { r := jlexer.Lexer{Data: data} - easyjsonC5a4559bDecodeGithubComKnqChromedpCdpIndexeddb14(&r, v) + easyjsonC5a4559bDecodeGithubComKnqChromedpCdpIndexeddb15(&r, v) return r.Error() } // UnmarshalEasyJSON supports easyjson.Unmarshaler interface func (v *DatabaseWithObjectStores) UnmarshalEasyJSON(l *jlexer.Lexer) { - easyjsonC5a4559bDecodeGithubComKnqChromedpCdpIndexeddb14(l, v) + easyjsonC5a4559bDecodeGithubComKnqChromedpCdpIndexeddb15(l, v) } -func easyjsonC5a4559bDecodeGithubComKnqChromedpCdpIndexeddb15(in *jlexer.Lexer, out *DataEntry) { +func easyjsonC5a4559bDecodeGithubComKnqChromedpCdpIndexeddb16(in *jlexer.Lexer, out *DataEntry) { isTopLevel := in.IsStart() if in.IsNull() { if isTopLevel { @@ -1718,7 +1837,7 @@ func easyjsonC5a4559bDecodeGithubComKnqChromedpCdpIndexeddb15(in *jlexer.Lexer, in.Consumed() } } -func easyjsonC5a4559bEncodeGithubComKnqChromedpCdpIndexeddb15(out *jwriter.Writer, in DataEntry) { +func easyjsonC5a4559bEncodeGithubComKnqChromedpCdpIndexeddb16(out *jwriter.Writer, in DataEntry) { out.RawByte('{') first := true _ = first @@ -1770,27 +1889,27 @@ func easyjsonC5a4559bEncodeGithubComKnqChromedpCdpIndexeddb15(out *jwriter.Write // MarshalJSON supports json.Marshaler interface func (v DataEntry) MarshalJSON() ([]byte, error) { w := jwriter.Writer{} - easyjsonC5a4559bEncodeGithubComKnqChromedpCdpIndexeddb15(&w, v) + easyjsonC5a4559bEncodeGithubComKnqChromedpCdpIndexeddb16(&w, v) return w.Buffer.BuildBytes(), w.Error } // MarshalEasyJSON supports easyjson.Marshaler interface func (v DataEntry) MarshalEasyJSON(w *jwriter.Writer) { - easyjsonC5a4559bEncodeGithubComKnqChromedpCdpIndexeddb15(w, v) + easyjsonC5a4559bEncodeGithubComKnqChromedpCdpIndexeddb16(w, v) } // UnmarshalJSON supports json.Unmarshaler interface func (v *DataEntry) UnmarshalJSON(data []byte) error { r := jlexer.Lexer{Data: data} - easyjsonC5a4559bDecodeGithubComKnqChromedpCdpIndexeddb15(&r, v) + easyjsonC5a4559bDecodeGithubComKnqChromedpCdpIndexeddb16(&r, v) return r.Error() } // UnmarshalEasyJSON supports easyjson.Unmarshaler interface func (v *DataEntry) UnmarshalEasyJSON(l *jlexer.Lexer) { - easyjsonC5a4559bDecodeGithubComKnqChromedpCdpIndexeddb15(l, v) + easyjsonC5a4559bDecodeGithubComKnqChromedpCdpIndexeddb16(l, v) } -func easyjsonC5a4559bDecodeGithubComKnqChromedpCdpIndexeddb16(in *jlexer.Lexer, out *ClearObjectStoreParams) { +func easyjsonC5a4559bDecodeGithubComKnqChromedpCdpIndexeddb17(in *jlexer.Lexer, out *ClearObjectStoreParams) { isTopLevel := in.IsStart() if in.IsNull() { if isTopLevel { @@ -1825,7 +1944,7 @@ func easyjsonC5a4559bDecodeGithubComKnqChromedpCdpIndexeddb16(in *jlexer.Lexer, in.Consumed() } } -func easyjsonC5a4559bEncodeGithubComKnqChromedpCdpIndexeddb16(out *jwriter.Writer, in ClearObjectStoreParams) { +func easyjsonC5a4559bEncodeGithubComKnqChromedpCdpIndexeddb17(out *jwriter.Writer, in ClearObjectStoreParams) { out.RawByte('{') first := true _ = first @@ -1865,23 +1984,23 @@ func easyjsonC5a4559bEncodeGithubComKnqChromedpCdpIndexeddb16(out *jwriter.Write // MarshalJSON supports json.Marshaler interface func (v ClearObjectStoreParams) MarshalJSON() ([]byte, error) { w := jwriter.Writer{} - easyjsonC5a4559bEncodeGithubComKnqChromedpCdpIndexeddb16(&w, v) + easyjsonC5a4559bEncodeGithubComKnqChromedpCdpIndexeddb17(&w, v) return w.Buffer.BuildBytes(), w.Error } // MarshalEasyJSON supports easyjson.Marshaler interface func (v ClearObjectStoreParams) MarshalEasyJSON(w *jwriter.Writer) { - easyjsonC5a4559bEncodeGithubComKnqChromedpCdpIndexeddb16(w, v) + easyjsonC5a4559bEncodeGithubComKnqChromedpCdpIndexeddb17(w, v) } // UnmarshalJSON supports json.Unmarshaler interface func (v *ClearObjectStoreParams) UnmarshalJSON(data []byte) error { r := jlexer.Lexer{Data: data} - easyjsonC5a4559bDecodeGithubComKnqChromedpCdpIndexeddb16(&r, v) + easyjsonC5a4559bDecodeGithubComKnqChromedpCdpIndexeddb17(&r, v) return r.Error() } // UnmarshalEasyJSON supports easyjson.Unmarshaler interface func (v *ClearObjectStoreParams) UnmarshalEasyJSON(l *jlexer.Lexer) { - easyjsonC5a4559bDecodeGithubComKnqChromedpCdpIndexeddb16(l, v) + easyjsonC5a4559bDecodeGithubComKnqChromedpCdpIndexeddb17(l, v) } diff --git a/cdp/indexeddb/indexeddb.go b/cdp/indexeddb/indexeddb.go index e4cc0df..881d699 100644 --- a/cdp/indexeddb/indexeddb.go +++ b/cdp/indexeddb/indexeddb.go @@ -12,18 +12,86 @@ import ( cdp "github.com/knq/chromedp/cdp" ) -// EnableParams enables events from backend. -type EnableParams struct{} - -// Enable enables events from backend. -func Enable() *EnableParams { - return &EnableParams{} +// ClearObjectStoreParams clears all entries from an object store. +type ClearObjectStoreParams struct { + SecurityOrigin string `json:"securityOrigin"` // Security origin. + DatabaseName string `json:"databaseName"` // Database name. + ObjectStoreName string `json:"objectStoreName"` // Object store name. } -// Do executes IndexedDB.enable against the provided context and +// ClearObjectStore clears all entries from an object store. +// +// parameters: +// securityOrigin - Security origin. +// databaseName - Database name. +// objectStoreName - Object store name. +func ClearObjectStore(securityOrigin string, databaseName string, objectStoreName string) *ClearObjectStoreParams { + return &ClearObjectStoreParams{ + SecurityOrigin: securityOrigin, + DatabaseName: databaseName, + ObjectStoreName: objectStoreName, + } +} + +// Do executes IndexedDB.clearObjectStore against the provided context and // target handler. -func (p *EnableParams) Do(ctxt context.Context, h cdp.Handler) (err error) { - return h.Execute(ctxt, cdp.CommandIndexedDBEnable, nil, nil) +func (p *ClearObjectStoreParams) Do(ctxt context.Context, h cdp.Handler) (err error) { + return h.Execute(ctxt, cdp.CommandIndexedDBClearObjectStore, p, nil) +} + +// DeleteDatabaseParams deletes a database. +type DeleteDatabaseParams struct { + SecurityOrigin string `json:"securityOrigin"` // Security origin. + DatabaseName string `json:"databaseName"` // Database name. +} + +// DeleteDatabase deletes a database. +// +// parameters: +// securityOrigin - Security origin. +// databaseName - Database name. +func DeleteDatabase(securityOrigin string, databaseName string) *DeleteDatabaseParams { + return &DeleteDatabaseParams{ + SecurityOrigin: securityOrigin, + DatabaseName: databaseName, + } +} + +// Do executes IndexedDB.deleteDatabase against the provided context and +// target handler. +func (p *DeleteDatabaseParams) Do(ctxt context.Context, h cdp.Handler) (err error) { + return h.Execute(ctxt, cdp.CommandIndexedDBDeleteDatabase, p, nil) +} + +// DeleteObjectStoreEntriesParams delete a range of entries from an object +// store. +type DeleteObjectStoreEntriesParams struct { + SecurityOrigin string `json:"securityOrigin"` + DatabaseName string `json:"databaseName"` + ObjectStoreName string `json:"objectStoreName"` + KeyRange *KeyRange `json:"keyRange"` // Range of entry keys to delete +} + +// DeleteObjectStoreEntries delete a range of entries from an object store. +// +// parameters: +// securityOrigin +// databaseName +// objectStoreName +// keyRange - Range of entry keys to delete +func DeleteObjectStoreEntries(securityOrigin string, databaseName string, objectStoreName string, keyRange *KeyRange) *DeleteObjectStoreEntriesParams { + return &DeleteObjectStoreEntriesParams{ + SecurityOrigin: securityOrigin, + DatabaseName: databaseName, + ObjectStoreName: objectStoreName, + KeyRange: keyRange, + } +} + +// Do executes IndexedDB.deleteObjectStoreEntries against the provided context and +// target handler. +func (p *DeleteObjectStoreEntriesParams) Do(ctxt context.Context, h cdp.Handler) (err error) { + return h.Execute(ctxt, cdp.CommandIndexedDBDeleteObjectStoreEntries, p, nil) } // DisableParams disables events from backend. @@ -40,80 +108,18 @@ func (p *DisableParams) Do(ctxt context.Context, h cdp.Handler) (err error) { return h.Execute(ctxt, cdp.CommandIndexedDBDisable, nil, nil) } -// RequestDatabaseNamesParams requests database names for given security -// origin. -type RequestDatabaseNamesParams struct { - SecurityOrigin string `json:"securityOrigin"` // Security origin. +// EnableParams enables events from backend. +type EnableParams struct{} + +// Enable enables events from backend. +func Enable() *EnableParams { + return &EnableParams{} } -// RequestDatabaseNames requests database names for given security origin. -// -// parameters: -// securityOrigin - Security origin. -func RequestDatabaseNames(securityOrigin string) *RequestDatabaseNamesParams { - return &RequestDatabaseNamesParams{ - SecurityOrigin: securityOrigin, - } -} - -// RequestDatabaseNamesReturns return values. -type RequestDatabaseNamesReturns struct { - DatabaseNames []string `json:"databaseNames,omitempty"` // Database names for origin. -} - -// Do executes IndexedDB.requestDatabaseNames against the provided context and +// Do executes IndexedDB.enable against the provided context and // target handler. -// -// returns: -// databaseNames - Database names for origin. -func (p *RequestDatabaseNamesParams) Do(ctxt context.Context, h cdp.Handler) (databaseNames []string, err error) { - // execute - var res RequestDatabaseNamesReturns - err = h.Execute(ctxt, cdp.CommandIndexedDBRequestDatabaseNames, p, &res) - if err != nil { - return nil, err - } - - return res.DatabaseNames, nil -} - -// RequestDatabaseParams requests database with given name in given frame. -type RequestDatabaseParams struct { - SecurityOrigin string `json:"securityOrigin"` // Security origin. - DatabaseName string `json:"databaseName"` // Database name. -} - -// RequestDatabase requests database with given name in given frame. -// -// parameters: -// securityOrigin - Security origin. -// databaseName - Database name. -func RequestDatabase(securityOrigin string, databaseName string) *RequestDatabaseParams { - return &RequestDatabaseParams{ - SecurityOrigin: securityOrigin, - DatabaseName: databaseName, - } -} - -// RequestDatabaseReturns return values. -type RequestDatabaseReturns struct { - DatabaseWithObjectStores *DatabaseWithObjectStores `json:"databaseWithObjectStores,omitempty"` // Database with an array of object stores. -} - -// Do executes IndexedDB.requestDatabase against the provided context and -// target handler. -// -// returns: -// databaseWithObjectStores - Database with an array of object stores. -func (p *RequestDatabaseParams) Do(ctxt context.Context, h cdp.Handler) (databaseWithObjectStores *DatabaseWithObjectStores, err error) { - // execute - var res RequestDatabaseReturns - err = h.Execute(ctxt, cdp.CommandIndexedDBRequestDatabase, p, &res) - if err != nil { - return nil, err - } - - return res.DatabaseWithObjectStores, nil +func (p *EnableParams) Do(ctxt context.Context, h cdp.Handler) (err error) { + return h.Execute(ctxt, cdp.CommandIndexedDBEnable, nil, nil) } // RequestDataParams requests data from object store or index. @@ -176,53 +182,78 @@ func (p *RequestDataParams) Do(ctxt context.Context, h cdp.Handler) (objectStore return res.ObjectStoreDataEntries, res.HasMore, nil } -// ClearObjectStoreParams clears all entries from an object store. -type ClearObjectStoreParams struct { - SecurityOrigin string `json:"securityOrigin"` // Security origin. - DatabaseName string `json:"databaseName"` // Database name. - ObjectStoreName string `json:"objectStoreName"` // Object store name. -} - -// ClearObjectStore clears all entries from an object store. -// -// parameters: -// securityOrigin - Security origin. -// databaseName - Database name. -// objectStoreName - Object store name. -func ClearObjectStore(securityOrigin string, databaseName string, objectStoreName string) *ClearObjectStoreParams { - return &ClearObjectStoreParams{ - SecurityOrigin: securityOrigin, - DatabaseName: databaseName, - ObjectStoreName: objectStoreName, - } -} - -// Do executes IndexedDB.clearObjectStore against the provided context and -// target handler. -func (p *ClearObjectStoreParams) Do(ctxt context.Context, h cdp.Handler) (err error) { - return h.Execute(ctxt, cdp.CommandIndexedDBClearObjectStore, p, nil) -} - -// DeleteDatabaseParams deletes a database. -type DeleteDatabaseParams struct { +// RequestDatabaseParams requests database with given name in given frame. +type RequestDatabaseParams struct { SecurityOrigin string `json:"securityOrigin"` // Security origin. DatabaseName string `json:"databaseName"` // Database name. } -// DeleteDatabase deletes a database. +// RequestDatabase requests database with given name in given frame. // // parameters: // securityOrigin - Security origin. // databaseName - Database name. -func DeleteDatabase(securityOrigin string, databaseName string) *DeleteDatabaseParams { - return &DeleteDatabaseParams{ +func RequestDatabase(securityOrigin string, databaseName string) *RequestDatabaseParams { + return &RequestDatabaseParams{ SecurityOrigin: securityOrigin, DatabaseName: databaseName, } } -// Do executes IndexedDB.deleteDatabase against the provided context and -// target handler. -func (p *DeleteDatabaseParams) Do(ctxt context.Context, h cdp.Handler) (err error) { - return h.Execute(ctxt, cdp.CommandIndexedDBDeleteDatabase, p, nil) +// RequestDatabaseReturns return values. +type RequestDatabaseReturns struct { + DatabaseWithObjectStores *DatabaseWithObjectStores `json:"databaseWithObjectStores,omitempty"` // Database with an array of object stores. +} + +// Do executes IndexedDB.requestDatabase against the provided context and +// target handler. +// +// returns: +// databaseWithObjectStores - Database with an array of object stores. +func (p *RequestDatabaseParams) Do(ctxt context.Context, h cdp.Handler) (databaseWithObjectStores *DatabaseWithObjectStores, err error) { + // execute + var res RequestDatabaseReturns + err = h.Execute(ctxt, cdp.CommandIndexedDBRequestDatabase, p, &res) + if err != nil { + return nil, err + } + + return res.DatabaseWithObjectStores, nil +} + +// RequestDatabaseNamesParams requests database names for given security +// origin. +type RequestDatabaseNamesParams struct { + SecurityOrigin string `json:"securityOrigin"` // Security origin. +} + +// RequestDatabaseNames requests database names for given security origin. +// +// parameters: +// securityOrigin - Security origin. +func RequestDatabaseNames(securityOrigin string) *RequestDatabaseNamesParams { + return &RequestDatabaseNamesParams{ + SecurityOrigin: securityOrigin, + } +} + +// RequestDatabaseNamesReturns return values. +type RequestDatabaseNamesReturns struct { + DatabaseNames []string `json:"databaseNames,omitempty"` // Database names for origin. +} + +// Do executes IndexedDB.requestDatabaseNames against the provided context and +// target handler. +// +// returns: +// databaseNames - Database names for origin. +func (p *RequestDatabaseNamesParams) Do(ctxt context.Context, h cdp.Handler) (databaseNames []string, err error) { + // execute + var res RequestDatabaseNamesReturns + err = h.Execute(ctxt, cdp.CommandIndexedDBRequestDatabaseNames, p, &res) + if err != nil { + return nil, err + } + + return res.DatabaseNames, nil } diff --git a/cdp/input/input.go b/cdp/input/input.go index ffe9ede..c673fb0 100644 --- a/cdp/input/input.go +++ b/cdp/input/input.go @@ -12,28 +12,6 @@ import ( cdp "github.com/knq/chromedp/cdp" ) -// SetIgnoreInputEventsParams ignores input events (useful while auditing -// page). -type SetIgnoreInputEventsParams struct { - Ignore bool `json:"ignore"` // Ignores input events processing when set to true. -} - -// SetIgnoreInputEvents ignores input events (useful while auditing page). -// -// parameters: -// ignore - Ignores input events processing when set to true. -func SetIgnoreInputEvents(ignore bool) *SetIgnoreInputEventsParams { - return &SetIgnoreInputEventsParams{ - Ignore: ignore, - } -} - -// Do executes Input.setIgnoreInputEvents against the provided context and -// target handler. -func (p *SetIgnoreInputEventsParams) Do(ctxt context.Context, h cdp.Handler) (err error) { - return h.Execute(ctxt, cdp.CommandInputSetIgnoreInputEvents, p, nil) -} - // DispatchKeyEventParams dispatches a key event to the page. type DispatchKeyEventParams struct { Type KeyType `json:"type"` // Type of the key event. @@ -330,6 +308,28 @@ func (p *EmulateTouchFromMouseEventParams) Do(ctxt context.Context, h cdp.Handle return h.Execute(ctxt, cdp.CommandInputEmulateTouchFromMouseEvent, p, nil) } +// SetIgnoreInputEventsParams ignores input events (useful while auditing +// page). +type SetIgnoreInputEventsParams struct { + Ignore bool `json:"ignore"` // Ignores input events processing when set to true. +} + +// SetIgnoreInputEvents ignores input events (useful while auditing page). +// +// parameters: +// ignore - Ignores input events processing when set to true. +func SetIgnoreInputEvents(ignore bool) *SetIgnoreInputEventsParams { + return &SetIgnoreInputEventsParams{ + Ignore: ignore, + } +} + +// Do executes Input.setIgnoreInputEvents against the provided context and +// target handler. +func (p *SetIgnoreInputEventsParams) Do(ctxt context.Context, h cdp.Handler) (err error) { + return h.Execute(ctxt, cdp.CommandInputSetIgnoreInputEvents, p, nil) +} + // SynthesizePinchGestureParams synthesizes a pinch gesture over a time // period by issuing appropriate touch events. type SynthesizePinchGestureParams struct { diff --git a/cdp/inspector/inspector.go b/cdp/inspector/inspector.go index 5350e59..61bc09b 100644 --- a/cdp/inspector/inspector.go +++ b/cdp/inspector/inspector.go @@ -12,20 +12,6 @@ import ( cdp "github.com/knq/chromedp/cdp" ) -// EnableParams enables inspector domain notifications. -type EnableParams struct{} - -// Enable enables inspector domain notifications. -func Enable() *EnableParams { - return &EnableParams{} -} - -// Do executes Inspector.enable against the provided context and -// target handler. -func (p *EnableParams) Do(ctxt context.Context, h cdp.Handler) (err error) { - return h.Execute(ctxt, cdp.CommandInspectorEnable, nil, nil) -} - // DisableParams disables inspector domain notifications. type DisableParams struct{} @@ -39,3 +25,17 @@ func Disable() *DisableParams { func (p *DisableParams) Do(ctxt context.Context, h cdp.Handler) (err error) { return h.Execute(ctxt, cdp.CommandInspectorDisable, nil, nil) } + +// EnableParams enables inspector domain notifications. +type EnableParams struct{} + +// Enable enables inspector domain notifications. +func Enable() *EnableParams { + return &EnableParams{} +} + +// Do executes Inspector.enable against the provided context and +// target handler. +func (p *EnableParams) Do(ctxt context.Context, h cdp.Handler) (err error) { + return h.Execute(ctxt, cdp.CommandInspectorEnable, nil, nil) +} diff --git a/cdp/io/io.go b/cdp/io/io.go index 70ee548..48cec07 100644 --- a/cdp/io/io.go +++ b/cdp/io/io.go @@ -15,6 +15,27 @@ import ( "github.com/knq/chromedp/cdp/runtime" ) +// CloseParams close the stream, discard any temporary backing storage. +type CloseParams struct { + Handle StreamHandle `json:"handle"` // Handle of the stream to close. +} + +// Close close the stream, discard any temporary backing storage. +// +// parameters: +// handle - Handle of the stream to close. +func Close(handle StreamHandle) *CloseParams { + return &CloseParams{ + Handle: handle, + } +} + +// Do executes IO.close against the provided context and +// target handler. +func (p *CloseParams) Do(ctxt context.Context, h cdp.Handler) (err error) { + return h.Execute(ctxt, cdp.CommandIOClose, p, nil) +} + // ReadParams read a chunk of the stream. type ReadParams struct { Handle StreamHandle `json:"handle"` // Handle of the stream to read. @@ -70,27 +91,6 @@ func (p *ReadParams) Do(ctxt context.Context, h cdp.Handler) (data string, eof b return res.Data, res.EOF, nil } -// CloseParams close the stream, discard any temporary backing storage. -type CloseParams struct { - Handle StreamHandle `json:"handle"` // Handle of the stream to close. -} - -// Close close the stream, discard any temporary backing storage. -// -// parameters: -// handle - Handle of the stream to close. -func Close(handle StreamHandle) *CloseParams { - return &CloseParams{ - Handle: handle, - } -} - -// Do executes IO.close against the provided context and -// target handler. -func (p *CloseParams) Do(ctxt context.Context, h cdp.Handler) (err error) { - return h.Execute(ctxt, cdp.CommandIOClose, p, nil) -} - // ResolveBlobParams return UUID of Blob object specified by a remote object // id. type ResolveBlobParams struct { diff --git a/cdp/layertree/events.go b/cdp/layertree/events.go index d19617e..d7a5dbe 100644 --- a/cdp/layertree/events.go +++ b/cdp/layertree/events.go @@ -7,19 +7,19 @@ import ( "github.com/knq/chromedp/cdp/dom" ) -// EventLayerTreeDidChange [no description]. -type EventLayerTreeDidChange struct { - Layers []*Layer `json:"layers,omitempty"` // Layer tree, absent if not in the comspositing mode. -} - // EventLayerPainted [no description]. type EventLayerPainted struct { LayerID LayerID `json:"layerId"` // The id of the painted layer. Clip *dom.Rect `json:"clip"` // Clip rectangle. } +// EventLayerTreeDidChange [no description]. +type EventLayerTreeDidChange struct { + Layers []*Layer `json:"layers,omitempty"` // Layer tree, absent if not in the comspositing mode. +} + // EventTypes all event types in the domain. var EventTypes = []cdp.MethodType{ - cdp.EventLayerTreeLayerTreeDidChange, cdp.EventLayerTreeLayerPainted, + cdp.EventLayerTreeLayerTreeDidChange, } diff --git a/cdp/layertree/layertree.go b/cdp/layertree/layertree.go index 7a06ce5..77804b6 100644 --- a/cdp/layertree/layertree.go +++ b/cdp/layertree/layertree.go @@ -14,34 +14,6 @@ import ( "github.com/mailru/easyjson" ) -// EnableParams enables compositing tree inspection. -type EnableParams struct{} - -// Enable enables compositing tree inspection. -func Enable() *EnableParams { - return &EnableParams{} -} - -// Do executes LayerTree.enable against the provided context and -// target handler. -func (p *EnableParams) Do(ctxt context.Context, h cdp.Handler) (err error) { - return h.Execute(ctxt, cdp.CommandLayerTreeEnable, nil, nil) -} - -// DisableParams disables compositing tree inspection. -type DisableParams struct{} - -// Disable disables compositing tree inspection. -func Disable() *DisableParams { - return &DisableParams{} -} - -// Do executes LayerTree.disable against the provided context and -// target handler. -func (p *DisableParams) Do(ctxt context.Context, h cdp.Handler) (err error) { - return h.Execute(ctxt, cdp.CommandLayerTreeDisable, nil, nil) -} - // CompositingReasonsParams provides the reasons why the given layer was // composited. type CompositingReasonsParams struct { @@ -80,40 +52,32 @@ func (p *CompositingReasonsParams) Do(ctxt context.Context, h cdp.Handler) (comp return res.CompositingReasons, nil } -// MakeSnapshotParams returns the layer snapshot identifier. -type MakeSnapshotParams struct { - LayerID LayerID `json:"layerId"` // The id of the layer. +// DisableParams disables compositing tree inspection. +type DisableParams struct{} + +// Disable disables compositing tree inspection. +func Disable() *DisableParams { + return &DisableParams{} } -// MakeSnapshot returns the layer snapshot identifier. -// -// parameters: -// layerID - The id of the layer. -func MakeSnapshot(layerID LayerID) *MakeSnapshotParams { - return &MakeSnapshotParams{ - LayerID: layerID, - } -} - -// MakeSnapshotReturns return values. -type MakeSnapshotReturns struct { - SnapshotID SnapshotID `json:"snapshotId,omitempty"` // The id of the layer snapshot. -} - -// Do executes LayerTree.makeSnapshot against the provided context and +// Do executes LayerTree.disable against the provided context and // target handler. -// -// returns: -// snapshotID - The id of the layer snapshot. -func (p *MakeSnapshotParams) Do(ctxt context.Context, h cdp.Handler) (snapshotID SnapshotID, err error) { - // execute - var res MakeSnapshotReturns - err = h.Execute(ctxt, cdp.CommandLayerTreeMakeSnapshot, p, &res) - if err != nil { - return "", err - } +func (p *DisableParams) Do(ctxt context.Context, h cdp.Handler) (err error) { + return h.Execute(ctxt, cdp.CommandLayerTreeDisable, nil, nil) +} - return res.SnapshotID, nil +// EnableParams enables compositing tree inspection. +type EnableParams struct{} + +// Enable enables compositing tree inspection. +func Enable() *EnableParams { + return &EnableParams{} +} + +// Do executes LayerTree.enable against the provided context and +// target handler. +func (p *EnableParams) Do(ctxt context.Context, h cdp.Handler) (err error) { + return h.Execute(ctxt, cdp.CommandLayerTreeEnable, nil, nil) } // LoadSnapshotParams returns the snapshot identifier. @@ -152,25 +116,40 @@ func (p *LoadSnapshotParams) Do(ctxt context.Context, h cdp.Handler) (snapshotID return res.SnapshotID, nil } -// ReleaseSnapshotParams releases layer snapshot captured by the back-end. -type ReleaseSnapshotParams struct { - SnapshotID SnapshotID `json:"snapshotId"` // The id of the layer snapshot. +// MakeSnapshotParams returns the layer snapshot identifier. +type MakeSnapshotParams struct { + LayerID LayerID `json:"layerId"` // The id of the layer. } -// ReleaseSnapshot releases layer snapshot captured by the back-end. +// MakeSnapshot returns the layer snapshot identifier. // // parameters: -// snapshotID - The id of the layer snapshot. -func ReleaseSnapshot(snapshotID SnapshotID) *ReleaseSnapshotParams { - return &ReleaseSnapshotParams{ - SnapshotID: snapshotID, +// layerID - The id of the layer. +func MakeSnapshot(layerID LayerID) *MakeSnapshotParams { + return &MakeSnapshotParams{ + LayerID: layerID, } } -// Do executes LayerTree.releaseSnapshot against the provided context and +// MakeSnapshotReturns return values. +type MakeSnapshotReturns struct { + SnapshotID SnapshotID `json:"snapshotId,omitempty"` // The id of the layer snapshot. +} + +// Do executes LayerTree.makeSnapshot against the provided context and // target handler. -func (p *ReleaseSnapshotParams) Do(ctxt context.Context, h cdp.Handler) (err error) { - return h.Execute(ctxt, cdp.CommandLayerTreeReleaseSnapshot, p, nil) +// +// returns: +// snapshotID - The id of the layer snapshot. +func (p *MakeSnapshotParams) Do(ctxt context.Context, h cdp.Handler) (snapshotID SnapshotID, err error) { + // execute + var res MakeSnapshotReturns + err = h.Execute(ctxt, cdp.CommandLayerTreeMakeSnapshot, p, &res) + if err != nil { + return "", err + } + + return res.SnapshotID, nil } // ProfileSnapshotParams [no description]. @@ -231,6 +210,27 @@ func (p *ProfileSnapshotParams) Do(ctxt context.Context, h cdp.Handler) (timings return res.Timings, nil } +// ReleaseSnapshotParams releases layer snapshot captured by the back-end. +type ReleaseSnapshotParams struct { + SnapshotID SnapshotID `json:"snapshotId"` // The id of the layer snapshot. +} + +// ReleaseSnapshot releases layer snapshot captured by the back-end. +// +// parameters: +// snapshotID - The id of the layer snapshot. +func ReleaseSnapshot(snapshotID SnapshotID) *ReleaseSnapshotParams { + return &ReleaseSnapshotParams{ + SnapshotID: snapshotID, + } +} + +// Do executes LayerTree.releaseSnapshot against the provided context and +// target handler. +func (p *ReleaseSnapshotParams) Do(ctxt context.Context, h cdp.Handler) (err error) { + return h.Execute(ctxt, cdp.CommandLayerTreeReleaseSnapshot, p, nil) +} + // ReplaySnapshotParams replays the layer snapshot and returns the resulting // bitmap. type ReplaySnapshotParams struct { diff --git a/cdp/log/log.go b/cdp/log/log.go index 1794944..5bfdd1c 100644 --- a/cdp/log/log.go +++ b/cdp/log/log.go @@ -14,20 +14,18 @@ import ( cdp "github.com/knq/chromedp/cdp" ) -// EnableParams enables log domain, sends the entries collected so far to the -// client by means of the entryAdded notification. -type EnableParams struct{} +// ClearParams clears the log. +type ClearParams struct{} -// Enable enables log domain, sends the entries collected so far to the -// client by means of the entryAdded notification. -func Enable() *EnableParams { - return &EnableParams{} +// Clear clears the log. +func Clear() *ClearParams { + return &ClearParams{} } -// Do executes Log.enable against the provided context and +// Do executes Log.clear against the provided context and // target handler. -func (p *EnableParams) Do(ctxt context.Context, h cdp.Handler) (err error) { - return h.Execute(ctxt, cdp.CommandLogEnable, nil, nil) +func (p *ClearParams) Do(ctxt context.Context, h cdp.Handler) (err error) { + return h.Execute(ctxt, cdp.CommandLogClear, nil, nil) } // DisableParams disables log domain, prevents further log entries from being @@ -46,18 +44,20 @@ func (p *DisableParams) Do(ctxt context.Context, h cdp.Handler) (err error) { return h.Execute(ctxt, cdp.CommandLogDisable, nil, nil) } -// ClearParams clears the log. -type ClearParams struct{} +// EnableParams enables log domain, sends the entries collected so far to the +// client by means of the entryAdded notification. +type EnableParams struct{} -// Clear clears the log. -func Clear() *ClearParams { - return &ClearParams{} +// Enable enables log domain, sends the entries collected so far to the +// client by means of the entryAdded notification. +func Enable() *EnableParams { + return &EnableParams{} } -// Do executes Log.clear against the provided context and +// Do executes Log.enable against the provided context and // target handler. -func (p *ClearParams) Do(ctxt context.Context, h cdp.Handler) (err error) { - return h.Execute(ctxt, cdp.CommandLogClear, nil, nil) +func (p *EnableParams) Do(ctxt context.Context, h cdp.Handler) (err error) { + return h.Execute(ctxt, cdp.CommandLogEnable, nil, nil) } // StartViolationsReportParams start violation reporting. diff --git a/cdp/network/events.go b/cdp/network/events.go index 4cc1465..dfb6131 100644 --- a/cdp/network/events.go +++ b/cdp/network/events.go @@ -7,43 +7,6 @@ import ( "github.com/knq/chromedp/cdp/page" ) -// EventResourceChangedPriority fired when resource loading priority is -// changed. -type EventResourceChangedPriority struct { - RequestID RequestID `json:"requestId"` // Request identifier. - NewPriority ResourcePriority `json:"newPriority"` // New priority - Timestamp *cdp.MonotonicTime `json:"timestamp"` // Timestamp. -} - -// EventRequestWillBeSent fired when page is about to send HTTP request. -type EventRequestWillBeSent struct { - RequestID RequestID `json:"requestId"` // Request identifier. - LoaderID cdp.LoaderID `json:"loaderId"` // Loader identifier. Empty string if the request is fetched from worker. - DocumentURL string `json:"documentURL"` // URL of the document this request is loaded for. - Request *Request `json:"request"` // Request data. - Timestamp *cdp.MonotonicTime `json:"timestamp"` // Timestamp. - WallTime *cdp.TimeSinceEpoch `json:"wallTime"` // Timestamp. - Initiator *Initiator `json:"initiator"` // Request initiator. - RedirectResponse *Response `json:"redirectResponse,omitempty"` // Redirect response data. - Type page.ResourceType `json:"type,omitempty"` // Type of this resource. - FrameID cdp.FrameID `json:"frameId,omitempty"` // Frame identifier. -} - -// EventRequestServedFromCache fired if request ended up loading from cache. -type EventRequestServedFromCache struct { - RequestID RequestID `json:"requestId"` // Request identifier. -} - -// EventResponseReceived fired when HTTP response is available. -type EventResponseReceived struct { - RequestID RequestID `json:"requestId"` // Request identifier. - LoaderID cdp.LoaderID `json:"loaderId"` // Loader identifier. Empty string if the request is fetched from worker. - Timestamp *cdp.MonotonicTime `json:"timestamp"` // Timestamp. - Type page.ResourceType `json:"type"` // Resource type. - Response *Response `json:"response"` // Response data. - FrameID cdp.FrameID `json:"frameId,omitempty"` // Frame identifier. -} - // EventDataReceived fired when data chunk was received over the network. type EventDataReceived struct { RequestID RequestID `json:"requestId"` // Request identifier. @@ -52,11 +15,14 @@ type EventDataReceived struct { EncodedDataLength int64 `json:"encodedDataLength"` // 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"` // Request identifier. - Timestamp *cdp.MonotonicTime `json:"timestamp"` // Timestamp. - EncodedDataLength float64 `json:"encodedDataLength"` // Total number of bytes received for this request. +// EventEventSourceMessageReceived fired when EventSource message is +// received. +type EventEventSourceMessageReceived struct { + RequestID RequestID `json:"requestId"` // Request identifier. + Timestamp *cdp.MonotonicTime `json:"timestamp"` // Timestamp. + EventName string `json:"eventName"` // Message type. + EventID string `json:"eventId"` // Message identifier. + Data string `json:"data"` // Message content. } // EventLoadingFailed fired when HTTP request has failed to load. @@ -69,65 +35,11 @@ type EventLoadingFailed struct { BlockedReason BlockedReason `json:"blockedReason,omitempty"` // The reason why loading was blocked, if any. } -// EventWebSocketWillSendHandshakeRequest fired when WebSocket is about to -// initiate handshake. -type EventWebSocketWillSendHandshakeRequest struct { - RequestID RequestID `json:"requestId"` // Request identifier. - Timestamp *cdp.MonotonicTime `json:"timestamp"` // Timestamp. - WallTime *cdp.TimeSinceEpoch `json:"wallTime"` // UTC Timestamp. - Request *WebSocketRequest `json:"request"` // WebSocket request data. -} - -// EventWebSocketHandshakeResponseReceived fired when WebSocket handshake -// response becomes available. -type EventWebSocketHandshakeResponseReceived struct { - RequestID RequestID `json:"requestId"` // Request identifier. - Timestamp *cdp.MonotonicTime `json:"timestamp"` // Timestamp. - Response *WebSocketResponse `json:"response"` // WebSocket response data. -} - -// EventWebSocketCreated fired upon WebSocket creation. -type EventWebSocketCreated struct { - RequestID RequestID `json:"requestId"` // Request identifier. - URL string `json:"url"` // WebSocket request URL. - Initiator *Initiator `json:"initiator,omitempty"` // Request initiator. -} - -// EventWebSocketClosed fired when WebSocket is closed. -type EventWebSocketClosed struct { - RequestID RequestID `json:"requestId"` // Request identifier. - Timestamp *cdp.MonotonicTime `json:"timestamp"` // Timestamp. -} - -// EventWebSocketFrameReceived fired when WebSocket frame is received. -type EventWebSocketFrameReceived struct { - RequestID RequestID `json:"requestId"` // Request identifier. - Timestamp *cdp.MonotonicTime `json:"timestamp"` // Timestamp. - Response *WebSocketFrame `json:"response"` // WebSocket response data. -} - -// EventWebSocketFrameError fired when WebSocket frame error occurs. -type EventWebSocketFrameError struct { - RequestID RequestID `json:"requestId"` // Request identifier. - Timestamp *cdp.MonotonicTime `json:"timestamp"` // Timestamp. - ErrorMessage string `json:"errorMessage"` // WebSocket frame error message. -} - -// EventWebSocketFrameSent fired when WebSocket frame is sent. -type EventWebSocketFrameSent struct { - RequestID RequestID `json:"requestId"` // Request identifier. - Timestamp *cdp.MonotonicTime `json:"timestamp"` // Timestamp. - Response *WebSocketFrame `json:"response"` // WebSocket response data. -} - -// EventEventSourceMessageReceived fired when EventSource message is -// received. -type EventEventSourceMessageReceived struct { - RequestID RequestID `json:"requestId"` // Request identifier. - Timestamp *cdp.MonotonicTime `json:"timestamp"` // Timestamp. - EventName string `json:"eventName"` // Message type. - EventID string `json:"eventId"` // Message identifier. - Data string `json:"data"` // Message content. +// EventLoadingFinished fired when HTTP request has finished loading. +type EventLoadingFinished struct { + RequestID RequestID `json:"requestId"` // Request identifier. + Timestamp *cdp.MonotonicTime `json:"timestamp"` // Timestamp. + EncodedDataLength float64 `json:"encodedDataLength"` // Total number of bytes received for this request. } // EventRequestIntercepted details of an intercepted HTTP request, which must @@ -145,22 +57,110 @@ type EventRequestIntercepted struct { ResponseHeaders Headers `json:"responseHeaders,omitempty"` // Response headers if intercepted at the response stage or if redirect occurred while intercepting request or auth retry occurred. } +// EventRequestServedFromCache fired if request ended up loading from cache. +type EventRequestServedFromCache struct { + RequestID RequestID `json:"requestId"` // Request identifier. +} + +// EventRequestWillBeSent fired when page is about to send HTTP request. +type EventRequestWillBeSent struct { + RequestID RequestID `json:"requestId"` // Request identifier. + LoaderID cdp.LoaderID `json:"loaderId"` // Loader identifier. Empty string if the request is fetched from worker. + DocumentURL string `json:"documentURL"` // URL of the document this request is loaded for. + Request *Request `json:"request"` // Request data. + Timestamp *cdp.MonotonicTime `json:"timestamp"` // Timestamp. + WallTime *cdp.TimeSinceEpoch `json:"wallTime"` // Timestamp. + Initiator *Initiator `json:"initiator"` // Request initiator. + RedirectResponse *Response `json:"redirectResponse,omitempty"` // Redirect response data. + Type page.ResourceType `json:"type,omitempty"` // Type of this resource. + FrameID cdp.FrameID `json:"frameId,omitempty"` // Frame identifier. +} + +// EventResourceChangedPriority fired when resource loading priority is +// changed. +type EventResourceChangedPriority struct { + RequestID RequestID `json:"requestId"` // Request identifier. + NewPriority ResourcePriority `json:"newPriority"` // New priority + Timestamp *cdp.MonotonicTime `json:"timestamp"` // Timestamp. +} + +// EventResponseReceived fired when HTTP response is available. +type EventResponseReceived struct { + RequestID RequestID `json:"requestId"` // Request identifier. + LoaderID cdp.LoaderID `json:"loaderId"` // Loader identifier. Empty string if the request is fetched from worker. + Timestamp *cdp.MonotonicTime `json:"timestamp"` // Timestamp. + Type page.ResourceType `json:"type"` // Resource type. + Response *Response `json:"response"` // Response data. + FrameID cdp.FrameID `json:"frameId,omitempty"` // Frame identifier. +} + +// EventWebSocketClosed fired when WebSocket is closed. +type EventWebSocketClosed struct { + RequestID RequestID `json:"requestId"` // Request identifier. + Timestamp *cdp.MonotonicTime `json:"timestamp"` // Timestamp. +} + +// EventWebSocketCreated fired upon WebSocket creation. +type EventWebSocketCreated struct { + RequestID RequestID `json:"requestId"` // Request identifier. + URL string `json:"url"` // WebSocket request URL. + Initiator *Initiator `json:"initiator,omitempty"` // Request initiator. +} + +// EventWebSocketFrameError fired when WebSocket frame error occurs. +type EventWebSocketFrameError struct { + RequestID RequestID `json:"requestId"` // Request identifier. + Timestamp *cdp.MonotonicTime `json:"timestamp"` // Timestamp. + ErrorMessage string `json:"errorMessage"` // WebSocket frame error message. +} + +// EventWebSocketFrameReceived fired when WebSocket frame is received. +type EventWebSocketFrameReceived struct { + RequestID RequestID `json:"requestId"` // Request identifier. + Timestamp *cdp.MonotonicTime `json:"timestamp"` // Timestamp. + Response *WebSocketFrame `json:"response"` // WebSocket response data. +} + +// EventWebSocketFrameSent fired when WebSocket frame is sent. +type EventWebSocketFrameSent struct { + RequestID RequestID `json:"requestId"` // Request identifier. + Timestamp *cdp.MonotonicTime `json:"timestamp"` // Timestamp. + Response *WebSocketFrame `json:"response"` // WebSocket response data. +} + +// EventWebSocketHandshakeResponseReceived fired when WebSocket handshake +// response becomes available. +type EventWebSocketHandshakeResponseReceived struct { + RequestID RequestID `json:"requestId"` // Request identifier. + Timestamp *cdp.MonotonicTime `json:"timestamp"` // Timestamp. + Response *WebSocketResponse `json:"response"` // WebSocket response data. +} + +// EventWebSocketWillSendHandshakeRequest fired when WebSocket is about to +// initiate handshake. +type EventWebSocketWillSendHandshakeRequest struct { + RequestID RequestID `json:"requestId"` // Request identifier. + Timestamp *cdp.MonotonicTime `json:"timestamp"` // Timestamp. + WallTime *cdp.TimeSinceEpoch `json:"wallTime"` // UTC Timestamp. + Request *WebSocketRequest `json:"request"` // WebSocket request data. +} + // EventTypes all event types in the domain. var EventTypes = []cdp.MethodType{ - cdp.EventNetworkResourceChangedPriority, - cdp.EventNetworkRequestWillBeSent, - cdp.EventNetworkRequestServedFromCache, - cdp.EventNetworkResponseReceived, cdp.EventNetworkDataReceived, - cdp.EventNetworkLoadingFinished, - cdp.EventNetworkLoadingFailed, - cdp.EventNetworkWebSocketWillSendHandshakeRequest, - cdp.EventNetworkWebSocketHandshakeResponseReceived, - cdp.EventNetworkWebSocketCreated, - cdp.EventNetworkWebSocketClosed, - cdp.EventNetworkWebSocketFrameReceived, - cdp.EventNetworkWebSocketFrameError, - cdp.EventNetworkWebSocketFrameSent, cdp.EventNetworkEventSourceMessageReceived, + cdp.EventNetworkLoadingFailed, + cdp.EventNetworkLoadingFinished, cdp.EventNetworkRequestIntercepted, + cdp.EventNetworkRequestServedFromCache, + cdp.EventNetworkRequestWillBeSent, + cdp.EventNetworkResourceChangedPriority, + cdp.EventNetworkResponseReceived, + cdp.EventNetworkWebSocketClosed, + cdp.EventNetworkWebSocketCreated, + cdp.EventNetworkWebSocketFrameError, + cdp.EventNetworkWebSocketFrameReceived, + cdp.EventNetworkWebSocketFrameSent, + cdp.EventNetworkWebSocketHandshakeResponseReceived, + cdp.EventNetworkWebSocketWillSendHandshakeRequest, } diff --git a/cdp/network/network.go b/cdp/network/network.go index 871ab72..0f7a36a 100644 --- a/cdp/network/network.go +++ b/cdp/network/network.go @@ -18,6 +18,219 @@ import ( "github.com/knq/chromedp/cdp/debugger" ) +// ClearBrowserCacheParams clears browser cache. +type ClearBrowserCacheParams struct{} + +// ClearBrowserCache clears browser cache. +func ClearBrowserCache() *ClearBrowserCacheParams { + return &ClearBrowserCacheParams{} +} + +// Do executes Network.clearBrowserCache against the provided context and +// target handler. +func (p *ClearBrowserCacheParams) Do(ctxt context.Context, h cdp.Handler) (err error) { + return h.Execute(ctxt, cdp.CommandNetworkClearBrowserCache, nil, nil) +} + +// ClearBrowserCookiesParams clears browser cookies. +type ClearBrowserCookiesParams struct{} + +// ClearBrowserCookies clears browser cookies. +func ClearBrowserCookies() *ClearBrowserCookiesParams { + return &ClearBrowserCookiesParams{} +} + +// Do executes Network.clearBrowserCookies against the provided context and +// target handler. +func (p *ClearBrowserCookiesParams) Do(ctxt context.Context, h cdp.Handler) (err error) { + return h.Execute(ctxt, cdp.CommandNetworkClearBrowserCookies, nil, nil) +} + +// ContinueInterceptedRequestParams response to Network.requestIntercepted +// which either modifies the request to continue with any modifications, or +// blocks it, or completes it with the provided response bytes. If a network +// fetch occurs as a result which encounters a redirect an additional +// Network.requestIntercepted event will be sent with the same InterceptionId. +type ContinueInterceptedRequestParams struct { + InterceptionID InterceptionID `json:"interceptionId"` + ErrorReason ErrorReason `json:"errorReason,omitempty"` // If set this causes the request to fail with the given reason. Passing Aborted for requests marked with isNavigationRequest also cancels the navigation. Must not be set in response to an authChallenge. + RawResponse string `json:"rawResponse,omitempty"` // If set the requests completes using with the provided base64 encoded raw response, including HTTP status line and headers etc... Must not be set in response to an authChallenge. + URL string `json:"url,omitempty"` // If set the request url will be modified in a way that's not observable by page. Must not be set in response to an authChallenge. + Method string `json:"method,omitempty"` // If set this allows the request method to be overridden. Must not be set in response to an authChallenge. + PostData string `json:"postData,omitempty"` // If set this allows postData to be set. Must not be set in response to an authChallenge. + Headers Headers `json:"headers,omitempty"` // If set this allows the request headers to be changed. Must not be set in response to an authChallenge. + AuthChallengeResponse *AuthChallengeResponse `json:"authChallengeResponse,omitempty"` // Response to a requestIntercepted with an authChallenge. Must not be set otherwise. +} + +// ContinueInterceptedRequest response to Network.requestIntercepted which +// either modifies the request to continue with any modifications, or blocks it, +// or completes it with the provided response bytes. If a network fetch occurs +// as a result which encounters a redirect an additional +// Network.requestIntercepted event will be sent with the same InterceptionId. +// +// parameters: +// interceptionID +func ContinueInterceptedRequest(interceptionID InterceptionID) *ContinueInterceptedRequestParams { + return &ContinueInterceptedRequestParams{ + InterceptionID: interceptionID, + } +} + +// WithErrorReason if set this causes the request to fail with the given +// reason. Passing Aborted for requests marked with isNavigationRequest also +// cancels the navigation. Must not be set in response to an authChallenge. +func (p ContinueInterceptedRequestParams) WithErrorReason(errorReason ErrorReason) *ContinueInterceptedRequestParams { + p.ErrorReason = errorReason + return &p +} + +// WithRawResponse if set the requests completes using with the provided +// base64 encoded raw response, including HTTP status line and headers etc... +// Must not be set in response to an authChallenge. +func (p ContinueInterceptedRequestParams) WithRawResponse(rawResponse string) *ContinueInterceptedRequestParams { + p.RawResponse = rawResponse + return &p +} + +// WithURL if set the request url will be modified in a way that's not +// observable by page. Must not be set in response to an authChallenge. +func (p ContinueInterceptedRequestParams) WithURL(url string) *ContinueInterceptedRequestParams { + p.URL = url + return &p +} + +// WithMethod if set this allows the request method to be overridden. Must +// not be set in response to an authChallenge. +func (p ContinueInterceptedRequestParams) WithMethod(method string) *ContinueInterceptedRequestParams { + p.Method = method + return &p +} + +// WithPostData if set this allows postData to be set. Must not be set in +// response to an authChallenge. +func (p ContinueInterceptedRequestParams) WithPostData(postData string) *ContinueInterceptedRequestParams { + p.PostData = postData + return &p +} + +// WithHeaders if set this allows the request headers to be changed. Must not +// be set in response to an authChallenge. +func (p ContinueInterceptedRequestParams) WithHeaders(headers Headers) *ContinueInterceptedRequestParams { + p.Headers = headers + return &p +} + +// WithAuthChallengeResponse response to a requestIntercepted with an +// authChallenge. Must not be set otherwise. +func (p ContinueInterceptedRequestParams) WithAuthChallengeResponse(authChallengeResponse *AuthChallengeResponse) *ContinueInterceptedRequestParams { + p.AuthChallengeResponse = authChallengeResponse + return &p +} + +// Do executes Network.continueInterceptedRequest against the provided context and +// target handler. +func (p *ContinueInterceptedRequestParams) Do(ctxt context.Context, h cdp.Handler) (err error) { + return h.Execute(ctxt, cdp.CommandNetworkContinueInterceptedRequest, p, nil) +} + +// DeleteCookiesParams deletes browser cookies with matching name and url or +// domain/path pair. +type DeleteCookiesParams struct { + Name string `json:"name"` // Name of the cookies to remove. + URL string `json:"url,omitempty"` // If specified, deletes all the cookies with the given name where domain and path match provided URL. + Domain string `json:"domain,omitempty"` // If specified, deletes only cookies with the exact domain. + Path string `json:"path,omitempty"` // If specified, deletes only cookies with the exact path. +} + +// DeleteCookies deletes browser cookies with matching name and url or +// domain/path pair. +// +// parameters: +// name - Name of the cookies to remove. +func DeleteCookies(name string) *DeleteCookiesParams { + return &DeleteCookiesParams{ + Name: name, + } +} + +// WithURL if specified, deletes all the cookies with the given name where +// domain and path match provided URL. +func (p DeleteCookiesParams) WithURL(url string) *DeleteCookiesParams { + p.URL = url + return &p +} + +// WithDomain if specified, deletes only cookies with the exact domain. +func (p DeleteCookiesParams) WithDomain(domain string) *DeleteCookiesParams { + p.Domain = domain + return &p +} + +// WithPath if specified, deletes only cookies with the exact path. +func (p DeleteCookiesParams) WithPath(path string) *DeleteCookiesParams { + p.Path = path + return &p +} + +// Do executes Network.deleteCookies against the provided context and +// target handler. +func (p *DeleteCookiesParams) Do(ctxt context.Context, h cdp.Handler) (err error) { + return h.Execute(ctxt, cdp.CommandNetworkDeleteCookies, p, nil) +} + +// DisableParams disables network tracking, prevents network events from +// being sent to the client. +type DisableParams struct{} + +// Disable disables network tracking, prevents network events from being sent +// to the client. +func Disable() *DisableParams { + return &DisableParams{} +} + +// Do executes Network.disable against the provided context and +// target handler. +func (p *DisableParams) Do(ctxt context.Context, h cdp.Handler) (err error) { + return h.Execute(ctxt, cdp.CommandNetworkDisable, nil, nil) +} + +// EmulateNetworkConditionsParams activates emulation of network conditions. +type EmulateNetworkConditionsParams struct { + Offline bool `json:"offline"` // True to emulate internet disconnection. + Latency float64 `json:"latency"` // Minimum latency from request sent to response headers received (ms). + DownloadThroughput float64 `json:"downloadThroughput"` // Maximal aggregated download throughput (bytes/sec). -1 disables download throttling. + UploadThroughput float64 `json:"uploadThroughput"` // Maximal aggregated upload throughput (bytes/sec). -1 disables upload throttling. + ConnectionType ConnectionType `json:"connectionType,omitempty"` // Connection type if known. +} + +// EmulateNetworkConditions activates emulation of network conditions. +// +// parameters: +// offline - True to emulate internet disconnection. +// latency - Minimum latency from request sent to response headers received (ms). +// downloadThroughput - Maximal aggregated download throughput (bytes/sec). -1 disables download throttling. +// uploadThroughput - Maximal aggregated upload throughput (bytes/sec). -1 disables upload throttling. +func EmulateNetworkConditions(offline bool, latency float64, downloadThroughput float64, uploadThroughput float64) *EmulateNetworkConditionsParams { + return &EmulateNetworkConditionsParams{ + Offline: offline, + Latency: latency, + DownloadThroughput: downloadThroughput, + UploadThroughput: uploadThroughput, + } +} + +// WithConnectionType connection type if known. +func (p EmulateNetworkConditionsParams) WithConnectionType(connectionType ConnectionType) *EmulateNetworkConditionsParams { + p.ConnectionType = connectionType + return &p +} + +// Do executes Network.emulateNetworkConditions against the provided context and +// target handler. +func (p *EmulateNetworkConditionsParams) Do(ctxt context.Context, h cdp.Handler) (err error) { + return h.Execute(ctxt, cdp.CommandNetworkEmulateNetworkConditions, p, nil) +} + // EnableParams enables network tracking, network events will now be // delivered to the client. type EnableParams struct { @@ -53,42 +266,237 @@ func (p *EnableParams) Do(ctxt context.Context, h cdp.Handler) (err error) { return h.Execute(ctxt, cdp.CommandNetworkEnable, p, nil) } -// DisableParams disables network tracking, prevents network events from -// being sent to the client. -type DisableParams struct{} +// GetAllCookiesParams returns all browser cookies. Depending on the backend +// support, will return detailed cookie information in the cookies field. +type GetAllCookiesParams struct{} -// Disable disables network tracking, prevents network events from being sent -// to the client. -func Disable() *DisableParams { - return &DisableParams{} +// GetAllCookies returns all browser cookies. Depending on the backend +// support, will return detailed cookie information in the cookies field. +func GetAllCookies() *GetAllCookiesParams { + return &GetAllCookiesParams{} } -// Do executes Network.disable against the provided context and +// GetAllCookiesReturns return values. +type GetAllCookiesReturns struct { + Cookies []*Cookie `json:"cookies,omitempty"` // Array of cookie objects. +} + +// Do executes Network.getAllCookies against the provided context and // target handler. -func (p *DisableParams) Do(ctxt context.Context, h cdp.Handler) (err error) { - return h.Execute(ctxt, cdp.CommandNetworkDisable, nil, nil) +// +// returns: +// cookies - Array of cookie objects. +func (p *GetAllCookiesParams) Do(ctxt context.Context, h cdp.Handler) (cookies []*Cookie, err error) { + // execute + var res GetAllCookiesReturns + err = h.Execute(ctxt, cdp.CommandNetworkGetAllCookies, nil, &res) + if err != nil { + return nil, err + } + + return res.Cookies, nil } -// SetUserAgentOverrideParams allows overriding user agent with the given -// string. -type SetUserAgentOverrideParams struct { - UserAgent string `json:"userAgent"` // User agent to use. +// GetCertificateParams returns the DER-encoded certificate. +type GetCertificateParams struct { + Origin string `json:"origin"` // Origin to get certificate for. } -// SetUserAgentOverride allows overriding user agent with the given string. +// GetCertificate returns the DER-encoded certificate. // // parameters: -// userAgent - User agent to use. -func SetUserAgentOverride(userAgent string) *SetUserAgentOverrideParams { - return &SetUserAgentOverrideParams{ - UserAgent: userAgent, +// origin - Origin to get certificate for. +func GetCertificate(origin string) *GetCertificateParams { + return &GetCertificateParams{ + Origin: origin, } } -// Do executes Network.setUserAgentOverride against the provided context and +// GetCertificateReturns return values. +type GetCertificateReturns struct { + TableNames []string `json:"tableNames,omitempty"` +} + +// Do executes Network.getCertificate against the provided context and // target handler. -func (p *SetUserAgentOverrideParams) Do(ctxt context.Context, h cdp.Handler) (err error) { - return h.Execute(ctxt, cdp.CommandNetworkSetUserAgentOverride, p, nil) +// +// returns: +// tableNames +func (p *GetCertificateParams) Do(ctxt context.Context, h cdp.Handler) (tableNames []string, err error) { + // execute + var res GetCertificateReturns + err = h.Execute(ctxt, cdp.CommandNetworkGetCertificate, p, &res) + if err != nil { + return nil, err + } + + return res.TableNames, nil +} + +// GetCookiesParams returns all browser cookies for the current URL. +// Depending on the backend support, will return detailed cookie information in +// the cookies field. +type GetCookiesParams struct { + Urls []string `json:"urls,omitempty"` // The list of URLs for which applicable cookies will be fetched +} + +// GetCookies returns all browser cookies for the current URL. Depending on +// the backend support, will return detailed cookie information in the cookies +// field. +// +// parameters: +func GetCookies() *GetCookiesParams { + return &GetCookiesParams{} +} + +// WithUrls the list of URLs for which applicable cookies will be fetched. +func (p GetCookiesParams) WithUrls(urls []string) *GetCookiesParams { + p.Urls = urls + return &p +} + +// GetCookiesReturns return values. +type GetCookiesReturns struct { + Cookies []*Cookie `json:"cookies,omitempty"` // Array of cookie objects. +} + +// Do executes Network.getCookies against the provided context and +// target handler. +// +// returns: +// cookies - Array of cookie objects. +func (p *GetCookiesParams) Do(ctxt context.Context, h cdp.Handler) (cookies []*Cookie, err error) { + // execute + var res GetCookiesReturns + err = h.Execute(ctxt, cdp.CommandNetworkGetCookies, p, &res) + if err != nil { + return nil, err + } + + return res.Cookies, nil +} + +// GetResponseBodyParams returns content served for the given request. +type GetResponseBodyParams struct { + RequestID RequestID `json:"requestId"` // Identifier of the network request to get content for. +} + +// GetResponseBody returns content served for the given request. +// +// parameters: +// requestID - Identifier of the network request to get content for. +func GetResponseBody(requestID RequestID) *GetResponseBodyParams { + return &GetResponseBodyParams{ + RequestID: requestID, + } +} + +// GetResponseBodyReturns return values. +type GetResponseBodyReturns struct { + Body string `json:"body,omitempty"` // Response body. + Base64encoded bool `json:"base64Encoded,omitempty"` // True, if content was sent as base64. +} + +// Do executes Network.getResponseBody against the provided context and +// target handler. +// +// returns: +// body - Response body. +func (p *GetResponseBodyParams) Do(ctxt context.Context, h cdp.Handler) (body []byte, err error) { + // execute + var res GetResponseBodyReturns + err = h.Execute(ctxt, cdp.CommandNetworkGetResponseBody, p, &res) + if err != nil { + return nil, err + } + + // decode + var dec []byte + if res.Base64encoded { + dec, err = base64.StdEncoding.DecodeString(res.Body) + if err != nil { + return nil, err + } + } else { + dec = []byte(res.Body) + } + return dec, nil +} + +// GetResponseBodyForInterceptionParams returns content served for the given +// currently intercepted request. +type GetResponseBodyForInterceptionParams struct { + InterceptionID InterceptionID `json:"interceptionId"` // Identifier for the intercepted request to get body for. +} + +// GetResponseBodyForInterception returns content served for the given +// currently intercepted request. +// +// parameters: +// interceptionID - Identifier for the intercepted request to get body for. +func GetResponseBodyForInterception(interceptionID InterceptionID) *GetResponseBodyForInterceptionParams { + return &GetResponseBodyForInterceptionParams{ + InterceptionID: interceptionID, + } +} + +// GetResponseBodyForInterceptionReturns return values. +type GetResponseBodyForInterceptionReturns struct { + Body string `json:"body,omitempty"` // Response body. + Base64encoded bool `json:"base64Encoded,omitempty"` // True, if content was sent as base64. +} + +// Do executes Network.getResponseBodyForInterception against the provided context and +// target handler. +// +// returns: +// body - Response body. +func (p *GetResponseBodyForInterceptionParams) Do(ctxt context.Context, h cdp.Handler) (body []byte, err error) { + // execute + var res GetResponseBodyForInterceptionReturns + err = h.Execute(ctxt, cdp.CommandNetworkGetResponseBodyForInterception, p, &res) + if err != nil { + return nil, err + } + + // decode + var dec []byte + if res.Base64encoded { + dec, err = base64.StdEncoding.DecodeString(res.Body) + if err != nil { + return nil, err + } + } else { + dec = []byte(res.Body) + } + return dec, nil +} + +// ReplayXHRParams this method sends a new XMLHttpRequest which is identical +// to the original one. The following parameters should be identical: method, +// url, async, request body, extra headers, withCredentials attribute, user, +// password. +type ReplayXHRParams struct { + RequestID RequestID `json:"requestId"` // Identifier of XHR to replay. +} + +// ReplayXHR this method sends a new XMLHttpRequest which is identical to the +// original one. The following parameters should be identical: method, url, +// async, request body, extra headers, withCredentials attribute, user, +// password. +// +// parameters: +// requestID - Identifier of XHR to replay. +func ReplayXHR(requestID RequestID) *ReplayXHRParams { + return &ReplayXHRParams{ + RequestID: requestID, + } +} + +// Do executes Network.replayXHR against the provided context and +// target handler. +func (p *ReplayXHRParams) Do(ctxt context.Context, h cdp.Handler) (err error) { + return h.Execute(ctxt, cdp.CommandNetworkReplayXHR, p, nil) } // SearchInResponseBodyParams searches for given string in response content. @@ -144,76 +552,6 @@ func (p *SearchInResponseBodyParams) Do(ctxt context.Context, h cdp.Handler) (re return res.Result, nil } -// SetExtraHTTPHeadersParams specifies whether to always send extra HTTP -// headers with the requests from this page. -type SetExtraHTTPHeadersParams struct { - Headers Headers `json:"headers"` // Map with extra HTTP headers. -} - -// SetExtraHTTPHeaders specifies whether to always send extra HTTP headers -// with the requests from this page. -// -// parameters: -// headers - Map with extra HTTP headers. -func SetExtraHTTPHeaders(headers Headers) *SetExtraHTTPHeadersParams { - return &SetExtraHTTPHeadersParams{ - Headers: headers, - } -} - -// Do executes Network.setExtraHTTPHeaders against the provided context and -// target handler. -func (p *SetExtraHTTPHeadersParams) Do(ctxt context.Context, h cdp.Handler) (err error) { - return h.Execute(ctxt, cdp.CommandNetworkSetExtraHTTPHeaders, p, nil) -} - -// GetResponseBodyParams returns content served for the given request. -type GetResponseBodyParams struct { - RequestID RequestID `json:"requestId"` // Identifier of the network request to get content for. -} - -// GetResponseBody returns content served for the given request. -// -// parameters: -// requestID - Identifier of the network request to get content for. -func GetResponseBody(requestID RequestID) *GetResponseBodyParams { - return &GetResponseBodyParams{ - RequestID: requestID, - } -} - -// GetResponseBodyReturns return values. -type GetResponseBodyReturns struct { - Body string `json:"body,omitempty"` // Response body. - Base64encoded bool `json:"base64Encoded,omitempty"` // True, if content was sent as base64. -} - -// Do executes Network.getResponseBody against the provided context and -// target handler. -// -// returns: -// body - Response body. -func (p *GetResponseBodyParams) Do(ctxt context.Context, h cdp.Handler) (body []byte, err error) { - // execute - var res GetResponseBodyReturns - err = h.Execute(ctxt, cdp.CommandNetworkGetResponseBody, p, &res) - if err != nil { - return nil, err - } - - // decode - var dec []byte - if res.Base64encoded { - dec, err = base64.StdEncoding.DecodeString(res.Body) - if err != nil { - return nil, err - } - } else { - dec = []byte(res.Body) - } - return dec, nil -} - // SetBlockedURLSParams blocks URLs from loading. type SetBlockedURLSParams struct { Urls []string `json:"urls"` // URL patterns to block. Wildcards ('*') are allowed. @@ -235,178 +573,50 @@ func (p *SetBlockedURLSParams) Do(ctxt context.Context, h cdp.Handler) (err erro return h.Execute(ctxt, cdp.CommandNetworkSetBlockedURLS, p, nil) } -// ReplayXHRParams this method sends a new XMLHttpRequest which is identical -// to the original one. The following parameters should be identical: method, -// url, async, request body, extra headers, withCredentials attribute, user, -// password. -type ReplayXHRParams struct { - RequestID RequestID `json:"requestId"` // Identifier of XHR to replay. +// SetBypassServiceWorkerParams toggles ignoring of service worker for each +// request. +type SetBypassServiceWorkerParams struct { + Bypass bool `json:"bypass"` // Bypass service worker and load from network. } -// ReplayXHR this method sends a new XMLHttpRequest which is identical to the -// original one. The following parameters should be identical: method, url, -// async, request body, extra headers, withCredentials attribute, user, -// password. +// SetBypassServiceWorker toggles ignoring of service worker for each +// request. // // parameters: -// requestID - Identifier of XHR to replay. -func ReplayXHR(requestID RequestID) *ReplayXHRParams { - return &ReplayXHRParams{ - RequestID: requestID, +// bypass - Bypass service worker and load from network. +func SetBypassServiceWorker(bypass bool) *SetBypassServiceWorkerParams { + return &SetBypassServiceWorkerParams{ + Bypass: bypass, } } -// Do executes Network.replayXHR against the provided context and +// Do executes Network.setBypassServiceWorker against the provided context and // target handler. -func (p *ReplayXHRParams) Do(ctxt context.Context, h cdp.Handler) (err error) { - return h.Execute(ctxt, cdp.CommandNetworkReplayXHR, p, nil) +func (p *SetBypassServiceWorkerParams) Do(ctxt context.Context, h cdp.Handler) (err error) { + return h.Execute(ctxt, cdp.CommandNetworkSetBypassServiceWorker, p, nil) } -// ClearBrowserCacheParams clears browser cache. -type ClearBrowserCacheParams struct{} - -// ClearBrowserCache clears browser cache. -func ClearBrowserCache() *ClearBrowserCacheParams { - return &ClearBrowserCacheParams{} +// SetCacheDisabledParams toggles ignoring cache for each request. If true, +// cache will not be used. +type SetCacheDisabledParams struct { + CacheDisabled bool `json:"cacheDisabled"` // Cache disabled state. } -// Do executes Network.clearBrowserCache against the provided context and -// target handler. -func (p *ClearBrowserCacheParams) Do(ctxt context.Context, h cdp.Handler) (err error) { - return h.Execute(ctxt, cdp.CommandNetworkClearBrowserCache, nil, nil) -} - -// ClearBrowserCookiesParams clears browser cookies. -type ClearBrowserCookiesParams struct{} - -// ClearBrowserCookies clears browser cookies. -func ClearBrowserCookies() *ClearBrowserCookiesParams { - return &ClearBrowserCookiesParams{} -} - -// Do executes Network.clearBrowserCookies against the provided context and -// target handler. -func (p *ClearBrowserCookiesParams) Do(ctxt context.Context, h cdp.Handler) (err error) { - return h.Execute(ctxt, cdp.CommandNetworkClearBrowserCookies, nil, nil) -} - -// GetCookiesParams returns all browser cookies for the current URL. -// Depending on the backend support, will return detailed cookie information in -// the cookies field. -type GetCookiesParams struct { - Urls []string `json:"urls,omitempty"` // The list of URLs for which applicable cookies will be fetched -} - -// GetCookies returns all browser cookies for the current URL. Depending on -// the backend support, will return detailed cookie information in the cookies -// field. +// SetCacheDisabled toggles ignoring cache for each request. If true, cache +// will not be used. // // parameters: -func GetCookies() *GetCookiesParams { - return &GetCookiesParams{} -} - -// WithUrls the list of URLs for which applicable cookies will be fetched. -func (p GetCookiesParams) WithUrls(urls []string) *GetCookiesParams { - p.Urls = urls - return &p -} - -// GetCookiesReturns return values. -type GetCookiesReturns struct { - Cookies []*Cookie `json:"cookies,omitempty"` // Array of cookie objects. -} - -// Do executes Network.getCookies against the provided context and -// target handler. -// -// returns: -// cookies - Array of cookie objects. -func (p *GetCookiesParams) Do(ctxt context.Context, h cdp.Handler) (cookies []*Cookie, err error) { - // execute - var res GetCookiesReturns - err = h.Execute(ctxt, cdp.CommandNetworkGetCookies, p, &res) - if err != nil { - return nil, err - } - - return res.Cookies, nil -} - -// GetAllCookiesParams returns all browser cookies. Depending on the backend -// support, will return detailed cookie information in the cookies field. -type GetAllCookiesParams struct{} - -// GetAllCookies returns all browser cookies. Depending on the backend -// support, will return detailed cookie information in the cookies field. -func GetAllCookies() *GetAllCookiesParams { - return &GetAllCookiesParams{} -} - -// GetAllCookiesReturns return values. -type GetAllCookiesReturns struct { - Cookies []*Cookie `json:"cookies,omitempty"` // Array of cookie objects. -} - -// Do executes Network.getAllCookies against the provided context and -// target handler. -// -// returns: -// cookies - Array of cookie objects. -func (p *GetAllCookiesParams) Do(ctxt context.Context, h cdp.Handler) (cookies []*Cookie, err error) { - // execute - var res GetAllCookiesReturns - err = h.Execute(ctxt, cdp.CommandNetworkGetAllCookies, nil, &res) - if err != nil { - return nil, err - } - - return res.Cookies, nil -} - -// DeleteCookiesParams deletes browser cookies with matching name and url or -// domain/path pair. -type DeleteCookiesParams struct { - Name string `json:"name"` // Name of the cookies to remove. - URL string `json:"url,omitempty"` // If specified, deletes all the cookies with the given name where domain and path match provided URL. - Domain string `json:"domain,omitempty"` // If specified, deletes only cookies with the exact domain. - Path string `json:"path,omitempty"` // If specified, deletes only cookies with the exact path. -} - -// DeleteCookies deletes browser cookies with matching name and url or -// domain/path pair. -// -// parameters: -// name - Name of the cookies to remove. -func DeleteCookies(name string) *DeleteCookiesParams { - return &DeleteCookiesParams{ - Name: name, +// cacheDisabled - Cache disabled state. +func SetCacheDisabled(cacheDisabled bool) *SetCacheDisabledParams { + return &SetCacheDisabledParams{ + CacheDisabled: cacheDisabled, } } -// WithURL if specified, deletes all the cookies with the given name where -// domain and path match provided URL. -func (p DeleteCookiesParams) WithURL(url string) *DeleteCookiesParams { - p.URL = url - return &p -} - -// WithDomain if specified, deletes only cookies with the exact domain. -func (p DeleteCookiesParams) WithDomain(domain string) *DeleteCookiesParams { - p.Domain = domain - return &p -} - -// WithPath if specified, deletes only cookies with the exact path. -func (p DeleteCookiesParams) WithPath(path string) *DeleteCookiesParams { - p.Path = path - return &p -} - -// Do executes Network.deleteCookies against the provided context and +// Do executes Network.setCacheDisabled against the provided context and // target handler. -func (p *DeleteCookiesParams) Do(ctxt context.Context, h cdp.Handler) (err error) { - return h.Execute(ctxt, cdp.CommandNetworkDeleteCookies, p, nil) +func (p *SetCacheDisabledParams) Do(ctxt context.Context, h cdp.Handler) (err error) { + return h.Execute(ctxt, cdp.CommandNetworkSetCacheDisabled, p, nil) } // SetCookieParams sets a cookie with the given cookie data; may overwrite @@ -521,89 +731,6 @@ func (p *SetCookiesParams) Do(ctxt context.Context, h cdp.Handler) (err error) { return h.Execute(ctxt, cdp.CommandNetworkSetCookies, p, nil) } -// EmulateNetworkConditionsParams activates emulation of network conditions. -type EmulateNetworkConditionsParams struct { - Offline bool `json:"offline"` // True to emulate internet disconnection. - Latency float64 `json:"latency"` // Minimum latency from request sent to response headers received (ms). - DownloadThroughput float64 `json:"downloadThroughput"` // Maximal aggregated download throughput (bytes/sec). -1 disables download throttling. - UploadThroughput float64 `json:"uploadThroughput"` // Maximal aggregated upload throughput (bytes/sec). -1 disables upload throttling. - ConnectionType ConnectionType `json:"connectionType,omitempty"` // Connection type if known. -} - -// EmulateNetworkConditions activates emulation of network conditions. -// -// parameters: -// offline - True to emulate internet disconnection. -// latency - Minimum latency from request sent to response headers received (ms). -// downloadThroughput - Maximal aggregated download throughput (bytes/sec). -1 disables download throttling. -// uploadThroughput - Maximal aggregated upload throughput (bytes/sec). -1 disables upload throttling. -func EmulateNetworkConditions(offline bool, latency float64, downloadThroughput float64, uploadThroughput float64) *EmulateNetworkConditionsParams { - return &EmulateNetworkConditionsParams{ - Offline: offline, - Latency: latency, - DownloadThroughput: downloadThroughput, - UploadThroughput: uploadThroughput, - } -} - -// WithConnectionType connection type if known. -func (p EmulateNetworkConditionsParams) WithConnectionType(connectionType ConnectionType) *EmulateNetworkConditionsParams { - p.ConnectionType = connectionType - return &p -} - -// Do executes Network.emulateNetworkConditions against the provided context and -// target handler. -func (p *EmulateNetworkConditionsParams) Do(ctxt context.Context, h cdp.Handler) (err error) { - return h.Execute(ctxt, cdp.CommandNetworkEmulateNetworkConditions, p, nil) -} - -// SetCacheDisabledParams toggles ignoring cache for each request. If true, -// cache will not be used. -type SetCacheDisabledParams struct { - CacheDisabled bool `json:"cacheDisabled"` // Cache disabled state. -} - -// SetCacheDisabled toggles ignoring cache for each request. If true, cache -// will not be used. -// -// parameters: -// cacheDisabled - Cache disabled state. -func SetCacheDisabled(cacheDisabled bool) *SetCacheDisabledParams { - return &SetCacheDisabledParams{ - CacheDisabled: cacheDisabled, - } -} - -// Do executes Network.setCacheDisabled against the provided context and -// target handler. -func (p *SetCacheDisabledParams) Do(ctxt context.Context, h cdp.Handler) (err error) { - return h.Execute(ctxt, cdp.CommandNetworkSetCacheDisabled, p, nil) -} - -// SetBypassServiceWorkerParams toggles ignoring of service worker for each -// request. -type SetBypassServiceWorkerParams struct { - Bypass bool `json:"bypass"` // Bypass service worker and load from network. -} - -// SetBypassServiceWorker toggles ignoring of service worker for each -// request. -// -// parameters: -// bypass - Bypass service worker and load from network. -func SetBypassServiceWorker(bypass bool) *SetBypassServiceWorkerParams { - return &SetBypassServiceWorkerParams{ - Bypass: bypass, - } -} - -// Do executes Network.setBypassServiceWorker against the provided context and -// target handler. -func (p *SetBypassServiceWorkerParams) Do(ctxt context.Context, h cdp.Handler) (err error) { - return h.Execute(ctxt, cdp.CommandNetworkSetBypassServiceWorker, p, nil) -} - // SetDataSizeLimitsForTestParams for testing. type SetDataSizeLimitsForTestParams struct { MaxTotalSize int64 `json:"maxTotalSize"` // Maximum total buffer size. @@ -628,40 +755,27 @@ func (p *SetDataSizeLimitsForTestParams) Do(ctxt context.Context, h cdp.Handler) return h.Execute(ctxt, cdp.CommandNetworkSetDataSizeLimitsForTest, p, nil) } -// GetCertificateParams returns the DER-encoded certificate. -type GetCertificateParams struct { - Origin string `json:"origin"` // Origin to get certificate for. +// SetExtraHTTPHeadersParams specifies whether to always send extra HTTP +// headers with the requests from this page. +type SetExtraHTTPHeadersParams struct { + Headers Headers `json:"headers"` // Map with extra HTTP headers. } -// GetCertificate returns the DER-encoded certificate. +// SetExtraHTTPHeaders specifies whether to always send extra HTTP headers +// with the requests from this page. // // parameters: -// origin - Origin to get certificate for. -func GetCertificate(origin string) *GetCertificateParams { - return &GetCertificateParams{ - Origin: origin, +// headers - Map with extra HTTP headers. +func SetExtraHTTPHeaders(headers Headers) *SetExtraHTTPHeadersParams { + return &SetExtraHTTPHeadersParams{ + Headers: headers, } } -// GetCertificateReturns return values. -type GetCertificateReturns struct { - TableNames []string `json:"tableNames,omitempty"` -} - -// Do executes Network.getCertificate against the provided context and +// Do executes Network.setExtraHTTPHeaders against the provided context and // target handler. -// -// returns: -// tableNames -func (p *GetCertificateParams) Do(ctxt context.Context, h cdp.Handler) (tableNames []string, err error) { - // execute - var res GetCertificateReturns - err = h.Execute(ctxt, cdp.CommandNetworkGetCertificate, p, &res) - if err != nil { - return nil, err - } - - return res.TableNames, nil +func (p *SetExtraHTTPHeadersParams) Do(ctxt context.Context, h cdp.Handler) (err error) { + return h.Execute(ctxt, cdp.CommandNetworkSetExtraHTTPHeaders, p, nil) } // SetRequestInterceptionParams sets the requests to intercept that match a @@ -687,138 +801,24 @@ func (p *SetRequestInterceptionParams) Do(ctxt context.Context, h cdp.Handler) ( return h.Execute(ctxt, cdp.CommandNetworkSetRequestInterception, p, nil) } -// ContinueInterceptedRequestParams response to Network.requestIntercepted -// which either modifies the request to continue with any modifications, or -// blocks it, or completes it with the provided response bytes. If a network -// fetch occurs as a result which encounters a redirect an additional -// Network.requestIntercepted event will be sent with the same InterceptionId. -type ContinueInterceptedRequestParams struct { - InterceptionID InterceptionID `json:"interceptionId"` - ErrorReason ErrorReason `json:"errorReason,omitempty"` // If set this causes the request to fail with the given reason. Passing Aborted for requests marked with isNavigationRequest also cancels the navigation. Must not be set in response to an authChallenge. - RawResponse string `json:"rawResponse,omitempty"` // If set the requests completes using with the provided base64 encoded raw response, including HTTP status line and headers etc... Must not be set in response to an authChallenge. - URL string `json:"url,omitempty"` // If set the request url will be modified in a way that's not observable by page. Must not be set in response to an authChallenge. - Method string `json:"method,omitempty"` // If set this allows the request method to be overridden. Must not be set in response to an authChallenge. - PostData string `json:"postData,omitempty"` // If set this allows postData to be set. Must not be set in response to an authChallenge. - Headers Headers `json:"headers,omitempty"` // If set this allows the request headers to be changed. Must not be set in response to an authChallenge. - AuthChallengeResponse *AuthChallengeResponse `json:"authChallengeResponse,omitempty"` // Response to a requestIntercepted with an authChallenge. Must not be set otherwise. +// SetUserAgentOverrideParams allows overriding user agent with the given +// string. +type SetUserAgentOverrideParams struct { + UserAgent string `json:"userAgent"` // User agent to use. } -// ContinueInterceptedRequest response to Network.requestIntercepted which -// either modifies the request to continue with any modifications, or blocks it, -// or completes it with the provided response bytes. If a network fetch occurs -// as a result which encounters a redirect an additional -// Network.requestIntercepted event will be sent with the same InterceptionId. +// SetUserAgentOverride allows overriding user agent with the given string. // // parameters: -// interceptionID -func ContinueInterceptedRequest(interceptionID InterceptionID) *ContinueInterceptedRequestParams { - return &ContinueInterceptedRequestParams{ - InterceptionID: interceptionID, +// userAgent - User agent to use. +func SetUserAgentOverride(userAgent string) *SetUserAgentOverrideParams { + return &SetUserAgentOverrideParams{ + UserAgent: userAgent, } } -// WithErrorReason if set this causes the request to fail with the given -// reason. Passing Aborted for requests marked with isNavigationRequest also -// cancels the navigation. Must not be set in response to an authChallenge. -func (p ContinueInterceptedRequestParams) WithErrorReason(errorReason ErrorReason) *ContinueInterceptedRequestParams { - p.ErrorReason = errorReason - return &p -} - -// WithRawResponse if set the requests completes using with the provided -// base64 encoded raw response, including HTTP status line and headers etc... -// Must not be set in response to an authChallenge. -func (p ContinueInterceptedRequestParams) WithRawResponse(rawResponse string) *ContinueInterceptedRequestParams { - p.RawResponse = rawResponse - return &p -} - -// WithURL if set the request url will be modified in a way that's not -// observable by page. Must not be set in response to an authChallenge. -func (p ContinueInterceptedRequestParams) WithURL(url string) *ContinueInterceptedRequestParams { - p.URL = url - return &p -} - -// WithMethod if set this allows the request method to be overridden. Must -// not be set in response to an authChallenge. -func (p ContinueInterceptedRequestParams) WithMethod(method string) *ContinueInterceptedRequestParams { - p.Method = method - return &p -} - -// WithPostData if set this allows postData to be set. Must not be set in -// response to an authChallenge. -func (p ContinueInterceptedRequestParams) WithPostData(postData string) *ContinueInterceptedRequestParams { - p.PostData = postData - return &p -} - -// WithHeaders if set this allows the request headers to be changed. Must not -// be set in response to an authChallenge. -func (p ContinueInterceptedRequestParams) WithHeaders(headers Headers) *ContinueInterceptedRequestParams { - p.Headers = headers - return &p -} - -// WithAuthChallengeResponse response to a requestIntercepted with an -// authChallenge. Must not be set otherwise. -func (p ContinueInterceptedRequestParams) WithAuthChallengeResponse(authChallengeResponse *AuthChallengeResponse) *ContinueInterceptedRequestParams { - p.AuthChallengeResponse = authChallengeResponse - return &p -} - -// Do executes Network.continueInterceptedRequest against the provided context and +// Do executes Network.setUserAgentOverride against the provided context and // target handler. -func (p *ContinueInterceptedRequestParams) Do(ctxt context.Context, h cdp.Handler) (err error) { - return h.Execute(ctxt, cdp.CommandNetworkContinueInterceptedRequest, p, nil) -} - -// GetResponseBodyForInterceptionParams returns content served for the given -// currently intercepted request. -type GetResponseBodyForInterceptionParams struct { - InterceptionID InterceptionID `json:"interceptionId"` // Identifier for the intercepted request to get body for. -} - -// GetResponseBodyForInterception returns content served for the given -// currently intercepted request. -// -// parameters: -// interceptionID - Identifier for the intercepted request to get body for. -func GetResponseBodyForInterception(interceptionID InterceptionID) *GetResponseBodyForInterceptionParams { - return &GetResponseBodyForInterceptionParams{ - InterceptionID: interceptionID, - } -} - -// GetResponseBodyForInterceptionReturns return values. -type GetResponseBodyForInterceptionReturns struct { - Body string `json:"body,omitempty"` // Response body. - Base64encoded bool `json:"base64Encoded,omitempty"` // True, if content was sent as base64. -} - -// Do executes Network.getResponseBodyForInterception against the provided context and -// target handler. -// -// returns: -// body - Response body. -func (p *GetResponseBodyForInterceptionParams) Do(ctxt context.Context, h cdp.Handler) (body []byte, err error) { - // execute - var res GetResponseBodyForInterceptionReturns - err = h.Execute(ctxt, cdp.CommandNetworkGetResponseBodyForInterception, p, &res) - if err != nil { - return nil, err - } - - // decode - var dec []byte - if res.Base64encoded { - dec, err = base64.StdEncoding.DecodeString(res.Body) - if err != nil { - return nil, err - } - } else { - dec = []byte(res.Body) - } - return dec, nil +func (p *SetUserAgentOverrideParams) Do(ctxt context.Context, h cdp.Handler) (err error) { + return h.Execute(ctxt, cdp.CommandNetworkSetUserAgentOverride, p, nil) } diff --git a/cdp/overlay/events.go b/cdp/overlay/events.go index df30c5b..9a41deb 100644 --- a/cdp/overlay/events.go +++ b/cdp/overlay/events.go @@ -7,12 +7,6 @@ import ( "github.com/knq/chromedp/cdp/page" ) -// EventNodeHighlightRequested fired when the node should be highlighted. -// This happens after call to setInspectMode. -type EventNodeHighlightRequested struct { - NodeID cdp.NodeID `json:"nodeId"` -} - // EventInspectNodeRequested fired when the node should be inspected. This // happens after call to setInspectMode or when user manually inspects an // element. @@ -20,6 +14,12 @@ type EventInspectNodeRequested struct { BackendNodeID cdp.BackendNodeID `json:"backendNodeId"` // Id of the node to inspect. } +// EventNodeHighlightRequested fired when the node should be highlighted. +// This happens after call to setInspectMode. +type EventNodeHighlightRequested struct { + NodeID cdp.NodeID `json:"nodeId"` +} + // EventScreenshotRequested fired when user asks to capture screenshot of // some area on the page. type EventScreenshotRequested struct { @@ -28,7 +28,7 @@ type EventScreenshotRequested struct { // EventTypes all event types in the domain. var EventTypes = []cdp.MethodType{ - cdp.EventOverlayNodeHighlightRequested, cdp.EventOverlayInspectNodeRequested, + cdp.EventOverlayNodeHighlightRequested, cdp.EventOverlayScreenshotRequested, } diff --git a/cdp/overlay/overlay.go b/cdp/overlay/overlay.go index d67fc60..16ffa5f 100644 --- a/cdp/overlay/overlay.go +++ b/cdp/overlay/overlay.go @@ -18,20 +18,6 @@ import ( "github.com/mailru/easyjson" ) -// EnableParams enables domain notifications. -type EnableParams struct{} - -// Enable enables domain notifications. -func Enable() *EnableParams { - return &EnableParams{} -} - -// Do executes Overlay.enable against the provided context and -// target handler. -func (p *EnableParams) Do(ctxt context.Context, h cdp.Handler) (err error) { - return h.Execute(ctxt, cdp.CommandOverlayEnable, nil, nil) -} - // DisableParams disables domain notifications. type DisableParams struct{} @@ -46,192 +32,186 @@ func (p *DisableParams) Do(ctxt context.Context, h cdp.Handler) (err error) { return h.Execute(ctxt, cdp.CommandOverlayDisable, nil, nil) } -// SetShowPaintRectsParams requests that backend shows paint rectangles. -type SetShowPaintRectsParams struct { - Result bool `json:"result"` // True for showing paint rectangles +// EnableParams enables domain notifications. +type EnableParams struct{} + +// Enable enables domain notifications. +func Enable() *EnableParams { + return &EnableParams{} } -// SetShowPaintRects requests that backend shows paint rectangles. +// Do executes Overlay.enable against the provided context and +// target handler. +func (p *EnableParams) Do(ctxt context.Context, h cdp.Handler) (err error) { + return h.Execute(ctxt, cdp.CommandOverlayEnable, nil, nil) +} + +// GetHighlightObjectForTestParams for testing. +type GetHighlightObjectForTestParams struct { + NodeID cdp.NodeID `json:"nodeId"` // Id of the node to get highlight object for. +} + +// GetHighlightObjectForTest for testing. // // parameters: -// result - True for showing paint rectangles -func SetShowPaintRects(result bool) *SetShowPaintRectsParams { - return &SetShowPaintRectsParams{ - Result: result, +// nodeID - Id of the node to get highlight object for. +func GetHighlightObjectForTest(nodeID cdp.NodeID) *GetHighlightObjectForTestParams { + return &GetHighlightObjectForTestParams{ + NodeID: nodeID, } } -// Do executes Overlay.setShowPaintRects against the provided context and +// GetHighlightObjectForTestReturns return values. +type GetHighlightObjectForTestReturns struct { + Highlight easyjson.RawMessage `json:"highlight,omitempty"` +} + +// Do executes Overlay.getHighlightObjectForTest against the provided context and // target handler. -func (p *SetShowPaintRectsParams) Do(ctxt context.Context, h cdp.Handler) (err error) { - return h.Execute(ctxt, cdp.CommandOverlaySetShowPaintRects, p, nil) +// +// returns: +// highlight - Highlight data for the node. +func (p *GetHighlightObjectForTestParams) Do(ctxt context.Context, h cdp.Handler) (highlight easyjson.RawMessage, err error) { + // execute + var res GetHighlightObjectForTestReturns + err = h.Execute(ctxt, cdp.CommandOverlayGetHighlightObjectForTest, p, &res) + if err != nil { + return nil, err + } + + return res.Highlight, nil } -// SetShowDebugBordersParams requests that backend shows debug borders on -// layers. -type SetShowDebugBordersParams struct { - Show bool `json:"show"` // True for showing debug borders +// HideHighlightParams hides any highlight. +type HideHighlightParams struct{} + +// HideHighlight hides any highlight. +func HideHighlight() *HideHighlightParams { + return &HideHighlightParams{} } -// SetShowDebugBorders requests that backend shows debug borders on layers. +// Do executes Overlay.hideHighlight against the provided context and +// target handler. +func (p *HideHighlightParams) Do(ctxt context.Context, h cdp.Handler) (err error) { + return h.Execute(ctxt, cdp.CommandOverlayHideHighlight, nil, nil) +} + +// HighlightFrameParams highlights owner element of the frame with given id. +type HighlightFrameParams struct { + FrameID cdp.FrameID `json:"frameId"` // Identifier of the frame to highlight. + ContentColor *cdp.RGBA `json:"contentColor,omitempty"` // The content box highlight fill color (default: transparent). + ContentOutlineColor *cdp.RGBA `json:"contentOutlineColor,omitempty"` // The content box highlight outline color (default: transparent). +} + +// HighlightFrame highlights owner element of the frame with given id. // // parameters: -// show - True for showing debug borders -func SetShowDebugBorders(show bool) *SetShowDebugBordersParams { - return &SetShowDebugBordersParams{ - Show: show, +// frameID - Identifier of the frame to highlight. +func HighlightFrame(frameID cdp.FrameID) *HighlightFrameParams { + return &HighlightFrameParams{ + FrameID: frameID, } } -// Do executes Overlay.setShowDebugBorders against the provided context and -// target handler. -func (p *SetShowDebugBordersParams) Do(ctxt context.Context, h cdp.Handler) (err error) { - return h.Execute(ctxt, cdp.CommandOverlaySetShowDebugBorders, p, nil) -} - -// SetShowFPSCounterParams requests that backend shows the FPS counter. -type SetShowFPSCounterParams struct { - Show bool `json:"show"` // True for showing the FPS counter -} - -// SetShowFPSCounter requests that backend shows the FPS counter. -// -// parameters: -// show - True for showing the FPS counter -func SetShowFPSCounter(show bool) *SetShowFPSCounterParams { - return &SetShowFPSCounterParams{ - Show: show, - } -} - -// Do executes Overlay.setShowFPSCounter against the provided context and -// target handler. -func (p *SetShowFPSCounterParams) Do(ctxt context.Context, h cdp.Handler) (err error) { - return h.Execute(ctxt, cdp.CommandOverlaySetShowFPSCounter, p, nil) -} - -// SetShowScrollBottleneckRectsParams requests that backend shows scroll -// bottleneck rects. -type SetShowScrollBottleneckRectsParams struct { - Show bool `json:"show"` // True for showing scroll bottleneck rects -} - -// SetShowScrollBottleneckRects requests that backend shows scroll bottleneck -// rects. -// -// parameters: -// show - True for showing scroll bottleneck rects -func SetShowScrollBottleneckRects(show bool) *SetShowScrollBottleneckRectsParams { - return &SetShowScrollBottleneckRectsParams{ - Show: show, - } -} - -// Do executes Overlay.setShowScrollBottleneckRects against the provided context and -// target handler. -func (p *SetShowScrollBottleneckRectsParams) Do(ctxt context.Context, h cdp.Handler) (err error) { - return h.Execute(ctxt, cdp.CommandOverlaySetShowScrollBottleneckRects, p, nil) -} - -// SetShowViewportSizeOnResizeParams paints viewport size upon main frame -// resize. -type SetShowViewportSizeOnResizeParams struct { - Show bool `json:"show"` // Whether to paint size or not. -} - -// SetShowViewportSizeOnResize paints viewport size upon main frame resize. -// -// parameters: -// show - Whether to paint size or not. -func SetShowViewportSizeOnResize(show bool) *SetShowViewportSizeOnResizeParams { - return &SetShowViewportSizeOnResizeParams{ - Show: show, - } -} - -// Do executes Overlay.setShowViewportSizeOnResize against the provided context and -// target handler. -func (p *SetShowViewportSizeOnResizeParams) Do(ctxt context.Context, h cdp.Handler) (err error) { - return h.Execute(ctxt, cdp.CommandOverlaySetShowViewportSizeOnResize, p, nil) -} - -// SetPausedInDebuggerMessageParams [no description]. -type SetPausedInDebuggerMessageParams struct { - Message string `json:"message,omitempty"` // The message to display, also triggers resume and step over controls. -} - -// SetPausedInDebuggerMessage [no description]. -// -// parameters: -func SetPausedInDebuggerMessage() *SetPausedInDebuggerMessageParams { - return &SetPausedInDebuggerMessageParams{} -} - -// WithMessage the message to display, also triggers resume and step over -// controls. -func (p SetPausedInDebuggerMessageParams) WithMessage(message string) *SetPausedInDebuggerMessageParams { - p.Message = message +// WithContentColor the content box highlight fill color (default: +// transparent). +func (p HighlightFrameParams) WithContentColor(contentColor *cdp.RGBA) *HighlightFrameParams { + p.ContentColor = contentColor return &p } -// Do executes Overlay.setPausedInDebuggerMessage against the provided context and -// target handler. -func (p *SetPausedInDebuggerMessageParams) Do(ctxt context.Context, h cdp.Handler) (err error) { - return h.Execute(ctxt, cdp.CommandOverlaySetPausedInDebuggerMessage, p, nil) -} - -// SetSuspendedParams [no description]. -type SetSuspendedParams struct { - Suspended bool `json:"suspended"` // Whether overlay should be suspended and not consume any resources until resumed. -} - -// SetSuspended [no description]. -// -// parameters: -// suspended - Whether overlay should be suspended and not consume any resources until resumed. -func SetSuspended(suspended bool) *SetSuspendedParams { - return &SetSuspendedParams{ - Suspended: suspended, - } -} - -// Do executes Overlay.setSuspended against the provided context and -// target handler. -func (p *SetSuspendedParams) Do(ctxt context.Context, h cdp.Handler) (err error) { - return h.Execute(ctxt, cdp.CommandOverlaySetSuspended, p, nil) -} - -// SetInspectModeParams enters the 'inspect' mode. In this mode, elements -// that user is hovering over are highlighted. Backend then generates -// 'inspectNodeRequested' event upon element selection. -type SetInspectModeParams struct { - Mode InspectMode `json:"mode"` // Set an inspection mode. - HighlightConfig *HighlightConfig `json:"highlightConfig,omitempty"` // A descriptor for the highlight appearance of hovered-over nodes. May be omitted if enabled == false. -} - -// SetInspectMode enters the 'inspect' mode. In this mode, elements that user -// is hovering over are highlighted. Backend then generates -// 'inspectNodeRequested' event upon element selection. -// -// parameters: -// mode - Set an inspection mode. -func SetInspectMode(mode InspectMode) *SetInspectModeParams { - return &SetInspectModeParams{ - Mode: mode, - } -} - -// WithHighlightConfig a descriptor for the highlight appearance of -// hovered-over nodes. May be omitted if enabled == false. -func (p SetInspectModeParams) WithHighlightConfig(highlightConfig *HighlightConfig) *SetInspectModeParams { - p.HighlightConfig = highlightConfig +// WithContentOutlineColor the content box highlight outline color (default: +// transparent). +func (p HighlightFrameParams) WithContentOutlineColor(contentOutlineColor *cdp.RGBA) *HighlightFrameParams { + p.ContentOutlineColor = contentOutlineColor return &p } -// Do executes Overlay.setInspectMode against the provided context and +// Do executes Overlay.highlightFrame against the provided context and // target handler. -func (p *SetInspectModeParams) Do(ctxt context.Context, h cdp.Handler) (err error) { - return h.Execute(ctxt, cdp.CommandOverlaySetInspectMode, p, nil) +func (p *HighlightFrameParams) Do(ctxt context.Context, h cdp.Handler) (err error) { + return h.Execute(ctxt, cdp.CommandOverlayHighlightFrame, p, nil) +} + +// HighlightNodeParams highlights DOM node with given id or with the given +// JavaScript object wrapper. Either nodeId or objectId must be specified. +type HighlightNodeParams struct { + HighlightConfig *HighlightConfig `json:"highlightConfig"` // A descriptor for the highlight appearance. + NodeID cdp.NodeID `json:"nodeId,omitempty"` // Identifier of the node to highlight. + BackendNodeID cdp.BackendNodeID `json:"backendNodeId,omitempty"` // Identifier of the backend node to highlight. + ObjectID runtime.RemoteObjectID `json:"objectId,omitempty"` // JavaScript object id of the node to be highlighted. +} + +// HighlightNode highlights DOM node with given id or with the given +// JavaScript object wrapper. Either nodeId or objectId must be specified. +// +// parameters: +// highlightConfig - A descriptor for the highlight appearance. +func HighlightNode(highlightConfig *HighlightConfig) *HighlightNodeParams { + return &HighlightNodeParams{ + HighlightConfig: highlightConfig, + } +} + +// WithNodeID identifier of the node to highlight. +func (p HighlightNodeParams) WithNodeID(nodeID cdp.NodeID) *HighlightNodeParams { + p.NodeID = nodeID + return &p +} + +// WithBackendNodeID identifier of the backend node to highlight. +func (p HighlightNodeParams) WithBackendNodeID(backendNodeID cdp.BackendNodeID) *HighlightNodeParams { + p.BackendNodeID = backendNodeID + return &p +} + +// WithObjectID JavaScript object id of the node to be highlighted. +func (p HighlightNodeParams) WithObjectID(objectID runtime.RemoteObjectID) *HighlightNodeParams { + p.ObjectID = objectID + return &p +} + +// Do executes Overlay.highlightNode against the provided context and +// target handler. +func (p *HighlightNodeParams) Do(ctxt context.Context, h cdp.Handler) (err error) { + return h.Execute(ctxt, cdp.CommandOverlayHighlightNode, p, nil) +} + +// HighlightQuadParams highlights given quad. Coordinates are absolute with +// respect to the main frame viewport. +type HighlightQuadParams struct { + Quad dom.Quad `json:"quad"` // Quad to highlight + Color *cdp.RGBA `json:"color,omitempty"` // The highlight fill color (default: transparent). + OutlineColor *cdp.RGBA `json:"outlineColor,omitempty"` // The highlight outline color (default: transparent). +} + +// HighlightQuad highlights given quad. Coordinates are absolute with respect +// to the main frame viewport. +// +// parameters: +// quad - Quad to highlight +func HighlightQuad(quad dom.Quad) *HighlightQuadParams { + return &HighlightQuadParams{ + Quad: quad, + } +} + +// WithColor the highlight fill color (default: transparent). +func (p HighlightQuadParams) WithColor(color *cdp.RGBA) *HighlightQuadParams { + p.Color = color + return &p +} + +// WithOutlineColor the highlight outline color (default: transparent). +func (p HighlightQuadParams) WithOutlineColor(outlineColor *cdp.RGBA) *HighlightQuadParams { + p.OutlineColor = outlineColor + return &p +} + +// Do executes Overlay.highlightQuad against the provided context and +// target handler. +func (p *HighlightQuadParams) Do(ctxt context.Context, h cdp.Handler) (err error) { + return h.Execute(ctxt, cdp.CommandOverlayHighlightQuad, p, nil) } // HighlightRectParams highlights given rectangle. Coordinates are absolute @@ -280,170 +260,190 @@ func (p *HighlightRectParams) Do(ctxt context.Context, h cdp.Handler) (err error return h.Execute(ctxt, cdp.CommandOverlayHighlightRect, p, nil) } -// HighlightQuadParams highlights given quad. Coordinates are absolute with -// respect to the main frame viewport. -type HighlightQuadParams struct { - Quad dom.Quad `json:"quad"` // Quad to highlight - Color *cdp.RGBA `json:"color,omitempty"` // The highlight fill color (default: transparent). - OutlineColor *cdp.RGBA `json:"outlineColor,omitempty"` // The highlight outline color (default: transparent). +// SetInspectModeParams enters the 'inspect' mode. In this mode, elements +// that user is hovering over are highlighted. Backend then generates +// 'inspectNodeRequested' event upon element selection. +type SetInspectModeParams struct { + Mode InspectMode `json:"mode"` // Set an inspection mode. + HighlightConfig *HighlightConfig `json:"highlightConfig,omitempty"` // A descriptor for the highlight appearance of hovered-over nodes. May be omitted if enabled == false. } -// HighlightQuad highlights given quad. Coordinates are absolute with respect -// to the main frame viewport. +// SetInspectMode enters the 'inspect' mode. In this mode, elements that user +// is hovering over are highlighted. Backend then generates +// 'inspectNodeRequested' event upon element selection. // // parameters: -// quad - Quad to highlight -func HighlightQuad(quad dom.Quad) *HighlightQuadParams { - return &HighlightQuadParams{ - Quad: quad, +// mode - Set an inspection mode. +func SetInspectMode(mode InspectMode) *SetInspectModeParams { + return &SetInspectModeParams{ + Mode: mode, } } -// WithColor the highlight fill color (default: transparent). -func (p HighlightQuadParams) WithColor(color *cdp.RGBA) *HighlightQuadParams { - p.Color = color +// WithHighlightConfig a descriptor for the highlight appearance of +// hovered-over nodes. May be omitted if enabled == false. +func (p SetInspectModeParams) WithHighlightConfig(highlightConfig *HighlightConfig) *SetInspectModeParams { + p.HighlightConfig = highlightConfig return &p } -// WithOutlineColor the highlight outline color (default: transparent). -func (p HighlightQuadParams) WithOutlineColor(outlineColor *cdp.RGBA) *HighlightQuadParams { - p.OutlineColor = outlineColor - return &p -} - -// Do executes Overlay.highlightQuad against the provided context and +// Do executes Overlay.setInspectMode against the provided context and // target handler. -func (p *HighlightQuadParams) Do(ctxt context.Context, h cdp.Handler) (err error) { - return h.Execute(ctxt, cdp.CommandOverlayHighlightQuad, p, nil) +func (p *SetInspectModeParams) Do(ctxt context.Context, h cdp.Handler) (err error) { + return h.Execute(ctxt, cdp.CommandOverlaySetInspectMode, p, nil) } -// HighlightNodeParams highlights DOM node with given id or with the given -// JavaScript object wrapper. Either nodeId or objectId must be specified. -type HighlightNodeParams struct { - HighlightConfig *HighlightConfig `json:"highlightConfig"` // A descriptor for the highlight appearance. - NodeID cdp.NodeID `json:"nodeId,omitempty"` // Identifier of the node to highlight. - BackendNodeID cdp.BackendNodeID `json:"backendNodeId,omitempty"` // Identifier of the backend node to highlight. - ObjectID runtime.RemoteObjectID `json:"objectId,omitempty"` // JavaScript object id of the node to be highlighted. +// SetPausedInDebuggerMessageParams [no description]. +type SetPausedInDebuggerMessageParams struct { + Message string `json:"message,omitempty"` // The message to display, also triggers resume and step over controls. } -// HighlightNode highlights DOM node with given id or with the given -// JavaScript object wrapper. Either nodeId or objectId must be specified. +// SetPausedInDebuggerMessage [no description]. // // parameters: -// highlightConfig - A descriptor for the highlight appearance. -func HighlightNode(highlightConfig *HighlightConfig) *HighlightNodeParams { - return &HighlightNodeParams{ - HighlightConfig: highlightConfig, - } +func SetPausedInDebuggerMessage() *SetPausedInDebuggerMessageParams { + return &SetPausedInDebuggerMessageParams{} } -// WithNodeID identifier of the node to highlight. -func (p HighlightNodeParams) WithNodeID(nodeID cdp.NodeID) *HighlightNodeParams { - p.NodeID = nodeID +// WithMessage the message to display, also triggers resume and step over +// controls. +func (p SetPausedInDebuggerMessageParams) WithMessage(message string) *SetPausedInDebuggerMessageParams { + p.Message = message return &p } -// WithBackendNodeID identifier of the backend node to highlight. -func (p HighlightNodeParams) WithBackendNodeID(backendNodeID cdp.BackendNodeID) *HighlightNodeParams { - p.BackendNodeID = backendNodeID - return &p -} - -// WithObjectID JavaScript object id of the node to be highlighted. -func (p HighlightNodeParams) WithObjectID(objectID runtime.RemoteObjectID) *HighlightNodeParams { - p.ObjectID = objectID - return &p -} - -// Do executes Overlay.highlightNode against the provided context and +// Do executes Overlay.setPausedInDebuggerMessage against the provided context and // target handler. -func (p *HighlightNodeParams) Do(ctxt context.Context, h cdp.Handler) (err error) { - return h.Execute(ctxt, cdp.CommandOverlayHighlightNode, p, nil) +func (p *SetPausedInDebuggerMessageParams) Do(ctxt context.Context, h cdp.Handler) (err error) { + return h.Execute(ctxt, cdp.CommandOverlaySetPausedInDebuggerMessage, p, nil) } -// HighlightFrameParams highlights owner element of the frame with given id. -type HighlightFrameParams struct { - FrameID cdp.FrameID `json:"frameId"` // Identifier of the frame to highlight. - ContentColor *cdp.RGBA `json:"contentColor,omitempty"` // The content box highlight fill color (default: transparent). - ContentOutlineColor *cdp.RGBA `json:"contentOutlineColor,omitempty"` // The content box highlight outline color (default: transparent). +// SetShowDebugBordersParams requests that backend shows debug borders on +// layers. +type SetShowDebugBordersParams struct { + Show bool `json:"show"` // True for showing debug borders } -// HighlightFrame highlights owner element of the frame with given id. +// SetShowDebugBorders requests that backend shows debug borders on layers. // // parameters: -// frameID - Identifier of the frame to highlight. -func HighlightFrame(frameID cdp.FrameID) *HighlightFrameParams { - return &HighlightFrameParams{ - FrameID: frameID, +// show - True for showing debug borders +func SetShowDebugBorders(show bool) *SetShowDebugBordersParams { + return &SetShowDebugBordersParams{ + Show: show, } } -// WithContentColor the content box highlight fill color (default: -// transparent). -func (p HighlightFrameParams) WithContentColor(contentColor *cdp.RGBA) *HighlightFrameParams { - p.ContentColor = contentColor - return &p -} - -// WithContentOutlineColor the content box highlight outline color (default: -// transparent). -func (p HighlightFrameParams) WithContentOutlineColor(contentOutlineColor *cdp.RGBA) *HighlightFrameParams { - p.ContentOutlineColor = contentOutlineColor - return &p -} - -// Do executes Overlay.highlightFrame against the provided context and +// Do executes Overlay.setShowDebugBorders against the provided context and // target handler. -func (p *HighlightFrameParams) Do(ctxt context.Context, h cdp.Handler) (err error) { - return h.Execute(ctxt, cdp.CommandOverlayHighlightFrame, p, nil) +func (p *SetShowDebugBordersParams) Do(ctxt context.Context, h cdp.Handler) (err error) { + return h.Execute(ctxt, cdp.CommandOverlaySetShowDebugBorders, p, nil) } -// HideHighlightParams hides any highlight. -type HideHighlightParams struct{} - -// HideHighlight hides any highlight. -func HideHighlight() *HideHighlightParams { - return &HideHighlightParams{} +// SetShowFPSCounterParams requests that backend shows the FPS counter. +type SetShowFPSCounterParams struct { + Show bool `json:"show"` // True for showing the FPS counter } -// Do executes Overlay.hideHighlight against the provided context and -// target handler. -func (p *HideHighlightParams) Do(ctxt context.Context, h cdp.Handler) (err error) { - return h.Execute(ctxt, cdp.CommandOverlayHideHighlight, nil, nil) -} - -// GetHighlightObjectForTestParams for testing. -type GetHighlightObjectForTestParams struct { - NodeID cdp.NodeID `json:"nodeId"` // Id of the node to get highlight object for. -} - -// GetHighlightObjectForTest for testing. +// SetShowFPSCounter requests that backend shows the FPS counter. // // parameters: -// nodeID - Id of the node to get highlight object for. -func GetHighlightObjectForTest(nodeID cdp.NodeID) *GetHighlightObjectForTestParams { - return &GetHighlightObjectForTestParams{ - NodeID: nodeID, +// show - True for showing the FPS counter +func SetShowFPSCounter(show bool) *SetShowFPSCounterParams { + return &SetShowFPSCounterParams{ + Show: show, } } -// GetHighlightObjectForTestReturns return values. -type GetHighlightObjectForTestReturns struct { - Highlight easyjson.RawMessage `json:"highlight,omitempty"` -} - -// Do executes Overlay.getHighlightObjectForTest against the provided context and +// Do executes Overlay.setShowFPSCounter against the provided context and // target handler. -// -// returns: -// highlight - Highlight data for the node. -func (p *GetHighlightObjectForTestParams) Do(ctxt context.Context, h cdp.Handler) (highlight easyjson.RawMessage, err error) { - // execute - var res GetHighlightObjectForTestReturns - err = h.Execute(ctxt, cdp.CommandOverlayGetHighlightObjectForTest, p, &res) - if err != nil { - return nil, err - } - - return res.Highlight, nil +func (p *SetShowFPSCounterParams) Do(ctxt context.Context, h cdp.Handler) (err error) { + return h.Execute(ctxt, cdp.CommandOverlaySetShowFPSCounter, p, nil) +} + +// SetShowPaintRectsParams requests that backend shows paint rectangles. +type SetShowPaintRectsParams struct { + Result bool `json:"result"` // True for showing paint rectangles +} + +// SetShowPaintRects requests that backend shows paint rectangles. +// +// parameters: +// result - True for showing paint rectangles +func SetShowPaintRects(result bool) *SetShowPaintRectsParams { + return &SetShowPaintRectsParams{ + Result: result, + } +} + +// Do executes Overlay.setShowPaintRects against the provided context and +// target handler. +func (p *SetShowPaintRectsParams) Do(ctxt context.Context, h cdp.Handler) (err error) { + return h.Execute(ctxt, cdp.CommandOverlaySetShowPaintRects, p, nil) +} + +// SetShowScrollBottleneckRectsParams requests that backend shows scroll +// bottleneck rects. +type SetShowScrollBottleneckRectsParams struct { + Show bool `json:"show"` // True for showing scroll bottleneck rects +} + +// SetShowScrollBottleneckRects requests that backend shows scroll bottleneck +// rects. +// +// parameters: +// show - True for showing scroll bottleneck rects +func SetShowScrollBottleneckRects(show bool) *SetShowScrollBottleneckRectsParams { + return &SetShowScrollBottleneckRectsParams{ + Show: show, + } +} + +// Do executes Overlay.setShowScrollBottleneckRects against the provided context and +// target handler. +func (p *SetShowScrollBottleneckRectsParams) Do(ctxt context.Context, h cdp.Handler) (err error) { + return h.Execute(ctxt, cdp.CommandOverlaySetShowScrollBottleneckRects, p, nil) +} + +// SetShowViewportSizeOnResizeParams paints viewport size upon main frame +// resize. +type SetShowViewportSizeOnResizeParams struct { + Show bool `json:"show"` // Whether to paint size or not. +} + +// SetShowViewportSizeOnResize paints viewport size upon main frame resize. +// +// parameters: +// show - Whether to paint size or not. +func SetShowViewportSizeOnResize(show bool) *SetShowViewportSizeOnResizeParams { + return &SetShowViewportSizeOnResizeParams{ + Show: show, + } +} + +// Do executes Overlay.setShowViewportSizeOnResize against the provided context and +// target handler. +func (p *SetShowViewportSizeOnResizeParams) Do(ctxt context.Context, h cdp.Handler) (err error) { + return h.Execute(ctxt, cdp.CommandOverlaySetShowViewportSizeOnResize, p, nil) +} + +// SetSuspendedParams [no description]. +type SetSuspendedParams struct { + Suspended bool `json:"suspended"` // Whether overlay should be suspended and not consume any resources until resumed. +} + +// SetSuspended [no description]. +// +// parameters: +// suspended - Whether overlay should be suspended and not consume any resources until resumed. +func SetSuspended(suspended bool) *SetSuspendedParams { + return &SetSuspendedParams{ + Suspended: suspended, + } +} + +// Do executes Overlay.setSuspended against the provided context and +// target handler. +func (p *SetSuspendedParams) Do(ctxt context.Context, h cdp.Handler) (err error) { + return h.Execute(ctxt, cdp.CommandOverlaySetSuspended, p, nil) } diff --git a/cdp/page/easyjson.go b/cdp/page/easyjson.go index 3201d68..b21fd0b 100644 --- a/cdp/page/easyjson.go +++ b/cdp/page/easyjson.go @@ -1680,6 +1680,10 @@ func easyjsonC5a4559bDecodeGithubComKnqChromedpCdpPage18(in *jlexer.Lexer, out * out.PageRanges = string(in.String()) case "ignoreInvalidPageRanges": out.IgnoreInvalidPageRanges = bool(in.Bool()) + case "headerTemplate": + out.HeaderTemplate = string(in.String()) + case "footerTemplate": + out.FooterTemplate = string(in.String()) default: in.SkipRecursive() } @@ -1814,6 +1818,26 @@ func easyjsonC5a4559bEncodeGithubComKnqChromedpCdpPage18(out *jwriter.Writer, in } out.Bool(bool(in.IgnoreInvalidPageRanges)) } + if in.HeaderTemplate != "" { + const prefix string = ",\"headerTemplate\":" + if first { + first = false + out.RawString(prefix[1:]) + } else { + out.RawString(prefix) + } + out.String(string(in.HeaderTemplate)) + } + if in.FooterTemplate != "" { + const prefix string = ",\"footerTemplate\":" + if first { + first = false + out.RawString(prefix[1:]) + } else { + out.RawString(prefix) + } + out.String(string(in.FooterTemplate)) + } out.RawByte('}') } diff --git a/cdp/page/events.go b/cdp/page/events.go index 12429b5..8b28c9e 100644 --- a/cdp/page/events.go +++ b/cdp/page/events.go @@ -12,20 +12,6 @@ type EventDomContentEventFired struct { Timestamp *cdp.MonotonicTime `json:"timestamp"` } -// EventLoadEventFired [no description]. -type EventLoadEventFired struct { - Timestamp *cdp.MonotonicTime `json:"timestamp"` -} - -// EventLifecycleEvent fired for top level page lifecycle events such as -// navigation, load, paint, etc. -type EventLifecycleEvent struct { - FrameID cdp.FrameID `json:"frameId"` // Id of the frame. - LoaderID cdp.LoaderID `json:"loaderId"` // Loader identifier. Empty string if the request is fetched from worker. - Name string `json:"name"` - Timestamp *cdp.MonotonicTime `json:"timestamp"` -} - // EventFrameAttached fired when frame has been attached to its parent. type EventFrameAttached struct { FrameID cdp.FrameID `json:"frameId"` // Id of the frame that has been attached. @@ -33,15 +19,33 @@ type EventFrameAttached struct { Stack *runtime.StackTrace `json:"stack,omitempty"` // JavaScript stack trace of when frame was attached, only set if frame initiated from script. } +// EventFrameClearedScheduledNavigation fired when frame no longer has a +// scheduled navigation. +type EventFrameClearedScheduledNavigation struct { + FrameID cdp.FrameID `json:"frameId"` // Id of the frame that has cleared its scheduled navigation. +} + +// EventFrameDetached fired when frame has been detached from its parent. +type EventFrameDetached struct { + FrameID cdp.FrameID `json:"frameId"` // Id of the frame that has been detached. +} + // EventFrameNavigated fired once navigation of the frame has completed. // Frame is now associated with the new loader. type EventFrameNavigated struct { Frame *cdp.Frame `json:"frame"` // Frame object. } -// EventFrameDetached fired when frame has been detached from its parent. -type EventFrameDetached struct { - FrameID cdp.FrameID `json:"frameId"` // Id of the frame that has been detached. +// EventFrameResized [no description]. +type EventFrameResized struct{} + +// EventFrameScheduledNavigation fired when frame schedules a potential +// navigation. +type EventFrameScheduledNavigation struct { + FrameID cdp.FrameID `json:"frameId"` // Id of the frame that has scheduled a navigation. + Delay float64 `json:"delay"` // Delay (in seconds) until the navigation is scheduled to begin. The navigation is not guaranteed to start. + Reason FrameScheduledNavigationReason `json:"reason"` // The reason for the navigation. + URL string `json:"url"` // The destination URL for the scheduled navigation. } // EventFrameStartedLoading fired when frame has started loading. @@ -54,23 +58,18 @@ type EventFrameStoppedLoading struct { FrameID cdp.FrameID `json:"frameId"` // Id of the frame that has stopped loading. } -// EventFrameScheduledNavigation fired when frame schedules a potential -// navigation. -type EventFrameScheduledNavigation struct { - FrameID cdp.FrameID `json:"frameId"` // Id of the frame that has scheduled a navigation. - Delay float64 `json:"delay"` // Delay (in seconds) until the navigation is scheduled to begin. The navigation is not guaranteed to start. - Reason FrameScheduledNavigationReason `json:"reason"` // The reason for the navigation. - URL string `json:"url"` // The destination URL for the scheduled navigation. -} +// EventInterstitialHidden fired when interstitial page was hidden. +type EventInterstitialHidden struct{} -// EventFrameClearedScheduledNavigation fired when frame no longer has a -// scheduled navigation. -type EventFrameClearedScheduledNavigation struct { - FrameID cdp.FrameID `json:"frameId"` // Id of the frame that has cleared its scheduled navigation. -} +// EventInterstitialShown fired when interstitial page was shown. +type EventInterstitialShown struct{} -// EventFrameResized [no description]. -type EventFrameResized struct{} +// EventJavascriptDialogClosed fired when a JavaScript initiated dialog +// (alert, confirm, prompt, or onbeforeunload) has been closed. +type EventJavascriptDialogClosed struct { + Result bool `json:"result"` // Whether dialog was confirmed. + UserInput string `json:"userInput"` // User input in case of prompt. +} // EventJavascriptDialogOpening fired when a JavaScript initiated dialog // (alert, confirm, prompt, or onbeforeunload) is about to open. @@ -81,11 +80,18 @@ type EventJavascriptDialogOpening struct { DefaultPrompt string `json:"defaultPrompt,omitempty"` // Default dialog prompt. } -// EventJavascriptDialogClosed fired when a JavaScript initiated dialog -// (alert, confirm, prompt, or onbeforeunload) has been closed. -type EventJavascriptDialogClosed struct { - Result bool `json:"result"` // Whether dialog was confirmed. - UserInput string `json:"userInput"` // User input in case of prompt. +// EventLifecycleEvent fired for top level page lifecycle events such as +// navigation, load, paint, etc. +type EventLifecycleEvent struct { + FrameID cdp.FrameID `json:"frameId"` // Id of the frame. + LoaderID cdp.LoaderID `json:"loaderId"` // Loader identifier. Empty string if the request is fetched from worker. + Name string `json:"name"` + Timestamp *cdp.MonotonicTime `json:"timestamp"` +} + +// EventLoadEventFired [no description]. +type EventLoadEventFired struct { + Timestamp *cdp.MonotonicTime `json:"timestamp"` } // EventScreencastFrame compressed image data requested by the @@ -102,12 +108,6 @@ type EventScreencastVisibilityChanged struct { Visible bool `json:"visible"` // True if the page is visible. } -// EventInterstitialShown fired when interstitial page was shown. -type EventInterstitialShown struct{} - -// EventInterstitialHidden fired when interstitial page was hidden. -type EventInterstitialHidden struct{} - // EventWindowOpen fired when a new window is going to be opened, via // window.open(), link click, form submission, etc. type EventWindowOpen struct { @@ -120,21 +120,21 @@ type EventWindowOpen struct { // EventTypes all event types in the domain. var EventTypes = []cdp.MethodType{ cdp.EventPageDomContentEventFired, - cdp.EventPageLoadEventFired, - cdp.EventPageLifecycleEvent, cdp.EventPageFrameAttached, - cdp.EventPageFrameNavigated, + cdp.EventPageFrameClearedScheduledNavigation, cdp.EventPageFrameDetached, + cdp.EventPageFrameNavigated, + cdp.EventPageFrameResized, + cdp.EventPageFrameScheduledNavigation, cdp.EventPageFrameStartedLoading, cdp.EventPageFrameStoppedLoading, - cdp.EventPageFrameScheduledNavigation, - cdp.EventPageFrameClearedScheduledNavigation, - cdp.EventPageFrameResized, - cdp.EventPageJavascriptDialogOpening, + cdp.EventPageInterstitialHidden, + cdp.EventPageInterstitialShown, cdp.EventPageJavascriptDialogClosed, + cdp.EventPageJavascriptDialogOpening, + cdp.EventPageLifecycleEvent, + cdp.EventPageLoadEventFired, cdp.EventPageScreencastFrame, cdp.EventPageScreencastVisibilityChanged, - cdp.EventPageInterstitialShown, - cdp.EventPageInterstitialHidden, cdp.EventPageWindowOpen, } diff --git a/cdp/page/page.go b/cdp/page/page.go index 96ddb2a..eb5e6b1 100644 --- a/cdp/page/page.go +++ b/cdp/page/page.go @@ -19,34 +19,6 @@ import ( "github.com/knq/chromedp/cdp/runtime" ) -// EnableParams enables page domain notifications. -type EnableParams struct{} - -// Enable enables page domain notifications. -func Enable() *EnableParams { - return &EnableParams{} -} - -// Do executes Page.enable against the provided context and -// target handler. -func (p *EnableParams) Do(ctxt context.Context, h cdp.Handler) (err error) { - return h.Execute(ctxt, cdp.CommandPageEnable, nil, nil) -} - -// DisableParams disables page domain notifications. -type DisableParams struct{} - -// Disable disables page domain notifications. -func Disable() *DisableParams { - return &DisableParams{} -} - -// Do executes Page.disable against the provided context and -// target handler. -func (p *DisableParams) Do(ctxt context.Context, h cdp.Handler) (err error) { - return h.Execute(ctxt, cdp.CommandPageDisable, nil, nil) -} - // AddScriptToEvaluateOnNewDocumentParams evaluates given script in every // frame upon creation (before loading frame's scripts). type AddScriptToEvaluateOnNewDocumentParams struct { @@ -85,439 +57,18 @@ func (p *AddScriptToEvaluateOnNewDocumentParams) Do(ctxt context.Context, h cdp. return res.Identifier, nil } -// RemoveScriptToEvaluateOnNewDocumentParams removes given script from the -// list. -type RemoveScriptToEvaluateOnNewDocumentParams struct { - Identifier ScriptIdentifier `json:"identifier"` +// BringToFrontParams brings page to front (activates tab). +type BringToFrontParams struct{} + +// BringToFront brings page to front (activates tab). +func BringToFront() *BringToFrontParams { + return &BringToFrontParams{} } -// RemoveScriptToEvaluateOnNewDocument removes given script from the list. -// -// parameters: -// identifier -func RemoveScriptToEvaluateOnNewDocument(identifier ScriptIdentifier) *RemoveScriptToEvaluateOnNewDocumentParams { - return &RemoveScriptToEvaluateOnNewDocumentParams{ - Identifier: identifier, - } -} - -// Do executes Page.removeScriptToEvaluateOnNewDocument against the provided context and +// Do executes Page.bringToFront against the provided context and // target handler. -func (p *RemoveScriptToEvaluateOnNewDocumentParams) Do(ctxt context.Context, h cdp.Handler) (err error) { - return h.Execute(ctxt, cdp.CommandPageRemoveScriptToEvaluateOnNewDocument, p, nil) -} - -// SetAutoAttachToCreatedPagesParams controls whether browser will open a new -// inspector window for connected pages. -type SetAutoAttachToCreatedPagesParams struct { - AutoAttach bool `json:"autoAttach"` // If true, browser will open a new inspector window for every page created from this one. -} - -// SetAutoAttachToCreatedPages controls whether browser will open a new -// inspector window for connected pages. -// -// parameters: -// autoAttach - If true, browser will open a new inspector window for every page created from this one. -func SetAutoAttachToCreatedPages(autoAttach bool) *SetAutoAttachToCreatedPagesParams { - return &SetAutoAttachToCreatedPagesParams{ - AutoAttach: autoAttach, - } -} - -// Do executes Page.setAutoAttachToCreatedPages against the provided context and -// target handler. -func (p *SetAutoAttachToCreatedPagesParams) Do(ctxt context.Context, h cdp.Handler) (err error) { - return h.Execute(ctxt, cdp.CommandPageSetAutoAttachToCreatedPages, p, nil) -} - -// SetLifecycleEventsEnabledParams controls whether page will emit lifecycle -// events. -type SetLifecycleEventsEnabledParams struct { - Enabled bool `json:"enabled"` // If true, starts emitting lifecycle events. -} - -// SetLifecycleEventsEnabled controls whether page will emit lifecycle -// events. -// -// parameters: -// enabled - If true, starts emitting lifecycle events. -func SetLifecycleEventsEnabled(enabled bool) *SetLifecycleEventsEnabledParams { - return &SetLifecycleEventsEnabledParams{ - Enabled: enabled, - } -} - -// Do executes Page.setLifecycleEventsEnabled against the provided context and -// target handler. -func (p *SetLifecycleEventsEnabledParams) Do(ctxt context.Context, h cdp.Handler) (err error) { - return h.Execute(ctxt, cdp.CommandPageSetLifecycleEventsEnabled, p, nil) -} - -// ReloadParams reloads given page optionally ignoring the cache. -type ReloadParams struct { - IgnoreCache bool `json:"ignoreCache,omitempty"` // If true, browser cache is ignored (as if the user pressed Shift+refresh). - ScriptToEvaluateOnLoad string `json:"scriptToEvaluateOnLoad,omitempty"` // If set, the script will be injected into all frames of the inspected page after reload. -} - -// Reload reloads given page optionally ignoring the cache. -// -// parameters: -func Reload() *ReloadParams { - return &ReloadParams{} -} - -// WithIgnoreCache if true, browser cache is ignored (as if the user pressed -// Shift+refresh). -func (p ReloadParams) WithIgnoreCache(ignoreCache bool) *ReloadParams { - p.IgnoreCache = ignoreCache - return &p -} - -// WithScriptToEvaluateOnLoad if set, the script will be injected into all -// frames of the inspected page after reload. -func (p ReloadParams) WithScriptToEvaluateOnLoad(scriptToEvaluateOnLoad string) *ReloadParams { - p.ScriptToEvaluateOnLoad = scriptToEvaluateOnLoad - return &p -} - -// Do executes Page.reload against the provided context and -// target handler. -func (p *ReloadParams) Do(ctxt context.Context, h cdp.Handler) (err error) { - return h.Execute(ctxt, cdp.CommandPageReload, p, nil) -} - -// SetAdBlockingEnabledParams enable Chrome's experimental ad filter on all -// sites. -type SetAdBlockingEnabledParams struct { - Enabled bool `json:"enabled"` // Whether to block ads. -} - -// SetAdBlockingEnabled enable Chrome's experimental ad filter on all sites. -// -// parameters: -// enabled - Whether to block ads. -func SetAdBlockingEnabled(enabled bool) *SetAdBlockingEnabledParams { - return &SetAdBlockingEnabledParams{ - Enabled: enabled, - } -} - -// Do executes Page.setAdBlockingEnabled against the provided context and -// target handler. -func (p *SetAdBlockingEnabledParams) Do(ctxt context.Context, h cdp.Handler) (err error) { - return h.Execute(ctxt, cdp.CommandPageSetAdBlockingEnabled, p, nil) -} - -// NavigateParams navigates current page to the given URL. -type NavigateParams struct { - URL string `json:"url"` // URL to navigate the page to. - Referrer string `json:"referrer,omitempty"` // Referrer URL. - TransitionType TransitionType `json:"transitionType,omitempty"` // Intended transition type. -} - -// Navigate navigates current page to the given URL. -// -// parameters: -// url - URL to navigate the page to. -func Navigate(url string) *NavigateParams { - return &NavigateParams{ - URL: url, - } -} - -// WithReferrer referrer URL. -func (p NavigateParams) WithReferrer(referrer string) *NavigateParams { - p.Referrer = referrer - return &p -} - -// WithTransitionType intended transition type. -func (p NavigateParams) WithTransitionType(transitionType TransitionType) *NavigateParams { - p.TransitionType = transitionType - return &p -} - -// NavigateReturns return values. -type NavigateReturns struct { - FrameID cdp.FrameID `json:"frameId,omitempty"` // Frame id that has navigated (or failed to navigate) - LoaderID cdp.LoaderID `json:"loaderId,omitempty"` // Loader identifier. - ErrorText string `json:"errorText,omitempty"` // User friendly error message, present if and only if navigation has failed. -} - -// Do executes Page.navigate against the provided context and -// target handler. -// -// returns: -// frameID - Frame id that has navigated (or failed to navigate) -// loaderID - Loader identifier. -// errorText - User friendly error message, present if and only if navigation has failed. -func (p *NavigateParams) Do(ctxt context.Context, h cdp.Handler) (frameID cdp.FrameID, loaderID cdp.LoaderID, errorText string, err error) { - // execute - var res NavigateReturns - err = h.Execute(ctxt, cdp.CommandPageNavigate, p, &res) - if err != nil { - return "", "", "", err - } - - return res.FrameID, res.LoaderID, res.ErrorText, nil -} - -// StopLoadingParams force the page stop all navigations and pending resource -// fetches. -type StopLoadingParams struct{} - -// StopLoading force the page stop all navigations and pending resource -// fetches. -func StopLoading() *StopLoadingParams { - return &StopLoadingParams{} -} - -// Do executes Page.stopLoading against the provided context and -// target handler. -func (p *StopLoadingParams) Do(ctxt context.Context, h cdp.Handler) (err error) { - return h.Execute(ctxt, cdp.CommandPageStopLoading, nil, nil) -} - -// GetNavigationHistoryParams returns navigation history for the current -// page. -type GetNavigationHistoryParams struct{} - -// GetNavigationHistory returns navigation history for the current page. -func GetNavigationHistory() *GetNavigationHistoryParams { - return &GetNavigationHistoryParams{} -} - -// GetNavigationHistoryReturns return values. -type GetNavigationHistoryReturns struct { - CurrentIndex int64 `json:"currentIndex,omitempty"` // Index of the current navigation history entry. - Entries []*NavigationEntry `json:"entries,omitempty"` // Array of navigation history entries. -} - -// Do executes Page.getNavigationHistory against the provided context and -// target handler. -// -// returns: -// currentIndex - Index of the current navigation history entry. -// entries - Array of navigation history entries. -func (p *GetNavigationHistoryParams) Do(ctxt context.Context, h cdp.Handler) (currentIndex int64, entries []*NavigationEntry, err error) { - // execute - var res GetNavigationHistoryReturns - err = h.Execute(ctxt, cdp.CommandPageGetNavigationHistory, nil, &res) - if err != nil { - return 0, nil, err - } - - return res.CurrentIndex, res.Entries, nil -} - -// NavigateToHistoryEntryParams navigates current page to the given history -// entry. -type NavigateToHistoryEntryParams struct { - EntryID int64 `json:"entryId"` // Unique id of the entry to navigate to. -} - -// NavigateToHistoryEntry navigates current page to the given history entry. -// -// parameters: -// entryID - Unique id of the entry to navigate to. -func NavigateToHistoryEntry(entryID int64) *NavigateToHistoryEntryParams { - return &NavigateToHistoryEntryParams{ - EntryID: entryID, - } -} - -// Do executes Page.navigateToHistoryEntry against the provided context and -// target handler. -func (p *NavigateToHistoryEntryParams) Do(ctxt context.Context, h cdp.Handler) (err error) { - return h.Execute(ctxt, cdp.CommandPageNavigateToHistoryEntry, p, nil) -} - -// GetResourceTreeParams returns present frame / resource tree structure. -type GetResourceTreeParams struct{} - -// GetResourceTree returns present frame / resource tree structure. -func GetResourceTree() *GetResourceTreeParams { - return &GetResourceTreeParams{} -} - -// GetResourceTreeReturns return values. -type GetResourceTreeReturns struct { - FrameTree *FrameResourceTree `json:"frameTree,omitempty"` // Present frame / resource tree structure. -} - -// Do executes Page.getResourceTree against the provided context and -// target handler. -// -// returns: -// frameTree - Present frame / resource tree structure. -func (p *GetResourceTreeParams) Do(ctxt context.Context, h cdp.Handler) (frameTree *FrameResourceTree, err error) { - // execute - var res GetResourceTreeReturns - err = h.Execute(ctxt, cdp.CommandPageGetResourceTree, nil, &res) - if err != nil { - return nil, err - } - - return res.FrameTree, nil -} - -// GetFrameTreeParams returns present frame tree structure. -type GetFrameTreeParams struct{} - -// GetFrameTree returns present frame tree structure. -func GetFrameTree() *GetFrameTreeParams { - return &GetFrameTreeParams{} -} - -// GetFrameTreeReturns return values. -type GetFrameTreeReturns struct { - FrameTree *FrameTree `json:"frameTree,omitempty"` // Present frame tree structure. -} - -// Do executes Page.getFrameTree against the provided context and -// target handler. -// -// returns: -// frameTree - Present frame tree structure. -func (p *GetFrameTreeParams) Do(ctxt context.Context, h cdp.Handler) (frameTree *FrameTree, err error) { - // execute - var res GetFrameTreeReturns - err = h.Execute(ctxt, cdp.CommandPageGetFrameTree, nil, &res) - if err != nil { - return nil, err - } - - return res.FrameTree, nil -} - -// GetResourceContentParams returns content of the given resource. -type GetResourceContentParams struct { - FrameID cdp.FrameID `json:"frameId"` // Frame id to get resource for. - URL string `json:"url"` // URL of the resource to get content for. -} - -// GetResourceContent returns content of the given resource. -// -// parameters: -// frameID - Frame id to get resource for. -// url - URL of the resource to get content for. -func GetResourceContent(frameID cdp.FrameID, url string) *GetResourceContentParams { - return &GetResourceContentParams{ - FrameID: frameID, - URL: url, - } -} - -// GetResourceContentReturns return values. -type GetResourceContentReturns struct { - Content string `json:"content,omitempty"` // Resource content. - Base64encoded bool `json:"base64Encoded,omitempty"` // True, if content was served as base64. -} - -// Do executes Page.getResourceContent against the provided context and -// target handler. -// -// returns: -// content - Resource content. -func (p *GetResourceContentParams) Do(ctxt context.Context, h cdp.Handler) (content []byte, err error) { - // execute - var res GetResourceContentReturns - err = h.Execute(ctxt, cdp.CommandPageGetResourceContent, p, &res) - if err != nil { - return nil, err - } - - // decode - var dec []byte - if res.Base64encoded { - dec, err = base64.StdEncoding.DecodeString(res.Content) - if err != nil { - return nil, err - } - } else { - dec = []byte(res.Content) - } - return dec, nil -} - -// SearchInResourceParams searches for given string in resource content. -type SearchInResourceParams struct { - FrameID cdp.FrameID `json:"frameId"` // Frame id for resource to search in. - URL string `json:"url"` // URL of the resource to search in. - Query string `json:"query"` // String to search for. - CaseSensitive bool `json:"caseSensitive,omitempty"` // If true, search is case sensitive. - IsRegex bool `json:"isRegex,omitempty"` // If true, treats string parameter as regex. -} - -// SearchInResource searches for given string in resource content. -// -// parameters: -// frameID - Frame id for resource to search in. -// url - URL of the resource to search in. -// query - String to search for. -func SearchInResource(frameID cdp.FrameID, url string, query string) *SearchInResourceParams { - return &SearchInResourceParams{ - FrameID: frameID, - URL: url, - Query: query, - } -} - -// WithCaseSensitive if true, search is case sensitive. -func (p SearchInResourceParams) WithCaseSensitive(caseSensitive bool) *SearchInResourceParams { - p.CaseSensitive = caseSensitive - return &p -} - -// WithIsRegex if true, treats string parameter as regex. -func (p SearchInResourceParams) WithIsRegex(isRegex bool) *SearchInResourceParams { - p.IsRegex = isRegex - return &p -} - -// SearchInResourceReturns return values. -type SearchInResourceReturns struct { - Result []*debugger.SearchMatch `json:"result,omitempty"` // List of search matches. -} - -// Do executes Page.searchInResource against the provided context and -// target handler. -// -// returns: -// result - List of search matches. -func (p *SearchInResourceParams) Do(ctxt context.Context, h cdp.Handler) (result []*debugger.SearchMatch, err error) { - // execute - var res SearchInResourceReturns - err = h.Execute(ctxt, cdp.CommandPageSearchInResource, p, &res) - if err != nil { - return nil, err - } - - return res.Result, nil -} - -// SetDocumentContentParams sets given markup as the document's HTML. -type SetDocumentContentParams struct { - FrameID cdp.FrameID `json:"frameId"` // Frame id to set HTML for. - HTML string `json:"html"` // HTML content to set. -} - -// SetDocumentContent sets given markup as the document's HTML. -// -// parameters: -// frameID - Frame id to set HTML for. -// html - HTML content to set. -func SetDocumentContent(frameID cdp.FrameID, html string) *SetDocumentContentParams { - return &SetDocumentContentParams{ - FrameID: frameID, - HTML: html, - } -} - -// Do executes Page.setDocumentContent against the provided context and -// target handler. -func (p *SetDocumentContentParams) Do(ctxt context.Context, h cdp.Handler) (err error) { - return h.Execute(ctxt, cdp.CommandPageSetDocumentContent, p, nil) +func (p *BringToFrontParams) Do(ctxt context.Context, h cdp.Handler) (err error) { + return h.Execute(ctxt, cdp.CommandPageBringToFront, nil, nil) } // CaptureScreenshotParams capture page screenshot. @@ -587,6 +138,400 @@ func (p *CaptureScreenshotParams) Do(ctxt context.Context, h cdp.Handler) (data return dec, nil } +// CreateIsolatedWorldParams creates an isolated world for the given frame. +type CreateIsolatedWorldParams struct { + FrameID cdp.FrameID `json:"frameId"` // Id of the frame in which the isolated world should be created. + WorldName string `json:"worldName,omitempty"` // An optional name which is reported in the Execution Context. + GrantUniveralAccess bool `json:"grantUniveralAccess,omitempty"` // Whether or not universal access should be granted to the isolated world. This is a powerful option, use with caution. +} + +// CreateIsolatedWorld creates an isolated world for the given frame. +// +// parameters: +// frameID - Id of the frame in which the isolated world should be created. +func CreateIsolatedWorld(frameID cdp.FrameID) *CreateIsolatedWorldParams { + return &CreateIsolatedWorldParams{ + FrameID: frameID, + } +} + +// WithWorldName an optional name which is reported in the Execution Context. +func (p CreateIsolatedWorldParams) WithWorldName(worldName string) *CreateIsolatedWorldParams { + p.WorldName = worldName + return &p +} + +// WithGrantUniveralAccess whether or not universal access should be granted +// to the isolated world. This is a powerful option, use with caution. +func (p CreateIsolatedWorldParams) WithGrantUniveralAccess(grantUniveralAccess bool) *CreateIsolatedWorldParams { + p.GrantUniveralAccess = grantUniveralAccess + return &p +} + +// CreateIsolatedWorldReturns return values. +type CreateIsolatedWorldReturns struct { + ExecutionContextID runtime.ExecutionContextID `json:"executionContextId,omitempty"` // Execution context of the isolated world. +} + +// Do executes Page.createIsolatedWorld against the provided context and +// target handler. +// +// returns: +// executionContextID - Execution context of the isolated world. +func (p *CreateIsolatedWorldParams) Do(ctxt context.Context, h cdp.Handler) (executionContextID runtime.ExecutionContextID, err error) { + // execute + var res CreateIsolatedWorldReturns + err = h.Execute(ctxt, cdp.CommandPageCreateIsolatedWorld, p, &res) + if err != nil { + return 0, err + } + + return res.ExecutionContextID, nil +} + +// DisableParams disables page domain notifications. +type DisableParams struct{} + +// Disable disables page domain notifications. +func Disable() *DisableParams { + return &DisableParams{} +} + +// Do executes Page.disable against the provided context and +// target handler. +func (p *DisableParams) Do(ctxt context.Context, h cdp.Handler) (err error) { + return h.Execute(ctxt, cdp.CommandPageDisable, nil, nil) +} + +// EnableParams enables page domain notifications. +type EnableParams struct{} + +// Enable enables page domain notifications. +func Enable() *EnableParams { + return &EnableParams{} +} + +// Do executes Page.enable against the provided context and +// target handler. +func (p *EnableParams) Do(ctxt context.Context, h cdp.Handler) (err error) { + return h.Execute(ctxt, cdp.CommandPageEnable, nil, nil) +} + +// GetAppManifestParams [no description]. +type GetAppManifestParams struct{} + +// GetAppManifest [no description]. +func GetAppManifest() *GetAppManifestParams { + return &GetAppManifestParams{} +} + +// GetAppManifestReturns return values. +type GetAppManifestReturns struct { + URL string `json:"url,omitempty"` // Manifest location. + Errors []*AppManifestError `json:"errors,omitempty"` + Data string `json:"data,omitempty"` // Manifest content. +} + +// Do executes Page.getAppManifest against the provided context and +// target handler. +// +// returns: +// url - Manifest location. +// errors +// data - Manifest content. +func (p *GetAppManifestParams) Do(ctxt context.Context, h cdp.Handler) (url string, errors []*AppManifestError, data string, err error) { + // execute + var res GetAppManifestReturns + err = h.Execute(ctxt, cdp.CommandPageGetAppManifest, nil, &res) + if err != nil { + return "", nil, "", err + } + + return res.URL, res.Errors, res.Data, nil +} + +// GetFrameTreeParams returns present frame tree structure. +type GetFrameTreeParams struct{} + +// GetFrameTree returns present frame tree structure. +func GetFrameTree() *GetFrameTreeParams { + return &GetFrameTreeParams{} +} + +// GetFrameTreeReturns return values. +type GetFrameTreeReturns struct { + FrameTree *FrameTree `json:"frameTree,omitempty"` // Present frame tree structure. +} + +// Do executes Page.getFrameTree against the provided context and +// target handler. +// +// returns: +// frameTree - Present frame tree structure. +func (p *GetFrameTreeParams) Do(ctxt context.Context, h cdp.Handler) (frameTree *FrameTree, err error) { + // execute + var res GetFrameTreeReturns + err = h.Execute(ctxt, cdp.CommandPageGetFrameTree, nil, &res) + if err != nil { + return nil, err + } + + return res.FrameTree, nil +} + +// GetLayoutMetricsParams returns metrics relating to the layouting of the +// page, such as viewport bounds/scale. +type GetLayoutMetricsParams struct{} + +// GetLayoutMetrics returns metrics relating to the layouting of the page, +// such as viewport bounds/scale. +func GetLayoutMetrics() *GetLayoutMetricsParams { + return &GetLayoutMetricsParams{} +} + +// GetLayoutMetricsReturns return values. +type GetLayoutMetricsReturns struct { + LayoutViewport *LayoutViewport `json:"layoutViewport,omitempty"` // Metrics relating to the layout viewport. + VisualViewport *VisualViewport `json:"visualViewport,omitempty"` // Metrics relating to the visual viewport. + ContentSize *dom.Rect `json:"contentSize,omitempty"` // Size of scrollable area. +} + +// Do executes Page.getLayoutMetrics against the provided context and +// target handler. +// +// returns: +// layoutViewport - Metrics relating to the layout viewport. +// visualViewport - Metrics relating to the visual viewport. +// contentSize - Size of scrollable area. +func (p *GetLayoutMetricsParams) Do(ctxt context.Context, h cdp.Handler) (layoutViewport *LayoutViewport, visualViewport *VisualViewport, contentSize *dom.Rect, err error) { + // execute + var res GetLayoutMetricsReturns + err = h.Execute(ctxt, cdp.CommandPageGetLayoutMetrics, nil, &res) + if err != nil { + return nil, nil, nil, err + } + + return res.LayoutViewport, res.VisualViewport, res.ContentSize, nil +} + +// GetNavigationHistoryParams returns navigation history for the current +// page. +type GetNavigationHistoryParams struct{} + +// GetNavigationHistory returns navigation history for the current page. +func GetNavigationHistory() *GetNavigationHistoryParams { + return &GetNavigationHistoryParams{} +} + +// GetNavigationHistoryReturns return values. +type GetNavigationHistoryReturns struct { + CurrentIndex int64 `json:"currentIndex,omitempty"` // Index of the current navigation history entry. + Entries []*NavigationEntry `json:"entries,omitempty"` // Array of navigation history entries. +} + +// Do executes Page.getNavigationHistory against the provided context and +// target handler. +// +// returns: +// currentIndex - Index of the current navigation history entry. +// entries - Array of navigation history entries. +func (p *GetNavigationHistoryParams) Do(ctxt context.Context, h cdp.Handler) (currentIndex int64, entries []*NavigationEntry, err error) { + // execute + var res GetNavigationHistoryReturns + err = h.Execute(ctxt, cdp.CommandPageGetNavigationHistory, nil, &res) + if err != nil { + return 0, nil, err + } + + return res.CurrentIndex, res.Entries, nil +} + +// GetResourceContentParams returns content of the given resource. +type GetResourceContentParams struct { + FrameID cdp.FrameID `json:"frameId"` // Frame id to get resource for. + URL string `json:"url"` // URL of the resource to get content for. +} + +// GetResourceContent returns content of the given resource. +// +// parameters: +// frameID - Frame id to get resource for. +// url - URL of the resource to get content for. +func GetResourceContent(frameID cdp.FrameID, url string) *GetResourceContentParams { + return &GetResourceContentParams{ + FrameID: frameID, + URL: url, + } +} + +// GetResourceContentReturns return values. +type GetResourceContentReturns struct { + Content string `json:"content,omitempty"` // Resource content. + Base64encoded bool `json:"base64Encoded,omitempty"` // True, if content was served as base64. +} + +// Do executes Page.getResourceContent against the provided context and +// target handler. +// +// returns: +// content - Resource content. +func (p *GetResourceContentParams) Do(ctxt context.Context, h cdp.Handler) (content []byte, err error) { + // execute + var res GetResourceContentReturns + err = h.Execute(ctxt, cdp.CommandPageGetResourceContent, p, &res) + if err != nil { + return nil, err + } + + // decode + var dec []byte + if res.Base64encoded { + dec, err = base64.StdEncoding.DecodeString(res.Content) + if err != nil { + return nil, err + } + } else { + dec = []byte(res.Content) + } + return dec, nil +} + +// GetResourceTreeParams returns present frame / resource tree structure. +type GetResourceTreeParams struct{} + +// GetResourceTree returns present frame / resource tree structure. +func GetResourceTree() *GetResourceTreeParams { + return &GetResourceTreeParams{} +} + +// GetResourceTreeReturns return values. +type GetResourceTreeReturns struct { + FrameTree *FrameResourceTree `json:"frameTree,omitempty"` // Present frame / resource tree structure. +} + +// Do executes Page.getResourceTree against the provided context and +// target handler. +// +// returns: +// frameTree - Present frame / resource tree structure. +func (p *GetResourceTreeParams) Do(ctxt context.Context, h cdp.Handler) (frameTree *FrameResourceTree, err error) { + // execute + var res GetResourceTreeReturns + err = h.Execute(ctxt, cdp.CommandPageGetResourceTree, nil, &res) + if err != nil { + return nil, err + } + + return res.FrameTree, nil +} + +// HandleJavaScriptDialogParams accepts or dismisses a JavaScript initiated +// dialog (alert, confirm, prompt, or onbeforeunload). +type HandleJavaScriptDialogParams struct { + Accept bool `json:"accept"` // Whether to accept or dismiss the dialog. + PromptText string `json:"promptText,omitempty"` // The text to enter into the dialog prompt before accepting. Used only if this is a prompt dialog. +} + +// HandleJavaScriptDialog accepts or dismisses a JavaScript initiated dialog +// (alert, confirm, prompt, or onbeforeunload). +// +// parameters: +// accept - Whether to accept or dismiss the dialog. +func HandleJavaScriptDialog(accept bool) *HandleJavaScriptDialogParams { + return &HandleJavaScriptDialogParams{ + Accept: accept, + } +} + +// WithPromptText the text to enter into the dialog prompt before accepting. +// Used only if this is a prompt dialog. +func (p HandleJavaScriptDialogParams) WithPromptText(promptText string) *HandleJavaScriptDialogParams { + p.PromptText = promptText + return &p +} + +// Do executes Page.handleJavaScriptDialog against the provided context and +// target handler. +func (p *HandleJavaScriptDialogParams) Do(ctxt context.Context, h cdp.Handler) (err error) { + return h.Execute(ctxt, cdp.CommandPageHandleJavaScriptDialog, p, nil) +} + +// NavigateParams navigates current page to the given URL. +type NavigateParams struct { + URL string `json:"url"` // URL to navigate the page to. + Referrer string `json:"referrer,omitempty"` // Referrer URL. + TransitionType TransitionType `json:"transitionType,omitempty"` // Intended transition type. +} + +// Navigate navigates current page to the given URL. +// +// parameters: +// url - URL to navigate the page to. +func Navigate(url string) *NavigateParams { + return &NavigateParams{ + URL: url, + } +} + +// WithReferrer referrer URL. +func (p NavigateParams) WithReferrer(referrer string) *NavigateParams { + p.Referrer = referrer + return &p +} + +// WithTransitionType intended transition type. +func (p NavigateParams) WithTransitionType(transitionType TransitionType) *NavigateParams { + p.TransitionType = transitionType + return &p +} + +// NavigateReturns return values. +type NavigateReturns struct { + FrameID cdp.FrameID `json:"frameId,omitempty"` // Frame id that has navigated (or failed to navigate) + LoaderID cdp.LoaderID `json:"loaderId,omitempty"` // Loader identifier. + ErrorText string `json:"errorText,omitempty"` // User friendly error message, present if and only if navigation has failed. +} + +// Do executes Page.navigate against the provided context and +// target handler. +// +// returns: +// frameID - Frame id that has navigated (or failed to navigate) +// loaderID - Loader identifier. +// errorText - User friendly error message, present if and only if navigation has failed. +func (p *NavigateParams) Do(ctxt context.Context, h cdp.Handler) (frameID cdp.FrameID, loaderID cdp.LoaderID, errorText string, err error) { + // execute + var res NavigateReturns + err = h.Execute(ctxt, cdp.CommandPageNavigate, p, &res) + if err != nil { + return "", "", "", err + } + + return res.FrameID, res.LoaderID, res.ErrorText, nil +} + +// NavigateToHistoryEntryParams navigates current page to the given history +// entry. +type NavigateToHistoryEntryParams struct { + EntryID int64 `json:"entryId"` // Unique id of the entry to navigate to. +} + +// NavigateToHistoryEntry navigates current page to the given history entry. +// +// parameters: +// entryID - Unique id of the entry to navigate to. +func NavigateToHistoryEntry(entryID int64) *NavigateToHistoryEntryParams { + return &NavigateToHistoryEntryParams{ + EntryID: entryID, + } +} + +// Do executes Page.navigateToHistoryEntry against the provided context and +// target handler. +func (p *NavigateToHistoryEntryParams) Do(ctxt context.Context, h cdp.Handler) (err error) { + return h.Execute(ctxt, cdp.CommandPageNavigateToHistoryEntry, p, nil) +} + // PrintToPDFParams print page as PDF. type PrintToPDFParams struct { Landscape bool `json:"landscape,omitempty"` // Paper orientation. Defaults to false. @@ -601,6 +546,8 @@ type PrintToPDFParams struct { MarginRight float64 `json:"marginRight,omitempty"` // Right margin in inches. Defaults to 1cm (~0.4 inches). PageRanges string `json:"pageRanges,omitempty"` // Paper ranges to print, e.g., '1-5, 8, 11-13'. Defaults to the empty string, which means print all pages. IgnoreInvalidPageRanges bool `json:"ignoreInvalidPageRanges,omitempty"` // Whether to silently ignore invalid but successfully parsed page ranges, such as '3-2'. Defaults to false. + HeaderTemplate string `json:"headerTemplate,omitempty"` // HTML template for the print header. Should be valid HTML markup with following classes used to inject printing values into them: - date - formatted print date - title - document title - url - document location - pageNumber - current page number - totalPages - total pages in the document For example, would generate span containing the title. + FooterTemplate string `json:"footerTemplate,omitempty"` // HTML template for the print footer. Should use the same format as the headerTemplate. } // PrintToPDF print page as PDF. @@ -684,6 +631,24 @@ func (p PrintToPDFParams) WithIgnoreInvalidPageRanges(ignoreInvalidPageRanges bo return &p } +// WithHeaderTemplate HTML template for the print header. Should be valid +// HTML markup with following classes used to inject printing values into them: +// - date - formatted print date - title - document title - url - document +// location - pageNumber - current page number - totalPages - total pages in the +// document For example, would generate span +// containing the title. +func (p PrintToPDFParams) WithHeaderTemplate(headerTemplate string) *PrintToPDFParams { + p.HeaderTemplate = headerTemplate + return &p +} + +// WithFooterTemplate HTML template for the print footer. Should use the same +// format as the headerTemplate. +func (p PrintToPDFParams) WithFooterTemplate(footerTemplate string) *PrintToPDFParams { + p.FooterTemplate = footerTemplate + return &p +} + // PrintToPDFReturns return values. type PrintToPDFReturns struct { Data string `json:"data,omitempty"` // Base64-encoded pdf data. @@ -711,6 +676,276 @@ func (p *PrintToPDFParams) Do(ctxt context.Context, h cdp.Handler) (data []byte, return dec, nil } +// ReloadParams reloads given page optionally ignoring the cache. +type ReloadParams struct { + IgnoreCache bool `json:"ignoreCache,omitempty"` // If true, browser cache is ignored (as if the user pressed Shift+refresh). + ScriptToEvaluateOnLoad string `json:"scriptToEvaluateOnLoad,omitempty"` // If set, the script will be injected into all frames of the inspected page after reload. Argument will be ignored if reloading dataURL origin. +} + +// Reload reloads given page optionally ignoring the cache. +// +// parameters: +func Reload() *ReloadParams { + return &ReloadParams{} +} + +// WithIgnoreCache if true, browser cache is ignored (as if the user pressed +// Shift+refresh). +func (p ReloadParams) WithIgnoreCache(ignoreCache bool) *ReloadParams { + p.IgnoreCache = ignoreCache + return &p +} + +// WithScriptToEvaluateOnLoad if set, the script will be injected into all +// frames of the inspected page after reload. Argument will be ignored if +// reloading dataURL origin. +func (p ReloadParams) WithScriptToEvaluateOnLoad(scriptToEvaluateOnLoad string) *ReloadParams { + p.ScriptToEvaluateOnLoad = scriptToEvaluateOnLoad + return &p +} + +// Do executes Page.reload against the provided context and +// target handler. +func (p *ReloadParams) Do(ctxt context.Context, h cdp.Handler) (err error) { + return h.Execute(ctxt, cdp.CommandPageReload, p, nil) +} + +// RemoveScriptToEvaluateOnNewDocumentParams removes given script from the +// list. +type RemoveScriptToEvaluateOnNewDocumentParams struct { + Identifier ScriptIdentifier `json:"identifier"` +} + +// RemoveScriptToEvaluateOnNewDocument removes given script from the list. +// +// parameters: +// identifier +func RemoveScriptToEvaluateOnNewDocument(identifier ScriptIdentifier) *RemoveScriptToEvaluateOnNewDocumentParams { + return &RemoveScriptToEvaluateOnNewDocumentParams{ + Identifier: identifier, + } +} + +// Do executes Page.removeScriptToEvaluateOnNewDocument against the provided context and +// target handler. +func (p *RemoveScriptToEvaluateOnNewDocumentParams) Do(ctxt context.Context, h cdp.Handler) (err error) { + return h.Execute(ctxt, cdp.CommandPageRemoveScriptToEvaluateOnNewDocument, p, nil) +} + +// RequestAppBannerParams [no description]. +type RequestAppBannerParams struct{} + +// RequestAppBanner [no description]. +func RequestAppBanner() *RequestAppBannerParams { + return &RequestAppBannerParams{} +} + +// Do executes Page.requestAppBanner against the provided context and +// target handler. +func (p *RequestAppBannerParams) Do(ctxt context.Context, h cdp.Handler) (err error) { + return h.Execute(ctxt, cdp.CommandPageRequestAppBanner, nil, nil) +} + +// ScreencastFrameAckParams acknowledges that a screencast frame has been +// received by the frontend. +type ScreencastFrameAckParams struct { + SessionID int64 `json:"sessionId"` // Frame number. +} + +// ScreencastFrameAck acknowledges that a screencast frame has been received +// by the frontend. +// +// parameters: +// sessionID - Frame number. +func ScreencastFrameAck(sessionID int64) *ScreencastFrameAckParams { + return &ScreencastFrameAckParams{ + SessionID: sessionID, + } +} + +// Do executes Page.screencastFrameAck against the provided context and +// target handler. +func (p *ScreencastFrameAckParams) Do(ctxt context.Context, h cdp.Handler) (err error) { + return h.Execute(ctxt, cdp.CommandPageScreencastFrameAck, p, nil) +} + +// SearchInResourceParams searches for given string in resource content. +type SearchInResourceParams struct { + FrameID cdp.FrameID `json:"frameId"` // Frame id for resource to search in. + URL string `json:"url"` // URL of the resource to search in. + Query string `json:"query"` // String to search for. + CaseSensitive bool `json:"caseSensitive,omitempty"` // If true, search is case sensitive. + IsRegex bool `json:"isRegex,omitempty"` // If true, treats string parameter as regex. +} + +// SearchInResource searches for given string in resource content. +// +// parameters: +// frameID - Frame id for resource to search in. +// url - URL of the resource to search in. +// query - String to search for. +func SearchInResource(frameID cdp.FrameID, url string, query string) *SearchInResourceParams { + return &SearchInResourceParams{ + FrameID: frameID, + URL: url, + Query: query, + } +} + +// WithCaseSensitive if true, search is case sensitive. +func (p SearchInResourceParams) WithCaseSensitive(caseSensitive bool) *SearchInResourceParams { + p.CaseSensitive = caseSensitive + return &p +} + +// WithIsRegex if true, treats string parameter as regex. +func (p SearchInResourceParams) WithIsRegex(isRegex bool) *SearchInResourceParams { + p.IsRegex = isRegex + return &p +} + +// SearchInResourceReturns return values. +type SearchInResourceReturns struct { + Result []*debugger.SearchMatch `json:"result,omitempty"` // List of search matches. +} + +// Do executes Page.searchInResource against the provided context and +// target handler. +// +// returns: +// result - List of search matches. +func (p *SearchInResourceParams) Do(ctxt context.Context, h cdp.Handler) (result []*debugger.SearchMatch, err error) { + // execute + var res SearchInResourceReturns + err = h.Execute(ctxt, cdp.CommandPageSearchInResource, p, &res) + if err != nil { + return nil, err + } + + return res.Result, nil +} + +// SetAdBlockingEnabledParams enable Chrome's experimental ad filter on all +// sites. +type SetAdBlockingEnabledParams struct { + Enabled bool `json:"enabled"` // Whether to block ads. +} + +// SetAdBlockingEnabled enable Chrome's experimental ad filter on all sites. +// +// parameters: +// enabled - Whether to block ads. +func SetAdBlockingEnabled(enabled bool) *SetAdBlockingEnabledParams { + return &SetAdBlockingEnabledParams{ + Enabled: enabled, + } +} + +// Do executes Page.setAdBlockingEnabled against the provided context and +// target handler. +func (p *SetAdBlockingEnabledParams) Do(ctxt context.Context, h cdp.Handler) (err error) { + return h.Execute(ctxt, cdp.CommandPageSetAdBlockingEnabled, p, nil) +} + +// SetAutoAttachToCreatedPagesParams controls whether browser will open a new +// inspector window for connected pages. +type SetAutoAttachToCreatedPagesParams struct { + AutoAttach bool `json:"autoAttach"` // If true, browser will open a new inspector window for every page created from this one. +} + +// SetAutoAttachToCreatedPages controls whether browser will open a new +// inspector window for connected pages. +// +// parameters: +// autoAttach - If true, browser will open a new inspector window for every page created from this one. +func SetAutoAttachToCreatedPages(autoAttach bool) *SetAutoAttachToCreatedPagesParams { + return &SetAutoAttachToCreatedPagesParams{ + AutoAttach: autoAttach, + } +} + +// Do executes Page.setAutoAttachToCreatedPages against the provided context and +// target handler. +func (p *SetAutoAttachToCreatedPagesParams) Do(ctxt context.Context, h cdp.Handler) (err error) { + return h.Execute(ctxt, cdp.CommandPageSetAutoAttachToCreatedPages, p, nil) +} + +// SetDocumentContentParams sets given markup as the document's HTML. +type SetDocumentContentParams struct { + FrameID cdp.FrameID `json:"frameId"` // Frame id to set HTML for. + HTML string `json:"html"` // HTML content to set. +} + +// SetDocumentContent sets given markup as the document's HTML. +// +// parameters: +// frameID - Frame id to set HTML for. +// html - HTML content to set. +func SetDocumentContent(frameID cdp.FrameID, html string) *SetDocumentContentParams { + return &SetDocumentContentParams{ + FrameID: frameID, + HTML: html, + } +} + +// Do executes Page.setDocumentContent against the provided context and +// target handler. +func (p *SetDocumentContentParams) Do(ctxt context.Context, h cdp.Handler) (err error) { + return h.Execute(ctxt, cdp.CommandPageSetDocumentContent, p, nil) +} + +// SetDownloadBehaviorParams set the behavior when downloading a file. +type SetDownloadBehaviorParams struct { + Behavior SetDownloadBehaviorBehavior `json:"behavior"` // Whether to allow all or deny all download requests, or use default Chrome behavior if available (otherwise deny). + DownloadPath string `json:"downloadPath,omitempty"` // The default path to save downloaded files to. This is required if behavior is set to 'allow' +} + +// SetDownloadBehavior set the behavior when downloading a file. +// +// parameters: +// behavior - Whether to allow all or deny all download requests, or use default Chrome behavior if available (otherwise deny). +func SetDownloadBehavior(behavior SetDownloadBehaviorBehavior) *SetDownloadBehaviorParams { + return &SetDownloadBehaviorParams{ + Behavior: behavior, + } +} + +// WithDownloadPath the default path to save downloaded files to. This is +// required if behavior is set to 'allow'. +func (p SetDownloadBehaviorParams) WithDownloadPath(downloadPath string) *SetDownloadBehaviorParams { + p.DownloadPath = downloadPath + return &p +} + +// Do executes Page.setDownloadBehavior against the provided context and +// target handler. +func (p *SetDownloadBehaviorParams) Do(ctxt context.Context, h cdp.Handler) (err error) { + return h.Execute(ctxt, cdp.CommandPageSetDownloadBehavior, p, nil) +} + +// SetLifecycleEventsEnabledParams controls whether page will emit lifecycle +// events. +type SetLifecycleEventsEnabledParams struct { + Enabled bool `json:"enabled"` // If true, starts emitting lifecycle events. +} + +// SetLifecycleEventsEnabled controls whether page will emit lifecycle +// events. +// +// parameters: +// enabled - If true, starts emitting lifecycle events. +func SetLifecycleEventsEnabled(enabled bool) *SetLifecycleEventsEnabledParams { + return &SetLifecycleEventsEnabledParams{ + Enabled: enabled, + } +} + +// Do executes Page.setLifecycleEventsEnabled against the provided context and +// target handler. +func (p *SetLifecycleEventsEnabledParams) Do(ctxt context.Context, h cdp.Handler) (err error) { + return h.Execute(ctxt, cdp.CommandPageSetLifecycleEventsEnabled, p, nil) +} + // StartScreencastParams starts sending each frame using the screencastFrame // event. type StartScreencastParams struct { @@ -764,6 +999,22 @@ func (p *StartScreencastParams) Do(ctxt context.Context, h cdp.Handler) (err err return h.Execute(ctxt, cdp.CommandPageStartScreencast, p, nil) } +// StopLoadingParams force the page stop all navigations and pending resource +// fetches. +type StopLoadingParams struct{} + +// StopLoading force the page stop all navigations and pending resource +// fetches. +func StopLoading() *StopLoadingParams { + return &StopLoadingParams{} +} + +// Do executes Page.stopLoading against the provided context and +// target handler. +func (p *StopLoadingParams) Do(ctxt context.Context, h cdp.Handler) (err error) { + return h.Execute(ctxt, cdp.CommandPageStopLoading, nil, nil) +} + // StopScreencastParams stops sending each frame in the screencastFrame. type StopScreencastParams struct{} @@ -777,233 +1028,3 @@ func StopScreencast() *StopScreencastParams { func (p *StopScreencastParams) Do(ctxt context.Context, h cdp.Handler) (err error) { return h.Execute(ctxt, cdp.CommandPageStopScreencast, nil, nil) } - -// ScreencastFrameAckParams acknowledges that a screencast frame has been -// received by the frontend. -type ScreencastFrameAckParams struct { - SessionID int64 `json:"sessionId"` // Frame number. -} - -// ScreencastFrameAck acknowledges that a screencast frame has been received -// by the frontend. -// -// parameters: -// sessionID - Frame number. -func ScreencastFrameAck(sessionID int64) *ScreencastFrameAckParams { - return &ScreencastFrameAckParams{ - SessionID: sessionID, - } -} - -// Do executes Page.screencastFrameAck against the provided context and -// target handler. -func (p *ScreencastFrameAckParams) Do(ctxt context.Context, h cdp.Handler) (err error) { - return h.Execute(ctxt, cdp.CommandPageScreencastFrameAck, p, nil) -} - -// HandleJavaScriptDialogParams accepts or dismisses a JavaScript initiated -// dialog (alert, confirm, prompt, or onbeforeunload). -type HandleJavaScriptDialogParams struct { - Accept bool `json:"accept"` // Whether to accept or dismiss the dialog. - PromptText string `json:"promptText,omitempty"` // The text to enter into the dialog prompt before accepting. Used only if this is a prompt dialog. -} - -// HandleJavaScriptDialog accepts or dismisses a JavaScript initiated dialog -// (alert, confirm, prompt, or onbeforeunload). -// -// parameters: -// accept - Whether to accept or dismiss the dialog. -func HandleJavaScriptDialog(accept bool) *HandleJavaScriptDialogParams { - return &HandleJavaScriptDialogParams{ - Accept: accept, - } -} - -// WithPromptText the text to enter into the dialog prompt before accepting. -// Used only if this is a prompt dialog. -func (p HandleJavaScriptDialogParams) WithPromptText(promptText string) *HandleJavaScriptDialogParams { - p.PromptText = promptText - return &p -} - -// Do executes Page.handleJavaScriptDialog against the provided context and -// target handler. -func (p *HandleJavaScriptDialogParams) Do(ctxt context.Context, h cdp.Handler) (err error) { - return h.Execute(ctxt, cdp.CommandPageHandleJavaScriptDialog, p, nil) -} - -// GetAppManifestParams [no description]. -type GetAppManifestParams struct{} - -// GetAppManifest [no description]. -func GetAppManifest() *GetAppManifestParams { - return &GetAppManifestParams{} -} - -// GetAppManifestReturns return values. -type GetAppManifestReturns struct { - URL string `json:"url,omitempty"` // Manifest location. - Errors []*AppManifestError `json:"errors,omitempty"` - Data string `json:"data,omitempty"` // Manifest content. -} - -// Do executes Page.getAppManifest against the provided context and -// target handler. -// -// returns: -// url - Manifest location. -// errors -// data - Manifest content. -func (p *GetAppManifestParams) Do(ctxt context.Context, h cdp.Handler) (url string, errors []*AppManifestError, data string, err error) { - // execute - var res GetAppManifestReturns - err = h.Execute(ctxt, cdp.CommandPageGetAppManifest, nil, &res) - if err != nil { - return "", nil, "", err - } - - return res.URL, res.Errors, res.Data, nil -} - -// RequestAppBannerParams [no description]. -type RequestAppBannerParams struct{} - -// RequestAppBanner [no description]. -func RequestAppBanner() *RequestAppBannerParams { - return &RequestAppBannerParams{} -} - -// Do executes Page.requestAppBanner against the provided context and -// target handler. -func (p *RequestAppBannerParams) Do(ctxt context.Context, h cdp.Handler) (err error) { - return h.Execute(ctxt, cdp.CommandPageRequestAppBanner, nil, nil) -} - -// GetLayoutMetricsParams returns metrics relating to the layouting of the -// page, such as viewport bounds/scale. -type GetLayoutMetricsParams struct{} - -// GetLayoutMetrics returns metrics relating to the layouting of the page, -// such as viewport bounds/scale. -func GetLayoutMetrics() *GetLayoutMetricsParams { - return &GetLayoutMetricsParams{} -} - -// GetLayoutMetricsReturns return values. -type GetLayoutMetricsReturns struct { - LayoutViewport *LayoutViewport `json:"layoutViewport,omitempty"` // Metrics relating to the layout viewport. - VisualViewport *VisualViewport `json:"visualViewport,omitempty"` // Metrics relating to the visual viewport. - ContentSize *dom.Rect `json:"contentSize,omitempty"` // Size of scrollable area. -} - -// Do executes Page.getLayoutMetrics against the provided context and -// target handler. -// -// returns: -// layoutViewport - Metrics relating to the layout viewport. -// visualViewport - Metrics relating to the visual viewport. -// contentSize - Size of scrollable area. -func (p *GetLayoutMetricsParams) Do(ctxt context.Context, h cdp.Handler) (layoutViewport *LayoutViewport, visualViewport *VisualViewport, contentSize *dom.Rect, err error) { - // execute - var res GetLayoutMetricsReturns - err = h.Execute(ctxt, cdp.CommandPageGetLayoutMetrics, nil, &res) - if err != nil { - return nil, nil, nil, err - } - - return res.LayoutViewport, res.VisualViewport, res.ContentSize, nil -} - -// CreateIsolatedWorldParams creates an isolated world for the given frame. -type CreateIsolatedWorldParams struct { - FrameID cdp.FrameID `json:"frameId"` // Id of the frame in which the isolated world should be created. - WorldName string `json:"worldName,omitempty"` // An optional name which is reported in the Execution Context. - GrantUniveralAccess bool `json:"grantUniveralAccess,omitempty"` // Whether or not universal access should be granted to the isolated world. This is a powerful option, use with caution. -} - -// CreateIsolatedWorld creates an isolated world for the given frame. -// -// parameters: -// frameID - Id of the frame in which the isolated world should be created. -func CreateIsolatedWorld(frameID cdp.FrameID) *CreateIsolatedWorldParams { - return &CreateIsolatedWorldParams{ - FrameID: frameID, - } -} - -// WithWorldName an optional name which is reported in the Execution Context. -func (p CreateIsolatedWorldParams) WithWorldName(worldName string) *CreateIsolatedWorldParams { - p.WorldName = worldName - return &p -} - -// WithGrantUniveralAccess whether or not universal access should be granted -// to the isolated world. This is a powerful option, use with caution. -func (p CreateIsolatedWorldParams) WithGrantUniveralAccess(grantUniveralAccess bool) *CreateIsolatedWorldParams { - p.GrantUniveralAccess = grantUniveralAccess - return &p -} - -// CreateIsolatedWorldReturns return values. -type CreateIsolatedWorldReturns struct { - ExecutionContextID runtime.ExecutionContextID `json:"executionContextId,omitempty"` // Execution context of the isolated world. -} - -// Do executes Page.createIsolatedWorld against the provided context and -// target handler. -// -// returns: -// executionContextID - Execution context of the isolated world. -func (p *CreateIsolatedWorldParams) Do(ctxt context.Context, h cdp.Handler) (executionContextID runtime.ExecutionContextID, err error) { - // execute - var res CreateIsolatedWorldReturns - err = h.Execute(ctxt, cdp.CommandPageCreateIsolatedWorld, p, &res) - if err != nil { - return 0, err - } - - return res.ExecutionContextID, nil -} - -// BringToFrontParams brings page to front (activates tab). -type BringToFrontParams struct{} - -// BringToFront brings page to front (activates tab). -func BringToFront() *BringToFrontParams { - return &BringToFrontParams{} -} - -// Do executes Page.bringToFront against the provided context and -// target handler. -func (p *BringToFrontParams) Do(ctxt context.Context, h cdp.Handler) (err error) { - return h.Execute(ctxt, cdp.CommandPageBringToFront, nil, nil) -} - -// SetDownloadBehaviorParams set the behavior when downloading a file. -type SetDownloadBehaviorParams struct { - Behavior SetDownloadBehaviorBehavior `json:"behavior"` // Whether to allow all or deny all download requests, or use default Chrome behavior if available (otherwise deny). - DownloadPath string `json:"downloadPath,omitempty"` // The default path to save downloaded files to. This is required if behavior is set to 'allow' -} - -// SetDownloadBehavior set the behavior when downloading a file. -// -// parameters: -// behavior - Whether to allow all or deny all download requests, or use default Chrome behavior if available (otherwise deny). -func SetDownloadBehavior(behavior SetDownloadBehaviorBehavior) *SetDownloadBehaviorParams { - return &SetDownloadBehaviorParams{ - Behavior: behavior, - } -} - -// WithDownloadPath the default path to save downloaded files to. This is -// required if behavior is set to 'allow'. -func (p SetDownloadBehaviorParams) WithDownloadPath(downloadPath string) *SetDownloadBehaviorParams { - p.DownloadPath = downloadPath - return &p -} - -// Do executes Page.setDownloadBehavior against the provided context and -// target handler. -func (p *SetDownloadBehaviorParams) Do(ctxt context.Context, h cdp.Handler) (err error) { - return h.Execute(ctxt, cdp.CommandPageSetDownloadBehavior, p, nil) -} diff --git a/cdp/page/types.go b/cdp/page/types.go index 255f109..89a7a7a 100644 --- a/cdp/page/types.go +++ b/cdp/page/types.go @@ -394,48 +394,6 @@ func (t *CaptureScreenshotFormat) UnmarshalJSON(buf []byte) error { return easyjson.Unmarshal(buf, t) } -// ScreencastFormat image compression format. -type ScreencastFormat string - -// String returns the ScreencastFormat as string value. -func (t ScreencastFormat) String() string { - return string(t) -} - -// ScreencastFormat values. -const ( - ScreencastFormatJpeg ScreencastFormat = "jpeg" - ScreencastFormatPng ScreencastFormat = "png" -) - -// MarshalEasyJSON satisfies easyjson.Marshaler. -func (t ScreencastFormat) MarshalEasyJSON(out *jwriter.Writer) { - out.String(string(t)) -} - -// MarshalJSON satisfies json.Marshaler. -func (t ScreencastFormat) MarshalJSON() ([]byte, error) { - return easyjson.Marshal(t) -} - -// UnmarshalEasyJSON satisfies easyjson.Unmarshaler. -func (t *ScreencastFormat) UnmarshalEasyJSON(in *jlexer.Lexer) { - switch ScreencastFormat(in.String()) { - case ScreencastFormatJpeg: - *t = ScreencastFormatJpeg - case ScreencastFormatPng: - *t = ScreencastFormatPng - - default: - in.AddError(errors.New("unknown ScreencastFormat value")) - } -} - -// UnmarshalJSON satisfies json.Unmarshaler. -func (t *ScreencastFormat) UnmarshalJSON(buf []byte) error { - return easyjson.Unmarshal(buf, t) -} - // SetDownloadBehaviorBehavior whether to allow all or deny all download // requests, or use default Chrome behavior if available (otherwise deny). type SetDownloadBehaviorBehavior string @@ -481,3 +439,45 @@ func (t *SetDownloadBehaviorBehavior) UnmarshalEasyJSON(in *jlexer.Lexer) { func (t *SetDownloadBehaviorBehavior) UnmarshalJSON(buf []byte) error { return easyjson.Unmarshal(buf, t) } + +// ScreencastFormat image compression format. +type ScreencastFormat string + +// String returns the ScreencastFormat as string value. +func (t ScreencastFormat) String() string { + return string(t) +} + +// ScreencastFormat values. +const ( + ScreencastFormatJpeg ScreencastFormat = "jpeg" + ScreencastFormatPng ScreencastFormat = "png" +) + +// MarshalEasyJSON satisfies easyjson.Marshaler. +func (t ScreencastFormat) MarshalEasyJSON(out *jwriter.Writer) { + out.String(string(t)) +} + +// MarshalJSON satisfies json.Marshaler. +func (t ScreencastFormat) MarshalJSON() ([]byte, error) { + return easyjson.Marshal(t) +} + +// UnmarshalEasyJSON satisfies easyjson.Unmarshaler. +func (t *ScreencastFormat) UnmarshalEasyJSON(in *jlexer.Lexer) { + switch ScreencastFormat(in.String()) { + case ScreencastFormatJpeg: + *t = ScreencastFormatJpeg + case ScreencastFormatPng: + *t = ScreencastFormatPng + + default: + in.AddError(errors.New("unknown ScreencastFormat value")) + } +} + +// UnmarshalJSON satisfies json.Unmarshaler. +func (t *ScreencastFormat) UnmarshalJSON(buf []byte) error { + return easyjson.Unmarshal(buf, t) +} diff --git a/cdp/performance/performance.go b/cdp/performance/performance.go index 4370597..63d33bd 100644 --- a/cdp/performance/performance.go +++ b/cdp/performance/performance.go @@ -12,20 +12,6 @@ import ( cdp "github.com/knq/chromedp/cdp" ) -// EnableParams enable collecting and reporting metrics. -type EnableParams struct{} - -// Enable enable collecting and reporting metrics. -func Enable() *EnableParams { - return &EnableParams{} -} - -// Do executes Performance.enable against the provided context and -// target handler. -func (p *EnableParams) Do(ctxt context.Context, h cdp.Handler) (err error) { - return h.Execute(ctxt, cdp.CommandPerformanceEnable, nil, nil) -} - // DisableParams disable collecting and reporting metrics. type DisableParams struct{} @@ -40,6 +26,20 @@ func (p *DisableParams) Do(ctxt context.Context, h cdp.Handler) (err error) { return h.Execute(ctxt, cdp.CommandPerformanceDisable, nil, nil) } +// EnableParams enable collecting and reporting metrics. +type EnableParams struct{} + +// Enable enable collecting and reporting metrics. +func Enable() *EnableParams { + return &EnableParams{} +} + +// Do executes Performance.enable against the provided context and +// target handler. +func (p *EnableParams) Do(ctxt context.Context, h cdp.Handler) (err error) { + return h.Execute(ctxt, cdp.CommandPerformanceEnable, nil, nil) +} + // GetMetricsParams retrieve current values of run-time metrics. type GetMetricsParams struct{} diff --git a/cdp/profiler/events.go b/cdp/profiler/events.go index b4a37c9..c299216 100644 --- a/cdp/profiler/events.go +++ b/cdp/profiler/events.go @@ -7,14 +7,6 @@ import ( "github.com/knq/chromedp/cdp/debugger" ) -// EventConsoleProfileStarted sent when new profile recording is started -// using console.profile() call. -type EventConsoleProfileStarted struct { - ID string `json:"id"` - Location *debugger.Location `json:"location"` // Location of console.profile(). - Title string `json:"title,omitempty"` // Profile title passed as an argument to console.profile(). -} - // EventConsoleProfileFinished [no description]. type EventConsoleProfileFinished struct { ID string `json:"id"` @@ -23,8 +15,16 @@ type EventConsoleProfileFinished struct { Title string `json:"title,omitempty"` // Profile title passed as an argument to console.profile(). } +// EventConsoleProfileStarted sent when new profile recording is started +// using console.profile() call. +type EventConsoleProfileStarted struct { + ID string `json:"id"` + Location *debugger.Location `json:"location"` // Location of console.profile(). + Title string `json:"title,omitempty"` // Profile title passed as an argument to console.profile(). +} + // EventTypes all event types in the domain. var EventTypes = []cdp.MethodType{ - cdp.EventProfilerConsoleProfileStarted, cdp.EventProfilerConsoleProfileFinished, + cdp.EventProfilerConsoleProfileStarted, } diff --git a/cdp/profiler/profiler.go b/cdp/profiler/profiler.go index 26a59c0..24a1c3d 100644 --- a/cdp/profiler/profiler.go +++ b/cdp/profiler/profiler.go @@ -12,6 +12,20 @@ import ( cdp "github.com/knq/chromedp/cdp" ) +// DisableParams [no description]. +type DisableParams struct{} + +// Disable [no description]. +func Disable() *DisableParams { + return &DisableParams{} +} + +// Do executes Profiler.disable against the provided context and +// target handler. +func (p *DisableParams) Do(ctxt context.Context, h cdp.Handler) (err error) { + return h.Execute(ctxt, cdp.CommandProfilerDisable, nil, nil) +} + // EnableParams [no description]. type EnableParams struct{} @@ -26,18 +40,35 @@ func (p *EnableParams) Do(ctxt context.Context, h cdp.Handler) (err error) { return h.Execute(ctxt, cdp.CommandProfilerEnable, nil, nil) } -// DisableParams [no description]. -type DisableParams struct{} +// GetBestEffortCoverageParams collect coverage data for the current isolate. +// The coverage data may be incomplete due to garbage collection. +type GetBestEffortCoverageParams struct{} -// Disable [no description]. -func Disable() *DisableParams { - return &DisableParams{} +// GetBestEffortCoverage collect coverage data for the current isolate. The +// coverage data may be incomplete due to garbage collection. +func GetBestEffortCoverage() *GetBestEffortCoverageParams { + return &GetBestEffortCoverageParams{} } -// Do executes Profiler.disable against the provided context and +// GetBestEffortCoverageReturns return values. +type GetBestEffortCoverageReturns struct { + Result []*ScriptCoverage `json:"result,omitempty"` // Coverage data for the current isolate. +} + +// Do executes Profiler.getBestEffortCoverage against the provided context and // target handler. -func (p *DisableParams) Do(ctxt context.Context, h cdp.Handler) (err error) { - return h.Execute(ctxt, cdp.CommandProfilerDisable, nil, nil) +// +// returns: +// result - Coverage data for the current isolate. +func (p *GetBestEffortCoverageParams) Do(ctxt context.Context, h cdp.Handler) (result []*ScriptCoverage, err error) { + // execute + var res GetBestEffortCoverageReturns + err = h.Execute(ctxt, cdp.CommandProfilerGetBestEffortCoverage, nil, &res) + if err != nil { + return nil, err + } + + return res.Result, nil } // SetSamplingIntervalParams changes CPU profiler sampling interval. Must be @@ -77,35 +108,6 @@ func (p *StartParams) Do(ctxt context.Context, h cdp.Handler) (err error) { return h.Execute(ctxt, cdp.CommandProfilerStart, nil, nil) } -// StopParams [no description]. -type StopParams struct{} - -// Stop [no description]. -func Stop() *StopParams { - return &StopParams{} -} - -// StopReturns return values. -type StopReturns struct { - Profile *Profile `json:"profile,omitempty"` // Recorded profile. -} - -// Do executes Profiler.stop against the provided context and -// target handler. -// -// returns: -// profile - Recorded profile. -func (p *StopParams) Do(ctxt context.Context, h cdp.Handler) (profile *Profile, err error) { - // execute - var res StopReturns - err = h.Execute(ctxt, cdp.CommandProfilerStop, nil, &res) - if err != nil { - return nil, err - } - - return res.Profile, nil -} - // StartPreciseCoverageParams enable precise code coverage. Coverage data for // JavaScript executed before enabling precise code coverage may be incomplete. // Enabling prevents running optimized code and resets execution counters. @@ -142,6 +144,49 @@ func (p *StartPreciseCoverageParams) Do(ctxt context.Context, h cdp.Handler) (er return h.Execute(ctxt, cdp.CommandProfilerStartPreciseCoverage, p, nil) } +// StartTypeProfileParams enable type profile. +type StartTypeProfileParams struct{} + +// StartTypeProfile enable type profile. +func StartTypeProfile() *StartTypeProfileParams { + return &StartTypeProfileParams{} +} + +// Do executes Profiler.startTypeProfile against the provided context and +// target handler. +func (p *StartTypeProfileParams) Do(ctxt context.Context, h cdp.Handler) (err error) { + return h.Execute(ctxt, cdp.CommandProfilerStartTypeProfile, nil, nil) +} + +// StopParams [no description]. +type StopParams struct{} + +// Stop [no description]. +func Stop() *StopParams { + return &StopParams{} +} + +// StopReturns return values. +type StopReturns struct { + Profile *Profile `json:"profile,omitempty"` // Recorded profile. +} + +// Do executes Profiler.stop against the provided context and +// target handler. +// +// returns: +// profile - Recorded profile. +func (p *StopParams) Do(ctxt context.Context, h cdp.Handler) (profile *Profile, err error) { + // execute + var res StopReturns + err = h.Execute(ctxt, cdp.CommandProfilerStop, nil, &res) + if err != nil { + return nil, err + } + + return res.Profile, nil +} + // StopPreciseCoverageParams disable precise code coverage. Disabling // releases unnecessary execution count records and allows executing optimized // code. @@ -159,6 +204,22 @@ func (p *StopPreciseCoverageParams) Do(ctxt context.Context, h cdp.Handler) (err return h.Execute(ctxt, cdp.CommandProfilerStopPreciseCoverage, nil, nil) } +// StopTypeProfileParams disable type profile. Disabling releases type +// profile data collected so far. +type StopTypeProfileParams struct{} + +// StopTypeProfile disable type profile. Disabling releases type profile data +// collected so far. +func StopTypeProfile() *StopTypeProfileParams { + return &StopTypeProfileParams{} +} + +// Do executes Profiler.stopTypeProfile against the provided context and +// target handler. +func (p *StopTypeProfileParams) Do(ctxt context.Context, h cdp.Handler) (err error) { + return h.Execute(ctxt, cdp.CommandProfilerStopTypeProfile, nil, nil) +} + // TakePreciseCoverageParams collect coverage data for the current isolate, // and resets execution counters. Precise code coverage needs to have started. type TakePreciseCoverageParams struct{} @@ -190,67 +251,6 @@ func (p *TakePreciseCoverageParams) Do(ctxt context.Context, h cdp.Handler) (res return res.Result, nil } -// GetBestEffortCoverageParams collect coverage data for the current isolate. -// The coverage data may be incomplete due to garbage collection. -type GetBestEffortCoverageParams struct{} - -// GetBestEffortCoverage collect coverage data for the current isolate. The -// coverage data may be incomplete due to garbage collection. -func GetBestEffortCoverage() *GetBestEffortCoverageParams { - return &GetBestEffortCoverageParams{} -} - -// GetBestEffortCoverageReturns return values. -type GetBestEffortCoverageReturns struct { - Result []*ScriptCoverage `json:"result,omitempty"` // Coverage data for the current isolate. -} - -// Do executes Profiler.getBestEffortCoverage against the provided context and -// target handler. -// -// returns: -// result - Coverage data for the current isolate. -func (p *GetBestEffortCoverageParams) Do(ctxt context.Context, h cdp.Handler) (result []*ScriptCoverage, err error) { - // execute - var res GetBestEffortCoverageReturns - err = h.Execute(ctxt, cdp.CommandProfilerGetBestEffortCoverage, nil, &res) - if err != nil { - return nil, err - } - - return res.Result, nil -} - -// StartTypeProfileParams enable type profile. -type StartTypeProfileParams struct{} - -// StartTypeProfile enable type profile. -func StartTypeProfile() *StartTypeProfileParams { - return &StartTypeProfileParams{} -} - -// Do executes Profiler.startTypeProfile against the provided context and -// target handler. -func (p *StartTypeProfileParams) Do(ctxt context.Context, h cdp.Handler) (err error) { - return h.Execute(ctxt, cdp.CommandProfilerStartTypeProfile, nil, nil) -} - -// StopTypeProfileParams disable type profile. Disabling releases type -// profile data collected so far. -type StopTypeProfileParams struct{} - -// StopTypeProfile disable type profile. Disabling releases type profile data -// collected so far. -func StopTypeProfile() *StopTypeProfileParams { - return &StopTypeProfileParams{} -} - -// Do executes Profiler.stopTypeProfile against the provided context and -// target handler. -func (p *StopTypeProfileParams) Do(ctxt context.Context, h cdp.Handler) (err error) { - return h.Execute(ctxt, cdp.CommandProfilerStopTypeProfile, nil, nil) -} - // TakeTypeProfileParams collect type profile. type TakeTypeProfileParams struct{} diff --git a/cdp/runtime/events.go b/cdp/runtime/events.go index a7fc627..c0c54c2 100644 --- a/cdp/runtime/events.go +++ b/cdp/runtime/events.go @@ -7,6 +7,28 @@ import ( "github.com/mailru/easyjson" ) +// EventConsoleAPICalled issued when console API was called. +type EventConsoleAPICalled struct { + Type APIType `json:"type"` // Type of the call. + Args []*RemoteObject `json:"args"` // Call arguments. + ExecutionContextID ExecutionContextID `json:"executionContextId"` // Identifier of the context where the call was made. + Timestamp *Timestamp `json:"timestamp"` // 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. +} + +// EventExceptionRevoked issued when unhandled exception was revoked. +type EventExceptionRevoked struct { + Reason string `json:"reason"` // Reason describing why exception was revoked. + ExceptionID int64 `json:"exceptionId"` // The id of revoked exception, as reported in exceptionThrown. +} + +// EventExceptionThrown issued when exception was thrown and unhandled. +type EventExceptionThrown struct { + Timestamp *Timestamp `json:"timestamp"` // Timestamp of the exception. + ExceptionDetails *ExceptionDetails `json:"exceptionDetails"` +} + // EventExecutionContextCreated issued when new execution context is created. type EventExecutionContextCreated struct { Context *ExecutionContextDescription `json:"context"` // A newly created execution context. @@ -21,28 +43,6 @@ type EventExecutionContextDestroyed struct { // cleared in browser. type EventExecutionContextsCleared struct{} -// EventExceptionThrown issued when exception was thrown and unhandled. -type EventExceptionThrown struct { - Timestamp *Timestamp `json:"timestamp"` // Timestamp of the exception. - ExceptionDetails *ExceptionDetails `json:"exceptionDetails"` -} - -// EventExceptionRevoked issued when unhandled exception was revoked. -type EventExceptionRevoked struct { - Reason string `json:"reason"` // Reason describing why exception was revoked. - ExceptionID int64 `json:"exceptionId"` // The id of revoked exception, as reported in exceptionThrown. -} - -// EventConsoleAPICalled issued when console API was called. -type EventConsoleAPICalled struct { - Type APIType `json:"type"` // Type of the call. - Args []*RemoteObject `json:"args"` // Call arguments. - ExecutionContextID ExecutionContextID `json:"executionContextId"` // Identifier of the context where the call was made. - Timestamp *Timestamp `json:"timestamp"` // 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. -} - // EventInspectRequested issued when object should be inspected (for example, // as a result of inspect() command line API call). type EventInspectRequested struct { @@ -52,11 +52,11 @@ type EventInspectRequested struct { // EventTypes all event types in the domain. var EventTypes = []cdp.MethodType{ + cdp.EventRuntimeConsoleAPICalled, + cdp.EventRuntimeExceptionRevoked, + cdp.EventRuntimeExceptionThrown, cdp.EventRuntimeExecutionContextCreated, cdp.EventRuntimeExecutionContextDestroyed, cdp.EventRuntimeExecutionContextsCleared, - cdp.EventRuntimeExceptionThrown, - cdp.EventRuntimeExceptionRevoked, - cdp.EventRuntimeConsoleAPICalled, cdp.EventRuntimeInspectRequested, } diff --git a/cdp/runtime/runtime.go b/cdp/runtime/runtime.go index a0d3bb2..d60e6ac 100644 --- a/cdp/runtime/runtime.go +++ b/cdp/runtime/runtime.go @@ -19,108 +19,6 @@ import ( cdp "github.com/knq/chromedp/cdp" ) -// EvaluateParams evaluates expression on global object. -type EvaluateParams struct { - Expression string `json:"expression"` // Expression to evaluate. - ObjectGroup string `json:"objectGroup,omitempty"` // Symbolic group name that can be used to release multiple objects. - IncludeCommandLineAPI bool `json:"includeCommandLineAPI,omitempty"` // Determines whether Command Line API should be available during the evaluation. - Silent bool `json:"silent,omitempty"` // In silent mode exceptions thrown during evaluation are not reported and do not pause execution. Overrides setPauseOnException state. - ContextID ExecutionContextID `json:"contextId,omitempty"` // Specifies in which execution context to perform evaluation. If the parameter is omitted the evaluation will be performed in the context of the inspected page. - ReturnByValue bool `json:"returnByValue,omitempty"` // Whether the result is expected to be a JSON object that should be sent by value. - GeneratePreview bool `json:"generatePreview,omitempty"` // Whether preview should be generated for the result. - UserGesture bool `json:"userGesture,omitempty"` // Whether execution should be treated as initiated by user in the UI. - AwaitPromise bool `json:"awaitPromise,omitempty"` // Whether execution should await for resulting value and return once awaited promise is resolved. -} - -// Evaluate evaluates expression on global object. -// -// parameters: -// expression - Expression to evaluate. -func Evaluate(expression string) *EvaluateParams { - return &EvaluateParams{ - Expression: expression, - } -} - -// WithObjectGroup symbolic group name that can be used to release multiple -// objects. -func (p EvaluateParams) WithObjectGroup(objectGroup string) *EvaluateParams { - p.ObjectGroup = objectGroup - return &p -} - -// WithIncludeCommandLineAPI determines whether Command Line API should be -// available during the evaluation. -func (p EvaluateParams) WithIncludeCommandLineAPI(includeCommandLineAPI bool) *EvaluateParams { - p.IncludeCommandLineAPI = includeCommandLineAPI - return &p -} - -// WithSilent in silent mode exceptions thrown during evaluation are not -// reported and do not pause execution. Overrides setPauseOnException state. -func (p EvaluateParams) WithSilent(silent bool) *EvaluateParams { - p.Silent = silent - return &p -} - -// WithContextID specifies in which execution context to perform evaluation. -// If the parameter is omitted the evaluation will be performed in the context -// of the inspected page. -func (p EvaluateParams) WithContextID(contextID ExecutionContextID) *EvaluateParams { - p.ContextID = contextID - return &p -} - -// WithReturnByValue whether the result is expected to be a JSON object that -// should be sent by value. -func (p EvaluateParams) WithReturnByValue(returnByValue bool) *EvaluateParams { - p.ReturnByValue = returnByValue - return &p -} - -// WithGeneratePreview whether preview should be generated for the result. -func (p EvaluateParams) WithGeneratePreview(generatePreview bool) *EvaluateParams { - p.GeneratePreview = generatePreview - return &p -} - -// WithUserGesture whether execution should be treated as initiated by user -// in the UI. -func (p EvaluateParams) WithUserGesture(userGesture bool) *EvaluateParams { - p.UserGesture = userGesture - return &p -} - -// WithAwaitPromise whether execution should await for resulting value and -// return once awaited promise is resolved. -func (p EvaluateParams) WithAwaitPromise(awaitPromise bool) *EvaluateParams { - p.AwaitPromise = awaitPromise - return &p -} - -// EvaluateReturns return values. -type EvaluateReturns struct { - Result *RemoteObject `json:"result,omitempty"` // Evaluation result. - ExceptionDetails *ExceptionDetails `json:"exceptionDetails,omitempty"` // Exception details. -} - -// Do executes Runtime.evaluate against the provided context and -// target handler. -// -// returns: -// result - Evaluation result. -// exceptionDetails - Exception details. -func (p *EvaluateParams) Do(ctxt context.Context, h cdp.Handler) (result *RemoteObject, exceptionDetails *ExceptionDetails, err error) { - // execute - var res EvaluateReturns - err = h.Execute(ctxt, cdp.CommandRuntimeEvaluate, p, &res) - if err != nil { - return nil, nil, err - } - - return res.Result, res.ExceptionDetails, nil -} - // AwaitPromiseParams add handler to promise with given promise object id. type AwaitPromiseParams struct { PromiseObjectID RemoteObjectID `json:"promiseObjectId"` // Identifier of the promise. @@ -287,6 +185,208 @@ func (p *CallFunctionOnParams) Do(ctxt context.Context, h cdp.Handler) (result * return res.Result, res.ExceptionDetails, nil } +// CompileScriptParams compiles expression. +type CompileScriptParams struct { + Expression string `json:"expression"` // Expression to compile. + SourceURL string `json:"sourceURL"` // Source url to be set for the script. + PersistScript bool `json:"persistScript"` // Specifies whether the compiled script should be persisted. + ExecutionContextID ExecutionContextID `json:"executionContextId,omitempty"` // Specifies in which execution context to perform script run. If the parameter is omitted the evaluation will be performed in the context of the inspected page. +} + +// CompileScript compiles expression. +// +// parameters: +// expression - Expression to compile. +// sourceURL - Source url to be set for the script. +// persistScript - Specifies whether the compiled script should be persisted. +func CompileScript(expression string, sourceURL string, persistScript bool) *CompileScriptParams { + return &CompileScriptParams{ + Expression: expression, + SourceURL: sourceURL, + PersistScript: persistScript, + } +} + +// WithExecutionContextID specifies in which execution context to perform +// script run. If the parameter is omitted the evaluation will be performed in +// the context of the inspected page. +func (p CompileScriptParams) WithExecutionContextID(executionContextID ExecutionContextID) *CompileScriptParams { + p.ExecutionContextID = executionContextID + return &p +} + +// CompileScriptReturns return values. +type CompileScriptReturns struct { + ScriptID ScriptID `json:"scriptId,omitempty"` // Id of the script. + ExceptionDetails *ExceptionDetails `json:"exceptionDetails,omitempty"` // Exception details. +} + +// Do executes Runtime.compileScript against the provided context and +// target handler. +// +// returns: +// scriptID - Id of the script. +// exceptionDetails - Exception details. +func (p *CompileScriptParams) Do(ctxt context.Context, h cdp.Handler) (scriptID ScriptID, exceptionDetails *ExceptionDetails, err error) { + // execute + var res CompileScriptReturns + err = h.Execute(ctxt, cdp.CommandRuntimeCompileScript, p, &res) + if err != nil { + return "", nil, err + } + + return res.ScriptID, res.ExceptionDetails, nil +} + +// DisableParams disables reporting of execution contexts creation. +type DisableParams struct{} + +// Disable disables reporting of execution contexts creation. +func Disable() *DisableParams { + return &DisableParams{} +} + +// Do executes Runtime.disable against the provided context and +// target handler. +func (p *DisableParams) Do(ctxt context.Context, h cdp.Handler) (err error) { + return h.Execute(ctxt, cdp.CommandRuntimeDisable, nil, nil) +} + +// DiscardConsoleEntriesParams discards collected exceptions and console API +// calls. +type DiscardConsoleEntriesParams struct{} + +// DiscardConsoleEntries discards collected exceptions and console API calls. +func DiscardConsoleEntries() *DiscardConsoleEntriesParams { + return &DiscardConsoleEntriesParams{} +} + +// Do executes Runtime.discardConsoleEntries against the provided context and +// target handler. +func (p *DiscardConsoleEntriesParams) Do(ctxt context.Context, h cdp.Handler) (err error) { + return h.Execute(ctxt, cdp.CommandRuntimeDiscardConsoleEntries, nil, nil) +} + +// EnableParams enables reporting of execution contexts creation by means of +// executionContextCreated event. When the reporting gets enabled the event will +// be sent immediately for each existing execution context. +type EnableParams struct{} + +// Enable enables reporting of execution contexts creation by means of +// executionContextCreated event. When the reporting gets enabled the event will +// be sent immediately for each existing execution context. +func Enable() *EnableParams { + return &EnableParams{} +} + +// Do executes Runtime.enable against the provided context and +// target handler. +func (p *EnableParams) Do(ctxt context.Context, h cdp.Handler) (err error) { + return h.Execute(ctxt, cdp.CommandRuntimeEnable, nil, nil) +} + +// EvaluateParams evaluates expression on global object. +type EvaluateParams struct { + Expression string `json:"expression"` // Expression to evaluate. + ObjectGroup string `json:"objectGroup,omitempty"` // Symbolic group name that can be used to release multiple objects. + IncludeCommandLineAPI bool `json:"includeCommandLineAPI,omitempty"` // Determines whether Command Line API should be available during the evaluation. + Silent bool `json:"silent,omitempty"` // In silent mode exceptions thrown during evaluation are not reported and do not pause execution. Overrides setPauseOnException state. + ContextID ExecutionContextID `json:"contextId,omitempty"` // Specifies in which execution context to perform evaluation. If the parameter is omitted the evaluation will be performed in the context of the inspected page. + ReturnByValue bool `json:"returnByValue,omitempty"` // Whether the result is expected to be a JSON object that should be sent by value. + GeneratePreview bool `json:"generatePreview,omitempty"` // Whether preview should be generated for the result. + UserGesture bool `json:"userGesture,omitempty"` // Whether execution should be treated as initiated by user in the UI. + AwaitPromise bool `json:"awaitPromise,omitempty"` // Whether execution should await for resulting value and return once awaited promise is resolved. +} + +// Evaluate evaluates expression on global object. +// +// parameters: +// expression - Expression to evaluate. +func Evaluate(expression string) *EvaluateParams { + return &EvaluateParams{ + Expression: expression, + } +} + +// WithObjectGroup symbolic group name that can be used to release multiple +// objects. +func (p EvaluateParams) WithObjectGroup(objectGroup string) *EvaluateParams { + p.ObjectGroup = objectGroup + return &p +} + +// WithIncludeCommandLineAPI determines whether Command Line API should be +// available during the evaluation. +func (p EvaluateParams) WithIncludeCommandLineAPI(includeCommandLineAPI bool) *EvaluateParams { + p.IncludeCommandLineAPI = includeCommandLineAPI + return &p +} + +// WithSilent in silent mode exceptions thrown during evaluation are not +// reported and do not pause execution. Overrides setPauseOnException state. +func (p EvaluateParams) WithSilent(silent bool) *EvaluateParams { + p.Silent = silent + return &p +} + +// WithContextID specifies in which execution context to perform evaluation. +// If the parameter is omitted the evaluation will be performed in the context +// of the inspected page. +func (p EvaluateParams) WithContextID(contextID ExecutionContextID) *EvaluateParams { + p.ContextID = contextID + return &p +} + +// WithReturnByValue whether the result is expected to be a JSON object that +// should be sent by value. +func (p EvaluateParams) WithReturnByValue(returnByValue bool) *EvaluateParams { + p.ReturnByValue = returnByValue + return &p +} + +// WithGeneratePreview whether preview should be generated for the result. +func (p EvaluateParams) WithGeneratePreview(generatePreview bool) *EvaluateParams { + p.GeneratePreview = generatePreview + return &p +} + +// WithUserGesture whether execution should be treated as initiated by user +// in the UI. +func (p EvaluateParams) WithUserGesture(userGesture bool) *EvaluateParams { + p.UserGesture = userGesture + return &p +} + +// WithAwaitPromise whether execution should await for resulting value and +// return once awaited promise is resolved. +func (p EvaluateParams) WithAwaitPromise(awaitPromise bool) *EvaluateParams { + p.AwaitPromise = awaitPromise + return &p +} + +// EvaluateReturns return values. +type EvaluateReturns struct { + Result *RemoteObject `json:"result,omitempty"` // Evaluation result. + ExceptionDetails *ExceptionDetails `json:"exceptionDetails,omitempty"` // Exception details. +} + +// Do executes Runtime.evaluate against the provided context and +// target handler. +// +// returns: +// result - Evaluation result. +// exceptionDetails - Exception details. +func (p *EvaluateParams) Do(ctxt context.Context, h cdp.Handler) (result *RemoteObject, exceptionDetails *ExceptionDetails, err error) { + // execute + var res EvaluateReturns + err = h.Execute(ctxt, cdp.CommandRuntimeEvaluate, p, &res) + if err != nil { + return nil, nil, err + } + + return res.Result, res.ExceptionDetails, nil +} + // GetPropertiesParams returns properties of a given object. Object group of // the result is inherited from the target object. type GetPropertiesParams struct { @@ -352,6 +452,84 @@ func (p *GetPropertiesParams) Do(ctxt context.Context, h cdp.Handler) (result [] return res.Result, res.InternalProperties, res.ExceptionDetails, nil } +// GlobalLexicalScopeNamesParams returns all let, const and class variables +// from global scope. +type GlobalLexicalScopeNamesParams struct { + ExecutionContextID ExecutionContextID `json:"executionContextId,omitempty"` // Specifies in which execution context to lookup global scope variables. +} + +// GlobalLexicalScopeNames returns all let, const and class variables from +// global scope. +// +// parameters: +func GlobalLexicalScopeNames() *GlobalLexicalScopeNamesParams { + return &GlobalLexicalScopeNamesParams{} +} + +// WithExecutionContextID specifies in which execution context to lookup +// global scope variables. +func (p GlobalLexicalScopeNamesParams) WithExecutionContextID(executionContextID ExecutionContextID) *GlobalLexicalScopeNamesParams { + p.ExecutionContextID = executionContextID + return &p +} + +// GlobalLexicalScopeNamesReturns return values. +type GlobalLexicalScopeNamesReturns struct { + Names []string `json:"names,omitempty"` +} + +// Do executes Runtime.globalLexicalScopeNames against the provided context and +// target handler. +// +// returns: +// names +func (p *GlobalLexicalScopeNamesParams) Do(ctxt context.Context, h cdp.Handler) (names []string, err error) { + // execute + var res GlobalLexicalScopeNamesReturns + err = h.Execute(ctxt, cdp.CommandRuntimeGlobalLexicalScopeNames, p, &res) + if err != nil { + return nil, err + } + + return res.Names, nil +} + +// QueryObjectsParams [no description]. +type QueryObjectsParams struct { + PrototypeObjectID RemoteObjectID `json:"prototypeObjectId"` // Identifier of the prototype to return objects for. +} + +// QueryObjects [no description]. +// +// parameters: +// prototypeObjectID - Identifier of the prototype to return objects for. +func QueryObjects(prototypeObjectID RemoteObjectID) *QueryObjectsParams { + return &QueryObjectsParams{ + PrototypeObjectID: prototypeObjectID, + } +} + +// QueryObjectsReturns return values. +type QueryObjectsReturns struct { + Objects *RemoteObject `json:"objects,omitempty"` // Array with objects. +} + +// Do executes Runtime.queryObjects against the provided context and +// target handler. +// +// returns: +// objects - Array with objects. +func (p *QueryObjectsParams) Do(ctxt context.Context, h cdp.Handler) (objects *RemoteObject, err error) { + // execute + var res QueryObjectsReturns + err = h.Execute(ctxt, cdp.CommandRuntimeQueryObjects, p, &res) + if err != nil { + return nil, err + } + + return res.Objects, nil +} + // ReleaseObjectParams releases remote object with given id. type ReleaseObjectParams struct { ObjectID RemoteObjectID `json:"objectId"` // Identifier of the object to release. @@ -412,127 +590,6 @@ func (p *RunIfWaitingForDebuggerParams) Do(ctxt context.Context, h cdp.Handler) return h.Execute(ctxt, cdp.CommandRuntimeRunIfWaitingForDebugger, nil, nil) } -// EnableParams enables reporting of execution contexts creation by means of -// executionContextCreated event. When the reporting gets enabled the event will -// be sent immediately for each existing execution context. -type EnableParams struct{} - -// Enable enables reporting of execution contexts creation by means of -// executionContextCreated event. When the reporting gets enabled the event will -// be sent immediately for each existing execution context. -func Enable() *EnableParams { - return &EnableParams{} -} - -// Do executes Runtime.enable against the provided context and -// target handler. -func (p *EnableParams) Do(ctxt context.Context, h cdp.Handler) (err error) { - return h.Execute(ctxt, cdp.CommandRuntimeEnable, nil, nil) -} - -// DisableParams disables reporting of execution contexts creation. -type DisableParams struct{} - -// Disable disables reporting of execution contexts creation. -func Disable() *DisableParams { - return &DisableParams{} -} - -// Do executes Runtime.disable against the provided context and -// target handler. -func (p *DisableParams) Do(ctxt context.Context, h cdp.Handler) (err error) { - return h.Execute(ctxt, cdp.CommandRuntimeDisable, nil, nil) -} - -// DiscardConsoleEntriesParams discards collected exceptions and console API -// calls. -type DiscardConsoleEntriesParams struct{} - -// DiscardConsoleEntries discards collected exceptions and console API calls. -func DiscardConsoleEntries() *DiscardConsoleEntriesParams { - return &DiscardConsoleEntriesParams{} -} - -// Do executes Runtime.discardConsoleEntries against the provided context and -// target handler. -func (p *DiscardConsoleEntriesParams) Do(ctxt context.Context, h cdp.Handler) (err error) { - return h.Execute(ctxt, cdp.CommandRuntimeDiscardConsoleEntries, nil, nil) -} - -// SetCustomObjectFormatterEnabledParams [no description]. -type SetCustomObjectFormatterEnabledParams struct { - Enabled bool `json:"enabled"` -} - -// SetCustomObjectFormatterEnabled [no description]. -// -// parameters: -// enabled -func SetCustomObjectFormatterEnabled(enabled bool) *SetCustomObjectFormatterEnabledParams { - return &SetCustomObjectFormatterEnabledParams{ - Enabled: enabled, - } -} - -// Do executes Runtime.setCustomObjectFormatterEnabled against the provided context and -// target handler. -func (p *SetCustomObjectFormatterEnabledParams) Do(ctxt context.Context, h cdp.Handler) (err error) { - return h.Execute(ctxt, cdp.CommandRuntimeSetCustomObjectFormatterEnabled, p, nil) -} - -// CompileScriptParams compiles expression. -type CompileScriptParams struct { - Expression string `json:"expression"` // Expression to compile. - SourceURL string `json:"sourceURL"` // Source url to be set for the script. - PersistScript bool `json:"persistScript"` // Specifies whether the compiled script should be persisted. - ExecutionContextID ExecutionContextID `json:"executionContextId,omitempty"` // Specifies in which execution context to perform script run. If the parameter is omitted the evaluation will be performed in the context of the inspected page. -} - -// CompileScript compiles expression. -// -// parameters: -// expression - Expression to compile. -// sourceURL - Source url to be set for the script. -// persistScript - Specifies whether the compiled script should be persisted. -func CompileScript(expression string, sourceURL string, persistScript bool) *CompileScriptParams { - return &CompileScriptParams{ - Expression: expression, - SourceURL: sourceURL, - PersistScript: persistScript, - } -} - -// WithExecutionContextID specifies in which execution context to perform -// script run. If the parameter is omitted the evaluation will be performed in -// the context of the inspected page. -func (p CompileScriptParams) WithExecutionContextID(executionContextID ExecutionContextID) *CompileScriptParams { - p.ExecutionContextID = executionContextID - return &p -} - -// CompileScriptReturns return values. -type CompileScriptReturns struct { - ScriptID ScriptID `json:"scriptId,omitempty"` // Id of the script. - ExceptionDetails *ExceptionDetails `json:"exceptionDetails,omitempty"` // Exception details. -} - -// Do executes Runtime.compileScript against the provided context and -// target handler. -// -// returns: -// scriptID - Id of the script. -// exceptionDetails - Exception details. -func (p *CompileScriptParams) Do(ctxt context.Context, h cdp.Handler) (scriptID ScriptID, exceptionDetails *ExceptionDetails, err error) { - // execute - var res CompileScriptReturns - err = h.Execute(ctxt, cdp.CommandRuntimeCompileScript, p, &res) - if err != nil { - return "", nil, err - } - - return res.ScriptID, res.ExceptionDetails, nil -} - // RunScriptParams runs script with given id in a given context. type RunScriptParams struct { ScriptID ScriptID `json:"scriptId"` // Id of the script to run. @@ -627,80 +684,23 @@ func (p *RunScriptParams) Do(ctxt context.Context, h cdp.Handler) (result *Remot return res.Result, res.ExceptionDetails, nil } -// QueryObjectsParams [no description]. -type QueryObjectsParams struct { - PrototypeObjectID RemoteObjectID `json:"prototypeObjectId"` // Identifier of the prototype to return objects for. +// SetCustomObjectFormatterEnabledParams [no description]. +type SetCustomObjectFormatterEnabledParams struct { + Enabled bool `json:"enabled"` } -// QueryObjects [no description]. +// SetCustomObjectFormatterEnabled [no description]. // // parameters: -// prototypeObjectID - Identifier of the prototype to return objects for. -func QueryObjects(prototypeObjectID RemoteObjectID) *QueryObjectsParams { - return &QueryObjectsParams{ - PrototypeObjectID: prototypeObjectID, +// enabled +func SetCustomObjectFormatterEnabled(enabled bool) *SetCustomObjectFormatterEnabledParams { + return &SetCustomObjectFormatterEnabledParams{ + Enabled: enabled, } } -// QueryObjectsReturns return values. -type QueryObjectsReturns struct { - Objects *RemoteObject `json:"objects,omitempty"` // Array with objects. -} - -// Do executes Runtime.queryObjects against the provided context and +// Do executes Runtime.setCustomObjectFormatterEnabled against the provided context and // target handler. -// -// returns: -// objects - Array with objects. -func (p *QueryObjectsParams) Do(ctxt context.Context, h cdp.Handler) (objects *RemoteObject, err error) { - // execute - var res QueryObjectsReturns - err = h.Execute(ctxt, cdp.CommandRuntimeQueryObjects, p, &res) - if err != nil { - return nil, err - } - - return res.Objects, nil -} - -// GlobalLexicalScopeNamesParams returns all let, const and class variables -// from global scope. -type GlobalLexicalScopeNamesParams struct { - ExecutionContextID ExecutionContextID `json:"executionContextId,omitempty"` // Specifies in which execution context to lookup global scope variables. -} - -// GlobalLexicalScopeNames returns all let, const and class variables from -// global scope. -// -// parameters: -func GlobalLexicalScopeNames() *GlobalLexicalScopeNamesParams { - return &GlobalLexicalScopeNamesParams{} -} - -// WithExecutionContextID specifies in which execution context to lookup -// global scope variables. -func (p GlobalLexicalScopeNamesParams) WithExecutionContextID(executionContextID ExecutionContextID) *GlobalLexicalScopeNamesParams { - p.ExecutionContextID = executionContextID - return &p -} - -// GlobalLexicalScopeNamesReturns return values. -type GlobalLexicalScopeNamesReturns struct { - Names []string `json:"names,omitempty"` -} - -// Do executes Runtime.globalLexicalScopeNames against the provided context and -// target handler. -// -// returns: -// names -func (p *GlobalLexicalScopeNamesParams) Do(ctxt context.Context, h cdp.Handler) (names []string, err error) { - // execute - var res GlobalLexicalScopeNamesReturns - err = h.Execute(ctxt, cdp.CommandRuntimeGlobalLexicalScopeNames, p, &res) - if err != nil { - return nil, err - } - - return res.Names, nil +func (p *SetCustomObjectFormatterEnabledParams) Do(ctxt context.Context, h cdp.Handler) (err error) { + return h.Execute(ctxt, cdp.CommandRuntimeSetCustomObjectFormatterEnabled, p, nil) } diff --git a/cdp/security/easyjson.go b/cdp/security/easyjson.go index 87da723..1bc2d8a 100644 --- a/cdp/security/easyjson.go +++ b/cdp/security/easyjson.go @@ -38,6 +38,8 @@ func easyjsonC5a4559bDecodeGithubComKnqChromedpCdpSecurity(in *jlexer.Lexer, out switch key { case "securityState": (out.SecurityState).UnmarshalEasyJSON(in) + case "title": + out.Title = string(in.String()) case "summary": out.Summary = string(in.String()) case "description": @@ -91,6 +93,16 @@ func easyjsonC5a4559bEncodeGithubComKnqChromedpCdpSecurity(out *jwriter.Writer, } (in.SecurityState).MarshalEasyJSON(out) } + { + const prefix string = ",\"title\":" + if first { + first = false + out.RawString(prefix[1:]) + } else { + out.RawString(prefix) + } + out.String(string(in.Title)) + } { const prefix string = ",\"summary\":" if first { diff --git a/cdp/security/events.go b/cdp/security/events.go index 14c6c31..5f0230d 100644 --- a/cdp/security/events.go +++ b/cdp/security/events.go @@ -6,15 +6,6 @@ import ( cdp "github.com/knq/chromedp/cdp" ) -// EventSecurityStateChanged the security state of the page changed. -type EventSecurityStateChanged struct { - SecurityState State `json:"securityState"` // Security state. - SchemeIsCryptographic bool `json:"schemeIsCryptographic"` // True if the page was loaded over cryptographic transport such as HTTPS. - Explanations []*StateExplanation `json:"explanations"` // List of explanations for the security state. If the overall security state is `insecure` or `warning`, at least one corresponding explanation should be included. - InsecureContentStatus *InsecureContentStatus `json:"insecureContentStatus"` // Information about insecure content on the page. - Summary string `json:"summary,omitempty"` // Overrides user-visible description of the state. -} - // EventCertificateError there is a certificate error. If overriding // certificate errors is enabled, then it should be handled with the // handleCertificateError command. Note: this event does not fire if the @@ -25,8 +16,17 @@ type EventCertificateError struct { RequestURL string `json:"requestURL"` // The url that was requested. } +// EventSecurityStateChanged the security state of the page changed. +type EventSecurityStateChanged struct { + SecurityState State `json:"securityState"` // Security state. + SchemeIsCryptographic bool `json:"schemeIsCryptographic"` // True if the page was loaded over cryptographic transport such as HTTPS. + Explanations []*StateExplanation `json:"explanations"` // List of explanations for the security state. If the overall security state is insecure or warning, at least one corresponding explanation should be included. + InsecureContentStatus *InsecureContentStatus `json:"insecureContentStatus"` // Information about insecure content on the page. + Summary string `json:"summary,omitempty"` // Overrides user-visible description of the state. +} + // EventTypes all event types in the domain. var EventTypes = []cdp.MethodType{ - cdp.EventSecuritySecurityStateChanged, cdp.EventSecurityCertificateError, + cdp.EventSecuritySecurityStateChanged, } diff --git a/cdp/security/security.go b/cdp/security/security.go index bcdf43a..2fcd149 100644 --- a/cdp/security/security.go +++ b/cdp/security/security.go @@ -14,20 +14,6 @@ import ( cdp "github.com/knq/chromedp/cdp" ) -// EnableParams enables tracking security state changes. -type EnableParams struct{} - -// Enable enables tracking security state changes. -func Enable() *EnableParams { - return &EnableParams{} -} - -// Do executes Security.enable against the provided context and -// target handler. -func (p *EnableParams) Do(ctxt context.Context, h cdp.Handler) (err error) { - return h.Execute(ctxt, cdp.CommandSecurityEnable, nil, nil) -} - // DisableParams disables tracking security state changes. type DisableParams struct{} @@ -42,6 +28,20 @@ func (p *DisableParams) Do(ctxt context.Context, h cdp.Handler) (err error) { return h.Execute(ctxt, cdp.CommandSecurityDisable, nil, nil) } +// EnableParams enables tracking security state changes. +type EnableParams struct{} + +// Enable enables tracking security state changes. +func Enable() *EnableParams { + return &EnableParams{} +} + +// Do executes Security.enable against the provided context and +// target handler. +func (p *EnableParams) Do(ctxt context.Context, h cdp.Handler) (err error) { + return h.Execute(ctxt, cdp.CommandSecurityEnable, nil, nil) +} + // HandleCertificateErrorParams handles a certificate error that fired a // certificateError event. type HandleCertificateErrorParams struct { diff --git a/cdp/security/types.go b/cdp/security/types.go index 182e3ba..4c56eb3 100644 --- a/cdp/security/types.go +++ b/cdp/security/types.go @@ -119,6 +119,7 @@ func (t *State) UnmarshalJSON(buf []byte) error { // state. type StateExplanation struct { SecurityState State `json:"securityState"` // Security state representing the severity of the factor being explained. + Title string `json:"title"` // Title describing the type of factor. Summary string `json:"summary"` // Short phrase describing the type of factor. Description string `json:"description"` // Full text explanation of the factor. MixedContentType MixedContentType `json:"mixedContentType"` // The type of mixed content described by the explanation. diff --git a/cdp/serviceworker/events.go b/cdp/serviceworker/events.go index 662a01a..164879c 100644 --- a/cdp/serviceworker/events.go +++ b/cdp/serviceworker/events.go @@ -6,6 +6,11 @@ import ( cdp "github.com/knq/chromedp/cdp" ) +// EventWorkerErrorReported [no description]. +type EventWorkerErrorReported struct { + ErrorMessage *ErrorMessage `json:"errorMessage"` +} + // EventWorkerRegistrationUpdated [no description]. type EventWorkerRegistrationUpdated struct { Registrations []*Registration `json:"registrations"` @@ -16,14 +21,9 @@ type EventWorkerVersionUpdated struct { Versions []*Version `json:"versions"` } -// EventWorkerErrorReported [no description]. -type EventWorkerErrorReported struct { - ErrorMessage *ErrorMessage `json:"errorMessage"` -} - // EventTypes all event types in the domain. var EventTypes = []cdp.MethodType{ + cdp.EventServiceWorkerWorkerErrorReported, cdp.EventServiceWorkerWorkerRegistrationUpdated, cdp.EventServiceWorkerWorkerVersionUpdated, - cdp.EventServiceWorkerWorkerErrorReported, } diff --git a/cdp/serviceworker/serviceworker.go b/cdp/serviceworker/serviceworker.go index a9ccb28..a0fe0c7 100644 --- a/cdp/serviceworker/serviceworker.go +++ b/cdp/serviceworker/serviceworker.go @@ -12,18 +12,31 @@ import ( cdp "github.com/knq/chromedp/cdp" ) -// EnableParams [no description]. -type EnableParams struct{} - -// Enable [no description]. -func Enable() *EnableParams { - return &EnableParams{} +// DeliverPushMessageParams [no description]. +type DeliverPushMessageParams struct { + Origin string `json:"origin"` + RegistrationID string `json:"registrationId"` + Data string `json:"data"` } -// Do executes ServiceWorker.enable against the provided context and +// DeliverPushMessage [no description]. +// +// parameters: +// origin +// registrationID +// data +func DeliverPushMessage(origin string, registrationID string, data string) *DeliverPushMessageParams { + return &DeliverPushMessageParams{ + Origin: origin, + RegistrationID: registrationID, + Data: data, + } +} + +// Do executes ServiceWorker.deliverPushMessage against the provided context and // target handler. -func (p *EnableParams) Do(ctxt context.Context, h cdp.Handler) (err error) { - return h.Execute(ctxt, cdp.CommandServiceWorkerEnable, nil, nil) +func (p *DeliverPushMessageParams) Do(ctxt context.Context, h cdp.Handler) (err error) { + return h.Execute(ctxt, cdp.CommandServiceWorkerDeliverPushMessage, p, nil) } // DisableParams [no description]. @@ -40,123 +53,48 @@ func (p *DisableParams) Do(ctxt context.Context, h cdp.Handler) (err error) { return h.Execute(ctxt, cdp.CommandServiceWorkerDisable, nil, nil) } -// UnregisterParams [no description]. -type UnregisterParams struct { - ScopeURL string `json:"scopeURL"` +// DispatchSyncEventParams [no description]. +type DispatchSyncEventParams struct { + Origin string `json:"origin"` + RegistrationID string `json:"registrationId"` + Tag string `json:"tag"` + LastChance bool `json:"lastChance"` } -// Unregister [no description]. +// DispatchSyncEvent [no description]. // // parameters: -// scopeURL -func Unregister(scopeURL string) *UnregisterParams { - return &UnregisterParams{ - ScopeURL: scopeURL, +// origin +// registrationID +// tag +// lastChance +func DispatchSyncEvent(origin string, registrationID string, tag string, lastChance bool) *DispatchSyncEventParams { + return &DispatchSyncEventParams{ + Origin: origin, + RegistrationID: registrationID, + Tag: tag, + LastChance: lastChance, } } -// Do executes ServiceWorker.unregister against the provided context and +// Do executes ServiceWorker.dispatchSyncEvent against the provided context and // target handler. -func (p *UnregisterParams) Do(ctxt context.Context, h cdp.Handler) (err error) { - return h.Execute(ctxt, cdp.CommandServiceWorkerUnregister, p, nil) +func (p *DispatchSyncEventParams) Do(ctxt context.Context, h cdp.Handler) (err error) { + return h.Execute(ctxt, cdp.CommandServiceWorkerDispatchSyncEvent, p, nil) } -// UpdateRegistrationParams [no description]. -type UpdateRegistrationParams struct { - ScopeURL string `json:"scopeURL"` +// EnableParams [no description]. +type EnableParams struct{} + +// Enable [no description]. +func Enable() *EnableParams { + return &EnableParams{} } -// UpdateRegistration [no description]. -// -// parameters: -// scopeURL -func UpdateRegistration(scopeURL string) *UpdateRegistrationParams { - return &UpdateRegistrationParams{ - ScopeURL: scopeURL, - } -} - -// Do executes ServiceWorker.updateRegistration against the provided context and +// Do executes ServiceWorker.enable against the provided context and // target handler. -func (p *UpdateRegistrationParams) Do(ctxt context.Context, h cdp.Handler) (err error) { - return h.Execute(ctxt, cdp.CommandServiceWorkerUpdateRegistration, p, nil) -} - -// StartWorkerParams [no description]. -type StartWorkerParams struct { - ScopeURL string `json:"scopeURL"` -} - -// StartWorker [no description]. -// -// parameters: -// scopeURL -func StartWorker(scopeURL string) *StartWorkerParams { - return &StartWorkerParams{ - ScopeURL: scopeURL, - } -} - -// Do executes ServiceWorker.startWorker against the provided context and -// target handler. -func (p *StartWorkerParams) Do(ctxt context.Context, h cdp.Handler) (err error) { - return h.Execute(ctxt, cdp.CommandServiceWorkerStartWorker, p, nil) -} - -// SkipWaitingParams [no description]. -type SkipWaitingParams struct { - ScopeURL string `json:"scopeURL"` -} - -// SkipWaiting [no description]. -// -// parameters: -// scopeURL -func SkipWaiting(scopeURL string) *SkipWaitingParams { - return &SkipWaitingParams{ - ScopeURL: scopeURL, - } -} - -// Do executes ServiceWorker.skipWaiting against the provided context and -// target handler. -func (p *SkipWaitingParams) Do(ctxt context.Context, h cdp.Handler) (err error) { - return h.Execute(ctxt, cdp.CommandServiceWorkerSkipWaiting, p, nil) -} - -// StopWorkerParams [no description]. -type StopWorkerParams struct { - VersionID string `json:"versionId"` -} - -// StopWorker [no description]. -// -// parameters: -// versionID -func StopWorker(versionID string) *StopWorkerParams { - return &StopWorkerParams{ - VersionID: versionID, - } -} - -// Do executes ServiceWorker.stopWorker against the provided context and -// target handler. -func (p *StopWorkerParams) Do(ctxt context.Context, h cdp.Handler) (err error) { - return h.Execute(ctxt, cdp.CommandServiceWorkerStopWorker, p, nil) -} - -// StopAllWorkersParams [no description]. -type StopAllWorkersParams struct{} - -// StopAllWorkers [no description]. -func StopAllWorkers() *StopAllWorkersParams { - return &StopAllWorkersParams{} -} - -// Do executes ServiceWorker.stopAllWorkers against the provided context and -// target handler. -func (p *StopAllWorkersParams) Do(ctxt context.Context, h cdp.Handler) (err error) { - return h.Execute(ctxt, cdp.CommandServiceWorkerStopAllWorkers, nil, nil) +func (p *EnableParams) Do(ctxt context.Context, h cdp.Handler) (err error) { + return h.Execute(ctxt, cdp.CommandServiceWorkerEnable, nil, nil) } // InspectWorkerParams [no description]. @@ -201,59 +139,121 @@ func (p *SetForceUpdateOnPageLoadParams) Do(ctxt context.Context, h cdp.Handler) return h.Execute(ctxt, cdp.CommandServiceWorkerSetForceUpdateOnPageLoad, p, nil) } -// DeliverPushMessageParams [no description]. -type DeliverPushMessageParams struct { - Origin string `json:"origin"` - RegistrationID string `json:"registrationId"` - Data string `json:"data"` +// SkipWaitingParams [no description]. +type SkipWaitingParams struct { + ScopeURL string `json:"scopeURL"` } -// DeliverPushMessage [no description]. +// SkipWaiting [no description]. // // parameters: -// origin -// registrationID -// data -func DeliverPushMessage(origin string, registrationID string, data string) *DeliverPushMessageParams { - return &DeliverPushMessageParams{ - Origin: origin, - RegistrationID: registrationID, - Data: data, +// scopeURL +func SkipWaiting(scopeURL string) *SkipWaitingParams { + return &SkipWaitingParams{ + ScopeURL: scopeURL, } } -// Do executes ServiceWorker.deliverPushMessage against the provided context and +// Do executes ServiceWorker.skipWaiting against the provided context and // target handler. -func (p *DeliverPushMessageParams) Do(ctxt context.Context, h cdp.Handler) (err error) { - return h.Execute(ctxt, cdp.CommandServiceWorkerDeliverPushMessage, p, nil) +func (p *SkipWaitingParams) Do(ctxt context.Context, h cdp.Handler) (err error) { + return h.Execute(ctxt, cdp.CommandServiceWorkerSkipWaiting, p, nil) } -// DispatchSyncEventParams [no description]. -type DispatchSyncEventParams struct { - Origin string `json:"origin"` - RegistrationID string `json:"registrationId"` - Tag string `json:"tag"` - LastChance bool `json:"lastChance"` +// StartWorkerParams [no description]. +type StartWorkerParams struct { + ScopeURL string `json:"scopeURL"` } -// DispatchSyncEvent [no description]. +// StartWorker [no description]. // // parameters: -// origin -// registrationID -// tag -// lastChance -func DispatchSyncEvent(origin string, registrationID string, tag string, lastChance bool) *DispatchSyncEventParams { - return &DispatchSyncEventParams{ - Origin: origin, - RegistrationID: registrationID, - Tag: tag, - LastChance: lastChance, +// scopeURL +func StartWorker(scopeURL string) *StartWorkerParams { + return &StartWorkerParams{ + ScopeURL: scopeURL, } } -// Do executes ServiceWorker.dispatchSyncEvent against the provided context and +// Do executes ServiceWorker.startWorker against the provided context and // target handler. -func (p *DispatchSyncEventParams) Do(ctxt context.Context, h cdp.Handler) (err error) { - return h.Execute(ctxt, cdp.CommandServiceWorkerDispatchSyncEvent, p, nil) +func (p *StartWorkerParams) Do(ctxt context.Context, h cdp.Handler) (err error) { + return h.Execute(ctxt, cdp.CommandServiceWorkerStartWorker, p, nil) +} + +// StopAllWorkersParams [no description]. +type StopAllWorkersParams struct{} + +// StopAllWorkers [no description]. +func StopAllWorkers() *StopAllWorkersParams { + return &StopAllWorkersParams{} +} + +// Do executes ServiceWorker.stopAllWorkers against the provided context and +// target handler. +func (p *StopAllWorkersParams) Do(ctxt context.Context, h cdp.Handler) (err error) { + return h.Execute(ctxt, cdp.CommandServiceWorkerStopAllWorkers, nil, nil) +} + +// StopWorkerParams [no description]. +type StopWorkerParams struct { + VersionID string `json:"versionId"` +} + +// StopWorker [no description]. +// +// parameters: +// versionID +func StopWorker(versionID string) *StopWorkerParams { + return &StopWorkerParams{ + VersionID: versionID, + } +} + +// Do executes ServiceWorker.stopWorker against the provided context and +// target handler. +func (p *StopWorkerParams) Do(ctxt context.Context, h cdp.Handler) (err error) { + return h.Execute(ctxt, cdp.CommandServiceWorkerStopWorker, p, nil) +} + +// UnregisterParams [no description]. +type UnregisterParams struct { + ScopeURL string `json:"scopeURL"` +} + +// Unregister [no description]. +// +// parameters: +// scopeURL +func Unregister(scopeURL string) *UnregisterParams { + return &UnregisterParams{ + ScopeURL: scopeURL, + } +} + +// Do executes ServiceWorker.unregister against the provided context and +// target handler. +func (p *UnregisterParams) Do(ctxt context.Context, h cdp.Handler) (err error) { + return h.Execute(ctxt, cdp.CommandServiceWorkerUnregister, p, nil) +} + +// UpdateRegistrationParams [no description]. +type UpdateRegistrationParams struct { + ScopeURL string `json:"scopeURL"` +} + +// UpdateRegistration [no description]. +// +// parameters: +// scopeURL +func UpdateRegistration(scopeURL string) *UpdateRegistrationParams { + return &UpdateRegistrationParams{ + ScopeURL: scopeURL, + } +} + +// Do executes ServiceWorker.updateRegistration against the provided context and +// target handler. +func (p *UpdateRegistrationParams) Do(ctxt context.Context, h cdp.Handler) (err error) { + return h.Execute(ctxt, cdp.CommandServiceWorkerUpdateRegistration, p, nil) } diff --git a/cdp/serviceworker/types.go b/cdp/serviceworker/types.go index 53767b3..450e474 100644 --- a/cdp/serviceworker/types.go +++ b/cdp/serviceworker/types.go @@ -128,7 +128,7 @@ type Version struct { RunningStatus VersionRunningStatus `json:"runningStatus"` Status VersionStatus `json:"status"` ScriptLastModified float64 `json:"scriptLastModified,omitempty"` // The Last-Modified header value of the main script. - ScriptResponseTime float64 `json:"scriptResponseTime,omitempty"` // The time at which the response headers of the main script were received from the server. For cached script it is the last time the cache entry was validated. + ScriptResponseTime float64 `json:"scriptResponseTime,omitempty"` // The time at which the response headers of the main script were received from the server. For cached script it is the last time the cache entry was validated. ControlledClients []target.ID `json:"controlledClients,omitempty"` TargetID target.ID `json:"targetId,omitempty"` } diff --git a/cdp/storage/events.go b/cdp/storage/events.go index d0c1c8c..62b0bbc 100644 --- a/cdp/storage/events.go +++ b/cdp/storage/events.go @@ -6,20 +6,14 @@ import ( cdp "github.com/knq/chromedp/cdp" ) -// EventCacheStorageListUpdated a cache has been added/deleted. -type EventCacheStorageListUpdated struct { - Origin string `json:"origin"` // Origin to update. -} - // EventCacheStorageContentUpdated a cache's contents have been modified. type EventCacheStorageContentUpdated struct { Origin string `json:"origin"` // Origin to update. CacheName string `json:"cacheName"` // Name of cache in origin. } -// EventIndexedDBListUpdated the origin's IndexedDB database list has been -// modified. -type EventIndexedDBListUpdated struct { +// EventCacheStorageListUpdated a cache has been added/deleted. +type EventCacheStorageListUpdated struct { Origin string `json:"origin"` // Origin to update. } @@ -31,10 +25,16 @@ type EventIndexedDBContentUpdated struct { ObjectStoreName string `json:"objectStoreName"` // ObjectStore to update. } +// EventIndexedDBListUpdated the origin's IndexedDB database list has been +// modified. +type EventIndexedDBListUpdated struct { + Origin string `json:"origin"` // Origin to update. +} + // EventTypes all event types in the domain. var EventTypes = []cdp.MethodType{ - cdp.EventStorageCacheStorageListUpdated, cdp.EventStorageCacheStorageContentUpdated, - cdp.EventStorageIndexedDBListUpdated, + cdp.EventStorageCacheStorageListUpdated, cdp.EventStorageIndexedDBContentUpdated, + cdp.EventStorageIndexedDBListUpdated, } diff --git a/cdp/storage/storage.go b/cdp/storage/storage.go index e3994a3..61f2736 100644 --- a/cdp/storage/storage.go +++ b/cdp/storage/storage.go @@ -99,29 +99,6 @@ func (p *TrackCacheStorageForOriginParams) Do(ctxt context.Context, h cdp.Handle return h.Execute(ctxt, cdp.CommandStorageTrackCacheStorageForOrigin, p, nil) } -// UntrackCacheStorageForOriginParams unregisters origin from receiving -// notifications for cache storage. -type UntrackCacheStorageForOriginParams struct { - Origin string `json:"origin"` // Security origin. -} - -// UntrackCacheStorageForOrigin unregisters origin from receiving -// notifications for cache storage. -// -// parameters: -// origin - Security origin. -func UntrackCacheStorageForOrigin(origin string) *UntrackCacheStorageForOriginParams { - return &UntrackCacheStorageForOriginParams{ - Origin: origin, - } -} - -// Do executes Storage.untrackCacheStorageForOrigin against the provided context and -// target handler. -func (p *UntrackCacheStorageForOriginParams) Do(ctxt context.Context, h cdp.Handler) (err error) { - return h.Execute(ctxt, cdp.CommandStorageUntrackCacheStorageForOrigin, p, nil) -} - // TrackIndexedDBForOriginParams registers origin to be notified when an // update occurs to its IndexedDB. type TrackIndexedDBForOriginParams struct { @@ -145,6 +122,29 @@ func (p *TrackIndexedDBForOriginParams) Do(ctxt context.Context, h cdp.Handler) return h.Execute(ctxt, cdp.CommandStorageTrackIndexedDBForOrigin, p, nil) } +// UntrackCacheStorageForOriginParams unregisters origin from receiving +// notifications for cache storage. +type UntrackCacheStorageForOriginParams struct { + Origin string `json:"origin"` // Security origin. +} + +// UntrackCacheStorageForOrigin unregisters origin from receiving +// notifications for cache storage. +// +// parameters: +// origin - Security origin. +func UntrackCacheStorageForOrigin(origin string) *UntrackCacheStorageForOriginParams { + return &UntrackCacheStorageForOriginParams{ + Origin: origin, + } +} + +// Do executes Storage.untrackCacheStorageForOrigin against the provided context and +// target handler. +func (p *UntrackCacheStorageForOriginParams) Do(ctxt context.Context, h cdp.Handler) (err error) { + return h.Execute(ctxt, cdp.CommandStorageUntrackCacheStorageForOrigin, p, nil) +} + // UntrackIndexedDBForOriginParams unregisters origin from receiving // notifications for IndexedDB. type UntrackIndexedDBForOriginParams struct { diff --git a/cdp/target/events.go b/cdp/target/events.go index 434ed31..fa684ca 100644 --- a/cdp/target/events.go +++ b/cdp/target/events.go @@ -6,22 +6,6 @@ import ( cdp "github.com/knq/chromedp/cdp" ) -// EventTargetCreated issued when a possible inspection target is created. -type EventTargetCreated struct { - TargetInfo *Info `json:"targetInfo"` -} - -// EventTargetInfoChanged issued when some information about a target has -// changed. This only happens between targetCreated and targetDestroyed. -type EventTargetInfoChanged struct { - TargetInfo *Info `json:"targetInfo"` -} - -// EventTargetDestroyed issued when a target is destroyed. -type EventTargetDestroyed struct { - TargetID ID `json:"targetId"` -} - // EventAttachedToTarget issued when attached to target because of // auto-attach or attachToTarget command. type EventAttachedToTarget struct { @@ -44,12 +28,28 @@ type EventReceivedMessageFromTarget struct { Message string `json:"message"` } +// EventTargetCreated issued when a possible inspection target is created. +type EventTargetCreated struct { + TargetInfo *Info `json:"targetInfo"` +} + +// EventTargetDestroyed issued when a target is destroyed. +type EventTargetDestroyed struct { + TargetID ID `json:"targetId"` +} + +// EventTargetInfoChanged issued when some information about a target has +// changed. This only happens between targetCreated and targetDestroyed. +type EventTargetInfoChanged struct { + TargetInfo *Info `json:"targetInfo"` +} + // EventTypes all event types in the domain. var EventTypes = []cdp.MethodType{ - cdp.EventTargetTargetCreated, - cdp.EventTargetTargetInfoChanged, - cdp.EventTargetTargetDestroyed, cdp.EventTargetAttachedToTarget, cdp.EventTargetDetachedFromTarget, cdp.EventTargetReceivedMessageFromTarget, + cdp.EventTargetTargetCreated, + cdp.EventTargetTargetDestroyed, + cdp.EventTargetTargetInfoChanged, } diff --git a/cdp/target/target.go b/cdp/target/target.go index a43d91d..fadaeb0 100644 --- a/cdp/target/target.go +++ b/cdp/target/target.go @@ -14,168 +14,6 @@ import ( cdp "github.com/knq/chromedp/cdp" ) -// SetDiscoverTargetsParams controls whether to discover available targets -// and notify via targetCreated/targetInfoChanged/targetDestroyed events. -type SetDiscoverTargetsParams struct { - Discover bool `json:"discover"` // Whether to discover available targets. -} - -// SetDiscoverTargets controls whether to discover available targets and -// notify via targetCreated/targetInfoChanged/targetDestroyed events. -// -// parameters: -// discover - Whether to discover available targets. -func SetDiscoverTargets(discover bool) *SetDiscoverTargetsParams { - return &SetDiscoverTargetsParams{ - Discover: discover, - } -} - -// Do executes Target.setDiscoverTargets against the provided context and -// target handler. -func (p *SetDiscoverTargetsParams) Do(ctxt context.Context, h cdp.Handler) (err error) { - return h.Execute(ctxt, cdp.CommandTargetSetDiscoverTargets, p, nil) -} - -// SetAutoAttachParams controls whether to automatically attach to new -// targets which are considered to be related to this one. When turned on, -// attaches to all existing related targets as well. When turned off, -// automatically detaches from all currently attached targets. -type SetAutoAttachParams struct { - AutoAttach bool `json:"autoAttach"` // Whether to auto-attach to related targets. - WaitForDebuggerOnStart bool `json:"waitForDebuggerOnStart"` // Whether to pause new targets when attaching to them. Use Runtime.runIfWaitingForDebugger to run paused targets. -} - -// SetAutoAttach controls whether to automatically attach to new targets -// which are considered to be related to this one. When turned on, attaches to -// all existing related targets as well. When turned off, automatically detaches -// from all currently attached targets. -// -// parameters: -// autoAttach - Whether to auto-attach to related targets. -// waitForDebuggerOnStart - Whether to pause new targets when attaching to them. Use Runtime.runIfWaitingForDebugger to run paused targets. -func SetAutoAttach(autoAttach bool, waitForDebuggerOnStart bool) *SetAutoAttachParams { - return &SetAutoAttachParams{ - AutoAttach: autoAttach, - WaitForDebuggerOnStart: waitForDebuggerOnStart, - } -} - -// Do executes Target.setAutoAttach against the provided context and -// target handler. -func (p *SetAutoAttachParams) Do(ctxt context.Context, h cdp.Handler) (err error) { - return h.Execute(ctxt, cdp.CommandTargetSetAutoAttach, p, nil) -} - -// SetAttachToFramesParams [no description]. -type SetAttachToFramesParams struct { - Value bool `json:"value"` // Whether to attach to frames. -} - -// SetAttachToFrames [no description]. -// -// parameters: -// value - Whether to attach to frames. -func SetAttachToFrames(value bool) *SetAttachToFramesParams { - return &SetAttachToFramesParams{ - Value: value, - } -} - -// Do executes Target.setAttachToFrames against the provided context and -// target handler. -func (p *SetAttachToFramesParams) Do(ctxt context.Context, h cdp.Handler) (err error) { - return h.Execute(ctxt, cdp.CommandTargetSetAttachToFrames, p, nil) -} - -// SetRemoteLocationsParams enables target discovery for the specified -// locations, when setDiscoverTargets was set to true. -type SetRemoteLocationsParams struct { - Locations []*RemoteLocation `json:"locations"` // List of remote locations. -} - -// SetRemoteLocations enables target discovery for the specified locations, -// when setDiscoverTargets was set to true. -// -// parameters: -// locations - List of remote locations. -func SetRemoteLocations(locations []*RemoteLocation) *SetRemoteLocationsParams { - return &SetRemoteLocationsParams{ - Locations: locations, - } -} - -// Do executes Target.setRemoteLocations against the provided context and -// target handler. -func (p *SetRemoteLocationsParams) Do(ctxt context.Context, h cdp.Handler) (err error) { - return h.Execute(ctxt, cdp.CommandTargetSetRemoteLocations, p, nil) -} - -// SendMessageToTargetParams sends protocol message over session with given -// id. -type SendMessageToTargetParams struct { - Message string `json:"message"` - SessionID SessionID `json:"sessionId,omitempty"` // Identifier of the session. -} - -// SendMessageToTarget sends protocol message over session with given id. -// -// parameters: -// message -func SendMessageToTarget(message string) *SendMessageToTargetParams { - return &SendMessageToTargetParams{ - Message: message, - } -} - -// WithSessionID identifier of the session. -func (p SendMessageToTargetParams) WithSessionID(sessionID SessionID) *SendMessageToTargetParams { - p.SessionID = sessionID - return &p -} - -// Do executes Target.sendMessageToTarget against the provided context and -// target handler. -func (p *SendMessageToTargetParams) Do(ctxt context.Context, h cdp.Handler) (err error) { - return h.Execute(ctxt, cdp.CommandTargetSendMessageToTarget, p, nil) -} - -// GetTargetInfoParams returns information about a target. -type GetTargetInfoParams struct { - TargetID ID `json:"targetId"` -} - -// GetTargetInfo returns information about a target. -// -// parameters: -// targetID -func GetTargetInfo(targetID ID) *GetTargetInfoParams { - return &GetTargetInfoParams{ - TargetID: targetID, - } -} - -// GetTargetInfoReturns return values. -type GetTargetInfoReturns struct { - TargetInfo *Info `json:"targetInfo,omitempty"` -} - -// Do executes Target.getTargetInfo against the provided context and -// target handler. -// -// returns: -// targetInfo -func (p *GetTargetInfoParams) Do(ctxt context.Context, h cdp.Handler) (targetInfo *Info, err error) { - // execute - var res GetTargetInfoReturns - err = h.Execute(ctxt, cdp.CommandTargetGetTargetInfo, p, &res) - if err != nil { - return nil, err - } - - return res.TargetInfo, nil -} - // ActivateTargetParams activates (focuses) the target. type ActivateTargetParams struct { TargetID ID `json:"targetId"` @@ -197,6 +35,42 @@ func (p *ActivateTargetParams) Do(ctxt context.Context, h cdp.Handler) (err erro return h.Execute(ctxt, cdp.CommandTargetActivateTarget, p, nil) } +// AttachToTargetParams attaches to the target with given id. +type AttachToTargetParams struct { + TargetID ID `json:"targetId"` +} + +// AttachToTarget attaches to the target with given id. +// +// parameters: +// targetID +func AttachToTarget(targetID ID) *AttachToTargetParams { + return &AttachToTargetParams{ + TargetID: targetID, + } +} + +// AttachToTargetReturns return values. +type AttachToTargetReturns struct { + SessionID SessionID `json:"sessionId,omitempty"` // Id assigned to the session. +} + +// Do executes Target.attachToTarget against the provided context and +// target handler. +// +// returns: +// sessionID - Id assigned to the session. +func (p *AttachToTargetParams) Do(ctxt context.Context, h cdp.Handler) (sessionID SessionID, err error) { + // execute + var res AttachToTargetReturns + err = h.Execute(ctxt, cdp.CommandTargetAttachToTarget, p, &res) + if err != nil { + return "", err + } + + return res.SessionID, nil +} + // CloseTargetParams closes the target. If the target is a page that gets // closed too. type CloseTargetParams struct { @@ -235,66 +109,6 @@ func (p *CloseTargetParams) Do(ctxt context.Context, h cdp.Handler) (success boo return res.Success, nil } -// AttachToTargetParams attaches to the target with given id. -type AttachToTargetParams struct { - TargetID ID `json:"targetId"` -} - -// AttachToTarget attaches to the target with given id. -// -// parameters: -// targetID -func AttachToTarget(targetID ID) *AttachToTargetParams { - return &AttachToTargetParams{ - TargetID: targetID, - } -} - -// AttachToTargetReturns return values. -type AttachToTargetReturns struct { - SessionID SessionID `json:"sessionId,omitempty"` // Id assigned to the session. -} - -// Do executes Target.attachToTarget against the provided context and -// target handler. -// -// returns: -// sessionID - Id assigned to the session. -func (p *AttachToTargetParams) Do(ctxt context.Context, h cdp.Handler) (sessionID SessionID, err error) { - // execute - var res AttachToTargetReturns - err = h.Execute(ctxt, cdp.CommandTargetAttachToTarget, p, &res) - if err != nil { - return "", err - } - - return res.SessionID, nil -} - -// DetachFromTargetParams detaches session with given id. -type DetachFromTargetParams struct { - SessionID SessionID `json:"sessionId,omitempty"` // Session to detach. -} - -// DetachFromTarget detaches session with given id. -// -// parameters: -func DetachFromTarget() *DetachFromTargetParams { - return &DetachFromTargetParams{} -} - -// WithSessionID session to detach. -func (p DetachFromTargetParams) WithSessionID(sessionID SessionID) *DetachFromTargetParams { - p.SessionID = sessionID - return &p -} - -// Do executes Target.detachFromTarget against the provided context and -// target handler. -func (p *DetachFromTargetParams) Do(ctxt context.Context, h cdp.Handler) (err error) { - return h.Execute(ctxt, cdp.CommandTargetDetachFromTarget, p, nil) -} - // CreateBrowserContextParams creates a new empty BrowserContext. Similar to // an incognito profile but you can have more than one. type CreateBrowserContextParams struct{} @@ -326,44 +140,6 @@ func (p *CreateBrowserContextParams) Do(ctxt context.Context, h cdp.Handler) (br return res.BrowserContextID, nil } -// DisposeBrowserContextParams deletes a BrowserContext, will fail of any -// open page uses it. -type DisposeBrowserContextParams struct { - BrowserContextID BrowserContextID `json:"browserContextId"` -} - -// DisposeBrowserContext deletes a BrowserContext, will fail of any open page -// uses it. -// -// parameters: -// browserContextID -func DisposeBrowserContext(browserContextID BrowserContextID) *DisposeBrowserContextParams { - return &DisposeBrowserContextParams{ - BrowserContextID: browserContextID, - } -} - -// DisposeBrowserContextReturns return values. -type DisposeBrowserContextReturns struct { - Success bool `json:"success,omitempty"` -} - -// Do executes Target.disposeBrowserContext against the provided context and -// target handler. -// -// returns: -// success -func (p *DisposeBrowserContextParams) Do(ctxt context.Context, h cdp.Handler) (success bool, err error) { - // execute - var res DisposeBrowserContextReturns - err = h.Execute(ctxt, cdp.CommandTargetDisposeBrowserContext, p, &res) - if err != nil { - return false, err - } - - return res.Success, nil -} - // CreateTargetParams creates a new page. type CreateTargetParams struct { URL string `json:"url"` // The initial URL the page will be navigated to. @@ -431,6 +207,104 @@ func (p *CreateTargetParams) Do(ctxt context.Context, h cdp.Handler) (targetID I return res.TargetID, nil } +// DetachFromTargetParams detaches session with given id. +type DetachFromTargetParams struct { + SessionID SessionID `json:"sessionId,omitempty"` // Session to detach. +} + +// DetachFromTarget detaches session with given id. +// +// parameters: +func DetachFromTarget() *DetachFromTargetParams { + return &DetachFromTargetParams{} +} + +// WithSessionID session to detach. +func (p DetachFromTargetParams) WithSessionID(sessionID SessionID) *DetachFromTargetParams { + p.SessionID = sessionID + return &p +} + +// Do executes Target.detachFromTarget against the provided context and +// target handler. +func (p *DetachFromTargetParams) Do(ctxt context.Context, h cdp.Handler) (err error) { + return h.Execute(ctxt, cdp.CommandTargetDetachFromTarget, p, nil) +} + +// DisposeBrowserContextParams deletes a BrowserContext, will fail of any +// open page uses it. +type DisposeBrowserContextParams struct { + BrowserContextID BrowserContextID `json:"browserContextId"` +} + +// DisposeBrowserContext deletes a BrowserContext, will fail of any open page +// uses it. +// +// parameters: +// browserContextID +func DisposeBrowserContext(browserContextID BrowserContextID) *DisposeBrowserContextParams { + return &DisposeBrowserContextParams{ + BrowserContextID: browserContextID, + } +} + +// DisposeBrowserContextReturns return values. +type DisposeBrowserContextReturns struct { + Success bool `json:"success,omitempty"` +} + +// Do executes Target.disposeBrowserContext against the provided context and +// target handler. +// +// returns: +// success +func (p *DisposeBrowserContextParams) Do(ctxt context.Context, h cdp.Handler) (success bool, err error) { + // execute + var res DisposeBrowserContextReturns + err = h.Execute(ctxt, cdp.CommandTargetDisposeBrowserContext, p, &res) + if err != nil { + return false, err + } + + return res.Success, nil +} + +// GetTargetInfoParams returns information about a target. +type GetTargetInfoParams struct { + TargetID ID `json:"targetId"` +} + +// GetTargetInfo returns information about a target. +// +// parameters: +// targetID +func GetTargetInfo(targetID ID) *GetTargetInfoParams { + return &GetTargetInfoParams{ + TargetID: targetID, + } +} + +// GetTargetInfoReturns return values. +type GetTargetInfoReturns struct { + TargetInfo *Info `json:"targetInfo,omitempty"` +} + +// Do executes Target.getTargetInfo against the provided context and +// target handler. +// +// returns: +// targetInfo +func (p *GetTargetInfoParams) Do(ctxt context.Context, h cdp.Handler) (targetInfo *Info, err error) { + // execute + var res GetTargetInfoReturns + err = h.Execute(ctxt, cdp.CommandTargetGetTargetInfo, p, &res) + if err != nil { + return nil, err + } + + return res.TargetInfo, nil +} + // GetTargetsParams retrieves a list of available targets. type GetTargetsParams struct{} @@ -459,3 +333,129 @@ func (p *GetTargetsParams) Do(ctxt context.Context, h cdp.Handler) (targetInfos return res.TargetInfos, nil } + +// SendMessageToTargetParams sends protocol message over session with given +// id. +type SendMessageToTargetParams struct { + Message string `json:"message"` + SessionID SessionID `json:"sessionId,omitempty"` // Identifier of the session. +} + +// SendMessageToTarget sends protocol message over session with given id. +// +// parameters: +// message +func SendMessageToTarget(message string) *SendMessageToTargetParams { + return &SendMessageToTargetParams{ + Message: message, + } +} + +// WithSessionID identifier of the session. +func (p SendMessageToTargetParams) WithSessionID(sessionID SessionID) *SendMessageToTargetParams { + p.SessionID = sessionID + return &p +} + +// Do executes Target.sendMessageToTarget against the provided context and +// target handler. +func (p *SendMessageToTargetParams) Do(ctxt context.Context, h cdp.Handler) (err error) { + return h.Execute(ctxt, cdp.CommandTargetSendMessageToTarget, p, nil) +} + +// SetAttachToFramesParams [no description]. +type SetAttachToFramesParams struct { + Value bool `json:"value"` // Whether to attach to frames. +} + +// SetAttachToFrames [no description]. +// +// parameters: +// value - Whether to attach to frames. +func SetAttachToFrames(value bool) *SetAttachToFramesParams { + return &SetAttachToFramesParams{ + Value: value, + } +} + +// Do executes Target.setAttachToFrames against the provided context and +// target handler. +func (p *SetAttachToFramesParams) Do(ctxt context.Context, h cdp.Handler) (err error) { + return h.Execute(ctxt, cdp.CommandTargetSetAttachToFrames, p, nil) +} + +// SetAutoAttachParams controls whether to automatically attach to new +// targets which are considered to be related to this one. When turned on, +// attaches to all existing related targets as well. When turned off, +// automatically detaches from all currently attached targets. +type SetAutoAttachParams struct { + AutoAttach bool `json:"autoAttach"` // Whether to auto-attach to related targets. + WaitForDebuggerOnStart bool `json:"waitForDebuggerOnStart"` // Whether to pause new targets when attaching to them. Use Runtime.runIfWaitingForDebugger to run paused targets. +} + +// SetAutoAttach controls whether to automatically attach to new targets +// which are considered to be related to this one. When turned on, attaches to +// all existing related targets as well. When turned off, automatically detaches +// from all currently attached targets. +// +// parameters: +// autoAttach - Whether to auto-attach to related targets. +// waitForDebuggerOnStart - Whether to pause new targets when attaching to them. Use Runtime.runIfWaitingForDebugger to run paused targets. +func SetAutoAttach(autoAttach bool, waitForDebuggerOnStart bool) *SetAutoAttachParams { + return &SetAutoAttachParams{ + AutoAttach: autoAttach, + WaitForDebuggerOnStart: waitForDebuggerOnStart, + } +} + +// Do executes Target.setAutoAttach against the provided context and +// target handler. +func (p *SetAutoAttachParams) Do(ctxt context.Context, h cdp.Handler) (err error) { + return h.Execute(ctxt, cdp.CommandTargetSetAutoAttach, p, nil) +} + +// SetDiscoverTargetsParams controls whether to discover available targets +// and notify via targetCreated/targetInfoChanged/targetDestroyed events. +type SetDiscoverTargetsParams struct { + Discover bool `json:"discover"` // Whether to discover available targets. +} + +// SetDiscoverTargets controls whether to discover available targets and +// notify via targetCreated/targetInfoChanged/targetDestroyed events. +// +// parameters: +// discover - Whether to discover available targets. +func SetDiscoverTargets(discover bool) *SetDiscoverTargetsParams { + return &SetDiscoverTargetsParams{ + Discover: discover, + } +} + +// Do executes Target.setDiscoverTargets against the provided context and +// target handler. +func (p *SetDiscoverTargetsParams) Do(ctxt context.Context, h cdp.Handler) (err error) { + return h.Execute(ctxt, cdp.CommandTargetSetDiscoverTargets, p, nil) +} + +// SetRemoteLocationsParams enables target discovery for the specified +// locations, when setDiscoverTargets was set to true. +type SetRemoteLocationsParams struct { + Locations []*RemoteLocation `json:"locations"` // List of remote locations. +} + +// SetRemoteLocations enables target discovery for the specified locations, +// when setDiscoverTargets was set to true. +// +// parameters: +// locations - List of remote locations. +func SetRemoteLocations(locations []*RemoteLocation) *SetRemoteLocationsParams { + return &SetRemoteLocationsParams{ + Locations: locations, + } +} + +// Do executes Target.setRemoteLocations against the provided context and +// target handler. +func (p *SetRemoteLocationsParams) Do(ctxt context.Context, h cdp.Handler) (err error) { + return h.Execute(ctxt, cdp.CommandTargetSetRemoteLocations, p, nil) +} diff --git a/cdp/tracing/easyjson.go b/cdp/tracing/easyjson.go index 392287c..36cc1b3 100644 --- a/cdp/tracing/easyjson.go +++ b/cdp/tracing/easyjson.go @@ -294,6 +294,8 @@ func easyjsonC5a4559bDecodeGithubComKnqChromedpCdpTracing1(in *jlexer.Lexer, out out.BufferUsageReportingInterval = float64(in.Float64()) case "transferMode": (out.TransferMode).UnmarshalEasyJSON(in) + case "streamCompression": + (out.StreamCompression).UnmarshalEasyJSON(in) case "traceConfig": if in.IsNull() { in.Skip() @@ -338,6 +340,16 @@ func easyjsonC5a4559bEncodeGithubComKnqChromedpCdpTracing1(out *jwriter.Writer, } (in.TransferMode).MarshalEasyJSON(out) } + if in.StreamCompression != "" { + const prefix string = ",\"streamCompression\":" + if first { + first = false + out.RawString(prefix[1:]) + } else { + out.RawString(prefix) + } + (in.StreamCompression).MarshalEasyJSON(out) + } if in.TraceConfig != nil { const prefix string = ",\"traceConfig\":" if first { @@ -827,6 +839,8 @@ func easyjsonC5a4559bDecodeGithubComKnqChromedpCdpTracing8(in *jlexer.Lexer, out switch key { case "stream": out.Stream = io.StreamHandle(in.String()) + case "streamCompression": + (out.StreamCompression).UnmarshalEasyJSON(in) default: in.SkipRecursive() } @@ -851,6 +865,16 @@ func easyjsonC5a4559bEncodeGithubComKnqChromedpCdpTracing8(out *jwriter.Writer, } out.String(string(in.Stream)) } + if in.StreamCompression != "" { + const prefix string = ",\"streamCompression\":" + if first { + first = false + out.RawString(prefix[1:]) + } else { + out.RawString(prefix) + } + (in.StreamCompression).MarshalEasyJSON(out) + } out.RawByte('}') } diff --git a/cdp/tracing/events.go b/cdp/tracing/events.go index 168c984..d1b998c 100644 --- a/cdp/tracing/events.go +++ b/cdp/tracing/events.go @@ -8,6 +8,13 @@ import ( "github.com/mailru/easyjson" ) +// EventBufferUsage [no description]. +type EventBufferUsage struct { + PercentFull float64 `json:"percentFull,omitempty"` // A number in range [0..1] that indicates the used size of event buffer as a fraction of its total size. + EventCount float64 `json:"eventCount,omitempty"` // An approximate number of events in the trace log. + Value float64 `json:"value,omitempty"` // A number in range [0..1] that indicates the used size of event buffer as a fraction of its total size. +} + // EventDataCollected contains an bucket of collected trace events. When // tracing is stopped collected events will be send as a sequence of // dataCollected events followed by tracingComplete event. @@ -18,19 +25,13 @@ type EventDataCollected struct { // EventTracingComplete signals that tracing is stopped and there is no trace // buffers pending flush, all data were delivered via dataCollected events. type EventTracingComplete struct { - Stream io.StreamHandle `json:"stream,omitempty"` // A handle of the stream that holds resulting trace data. -} - -// EventBufferUsage [no description]. -type EventBufferUsage struct { - PercentFull float64 `json:"percentFull,omitempty"` // A number in range [0..1] that indicates the used size of event buffer as a fraction of its total size. - EventCount float64 `json:"eventCount,omitempty"` // An approximate number of events in the trace log. - Value float64 `json:"value,omitempty"` // A number in range [0..1] that indicates the used size of event buffer as a fraction of its total size. + Stream io.StreamHandle `json:"stream,omitempty"` // A handle of the stream that holds resulting trace data. + StreamCompression StreamCompression `json:"streamCompression,omitempty"` // Compression format of returned stream. } // EventTypes all event types in the domain. var EventTypes = []cdp.MethodType{ + cdp.EventTracingBufferUsage, cdp.EventTracingDataCollected, cdp.EventTracingTracingComplete, - cdp.EventTracingBufferUsage, } diff --git a/cdp/tracing/tracing.go b/cdp/tracing/tracing.go index a6779bc..b4bb696 100644 --- a/cdp/tracing/tracing.go +++ b/cdp/tracing/tracing.go @@ -12,46 +12,6 @@ import ( cdp "github.com/knq/chromedp/cdp" ) -// StartParams start trace events collection. -type StartParams struct { - BufferUsageReportingInterval float64 `json:"bufferUsageReportingInterval,omitempty"` // If set, the agent will issue bufferUsage events at this interval, specified in milliseconds - TransferMode TransferMode `json:"transferMode,omitempty"` // Whether to report trace events as series of dataCollected events or to save trace to a stream (defaults to ReportEvents). - TraceConfig *TraceConfig `json:"traceConfig,omitempty"` -} - -// Start start trace events collection. -// -// parameters: -func Start() *StartParams { - return &StartParams{} -} - -// WithBufferUsageReportingInterval if set, the agent will issue bufferUsage -// events at this interval, specified in milliseconds. -func (p StartParams) WithBufferUsageReportingInterval(bufferUsageReportingInterval float64) *StartParams { - p.BufferUsageReportingInterval = bufferUsageReportingInterval - return &p -} - -// WithTransferMode whether to report trace events as series of dataCollected -// events or to save trace to a stream (defaults to ReportEvents). -func (p StartParams) WithTransferMode(transferMode TransferMode) *StartParams { - p.TransferMode = transferMode - return &p -} - -// WithTraceConfig [no description]. -func (p StartParams) WithTraceConfig(traceConfig *TraceConfig) *StartParams { - p.TraceConfig = traceConfig - return &p -} - -// Do executes Tracing.start against the provided context and -// target handler. -func (p *StartParams) Do(ctxt context.Context, h cdp.Handler) (err error) { - return h.Execute(ctxt, cdp.CommandTracingStart, p, nil) -} - // EndParams stop trace events collection. type EndParams struct{} @@ -95,6 +55,27 @@ func (p *GetCategoriesParams) Do(ctxt context.Context, h cdp.Handler) (categorie return res.Categories, nil } +// RecordClockSyncMarkerParams record a clock sync marker in the trace. +type RecordClockSyncMarkerParams struct { + SyncID string `json:"syncId"` // The ID of this clock sync marker +} + +// RecordClockSyncMarker record a clock sync marker in the trace. +// +// parameters: +// syncID - The ID of this clock sync marker +func RecordClockSyncMarker(syncID string) *RecordClockSyncMarkerParams { + return &RecordClockSyncMarkerParams{ + SyncID: syncID, + } +} + +// Do executes Tracing.recordClockSyncMarker against the provided context and +// target handler. +func (p *RecordClockSyncMarkerParams) Do(ctxt context.Context, h cdp.Handler) (err error) { + return h.Execute(ctxt, cdp.CommandTracingRecordClockSyncMarker, p, nil) +} + // RequestMemoryDumpParams request a global memory dump. type RequestMemoryDumpParams struct{} @@ -126,23 +107,50 @@ func (p *RequestMemoryDumpParams) Do(ctxt context.Context, h cdp.Handler) (dumpG return res.DumpGUID, res.Success, nil } -// RecordClockSyncMarkerParams record a clock sync marker in the trace. -type RecordClockSyncMarkerParams struct { - SyncID string `json:"syncId"` // The ID of this clock sync marker +// StartParams start trace events collection. +type StartParams struct { + BufferUsageReportingInterval float64 `json:"bufferUsageReportingInterval,omitempty"` // If set, the agent will issue bufferUsage events at this interval, specified in milliseconds + TransferMode TransferMode `json:"transferMode,omitempty"` // Whether to report trace events as series of dataCollected events or to save trace to a stream (defaults to ReportEvents). + StreamCompression StreamCompression `json:"streamCompression,omitempty"` // Compression format to use. This only applies when using ReturnAsStream transfer mode (defaults to none) + TraceConfig *TraceConfig `json:"traceConfig,omitempty"` } -// RecordClockSyncMarker record a clock sync marker in the trace. +// Start start trace events collection. // // parameters: -// syncID - The ID of this clock sync marker -func RecordClockSyncMarker(syncID string) *RecordClockSyncMarkerParams { - return &RecordClockSyncMarkerParams{ - SyncID: syncID, - } +func Start() *StartParams { + return &StartParams{} } -// Do executes Tracing.recordClockSyncMarker against the provided context and -// target handler. -func (p *RecordClockSyncMarkerParams) Do(ctxt context.Context, h cdp.Handler) (err error) { - return h.Execute(ctxt, cdp.CommandTracingRecordClockSyncMarker, p, nil) +// WithBufferUsageReportingInterval if set, the agent will issue bufferUsage +// events at this interval, specified in milliseconds. +func (p StartParams) WithBufferUsageReportingInterval(bufferUsageReportingInterval float64) *StartParams { + p.BufferUsageReportingInterval = bufferUsageReportingInterval + return &p +} + +// WithTransferMode whether to report trace events as series of dataCollected +// events or to save trace to a stream (defaults to ReportEvents). +func (p StartParams) WithTransferMode(transferMode TransferMode) *StartParams { + p.TransferMode = transferMode + return &p +} + +// WithStreamCompression compression format to use. This only applies when +// using ReturnAsStream transfer mode (defaults to none). +func (p StartParams) WithStreamCompression(streamCompression StreamCompression) *StartParams { + p.StreamCompression = streamCompression + return &p +} + +// WithTraceConfig [no description]. +func (p StartParams) WithTraceConfig(traceConfig *TraceConfig) *StartParams { + p.TraceConfig = traceConfig + return &p +} + +// Do executes Tracing.start against the provided context and +// target handler. +func (p *StartParams) Do(ctxt context.Context, h cdp.Handler) (err error) { + return h.Execute(ctxt, cdp.CommandTracingStart, p, nil) } diff --git a/cdp/tracing/types.go b/cdp/tracing/types.go index 120a813..0d82f2a 100644 --- a/cdp/tracing/types.go +++ b/cdp/tracing/types.go @@ -26,6 +26,48 @@ type TraceConfig struct { MemoryDumpConfig *MemoryDumpConfig `json:"memoryDumpConfig,omitempty"` // Configuration for memory dump triggers. Used only when "memory-infra" category is enabled. } +// StreamCompression compression type to use for traces returned via streams. +type StreamCompression string + +// String returns the StreamCompression as string value. +func (t StreamCompression) String() string { + return string(t) +} + +// StreamCompression values. +const ( + StreamCompressionNone StreamCompression = "none" + StreamCompressionGzip StreamCompression = "gzip" +) + +// MarshalEasyJSON satisfies easyjson.Marshaler. +func (t StreamCompression) MarshalEasyJSON(out *jwriter.Writer) { + out.String(string(t)) +} + +// MarshalJSON satisfies json.Marshaler. +func (t StreamCompression) MarshalJSON() ([]byte, error) { + return easyjson.Marshal(t) +} + +// UnmarshalEasyJSON satisfies easyjson.Unmarshaler. +func (t *StreamCompression) UnmarshalEasyJSON(in *jlexer.Lexer) { + switch StreamCompression(in.String()) { + case StreamCompressionNone: + *t = StreamCompressionNone + case StreamCompressionGzip: + *t = StreamCompressionGzip + + default: + in.AddError(errors.New("unknown StreamCompression value")) + } +} + +// UnmarshalJSON satisfies json.Unmarshaler. +func (t *StreamCompression) UnmarshalJSON(buf []byte) error { + return easyjson.Unmarshal(buf, t) +} + // RecordMode controls how the trace buffer stores data. type RecordMode string diff --git a/cmd/chromedp-gen/protocol.json b/cmd/chromedp-gen/protocol.json index 916a5cf..3116a9a 100644 --- a/cmd/chromedp-gen/protocol.json +++ b/cmd/chromedp-gen/protocol.json @@ -5,17 +5,6131 @@ }, "domains": [ { - "domain": "Inspector", + "domain": "Accessibility", "experimental": true, - "types": [], + "dependencies": [ + "DOM" + ], + "types": [ + { + "id": "AXNodeId", + "description": "Unique accessibility node identifier.", + "type": "string" + }, + { + "id": "AXValueType", + "description": "Enum of possible property types.", + "type": "string", + "enum": [ + "boolean", + "tristate", + "booleanOrUndefined", + "idref", + "idrefList", + "integer", + "node", + "nodeList", + "number", + "string", + "computedString", + "token", + "tokenList", + "domRelation", + "role", + "internalRole", + "valueUndefined" + ] + }, + { + "id": "AXValueSourceType", + "description": "Enum of possible property sources.", + "type": "string", + "enum": [ + "attribute", + "implicit", + "style", + "contents", + "placeholder", + "relatedElement" + ] + }, + { + "id": "AXValueNativeSourceType", + "description": "Enum of possible native property sources (as a subtype of a particular AXValueSourceType).", + "type": "string", + "enum": [ + "figcaption", + "label", + "labelfor", + "labelwrapped", + "legend", + "tablecaption", + "title", + "other" + ] + }, + { + "id": "AXValueSource", + "description": "A single source for a computed AX property.", + "type": "object", + "properties": [ + { + "name": "type", + "description": "What type of source this is.", + "$ref": "AXValueSourceType" + }, + { + "name": "value", + "description": "The value of this property source.", + "optional": true, + "$ref": "AXValue" + }, + { + "name": "attribute", + "description": "The name of the relevant attribute, if any.", + "optional": true, + "type": "string" + }, + { + "name": "attributeValue", + "description": "The value of the relevant attribute, if any.", + "optional": true, + "$ref": "AXValue" + }, + { + "name": "superseded", + "description": "Whether this source is superseded by a higher priority source.", + "optional": true, + "type": "boolean" + }, + { + "name": "nativeSource", + "description": "The native markup source for this value, e.g. a