// Package headlessexperimental provides the Chrome Debugging Protocol // commands, types, and events for the HeadlessExperimental domain. // // This domain provides experimental commands only supported in headless // mode. // // Generated by the chromedp-gen command. package headlessexperimental // Code generated by chromedp-gen. DO NOT EDIT. import ( "context" "encoding/base64" cdp "github.com/knq/chromedp/cdp" "github.com/knq/chromedp/cdp/runtime" ) // 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. type BeginFrameParams struct { FrameTime *runtime.Timestamp `json:"frameTime,omitempty"` // Timestamp of this BeginFrame (milliseconds since epoch). If not set, the current time will be used. Deadline *runtime.Timestamp `json:"deadline,omitempty"` // Deadline of this BeginFrame (milliseconds since epoch). If not set, the deadline will be calculated from the frameTime and interval. Interval float64 `json:"interval,omitempty"` // The interval between BeginFrames that is reported to the compositor, in milliseconds. Defaults to a 60 frames/second interval, i.e. about 16.666 milliseconds. Screenshot *ScreenshotParams `json:"screenshot,omitempty"` // If set, a screenshot of the frame will be captured and returned in the response. Otherwise, no screenshot will be captured. } // BeginFrame 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. // // parameters: func BeginFrame() *BeginFrameParams { return &BeginFrameParams{} } // WithFrameTime timestamp of this BeginFrame (milliseconds since epoch). If // not set, the current time will be used. func (p BeginFrameParams) WithFrameTime(frameTime *runtime.Timestamp) *BeginFrameParams { p.FrameTime = frameTime return &p } // WithDeadline deadline of this BeginFrame (milliseconds since epoch). If // not set, the deadline will be calculated from the frameTime and interval. func (p BeginFrameParams) WithDeadline(deadline *runtime.Timestamp) *BeginFrameParams { p.Deadline = deadline return &p } // WithInterval the interval between BeginFrames that is reported to the // compositor, in milliseconds. Defaults to a 60 frames/second interval, i.e. // about 16.666 milliseconds. func (p BeginFrameParams) WithInterval(interval float64) *BeginFrameParams { p.Interval = interval return &p } // WithScreenshot if set, a screenshot of the frame will be captured and // returned in the response. Otherwise, no screenshot will be captured. func (p BeginFrameParams) WithScreenshot(screenshot *ScreenshotParams) *BeginFrameParams { p.Screenshot = screenshot return &p } // BeginFrameReturns return values. type BeginFrameReturns struct { HasDamage bool `json:"hasDamage,omitempty"` // Whether the BeginFrame resulted in damage and, thus, a new frame was committed to the display. MainFrameContentUpdated bool `json:"mainFrameContentUpdated,omitempty"` // Whether the main frame submitted a new display frame in response to this BeginFrame. ScreenshotData string `json:"screenshotData,omitempty"` // Base64-encoded image data of the screenshot, if one was requested and successfully taken. } // Do executes HeadlessExperimental.beginFrame against the provided context and // target handler. // // returns: // hasDamage - Whether the BeginFrame resulted in damage and, thus, a new frame was committed to the display. // mainFrameContentUpdated - Whether the main frame submitted a new display frame in response to this BeginFrame. // screenshotData - Base64-encoded image data of the screenshot, if one was requested and successfully taken. func (p *BeginFrameParams) Do(ctxt context.Context, h cdp.Handler) (hasDamage bool, mainFrameContentUpdated bool, screenshotData []byte, err error) { // execute var res BeginFrameReturns err = h.Execute(ctxt, cdp.CommandHeadlessExperimentalBeginFrame, p, &res) if err != nil { return false, false, nil, err } // decode var dec []byte dec, err = base64.StdEncoding.DecodeString(res.ScreenshotData) if err != nil { return false, false, nil, err } 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) }