Initial import

This commit is contained in:
Kenneth Shaw 2017-01-24 22:09:23 +07:00
commit 20d575fece
183 changed files with 107971 additions and 0 deletions

7
.gitignore vendored Normal file
View File

@ -0,0 +1,7 @@
out.txt
out*.txt
old*.txt
# binaries
/chromedp-gen
/cmd/chromedp-gen/chromedp-gen

21
LICENSE Normal file
View File

@ -0,0 +1,21 @@
The MIT License (MIT)
Copyright (c) 2016-2017 Kenneth Shaw
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

29
README.md Normal file
View File

@ -0,0 +1,29 @@
# About chromedp
Package chromedp is a faster, simpler way to drive browsers in Go using the
[Chrome Debugging Protocol](https://developer.chrome.com/devtools/docs/debugger-protocol)
(for Chrome, Edge, Safari, etc) without external dependencies (ie, Selenium, PhantomJS, etc).
**NOTE:** chromedp's API is currently unstable, and may change at a moments
notice. There are likely extremely bad bugs lurking in this code. **CAVEAT USER**.
## Installation
Install in the usual way:
```sh
go get -u github.com/knq/chromedp
```
## Usage
Please see the [examples](examples/) directory for examples.
## TODO
* Move timeouts to context (defaults)
* Implement more query selector options (allow over riding context timeouts)
* Contextual actions for "dry run" (or via an accumulator?)
* Network loader / manager
* More examples
* Profiler
* Unit tests / coverage: travis-ci + coveralls integration

49
actions.go Normal file
View File

@ -0,0 +1,49 @@
package chromedp
import (
"context"
"time"
. "github.com/knq/chromedp/cdp"
)
// Action is a single atomic action.
type Action interface {
Do(context.Context, FrameHandler) error
}
// ActionFunc is a single action func.
type ActionFunc func(context.Context, FrameHandler) error
// Do executes the action using the provided context.
func (f ActionFunc) Do(ctxt context.Context, h FrameHandler) error {
return f(ctxt, h)
}
// Tasks is a list of Actions that can be used as a single Action.
type Tasks []Action
// Do executes the list of Tasks using the provided context.
func (t Tasks) Do(ctxt context.Context, h FrameHandler) error {
var err error
// TODO: put individual task timeouts from context here
for _, a := range t {
// ctxt, cancel = context.WithTimeout(ctxt, timeout)
// defer cancel()
err = a.Do(ctxt, h)
if err != nil {
return err
}
}
return nil
}
// Sleep is an empty action that calls time.Sleep with the specified duration.
func Sleep(d time.Duration) Action {
return ActionFunc(func(context.Context, FrameHandler) error {
time.Sleep(d)
return nil
})
}

View File

@ -0,0 +1,111 @@
// Package accessibility provides the Chrome Debugging Protocol
// commands, types, and events for the Chrome Accessibility domain.
//
// Generated by the chromedp-gen command.
package accessibility
// AUTOGENERATED. DO NOT EDIT.
import (
"context"
. "github.com/knq/chromedp/cdp"
"github.com/mailru/easyjson"
)
var (
_ BackendNode
_ BackendNodeID
_ ComputedProperty
_ ErrorType
_ Frame
_ FrameID
_ LoaderID
_ Message
_ MessageError
_ MethodType
_ Node
_ NodeID
_ NodeType
_ PseudoType
_ RGBA
_ ShadowRootType
_ Timestamp
)
// GetPartialAXTreeParams fetches the accessibility node and partial
// accessibility tree for this DOM node, if it exists.
type GetPartialAXTreeParams struct {
NodeID NodeID `json:"nodeId"` // ID of node to get the partial accessibility tree for.
FetchRelatives bool `json:"fetchRelatives,omitempty"` // Whether to fetch this nodes ancestors, siblings and children. Defaults to true.
}
// GetPartialAXTree fetches the accessibility node and partial accessibility
// tree for this DOM node, if it exists.
//
// parameters:
// nodeId - ID of node to get the partial accessibility tree for.
func GetPartialAXTree(nodeId NodeID) *GetPartialAXTreeParams {
return &GetPartialAXTreeParams{
NodeID: nodeId,
}
}
// WithFetchRelatives whether to fetch this nodes ancestors, siblings and
// children. Defaults to true.
func (p GetPartialAXTreeParams) WithFetchRelatives(fetchRelatives bool) *GetPartialAXTreeParams {
p.FetchRelatives = fetchRelatives
return &p
}
// GetPartialAXTreeReturns return values.
type GetPartialAXTreeReturns struct {
Nodes []*AXNode `json:"nodes,omitempty"` // The Accessibility.AXNode for this DOM node, if it exists, plus its ancestors, siblings and children, if requested.
}
// Do executes Accessibility.getPartialAXTree.
//
// returns:
// nodes - The Accessibility.AXNode for this DOM node, if it exists, plus its ancestors, siblings and children, if requested.
func (p *GetPartialAXTreeParams) Do(ctxt context.Context, h FrameHandler) (nodes []*AXNode, err error) {
if ctxt == nil {
ctxt = context.Background()
}
// marshal
buf, err := easyjson.Marshal(p)
if err != nil {
return nil, err
}
// execute
ch := h.Execute(ctxt, CommandAccessibilityGetPartialAXTree, easyjson.RawMessage(buf))
// read response
select {
case res := <-ch:
if res == nil {
return nil, ErrChannelClosed
}
switch v := res.(type) {
case easyjson.RawMessage:
// unmarshal
var r GetPartialAXTreeReturns
err = easyjson.Unmarshal(v, &r)
if err != nil {
return nil, ErrInvalidResult
}
return r.Nodes, nil
case error:
return nil, v
}
case <-ctxt.Done():
return nil, ErrContextDone
}
return nil, ErrUnknownResult
}

File diff suppressed because it is too large Load Diff

559
cdp/accessibility/types.go Normal file
View File

@ -0,0 +1,559 @@
package accessibility
// AUTOGENERATED. DO NOT EDIT.
import (
"errors"
. "github.com/knq/chromedp/cdp"
"github.com/mailru/easyjson"
"github.com/mailru/easyjson/jlexer"
"github.com/mailru/easyjson/jwriter"
)
var (
_ BackendNode
_ BackendNodeID
_ ComputedProperty
_ ErrorType
_ Frame
_ FrameID
_ LoaderID
_ Message
_ MessageError
_ MethodType
_ Node
_ NodeID
_ NodeType
_ PseudoType
_ RGBA
_ ShadowRootType
_ Timestamp
)
// AXNodeID unique accessibility node identifier.
type AXNodeID string
// String returns the AXNodeID as string value.
func (t AXNodeID) String() string {
return string(t)
}
// AXValueType enum of possible property types.
type AXValueType string
// String returns the AXValueType as string value.
func (t AXValueType) String() string {
return string(t)
}
// AXValueType values.
const (
AXValueTypeBoolean AXValueType = "boolean"
AXValueTypeTristate AXValueType = "tristate"
AXValueTypeBooleanOrUndefined AXValueType = "booleanOrUndefined"
AXValueTypeIdref AXValueType = "idref"
AXValueTypeIdrefList AXValueType = "idrefList"
AXValueTypeInteger AXValueType = "integer"
AXValueTypeNode AXValueType = "node"
AXValueTypeNodeList AXValueType = "nodeList"
AXValueTypeNumber AXValueType = "number"
AXValueTypeString AXValueType = "string"
AXValueTypeComputedString AXValueType = "computedString"
AXValueTypeToken AXValueType = "token"
AXValueTypeTokenList AXValueType = "tokenList"
AXValueTypeDomRelation AXValueType = "domRelation"
AXValueTypeRole AXValueType = "role"
AXValueTypeInternalRole AXValueType = "internalRole"
AXValueTypeValueUndefined AXValueType = "valueUndefined"
)
// MarshalEasyJSON satisfies easyjson.Marshaler.
func (t AXValueType) MarshalEasyJSON(out *jwriter.Writer) {
out.String(string(t))
}
// MarshalJSON satisfies json.Marshaler.
func (t AXValueType) MarshalJSON() ([]byte, error) {
return easyjson.Marshal(t)
}
// UnmarshalEasyJSON satisfies easyjson.Unmarshaler.
func (t *AXValueType) UnmarshalEasyJSON(in *jlexer.Lexer) {
switch AXValueType(in.String()) {
case AXValueTypeBoolean:
*t = AXValueTypeBoolean
case AXValueTypeTristate:
*t = AXValueTypeTristate
case AXValueTypeBooleanOrUndefined:
*t = AXValueTypeBooleanOrUndefined
case AXValueTypeIdref:
*t = AXValueTypeIdref
case AXValueTypeIdrefList:
*t = AXValueTypeIdrefList
case AXValueTypeInteger:
*t = AXValueTypeInteger
case AXValueTypeNode:
*t = AXValueTypeNode
case AXValueTypeNodeList:
*t = AXValueTypeNodeList
case AXValueTypeNumber:
*t = AXValueTypeNumber
case AXValueTypeString:
*t = AXValueTypeString
case AXValueTypeComputedString:
*t = AXValueTypeComputedString
case AXValueTypeToken:
*t = AXValueTypeToken
case AXValueTypeTokenList:
*t = AXValueTypeTokenList
case AXValueTypeDomRelation:
*t = AXValueTypeDomRelation
case AXValueTypeRole:
*t = AXValueTypeRole
case AXValueTypeInternalRole:
*t = AXValueTypeInternalRole
case AXValueTypeValueUndefined:
*t = AXValueTypeValueUndefined
default:
in.AddError(errors.New("unknown AXValueType value"))
}
}
// UnmarshalJSON satisfies json.Unmarshaler.
func (t *AXValueType) UnmarshalJSON(buf []byte) error {
return easyjson.Unmarshal(buf, t)
}
// AXValueSourceType enum of possible property sources.
type AXValueSourceType string
// String returns the AXValueSourceType as string value.
func (t AXValueSourceType) String() string {
return string(t)
}
// AXValueSourceType values.
const (
AXValueSourceTypeAttribute AXValueSourceType = "attribute"
AXValueSourceTypeImplicit AXValueSourceType = "implicit"
AXValueSourceTypeStyle AXValueSourceType = "style"
AXValueSourceTypeContents AXValueSourceType = "contents"
AXValueSourceTypePlaceholder AXValueSourceType = "placeholder"
AXValueSourceTypeRelatedElement AXValueSourceType = "relatedElement"
)
// MarshalEasyJSON satisfies easyjson.Marshaler.
func (t AXValueSourceType) MarshalEasyJSON(out *jwriter.Writer) {
out.String(string(t))
}
// MarshalJSON satisfies json.Marshaler.
func (t AXValueSourceType) MarshalJSON() ([]byte, error) {
return easyjson.Marshal(t)
}
// UnmarshalEasyJSON satisfies easyjson.Unmarshaler.
func (t *AXValueSourceType) UnmarshalEasyJSON(in *jlexer.Lexer) {
switch AXValueSourceType(in.String()) {
case AXValueSourceTypeAttribute:
*t = AXValueSourceTypeAttribute
case AXValueSourceTypeImplicit:
*t = AXValueSourceTypeImplicit
case AXValueSourceTypeStyle:
*t = AXValueSourceTypeStyle
case AXValueSourceTypeContents:
*t = AXValueSourceTypeContents
case AXValueSourceTypePlaceholder:
*t = AXValueSourceTypePlaceholder
case AXValueSourceTypeRelatedElement:
*t = AXValueSourceTypeRelatedElement
default:
in.AddError(errors.New("unknown AXValueSourceType value"))
}
}
// UnmarshalJSON satisfies json.Unmarshaler.
func (t *AXValueSourceType) UnmarshalJSON(buf []byte) error {
return easyjson.Unmarshal(buf, t)
}
// AXValueNativeSourceType enum of possible native property sources (as a
// subtype of a particular AXValueSourceType).
type AXValueNativeSourceType string
// String returns the AXValueNativeSourceType as string value.
func (t AXValueNativeSourceType) String() string {
return string(t)
}
// AXValueNativeSourceType values.
const (
AXValueNativeSourceTypeFigcaption AXValueNativeSourceType = "figcaption"
AXValueNativeSourceTypeLabel AXValueNativeSourceType = "label"
AXValueNativeSourceTypeLabelfor AXValueNativeSourceType = "labelfor"
AXValueNativeSourceTypeLabelwrapped AXValueNativeSourceType = "labelwrapped"
AXValueNativeSourceTypeLegend AXValueNativeSourceType = "legend"
AXValueNativeSourceTypeTablecaption AXValueNativeSourceType = "tablecaption"
AXValueNativeSourceTypeTitle AXValueNativeSourceType = "title"
AXValueNativeSourceTypeOther AXValueNativeSourceType = "other"
)
// MarshalEasyJSON satisfies easyjson.Marshaler.
func (t AXValueNativeSourceType) MarshalEasyJSON(out *jwriter.Writer) {
out.String(string(t))
}
// MarshalJSON satisfies json.Marshaler.
func (t AXValueNativeSourceType) MarshalJSON() ([]byte, error) {
return easyjson.Marshal(t)
}
// UnmarshalEasyJSON satisfies easyjson.Unmarshaler.
func (t *AXValueNativeSourceType) UnmarshalEasyJSON(in *jlexer.Lexer) {
switch AXValueNativeSourceType(in.String()) {
case AXValueNativeSourceTypeFigcaption:
*t = AXValueNativeSourceTypeFigcaption
case AXValueNativeSourceTypeLabel:
*t = AXValueNativeSourceTypeLabel
case AXValueNativeSourceTypeLabelfor:
*t = AXValueNativeSourceTypeLabelfor
case AXValueNativeSourceTypeLabelwrapped:
*t = AXValueNativeSourceTypeLabelwrapped
case AXValueNativeSourceTypeLegend:
*t = AXValueNativeSourceTypeLegend
case AXValueNativeSourceTypeTablecaption:
*t = AXValueNativeSourceTypeTablecaption
case AXValueNativeSourceTypeTitle:
*t = AXValueNativeSourceTypeTitle
case AXValueNativeSourceTypeOther:
*t = AXValueNativeSourceTypeOther
default:
in.AddError(errors.New("unknown AXValueNativeSourceType value"))
}
}
// UnmarshalJSON satisfies json.Unmarshaler.
func (t *AXValueNativeSourceType) UnmarshalJSON(buf []byte) error {
return easyjson.Unmarshal(buf, t)
}
// AXValueSource a single source for a computed AX property.
type AXValueSource struct {
Type AXValueSourceType `json:"type,omitempty"` // What type of source this is.
Value *AXValue `json:"value,omitempty"` // The value of this property source.
Attribute string `json:"attribute,omitempty"` // The name of the relevant attribute, if any.
AttributeValue *AXValue `json:"attributeValue,omitempty"` // The value of the relevant attribute, if any.
Superseded bool `json:"superseded,omitempty"` // Whether this source is superseded by a higher priority source.
NativeSource AXValueNativeSourceType `json:"nativeSource,omitempty"` // The native markup source for this value, e.g. a <label> element.
NativeSourceValue *AXValue `json:"nativeSourceValue,omitempty"` // The value, such as a node or node list, of the native source.
Invalid bool `json:"invalid,omitempty"` // Whether the value for this property is invalid.
InvalidReason string `json:"invalidReason,omitempty"` // Reason for the value being invalid, if it is.
}
type AXRelatedNode struct {
BackendDOMNodeID BackendNodeID `json:"backendDOMNodeId,omitempty"` // The BackendNodeId of the related DOM node.
Idref string `json:"idref,omitempty"` // The IDRef value provided, if any.
Text string `json:"text,omitempty"` // The text alternative of this node in the current context.
}
type AXProperty struct {
Name string `json:"name,omitempty"` // The name of this property.
Value *AXValue `json:"value,omitempty"` // The value of this property.
}
// AXValue a single computed AX property.
type AXValue struct {
Type AXValueType `json:"type,omitempty"` // The type of this value.
Value easyjson.RawMessage `json:"value,omitempty"` // The computed value of this property.
RelatedNodes []*AXRelatedNode `json:"relatedNodes,omitempty"` // One or more related nodes, if applicable.
Sources []*AXValueSource `json:"sources,omitempty"` // The sources which contributed to the computation of this property.
}
// AXGlobalStates states which apply to every AX node.
type AXGlobalStates string
// String returns the AXGlobalStates as string value.
func (t AXGlobalStates) String() string {
return string(t)
}
// AXGlobalStates values.
const (
AXGlobalStatesDisabled AXGlobalStates = "disabled"
AXGlobalStatesHidden AXGlobalStates = "hidden"
AXGlobalStatesHiddenRoot AXGlobalStates = "hiddenRoot"
AXGlobalStatesInvalid AXGlobalStates = "invalid"
)
// MarshalEasyJSON satisfies easyjson.Marshaler.
func (t AXGlobalStates) MarshalEasyJSON(out *jwriter.Writer) {
out.String(string(t))
}
// MarshalJSON satisfies json.Marshaler.
func (t AXGlobalStates) MarshalJSON() ([]byte, error) {
return easyjson.Marshal(t)
}
// UnmarshalEasyJSON satisfies easyjson.Unmarshaler.
func (t *AXGlobalStates) UnmarshalEasyJSON(in *jlexer.Lexer) {
switch AXGlobalStates(in.String()) {
case AXGlobalStatesDisabled:
*t = AXGlobalStatesDisabled
case AXGlobalStatesHidden:
*t = AXGlobalStatesHidden
case AXGlobalStatesHiddenRoot:
*t = AXGlobalStatesHiddenRoot
case AXGlobalStatesInvalid:
*t = AXGlobalStatesInvalid
default:
in.AddError(errors.New("unknown AXGlobalStates value"))
}
}
// UnmarshalJSON satisfies json.Unmarshaler.
func (t *AXGlobalStates) UnmarshalJSON(buf []byte) error {
return easyjson.Unmarshal(buf, t)
}
// AXLiveRegionAttributes attributes which apply to nodes in live regions.
type AXLiveRegionAttributes string
// String returns the AXLiveRegionAttributes as string value.
func (t AXLiveRegionAttributes) String() string {
return string(t)
}
// AXLiveRegionAttributes values.
const (
AXLiveRegionAttributesLive AXLiveRegionAttributes = "live"
AXLiveRegionAttributesAtomic AXLiveRegionAttributes = "atomic"
AXLiveRegionAttributesRelevant AXLiveRegionAttributes = "relevant"
AXLiveRegionAttributesBusy AXLiveRegionAttributes = "busy"
AXLiveRegionAttributesRoot AXLiveRegionAttributes = "root"
)
// MarshalEasyJSON satisfies easyjson.Marshaler.
func (t AXLiveRegionAttributes) MarshalEasyJSON(out *jwriter.Writer) {
out.String(string(t))
}
// MarshalJSON satisfies json.Marshaler.
func (t AXLiveRegionAttributes) MarshalJSON() ([]byte, error) {
return easyjson.Marshal(t)
}
// UnmarshalEasyJSON satisfies easyjson.Unmarshaler.
func (t *AXLiveRegionAttributes) UnmarshalEasyJSON(in *jlexer.Lexer) {
switch AXLiveRegionAttributes(in.String()) {
case AXLiveRegionAttributesLive:
*t = AXLiveRegionAttributesLive
case AXLiveRegionAttributesAtomic:
*t = AXLiveRegionAttributesAtomic
case AXLiveRegionAttributesRelevant:
*t = AXLiveRegionAttributesRelevant
case AXLiveRegionAttributesBusy:
*t = AXLiveRegionAttributesBusy
case AXLiveRegionAttributesRoot:
*t = AXLiveRegionAttributesRoot
default:
in.AddError(errors.New("unknown AXLiveRegionAttributes value"))
}
}
// UnmarshalJSON satisfies json.Unmarshaler.
func (t *AXLiveRegionAttributes) UnmarshalJSON(buf []byte) error {
return easyjson.Unmarshal(buf, t)
}
// AXWidgetAttributes attributes which apply to widgets.
type AXWidgetAttributes string
// String returns the AXWidgetAttributes as string value.
func (t AXWidgetAttributes) String() string {
return string(t)
}
// AXWidgetAttributes values.
const (
AXWidgetAttributesAutocomplete AXWidgetAttributes = "autocomplete"
AXWidgetAttributesHaspopup AXWidgetAttributes = "haspopup"
AXWidgetAttributesLevel AXWidgetAttributes = "level"
AXWidgetAttributesMultiselectable AXWidgetAttributes = "multiselectable"
AXWidgetAttributesOrientation AXWidgetAttributes = "orientation"
AXWidgetAttributesMultiline AXWidgetAttributes = "multiline"
AXWidgetAttributesReadonly AXWidgetAttributes = "readonly"
AXWidgetAttributesRequired AXWidgetAttributes = "required"
AXWidgetAttributesValuemin AXWidgetAttributes = "valuemin"
AXWidgetAttributesValuemax AXWidgetAttributes = "valuemax"
AXWidgetAttributesValuetext AXWidgetAttributes = "valuetext"
)
// MarshalEasyJSON satisfies easyjson.Marshaler.
func (t AXWidgetAttributes) MarshalEasyJSON(out *jwriter.Writer) {
out.String(string(t))
}
// MarshalJSON satisfies json.Marshaler.
func (t AXWidgetAttributes) MarshalJSON() ([]byte, error) {
return easyjson.Marshal(t)
}
// UnmarshalEasyJSON satisfies easyjson.Unmarshaler.
func (t *AXWidgetAttributes) UnmarshalEasyJSON(in *jlexer.Lexer) {
switch AXWidgetAttributes(in.String()) {
case AXWidgetAttributesAutocomplete:
*t = AXWidgetAttributesAutocomplete
case AXWidgetAttributesHaspopup:
*t = AXWidgetAttributesHaspopup
case AXWidgetAttributesLevel:
*t = AXWidgetAttributesLevel
case AXWidgetAttributesMultiselectable:
*t = AXWidgetAttributesMultiselectable
case AXWidgetAttributesOrientation:
*t = AXWidgetAttributesOrientation
case AXWidgetAttributesMultiline:
*t = AXWidgetAttributesMultiline
case AXWidgetAttributesReadonly:
*t = AXWidgetAttributesReadonly
case AXWidgetAttributesRequired:
*t = AXWidgetAttributesRequired
case AXWidgetAttributesValuemin:
*t = AXWidgetAttributesValuemin
case AXWidgetAttributesValuemax:
*t = AXWidgetAttributesValuemax
case AXWidgetAttributesValuetext:
*t = AXWidgetAttributesValuetext
default:
in.AddError(errors.New("unknown AXWidgetAttributes value"))
}
}
// UnmarshalJSON satisfies json.Unmarshaler.
func (t *AXWidgetAttributes) UnmarshalJSON(buf []byte) error {
return easyjson.Unmarshal(buf, t)
}
// AXWidgetStates states which apply to widgets.
type AXWidgetStates string
// String returns the AXWidgetStates as string value.
func (t AXWidgetStates) String() string {
return string(t)
}
// AXWidgetStates values.
const (
AXWidgetStatesChecked AXWidgetStates = "checked"
AXWidgetStatesExpanded AXWidgetStates = "expanded"
AXWidgetStatesPressed AXWidgetStates = "pressed"
AXWidgetStatesSelected AXWidgetStates = "selected"
)
// MarshalEasyJSON satisfies easyjson.Marshaler.
func (t AXWidgetStates) MarshalEasyJSON(out *jwriter.Writer) {
out.String(string(t))
}
// MarshalJSON satisfies json.Marshaler.
func (t AXWidgetStates) MarshalJSON() ([]byte, error) {
return easyjson.Marshal(t)
}
// UnmarshalEasyJSON satisfies easyjson.Unmarshaler.
func (t *AXWidgetStates) UnmarshalEasyJSON(in *jlexer.Lexer) {
switch AXWidgetStates(in.String()) {
case AXWidgetStatesChecked:
*t = AXWidgetStatesChecked
case AXWidgetStatesExpanded:
*t = AXWidgetStatesExpanded
case AXWidgetStatesPressed:
*t = AXWidgetStatesPressed
case AXWidgetStatesSelected:
*t = AXWidgetStatesSelected
default:
in.AddError(errors.New("unknown AXWidgetStates value"))
}
}
// UnmarshalJSON satisfies json.Unmarshaler.
func (t *AXWidgetStates) UnmarshalJSON(buf []byte) error {
return easyjson.Unmarshal(buf, t)
}
// AXRelationshipAttributes relationships between elements other than
// parent/child/sibling.
type AXRelationshipAttributes string
// String returns the AXRelationshipAttributes as string value.
func (t AXRelationshipAttributes) String() string {
return string(t)
}
// AXRelationshipAttributes values.
const (
AXRelationshipAttributesActivedescendant AXRelationshipAttributes = "activedescendant"
AXRelationshipAttributesFlowto AXRelationshipAttributes = "flowto"
AXRelationshipAttributesControls AXRelationshipAttributes = "controls"
AXRelationshipAttributesDescribedby AXRelationshipAttributes = "describedby"
AXRelationshipAttributesLabelledby AXRelationshipAttributes = "labelledby"
AXRelationshipAttributesOwns AXRelationshipAttributes = "owns"
)
// MarshalEasyJSON satisfies easyjson.Marshaler.
func (t AXRelationshipAttributes) MarshalEasyJSON(out *jwriter.Writer) {
out.String(string(t))
}
// MarshalJSON satisfies json.Marshaler.
func (t AXRelationshipAttributes) MarshalJSON() ([]byte, error) {
return easyjson.Marshal(t)
}
// UnmarshalEasyJSON satisfies easyjson.Unmarshaler.
func (t *AXRelationshipAttributes) UnmarshalEasyJSON(in *jlexer.Lexer) {
switch AXRelationshipAttributes(in.String()) {
case AXRelationshipAttributesActivedescendant:
*t = AXRelationshipAttributesActivedescendant
case AXRelationshipAttributesFlowto:
*t = AXRelationshipAttributesFlowto
case AXRelationshipAttributesControls:
*t = AXRelationshipAttributesControls
case AXRelationshipAttributesDescribedby:
*t = AXRelationshipAttributesDescribedby
case AXRelationshipAttributesLabelledby:
*t = AXRelationshipAttributesLabelledby
case AXRelationshipAttributesOwns:
*t = AXRelationshipAttributesOwns
default:
in.AddError(errors.New("unknown AXRelationshipAttributes value"))
}
}
// UnmarshalJSON satisfies json.Unmarshaler.
func (t *AXRelationshipAttributes) UnmarshalJSON(buf []byte) error {
return easyjson.Unmarshal(buf, t)
}
// AXNode a node in the accessibility tree.
type AXNode struct {
NodeID AXNodeID `json:"nodeId,omitempty"` // Unique identifier for this node.
Ignored bool `json:"ignored,omitempty"` // Whether this node is ignored for accessibility
IgnoredReasons []*AXProperty `json:"ignoredReasons,omitempty"` // Collection of reasons why this node is hidden.
Role *AXValue `json:"role,omitempty"` // This Node's role, whether explicit or implicit.
Name *AXValue `json:"name,omitempty"` // The accessible name for this Node.
Description *AXValue `json:"description,omitempty"` // The accessible description for this Node.
Value *AXValue `json:"value,omitempty"` // The value for this Node.
Properties []*AXProperty `json:"properties,omitempty"` // All other properties
ChildIds []AXNodeID `json:"childIds,omitempty"` // IDs for each of this node's child nodes.
BackendDOMNodeID BackendNodeID `json:"backendDOMNodeId,omitempty"` // The backend ID for the associated DOM node, if any.
}

577
cdp/animation/animation.go Normal file
View File

@ -0,0 +1,577 @@
// Package animation provides the Chrome Debugging Protocol
// commands, types, and events for the Chrome Animation domain.
//
// Generated by the chromedp-gen command.
package animation
// AUTOGENERATED. DO NOT EDIT.
import (
"context"
. "github.com/knq/chromedp/cdp"
"github.com/knq/chromedp/cdp/runtime"
"github.com/mailru/easyjson"
)
var (
_ BackendNode
_ BackendNodeID
_ ComputedProperty
_ ErrorType
_ Frame
_ FrameID
_ LoaderID
_ Message
_ MessageError
_ MethodType
_ Node
_ NodeID
_ NodeType
_ PseudoType
_ RGBA
_ ShadowRootType
_ Timestamp
)
// EnableParams enables animation domain notifications.
type EnableParams struct{}
// Enable enables animation domain notifications.
func Enable() *EnableParams {
return &EnableParams{}
}
// Do executes Animation.enable.
func (p *EnableParams) Do(ctxt context.Context, h FrameHandler) (err error) {
if ctxt == nil {
ctxt = context.Background()
}
// execute
ch := h.Execute(ctxt, CommandAnimationEnable, Empty)
// read response
select {
case res := <-ch:
if res == nil {
return ErrChannelClosed
}
switch v := res.(type) {
case easyjson.RawMessage:
return nil
case error:
return v
}
case <-ctxt.Done():
return ErrContextDone
}
return ErrUnknownResult
}
// DisableParams disables animation domain notifications.
type DisableParams struct{}
// Disable disables animation domain notifications.
func Disable() *DisableParams {
return &DisableParams{}
}
// Do executes Animation.disable.
func (p *DisableParams) Do(ctxt context.Context, h FrameHandler) (err error) {
if ctxt == nil {
ctxt = context.Background()
}
// execute
ch := h.Execute(ctxt, CommandAnimationDisable, Empty)
// read response
select {
case res := <-ch:
if res == nil {
return ErrChannelClosed
}
switch v := res.(type) {
case easyjson.RawMessage:
return nil
case error:
return v
}
case <-ctxt.Done():
return ErrContextDone
}
return ErrUnknownResult
}
// 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{}
}
// GetPlaybackRateReturns return values.
type GetPlaybackRateReturns struct {
PlaybackRate float64 `json:"playbackRate,omitempty"` // Playback rate for animations on page.
}
// Do executes Animation.getPlaybackRate.
//
// returns:
// playbackRate - Playback rate for animations on page.
func (p *GetPlaybackRateParams) Do(ctxt context.Context, h FrameHandler) (playbackRate float64, err error) {
if ctxt == nil {
ctxt = context.Background()
}
// execute
ch := h.Execute(ctxt, CommandAnimationGetPlaybackRate, Empty)
// read response
select {
case res := <-ch:
if res == nil {
return 0, ErrChannelClosed
}
switch v := res.(type) {
case easyjson.RawMessage:
// unmarshal
var r GetPlaybackRateReturns
err = easyjson.Unmarshal(v, &r)
if err != nil {
return 0, ErrInvalidResult
}
return r.PlaybackRate, nil
case error:
return 0, v
}
case <-ctxt.Done():
return 0, ErrContextDone
}
return 0, ErrUnknownResult
}
// 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.
func (p *SetPlaybackRateParams) Do(ctxt context.Context, h FrameHandler) (err error) {
if ctxt == nil {
ctxt = context.Background()
}
// marshal
buf, err := easyjson.Marshal(p)
if err != nil {
return err
}
// execute
ch := h.Execute(ctxt, CommandAnimationSetPlaybackRate, easyjson.RawMessage(buf))
// read response
select {
case res := <-ch:
if res == nil {
return ErrChannelClosed
}
switch v := res.(type) {
case easyjson.RawMessage:
return nil
case error:
return v
}
case <-ctxt.Done():
return ErrContextDone
}
return ErrUnknownResult
}
// GetCurrentTimeParams returns the current time of the an animation.
type GetCurrentTimeParams struct {
ID string `json:"id"` // Id of animation.
}
// GetCurrentTime returns the current time of the an animation.
//
// parameters:
// id - Id of animation.
func GetCurrentTime(id string) *GetCurrentTimeParams {
return &GetCurrentTimeParams{
ID: id,
}
}
// GetCurrentTimeReturns return values.
type GetCurrentTimeReturns struct {
CurrentTime float64 `json:"currentTime,omitempty"` // Current time of the page.
}
// Do executes Animation.getCurrentTime.
//
// returns:
// currentTime - Current time of the page.
func (p *GetCurrentTimeParams) Do(ctxt context.Context, h FrameHandler) (currentTime float64, err error) {
if ctxt == nil {
ctxt = context.Background()
}
// marshal
buf, err := easyjson.Marshal(p)
if err != nil {
return 0, err
}
// execute
ch := h.Execute(ctxt, CommandAnimationGetCurrentTime, easyjson.RawMessage(buf))
// read response
select {
case res := <-ch:
if res == nil {
return 0, ErrChannelClosed
}
switch v := res.(type) {
case easyjson.RawMessage:
// unmarshal
var r GetCurrentTimeReturns
err = easyjson.Unmarshal(v, &r)
if err != nil {
return 0, ErrInvalidResult
}
return r.CurrentTime, nil
case error:
return 0, v
}
case <-ctxt.Done():
return 0, ErrContextDone
}
return 0, ErrUnknownResult
}
// 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.
func (p *SetPausedParams) Do(ctxt context.Context, h FrameHandler) (err error) {
if ctxt == nil {
ctxt = context.Background()
}
// marshal
buf, err := easyjson.Marshal(p)
if err != nil {
return err
}
// execute
ch := h.Execute(ctxt, CommandAnimationSetPaused, easyjson.RawMessage(buf))
// read response
select {
case res := <-ch:
if res == nil {
return ErrChannelClosed
}
switch v := res.(type) {
case easyjson.RawMessage:
return nil
case error:
return v
}
case <-ctxt.Done():
return ErrContextDone
}
return ErrUnknownResult
}
// 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.
func (p *SetTimingParams) Do(ctxt context.Context, h FrameHandler) (err error) {
if ctxt == nil {
ctxt = context.Background()
}
// marshal
buf, err := easyjson.Marshal(p)
if err != nil {
return err
}
// execute
ch := h.Execute(ctxt, CommandAnimationSetTiming, easyjson.RawMessage(buf))
// read response
select {
case res := <-ch:
if res == nil {
return ErrChannelClosed
}
switch v := res.(type) {
case easyjson.RawMessage:
return nil
case error:
return v
}
case <-ctxt.Done():
return ErrContextDone
}
return ErrUnknownResult
}
// 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.
func (p *SeekAnimationsParams) Do(ctxt context.Context, h FrameHandler) (err error) {
if ctxt == nil {
ctxt = context.Background()
}
// marshal
buf, err := easyjson.Marshal(p)
if err != nil {
return err
}
// execute
ch := h.Execute(ctxt, CommandAnimationSeekAnimations, easyjson.RawMessage(buf))
// read response
select {
case res := <-ch:
if res == nil {
return ErrChannelClosed
}
switch v := res.(type) {
case easyjson.RawMessage:
return nil
case error:
return v
}
case <-ctxt.Done():
return ErrContextDone
}
return ErrUnknownResult
}
// ReleaseAnimationsParams releases a set of animations to no longer be
// manipulated.
type ReleaseAnimationsParams struct {
Animations []string `json:"animations"` // List of animation ids to seek.
}
// ReleaseAnimations releases a set of animations to no longer be
// manipulated.
//
// parameters:
// animations - List of animation ids to seek.
func ReleaseAnimations(animations []string) *ReleaseAnimationsParams {
return &ReleaseAnimationsParams{
Animations: animations,
}
}
// Do executes Animation.releaseAnimations.
func (p *ReleaseAnimationsParams) Do(ctxt context.Context, h FrameHandler) (err error) {
if ctxt == nil {
ctxt = context.Background()
}
// marshal
buf, err := easyjson.Marshal(p)
if err != nil {
return err
}
// execute
ch := h.Execute(ctxt, CommandAnimationReleaseAnimations, easyjson.RawMessage(buf))
// read response
select {
case res := <-ch:
if res == nil {
return ErrChannelClosed
}
switch v := res.(type) {
case easyjson.RawMessage:
return nil
case error:
return v
}
case <-ctxt.Done():
return ErrContextDone
}
return ErrUnknownResult
}
// ResolveAnimationParams gets the remote object of the Animation.
type ResolveAnimationParams struct {
AnimationID string `json:"animationId"` // Animation id.
}
// ResolveAnimation gets the remote object of the Animation.
//
// parameters:
// animationId - Animation id.
func ResolveAnimation(animationId string) *ResolveAnimationParams {
return &ResolveAnimationParams{
AnimationID: animationId,
}
}
// ResolveAnimationReturns return values.
type ResolveAnimationReturns struct {
RemoteObject *runtime.RemoteObject `json:"remoteObject,omitempty"` // Corresponding remote object.
}
// Do executes Animation.resolveAnimation.
//
// returns:
// remoteObject - Corresponding remote object.
func (p *ResolveAnimationParams) Do(ctxt context.Context, h FrameHandler) (remoteObject *runtime.RemoteObject, err error) {
if ctxt == nil {
ctxt = context.Background()
}
// marshal
buf, err := easyjson.Marshal(p)
if err != nil {
return nil, err
}
// execute
ch := h.Execute(ctxt, CommandAnimationResolveAnimation, easyjson.RawMessage(buf))
// read response
select {
case res := <-ch:
if res == nil {
return nil, ErrChannelClosed
}
switch v := res.(type) {
case easyjson.RawMessage:
// unmarshal
var r ResolveAnimationReturns
err = easyjson.Unmarshal(v, &r)
if err != nil {
return nil, ErrInvalidResult
}
return r.RemoteObject, nil
case error:
return nil, v
}
case <-ctxt.Done():
return nil, ErrContextDone
}
return nil, ErrUnknownResult
}

1760
cdp/animation/easyjson.go Normal file

File diff suppressed because it is too large Load Diff

49
cdp/animation/events.go Normal file
View File

@ -0,0 +1,49 @@
package animation
// AUTOGENERATED. DO NOT EDIT.
import (
. "github.com/knq/chromedp/cdp"
)
var (
_ BackendNode
_ BackendNodeID
_ ComputedProperty
_ ErrorType
_ Frame
_ FrameID
_ LoaderID
_ Message
_ MessageError
_ MethodType
_ Node
_ NodeID
_ NodeType
_ PseudoType
_ RGBA
_ ShadowRootType
_ Timestamp
)
// EventAnimationCreated event for each animation that has been created.
type EventAnimationCreated struct {
ID string `json:"id,omitempty"` // Id of the animation that was created.
}
// EventAnimationStarted event for animation that has been started.
type EventAnimationStarted struct {
Animation *Animation `json:"animation,omitempty"` // Animation that was started.
}
// EventAnimationCanceled event for when an animation has been cancelled.
type EventAnimationCanceled struct {
ID string `json:"id,omitempty"` // Id of the animation that was cancelled.
}
// EventTypes is all event types in the domain.
var EventTypes = []MethodType{
EventAnimationAnimationCreated,
EventAnimationAnimationStarted,
EventAnimationAnimationCanceled,
}

117
cdp/animation/types.go Normal file
View File

@ -0,0 +1,117 @@
package animation
// AUTOGENERATED. DO NOT EDIT.
import (
"errors"
. "github.com/knq/chromedp/cdp"
"github.com/mailru/easyjson"
"github.com/mailru/easyjson/jlexer"
"github.com/mailru/easyjson/jwriter"
)
var (
_ BackendNode
_ BackendNodeID
_ ComputedProperty
_ ErrorType
_ Frame
_ FrameID
_ LoaderID
_ Message
_ MessageError
_ MethodType
_ Node
_ NodeID
_ NodeType
_ PseudoType
_ RGBA
_ ShadowRootType
_ Timestamp
)
// Animation animation instance.
type Animation struct {
ID string `json:"id,omitempty"` // Animation's id.
Name string `json:"name,omitempty"` // Animation's name.
PausedState bool `json:"pausedState,omitempty"` // Animation's internal paused state.
PlayState string `json:"playState,omitempty"` // Animation's play state.
PlaybackRate float64 `json:"playbackRate,omitempty"` // Animation's playback rate.
StartTime float64 `json:"startTime,omitempty"` // Animation's start time.
CurrentTime float64 `json:"currentTime,omitempty"` // Animation's current time.
Source *AnimationEffect `json:"source,omitempty"` // Animation's source animation node.
Type AnimationType `json:"type,omitempty"` // Animation type of Animation.
CSSID string `json:"cssId,omitempty"` // A unique ID for Animation representing the sources that triggered this CSS animation/transition.
}
// AnimationEffect animationEffect instance.
type AnimationEffect struct {
Delay float64 `json:"delay,omitempty"` // AnimationEffect's delay.
EndDelay float64 `json:"endDelay,omitempty"` // AnimationEffect's end delay.
IterationStart float64 `json:"iterationStart,omitempty"` // AnimationEffect's iteration start.
Iterations float64 `json:"iterations,omitempty"` // AnimationEffect's iterations.
Duration float64 `json:"duration,omitempty"` // AnimationEffect's iteration duration.
Direction string `json:"direction,omitempty"` // AnimationEffect's playback direction.
Fill string `json:"fill,omitempty"` // AnimationEffect's fill mode.
BackendNodeID BackendNodeID `json:"backendNodeId,omitempty"` // AnimationEffect's target node.
KeyframesRule *KeyframesRule `json:"keyframesRule,omitempty"` // AnimationEffect's keyframes.
Easing string `json:"easing,omitempty"` // AnimationEffect's timing function.
}
// KeyframesRule keyframes Rule.
type KeyframesRule struct {
Name string `json:"name,omitempty"` // CSS keyframed animation's name.
Keyframes []*KeyframeStyle `json:"keyframes,omitempty"` // List of animation keyframes.
}
// KeyframeStyle keyframe Style.
type KeyframeStyle struct {
Offset string `json:"offset,omitempty"` // Keyframe's time offset.
Easing string `json:"easing,omitempty"` // AnimationEffect's timing function.
}
// AnimationType animation type of Animation.
type AnimationType string
// String returns the AnimationType as string value.
func (t AnimationType) String() string {
return string(t)
}
// AnimationType values.
const (
AnimationTypeCSSTransition AnimationType = "CSSTransition"
AnimationTypeCSSAnimation AnimationType = "CSSAnimation"
AnimationTypeWebAnimation AnimationType = "WebAnimation"
)
// MarshalEasyJSON satisfies easyjson.Marshaler.
func (t AnimationType) MarshalEasyJSON(out *jwriter.Writer) {
out.String(string(t))
}
// MarshalJSON satisfies json.Marshaler.
func (t AnimationType) MarshalJSON() ([]byte, error) {
return easyjson.Marshal(t)
}
// UnmarshalEasyJSON satisfies easyjson.Unmarshaler.
func (t *AnimationType) UnmarshalEasyJSON(in *jlexer.Lexer) {
switch AnimationType(in.String()) {
case AnimationTypeCSSTransition:
*t = AnimationTypeCSSTransition
case AnimationTypeCSSAnimation:
*t = AnimationTypeCSSAnimation
case AnimationTypeWebAnimation:
*t = AnimationTypeWebAnimation
default:
in.AddError(errors.New("unknown AnimationType value"))
}
}
// UnmarshalJSON satisfies json.Unmarshaler.
func (t *AnimationType) UnmarshalJSON(buf []byte) error {
return easyjson.Unmarshal(buf, t)
}

View File

@ -0,0 +1,268 @@
// Package applicationcache provides the Chrome Debugging Protocol
// commands, types, and events for the Chrome ApplicationCache domain.
//
// Generated by the chromedp-gen command.
package applicationcache
// AUTOGENERATED. DO NOT EDIT.
import (
"context"
. "github.com/knq/chromedp/cdp"
"github.com/mailru/easyjson"
)
var (
_ BackendNode
_ BackendNodeID
_ ComputedProperty
_ ErrorType
_ Frame
_ FrameID
_ LoaderID
_ Message
_ MessageError
_ MethodType
_ Node
_ NodeID
_ NodeType
_ PseudoType
_ RGBA
_ ShadowRootType
_ Timestamp
)
// 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.
//
// 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 FrameHandler) (frameIds []*FrameWithManifest, err error) {
if ctxt == nil {
ctxt = context.Background()
}
// execute
ch := h.Execute(ctxt, CommandApplicationCacheGetFramesWithManifests, Empty)
// read response
select {
case res := <-ch:
if res == nil {
return nil, ErrChannelClosed
}
switch v := res.(type) {
case easyjson.RawMessage:
// unmarshal
var r GetFramesWithManifestsReturns
err = easyjson.Unmarshal(v, &r)
if err != nil {
return nil, ErrInvalidResult
}
return r.FrameIds, nil
case error:
return nil, v
}
case <-ctxt.Done():
return nil, ErrContextDone
}
return nil, ErrUnknownResult
}
// EnableParams enables application cache domain notifications.
type EnableParams struct{}
// Enable enables application cache domain notifications.
func Enable() *EnableParams {
return &EnableParams{}
}
// Do executes ApplicationCache.enable.
func (p *EnableParams) Do(ctxt context.Context, h FrameHandler) (err error) {
if ctxt == nil {
ctxt = context.Background()
}
// execute
ch := h.Execute(ctxt, CommandApplicationCacheEnable, Empty)
// read response
select {
case res := <-ch:
if res == nil {
return ErrChannelClosed
}
switch v := res.(type) {
case easyjson.RawMessage:
return nil
case error:
return v
}
case <-ctxt.Done():
return ErrContextDone
}
return ErrUnknownResult
}
// GetManifestForFrameParams returns manifest URL for document in the given
// frame.
type GetManifestForFrameParams struct {
FrameID 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 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.
//
// returns:
// manifestURL - Manifest URL for document in the given frame.
func (p *GetManifestForFrameParams) Do(ctxt context.Context, h FrameHandler) (manifestURL string, err error) {
if ctxt == nil {
ctxt = context.Background()
}
// marshal
buf, err := easyjson.Marshal(p)
if err != nil {
return "", err
}
// execute
ch := h.Execute(ctxt, CommandApplicationCacheGetManifestForFrame, easyjson.RawMessage(buf))
// read response
select {
case res := <-ch:
if res == nil {
return "", ErrChannelClosed
}
switch v := res.(type) {
case easyjson.RawMessage:
// unmarshal
var r GetManifestForFrameReturns
err = easyjson.Unmarshal(v, &r)
if err != nil {
return "", ErrInvalidResult
}
return r.ManifestURL, nil
case error:
return "", v
}
case <-ctxt.Done():
return "", ErrContextDone
}
return "", ErrUnknownResult
}
// GetApplicationCacheForFrameParams returns relevant application cache data
// for the document in given frame.
type GetApplicationCacheForFrameParams struct {
FrameID FrameID `json:"frameId"` // Identifier of the frame containing document whose application cache is retrieved.
}
// GetApplicationCacheForFrame returns relevant application cache data for
// the document in given frame.
//
// parameters:
// frameId - Identifier of the frame containing document whose application cache is retrieved.
func GetApplicationCacheForFrame(frameId FrameID) *GetApplicationCacheForFrameParams {
return &GetApplicationCacheForFrameParams{
FrameID: frameId,
}
}
// GetApplicationCacheForFrameReturns return values.
type GetApplicationCacheForFrameReturns struct {
ApplicationCache *ApplicationCache `json:"applicationCache,omitempty"` // Relevant application cache data for the document in given frame.
}
// Do executes ApplicationCache.getApplicationCacheForFrame.
//
// returns:
// applicationCache - Relevant application cache data for the document in given frame.
func (p *GetApplicationCacheForFrameParams) Do(ctxt context.Context, h FrameHandler) (applicationCache *ApplicationCache, err error) {
if ctxt == nil {
ctxt = context.Background()
}
// marshal
buf, err := easyjson.Marshal(p)
if err != nil {
return nil, err
}
// execute
ch := h.Execute(ctxt, CommandApplicationCacheGetApplicationCacheForFrame, easyjson.RawMessage(buf))
// read response
select {
case res := <-ch:
if res == nil {
return nil, ErrChannelClosed
}
switch v := res.(type) {
case easyjson.RawMessage:
// unmarshal
var r GetApplicationCacheForFrameReturns
err = easyjson.Unmarshal(v, &r)
if err != nil {
return nil, ErrInvalidResult
}
return r.ApplicationCache, nil
case error:
return nil, v
}
case <-ctxt.Done():
return nil, ErrContextDone
}
return nil, ErrUnknownResult
}

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,43 @@
package applicationcache
// AUTOGENERATED. DO NOT EDIT.
import (
. "github.com/knq/chromedp/cdp"
)
var (
_ BackendNode
_ BackendNodeID
_ ComputedProperty
_ ErrorType
_ Frame
_ FrameID
_ LoaderID
_ Message
_ MessageError
_ MethodType
_ Node
_ NodeID
_ NodeType
_ PseudoType
_ RGBA
_ ShadowRootType
_ Timestamp
)
type EventApplicationCacheStatusUpdated struct {
FrameID FrameID `json:"frameId,omitempty"` // Identifier of the frame containing document whose application cache updated status.
ManifestURL string `json:"manifestURL,omitempty"` // Manifest URL.
Status int64 `json:"status,omitempty"` // Updated application cache status.
}
type EventNetworkStateUpdated struct {
IsNowOnline bool `json:"isNowOnline,omitempty"`
}
// EventTypes is all event types in the domain.
var EventTypes = []MethodType{
EventApplicationCacheApplicationCacheStatusUpdated,
EventApplicationCacheNetworkStateUpdated,
}

View File

@ -0,0 +1,50 @@
package applicationcache
// AUTOGENERATED. DO NOT EDIT.
import (
. "github.com/knq/chromedp/cdp"
)
var (
_ BackendNode
_ BackendNodeID
_ ComputedProperty
_ ErrorType
_ Frame
_ FrameID
_ LoaderID
_ Message
_ MessageError
_ MethodType
_ Node
_ NodeID
_ NodeType
_ PseudoType
_ RGBA
_ ShadowRootType
_ Timestamp
)
// ApplicationCacheResource detailed application cache resource information.
type ApplicationCacheResource struct {
URL string `json:"url,omitempty"` // Resource url.
Size int64 `json:"size,omitempty"` // Resource size.
Type string `json:"type,omitempty"` // Resource type.
}
// ApplicationCache detailed application cache information.
type ApplicationCache struct {
ManifestURL string `json:"manifestURL,omitempty"` // Manifest URL.
Size float64 `json:"size,omitempty"` // Application cache size.
CreationTime float64 `json:"creationTime,omitempty"` // Application cache creation time.
UpdateTime float64 `json:"updateTime,omitempty"` // Application cache update time.
Resources []*ApplicationCacheResource `json:"resources,omitempty"` // Application cache resources.
}
// FrameWithManifest frame identifier - manifest URL pair.
type FrameWithManifest struct {
FrameID FrameID `json:"frameId,omitempty"` // Frame identifier.
ManifestURL string `json:"manifestURL,omitempty"` // Manifest URL.
Status int64 `json:"status,omitempty"` // Application cache status.
}

View File

@ -0,0 +1,283 @@
// Package cachestorage provides the Chrome Debugging Protocol
// commands, types, and events for the Chrome CacheStorage domain.
//
// Generated by the chromedp-gen command.
package cachestorage
// AUTOGENERATED. DO NOT EDIT.
import (
"context"
. "github.com/knq/chromedp/cdp"
"github.com/mailru/easyjson"
)
var (
_ BackendNode
_ BackendNodeID
_ ComputedProperty
_ ErrorType
_ Frame
_ FrameID
_ LoaderID
_ Message
_ MessageError
_ MethodType
_ Node
_ NodeID
_ NodeType
_ PseudoType
_ RGBA
_ ShadowRootType
_ Timestamp
)
// 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.
//
// returns:
// caches - Caches for the security origin.
func (p *RequestCacheNamesParams) Do(ctxt context.Context, h FrameHandler) (caches []*Cache, err error) {
if ctxt == nil {
ctxt = context.Background()
}
// marshal
buf, err := easyjson.Marshal(p)
if err != nil {
return nil, err
}
// execute
ch := h.Execute(ctxt, CommandCacheStorageRequestCacheNames, easyjson.RawMessage(buf))
// read response
select {
case res := <-ch:
if res == nil {
return nil, ErrChannelClosed
}
switch v := res.(type) {
case easyjson.RawMessage:
// unmarshal
var r RequestCacheNamesReturns
err = easyjson.Unmarshal(v, &r)
if err != nil {
return nil, ErrInvalidResult
}
return r.Caches, nil
case error:
return nil, v
}
case <-ctxt.Done():
return nil, ErrContextDone
}
return nil, ErrUnknownResult
}
// 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.
//
// 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 FrameHandler) (cacheDataEntries []*DataEntry, hasMore bool, err error) {
if ctxt == nil {
ctxt = context.Background()
}
// marshal
buf, err := easyjson.Marshal(p)
if err != nil {
return nil, false, err
}
// execute
ch := h.Execute(ctxt, CommandCacheStorageRequestEntries, easyjson.RawMessage(buf))
// read response
select {
case res := <-ch:
if res == nil {
return nil, false, ErrChannelClosed
}
switch v := res.(type) {
case easyjson.RawMessage:
// unmarshal
var r RequestEntriesReturns
err = easyjson.Unmarshal(v, &r)
if err != nil {
return nil, false, ErrInvalidResult
}
return r.CacheDataEntries, r.HasMore, nil
case error:
return nil, false, v
}
case <-ctxt.Done():
return nil, false, ErrContextDone
}
return nil, false, ErrUnknownResult
}
// DeleteCacheParams deletes a cache.
type DeleteCacheParams struct {
CacheID CacheID `json:"cacheId"` // Id of cache for deletion.
}
// DeleteCache deletes a cache.
//
// parameters:
// cacheId - Id of cache for deletion.
func DeleteCache(cacheId CacheID) *DeleteCacheParams {
return &DeleteCacheParams{
CacheID: cacheId,
}
}
// Do executes CacheStorage.deleteCache.
func (p *DeleteCacheParams) Do(ctxt context.Context, h FrameHandler) (err error) {
if ctxt == nil {
ctxt = context.Background()
}
// marshal
buf, err := easyjson.Marshal(p)
if err != nil {
return err
}
// execute
ch := h.Execute(ctxt, CommandCacheStorageDeleteCache, easyjson.RawMessage(buf))
// read response
select {
case res := <-ch:
if res == nil {
return ErrChannelClosed
}
switch v := res.(type) {
case easyjson.RawMessage:
return nil
case error:
return v
}
case <-ctxt.Done():
return ErrContextDone
}
return ErrUnknownResult
}
// DeleteEntryParams deletes a cache entry.
type DeleteEntryParams struct {
CacheID CacheID `json:"cacheId"` // Id of cache where the entry will be deleted.
Request string `json:"request"` // URL spec of the request.
}
// DeleteEntry deletes a cache entry.
//
// parameters:
// cacheId - Id of cache where the entry will be deleted.
// request - URL spec of the request.
func DeleteEntry(cacheId CacheID, request string) *DeleteEntryParams {
return &DeleteEntryParams{
CacheID: cacheId,
Request: request,
}
}
// Do executes CacheStorage.deleteEntry.
func (p *DeleteEntryParams) Do(ctxt context.Context, h FrameHandler) (err error) {
if ctxt == nil {
ctxt = context.Background()
}
// marshal
buf, err := easyjson.Marshal(p)
if err != nil {
return err
}
// execute
ch := h.Execute(ctxt, CommandCacheStorageDeleteEntry, easyjson.RawMessage(buf))
// read response
select {
case res := <-ch:
if res == nil {
return ErrChannelClosed
}
switch v := res.(type) {
case easyjson.RawMessage:
return nil
case error:
return v
}
case <-ctxt.Done():
return ErrContextDone
}
return ErrUnknownResult
}

View File

@ -0,0 +1,707 @@
// AUTOGENERATED FILE: easyjson marshaler/unmarshalers.
package cachestorage
import (
json "encoding/json"
easyjson "github.com/mailru/easyjson"
jlexer "github.com/mailru/easyjson/jlexer"
jwriter "github.com/mailru/easyjson/jwriter"
)
// suppress unused package warning
var (
_ *json.RawMessage
_ *jlexer.Lexer
_ *jwriter.Writer
_ easyjson.Marshaler
)
func easyjsonC5a4559bDecodeGithubComKnqChromedpCdpCachestorage(in *jlexer.Lexer, out *RequestEntriesReturns) {
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 "cacheDataEntries":
if in.IsNull() {
in.Skip()
out.CacheDataEntries = nil
} else {
in.Delim('[')
if !in.IsDelim(']') {
out.CacheDataEntries = make([]*DataEntry, 0, 8)
} else {
out.CacheDataEntries = []*DataEntry{}
}
for !in.IsDelim(']') {
var v1 *DataEntry
if in.IsNull() {
in.Skip()
v1 = nil
} else {
if v1 == nil {
v1 = new(DataEntry)
}
(*v1).UnmarshalEasyJSON(in)
}
out.CacheDataEntries = append(out.CacheDataEntries, v1)
in.WantComma()
}
in.Delim(']')
}
case "hasMore":
out.HasMore = bool(in.Bool())
default:
in.SkipRecursive()
}
in.WantComma()
}
in.Delim('}')
if isTopLevel {
in.Consumed()
}
}
func easyjsonC5a4559bEncodeGithubComKnqChromedpCdpCachestorage(out *jwriter.Writer, in RequestEntriesReturns) {
out.RawByte('{')
first := true
_ = first
if len(in.CacheDataEntries) != 0 {
if !first {
out.RawByte(',')
}
first = false
out.RawString("\"cacheDataEntries\":")
if in.CacheDataEntries == nil && (out.Flags&jwriter.NilSliceAsEmpty) == 0 {
out.RawString("null")
} else {
out.RawByte('[')
for v2, v3 := range in.CacheDataEntries {
if v2 > 0 {
out.RawByte(',')
}
if v3 == nil {
out.RawString("null")
} else {
(*v3).MarshalEasyJSON(out)
}
}
out.RawByte(']')
}
}
if in.HasMore {
if !first {
out.RawByte(',')
}
first = false
out.RawString("\"hasMore\":")
out.Bool(bool(in.HasMore))
}
out.RawByte('}')
}
// MarshalJSON supports json.Marshaler interface
func (v RequestEntriesReturns) MarshalJSON() ([]byte, error) {
w := jwriter.Writer{}
easyjsonC5a4559bEncodeGithubComKnqChromedpCdpCachestorage(&w, v)
return w.Buffer.BuildBytes(), w.Error
}
// MarshalEasyJSON supports easyjson.Marshaler interface
func (v RequestEntriesReturns) MarshalEasyJSON(w *jwriter.Writer) {
easyjsonC5a4559bEncodeGithubComKnqChromedpCdpCachestorage(w, v)
}
// UnmarshalJSON supports json.Unmarshaler interface
func (v *RequestEntriesReturns) UnmarshalJSON(data []byte) error {
r := jlexer.Lexer{Data: data}
easyjsonC5a4559bDecodeGithubComKnqChromedpCdpCachestorage(&r, v)
return r.Error()
}
// UnmarshalEasyJSON supports easyjson.Unmarshaler interface
func (v *RequestEntriesReturns) UnmarshalEasyJSON(l *jlexer.Lexer) {
easyjsonC5a4559bDecodeGithubComKnqChromedpCdpCachestorage(l, v)
}
func easyjsonC5a4559bDecodeGithubComKnqChromedpCdpCachestorage1(in *jlexer.Lexer, out *RequestEntriesParams) {
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 "cacheId":
out.CacheID = CacheID(in.String())
case "skipCount":
out.SkipCount = int64(in.Int64())
case "pageSize":
out.PageSize = int64(in.Int64())
default:
in.SkipRecursive()
}
in.WantComma()
}
in.Delim('}')
if isTopLevel {
in.Consumed()
}
}
func easyjsonC5a4559bEncodeGithubComKnqChromedpCdpCachestorage1(out *jwriter.Writer, in RequestEntriesParams) {
out.RawByte('{')
first := true
_ = first
if !first {
out.RawByte(',')
}
first = false
out.RawString("\"cacheId\":")
out.String(string(in.CacheID))
if !first {
out.RawByte(',')
}
first = false
out.RawString("\"skipCount\":")
out.Int64(int64(in.SkipCount))
if !first {
out.RawByte(',')
}
first = false
out.RawString("\"pageSize\":")
out.Int64(int64(in.PageSize))
out.RawByte('}')
}
// MarshalJSON supports json.Marshaler interface
func (v RequestEntriesParams) MarshalJSON() ([]byte, error) {
w := jwriter.Writer{}
easyjsonC5a4559bEncodeGithubComKnqChromedpCdpCachestorage1(&w, v)
return w.Buffer.BuildBytes(), w.Error
}
// MarshalEasyJSON supports easyjson.Marshaler interface
func (v RequestEntriesParams) MarshalEasyJSON(w *jwriter.Writer) {
easyjsonC5a4559bEncodeGithubComKnqChromedpCdpCachestorage1(w, v)
}
// UnmarshalJSON supports json.Unmarshaler interface
func (v *RequestEntriesParams) UnmarshalJSON(data []byte) error {
r := jlexer.Lexer{Data: data}
easyjsonC5a4559bDecodeGithubComKnqChromedpCdpCachestorage1(&r, v)
return r.Error()
}
// UnmarshalEasyJSON supports easyjson.Unmarshaler interface
func (v *RequestEntriesParams) UnmarshalEasyJSON(l *jlexer.Lexer) {
easyjsonC5a4559bDecodeGithubComKnqChromedpCdpCachestorage1(l, v)
}
func easyjsonC5a4559bDecodeGithubComKnqChromedpCdpCachestorage2(in *jlexer.Lexer, out *RequestCacheNamesReturns) {
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 "caches":
if in.IsNull() {
in.Skip()
out.Caches = nil
} else {
in.Delim('[')
if !in.IsDelim(']') {
out.Caches = make([]*Cache, 0, 8)
} else {
out.Caches = []*Cache{}
}
for !in.IsDelim(']') {
var v4 *Cache
if in.IsNull() {
in.Skip()
v4 = nil
} else {
if v4 == nil {
v4 = new(Cache)
}
(*v4).UnmarshalEasyJSON(in)
}
out.Caches = append(out.Caches, v4)
in.WantComma()
}
in.Delim(']')
}
default:
in.SkipRecursive()
}
in.WantComma()
}
in.Delim('}')
if isTopLevel {
in.Consumed()
}
}
func easyjsonC5a4559bEncodeGithubComKnqChromedpCdpCachestorage2(out *jwriter.Writer, in RequestCacheNamesReturns) {
out.RawByte('{')
first := true
_ = first
if len(in.Caches) != 0 {
if !first {
out.RawByte(',')
}
first = false
out.RawString("\"caches\":")
if in.Caches == nil && (out.Flags&jwriter.NilSliceAsEmpty) == 0 {
out.RawString("null")
} else {
out.RawByte('[')
for v5, v6 := range in.Caches {
if v5 > 0 {
out.RawByte(',')
}
if v6 == nil {
out.RawString("null")
} else {
(*v6).MarshalEasyJSON(out)
}
}
out.RawByte(']')
}
}
out.RawByte('}')
}
// MarshalJSON supports json.Marshaler interface
func (v RequestCacheNamesReturns) MarshalJSON() ([]byte, error) {
w := jwriter.Writer{}
easyjsonC5a4559bEncodeGithubComKnqChromedpCdpCachestorage2(&w, v)
return w.Buffer.BuildBytes(), w.Error
}
// MarshalEasyJSON supports easyjson.Marshaler interface
func (v RequestCacheNamesReturns) MarshalEasyJSON(w *jwriter.Writer) {
easyjsonC5a4559bEncodeGithubComKnqChromedpCdpCachestorage2(w, v)
}
// UnmarshalJSON supports json.Unmarshaler interface
func (v *RequestCacheNamesReturns) UnmarshalJSON(data []byte) error {
r := jlexer.Lexer{Data: data}
easyjsonC5a4559bDecodeGithubComKnqChromedpCdpCachestorage2(&r, v)
return r.Error()
}
// UnmarshalEasyJSON supports easyjson.Unmarshaler interface
func (v *RequestCacheNamesReturns) UnmarshalEasyJSON(l *jlexer.Lexer) {
easyjsonC5a4559bDecodeGithubComKnqChromedpCdpCachestorage2(l, v)
}
func easyjsonC5a4559bDecodeGithubComKnqChromedpCdpCachestorage3(in *jlexer.Lexer, out *RequestCacheNamesParams) {
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())
default:
in.SkipRecursive()
}
in.WantComma()
}
in.Delim('}')
if isTopLevel {
in.Consumed()
}
}
func easyjsonC5a4559bEncodeGithubComKnqChromedpCdpCachestorage3(out *jwriter.Writer, in RequestCacheNamesParams) {
out.RawByte('{')
first := true
_ = first
if !first {
out.RawByte(',')
}
first = false
out.RawString("\"securityOrigin\":")
out.String(string(in.SecurityOrigin))
out.RawByte('}')
}
// MarshalJSON supports json.Marshaler interface
func (v RequestCacheNamesParams) MarshalJSON() ([]byte, error) {
w := jwriter.Writer{}
easyjsonC5a4559bEncodeGithubComKnqChromedpCdpCachestorage3(&w, v)
return w.Buffer.BuildBytes(), w.Error
}
// MarshalEasyJSON supports easyjson.Marshaler interface
func (v RequestCacheNamesParams) MarshalEasyJSON(w *jwriter.Writer) {
easyjsonC5a4559bEncodeGithubComKnqChromedpCdpCachestorage3(w, v)
}
// UnmarshalJSON supports json.Unmarshaler interface
func (v *RequestCacheNamesParams) UnmarshalJSON(data []byte) error {
r := jlexer.Lexer{Data: data}
easyjsonC5a4559bDecodeGithubComKnqChromedpCdpCachestorage3(&r, v)
return r.Error()
}
// UnmarshalEasyJSON supports easyjson.Unmarshaler interface
func (v *RequestCacheNamesParams) UnmarshalEasyJSON(l *jlexer.Lexer) {
easyjsonC5a4559bDecodeGithubComKnqChromedpCdpCachestorage3(l, v)
}
func easyjsonC5a4559bDecodeGithubComKnqChromedpCdpCachestorage4(in *jlexer.Lexer, out *DeleteEntryParams) {
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 "cacheId":
out.CacheID = CacheID(in.String())
case "request":
out.Request = string(in.String())
default:
in.SkipRecursive()
}
in.WantComma()
}
in.Delim('}')
if isTopLevel {
in.Consumed()
}
}
func easyjsonC5a4559bEncodeGithubComKnqChromedpCdpCachestorage4(out *jwriter.Writer, in DeleteEntryParams) {
out.RawByte('{')
first := true
_ = first
if !first {
out.RawByte(',')
}
first = false
out.RawString("\"cacheId\":")
out.String(string(in.CacheID))
if !first {
out.RawByte(',')
}
first = false
out.RawString("\"request\":")
out.String(string(in.Request))
out.RawByte('}')
}
// MarshalJSON supports json.Marshaler interface
func (v DeleteEntryParams) MarshalJSON() ([]byte, error) {
w := jwriter.Writer{}
easyjsonC5a4559bEncodeGithubComKnqChromedpCdpCachestorage4(&w, v)
return w.Buffer.BuildBytes(), w.Error
}
// MarshalEasyJSON supports easyjson.Marshaler interface
func (v DeleteEntryParams) MarshalEasyJSON(w *jwriter.Writer) {
easyjsonC5a4559bEncodeGithubComKnqChromedpCdpCachestorage4(w, v)
}
// UnmarshalJSON supports json.Unmarshaler interface
func (v *DeleteEntryParams) UnmarshalJSON(data []byte) error {
r := jlexer.Lexer{Data: data}
easyjsonC5a4559bDecodeGithubComKnqChromedpCdpCachestorage4(&r, v)
return r.Error()
}
// UnmarshalEasyJSON supports easyjson.Unmarshaler interface
func (v *DeleteEntryParams) UnmarshalEasyJSON(l *jlexer.Lexer) {
easyjsonC5a4559bDecodeGithubComKnqChromedpCdpCachestorage4(l, v)
}
func easyjsonC5a4559bDecodeGithubComKnqChromedpCdpCachestorage5(in *jlexer.Lexer, out *DeleteCacheParams) {
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 "cacheId":
out.CacheID = CacheID(in.String())
default:
in.SkipRecursive()
}
in.WantComma()
}
in.Delim('}')
if isTopLevel {
in.Consumed()
}
}
func easyjsonC5a4559bEncodeGithubComKnqChromedpCdpCachestorage5(out *jwriter.Writer, in DeleteCacheParams) {
out.RawByte('{')
first := true
_ = first
if !first {
out.RawByte(',')
}
first = false
out.RawString("\"cacheId\":")
out.String(string(in.CacheID))
out.RawByte('}')
}
// MarshalJSON supports json.Marshaler interface
func (v DeleteCacheParams) MarshalJSON() ([]byte, error) {
w := jwriter.Writer{}
easyjsonC5a4559bEncodeGithubComKnqChromedpCdpCachestorage5(&w, v)
return w.Buffer.BuildBytes(), w.Error
}
// MarshalEasyJSON supports easyjson.Marshaler interface
func (v DeleteCacheParams) MarshalEasyJSON(w *jwriter.Writer) {
easyjsonC5a4559bEncodeGithubComKnqChromedpCdpCachestorage5(w, v)
}
// UnmarshalJSON supports json.Unmarshaler interface
func (v *DeleteCacheParams) UnmarshalJSON(data []byte) error {
r := jlexer.Lexer{Data: data}
easyjsonC5a4559bDecodeGithubComKnqChromedpCdpCachestorage5(&r, v)
return r.Error()
}
// UnmarshalEasyJSON supports easyjson.Unmarshaler interface
func (v *DeleteCacheParams) UnmarshalEasyJSON(l *jlexer.Lexer) {
easyjsonC5a4559bDecodeGithubComKnqChromedpCdpCachestorage5(l, v)
}
func easyjsonC5a4559bDecodeGithubComKnqChromedpCdpCachestorage6(in *jlexer.Lexer, out *DataEntry) {
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 "request":
out.Request = string(in.String())
case "response":
out.Response = string(in.String())
default:
in.SkipRecursive()
}
in.WantComma()
}
in.Delim('}')
if isTopLevel {
in.Consumed()
}
}
func easyjsonC5a4559bEncodeGithubComKnqChromedpCdpCachestorage6(out *jwriter.Writer, in DataEntry) {
out.RawByte('{')
first := true
_ = first
if in.Request != "" {
if !first {
out.RawByte(',')
}
first = false
out.RawString("\"request\":")
out.String(string(in.Request))
}
if in.Response != "" {
if !first {
out.RawByte(',')
}
first = false
out.RawString("\"response\":")
out.String(string(in.Response))
}
out.RawByte('}')
}
// MarshalJSON supports json.Marshaler interface
func (v DataEntry) MarshalJSON() ([]byte, error) {
w := jwriter.Writer{}
easyjsonC5a4559bEncodeGithubComKnqChromedpCdpCachestorage6(&w, v)
return w.Buffer.BuildBytes(), w.Error
}
// MarshalEasyJSON supports easyjson.Marshaler interface
func (v DataEntry) MarshalEasyJSON(w *jwriter.Writer) {
easyjsonC5a4559bEncodeGithubComKnqChromedpCdpCachestorage6(w, v)
}
// UnmarshalJSON supports json.Unmarshaler interface
func (v *DataEntry) UnmarshalJSON(data []byte) error {
r := jlexer.Lexer{Data: data}
easyjsonC5a4559bDecodeGithubComKnqChromedpCdpCachestorage6(&r, v)
return r.Error()
}
// UnmarshalEasyJSON supports easyjson.Unmarshaler interface
func (v *DataEntry) UnmarshalEasyJSON(l *jlexer.Lexer) {
easyjsonC5a4559bDecodeGithubComKnqChromedpCdpCachestorage6(l, v)
}
func easyjsonC5a4559bDecodeGithubComKnqChromedpCdpCachestorage7(in *jlexer.Lexer, out *Cache) {
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 "cacheId":
out.CacheID = CacheID(in.String())
case "securityOrigin":
out.SecurityOrigin = string(in.String())
case "cacheName":
out.CacheName = string(in.String())
default:
in.SkipRecursive()
}
in.WantComma()
}
in.Delim('}')
if isTopLevel {
in.Consumed()
}
}
func easyjsonC5a4559bEncodeGithubComKnqChromedpCdpCachestorage7(out *jwriter.Writer, in Cache) {
out.RawByte('{')
first := true
_ = first
if in.CacheID != "" {
if !first {
out.RawByte(',')
}
first = false
out.RawString("\"cacheId\":")
out.String(string(in.CacheID))
}
if in.SecurityOrigin != "" {
if !first {
out.RawByte(',')
}
first = false
out.RawString("\"securityOrigin\":")
out.String(string(in.SecurityOrigin))
}
if in.CacheName != "" {
if !first {
out.RawByte(',')
}
first = false
out.RawString("\"cacheName\":")
out.String(string(in.CacheName))
}
out.RawByte('}')
}
// MarshalJSON supports json.Marshaler interface
func (v Cache) MarshalJSON() ([]byte, error) {
w := jwriter.Writer{}
easyjsonC5a4559bEncodeGithubComKnqChromedpCdpCachestorage7(&w, v)
return w.Buffer.BuildBytes(), w.Error
}
// MarshalEasyJSON supports easyjson.Marshaler interface
func (v Cache) MarshalEasyJSON(w *jwriter.Writer) {
easyjsonC5a4559bEncodeGithubComKnqChromedpCdpCachestorage7(w, v)
}
// UnmarshalJSON supports json.Unmarshaler interface
func (v *Cache) UnmarshalJSON(data []byte) error {
r := jlexer.Lexer{Data: data}
easyjsonC5a4559bDecodeGithubComKnqChromedpCdpCachestorage7(&r, v)
return r.Error()
}
// UnmarshalEasyJSON supports easyjson.Unmarshaler interface
func (v *Cache) UnmarshalEasyJSON(l *jlexer.Lexer) {
easyjsonC5a4559bDecodeGithubComKnqChromedpCdpCachestorage7(l, v)
}

48
cdp/cachestorage/types.go Normal file
View File

@ -0,0 +1,48 @@
package cachestorage
// AUTOGENERATED. DO NOT EDIT.
import (
. "github.com/knq/chromedp/cdp"
)
var (
_ BackendNode
_ BackendNodeID
_ ComputedProperty
_ ErrorType
_ Frame
_ FrameID
_ LoaderID
_ Message
_ MessageError
_ MethodType
_ Node
_ NodeID
_ NodeType
_ PseudoType
_ RGBA
_ ShadowRootType
_ Timestamp
)
// CacheID unique identifier of the Cache object.
type CacheID string
// String returns the CacheID as string value.
func (t CacheID) String() string {
return string(t)
}
// DataEntry data entry.
type DataEntry struct {
Request string `json:"request,omitempty"` // Request url spec.
Response string `json:"response,omitempty"` // Response stataus text.
}
// Cache cache identifier.
type Cache struct {
CacheID CacheID `json:"cacheId,omitempty"` // An opaque unique id of the cache.
SecurityOrigin string `json:"securityOrigin,omitempty"` // Security origin of the cache.
CacheName string `json:"cacheName,omitempty"` // The name of the cache.
}

1886
cdp/cdp.go Normal file

File diff suppressed because it is too large Load Diff

1460
cdp/css/css.go Normal file

File diff suppressed because it is too large Load Diff

6665
cdp/css/easyjson.go Normal file

File diff suppressed because it is too large Load Diff

62
cdp/css/events.go Normal file
View File

@ -0,0 +1,62 @@
package css
// AUTOGENERATED. DO NOT EDIT.
import (
. "github.com/knq/chromedp/cdp"
)
var (
_ BackendNode
_ BackendNodeID
_ ComputedProperty
_ ErrorType
_ Frame
_ FrameID
_ LoaderID
_ Message
_ MessageError
_ MethodType
_ Node
_ NodeID
_ NodeType
_ PseudoType
_ RGBA
_ ShadowRootType
_ Timestamp
)
// 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{}
// EventStyleSheetChanged fired whenever a stylesheet is changed as a result
// of the client operation.
type EventStyleSheetChanged struct {
StyleSheetID StyleSheetID `json:"styleSheetId,omitempty"`
}
// EventStyleSheetAdded fired whenever an active document stylesheet is
// added.
type EventStyleSheetAdded struct {
Header *StyleSheetHeader `json:"header,omitempty"` // Added stylesheet metainfo.
}
// EventStyleSheetRemoved fired whenever an active document stylesheet is
// removed.
type EventStyleSheetRemoved struct {
StyleSheetID StyleSheetID `json:"styleSheetId,omitempty"` // Identifier of the removed stylesheet.
}
// EventTypes is all event types in the domain.
var EventTypes = []MethodType{
EventCSSMediaQueryResultChanged,
EventCSSFontsUpdated,
EventCSSStyleSheetChanged,
EventCSSStyleSheetAdded,
EventCSSStyleSheetRemoved,
}

366
cdp/css/types.go Normal file
View File

@ -0,0 +1,366 @@
package css
// AUTOGENERATED. DO NOT EDIT.
import (
"errors"
. "github.com/knq/chromedp/cdp"
"github.com/knq/chromedp/cdp/dom"
"github.com/mailru/easyjson"
"github.com/mailru/easyjson/jlexer"
"github.com/mailru/easyjson/jwriter"
)
var (
_ BackendNode
_ BackendNodeID
_ ComputedProperty
_ ErrorType
_ Frame
_ FrameID
_ LoaderID
_ Message
_ MessageError
_ MethodType
_ Node
_ NodeID
_ NodeType
_ PseudoType
_ RGBA
_ ShadowRootType
_ Timestamp
)
type StyleSheetID string
// String returns the StyleSheetID as string value.
func (t StyleSheetID) String() string {
return string(t)
}
// StyleSheetOrigin stylesheet type: "injected" for stylesheets injected via
// extension, "user-agent" for user-agent stylesheets, "inspector" for
// stylesheets created by the inspector (i.e. those holding the "via inspector"
// rules), "regular" for regular stylesheets.
type StyleSheetOrigin string
// String returns the StyleSheetOrigin as string value.
func (t StyleSheetOrigin) String() string {
return string(t)
}
// StyleSheetOrigin values.
const (
StyleSheetOriginInjected StyleSheetOrigin = "injected"
StyleSheetOriginUserAgent StyleSheetOrigin = "user-agent"
StyleSheetOriginInspector StyleSheetOrigin = "inspector"
StyleSheetOriginRegular StyleSheetOrigin = "regular"
)
// MarshalEasyJSON satisfies easyjson.Marshaler.
func (t StyleSheetOrigin) MarshalEasyJSON(out *jwriter.Writer) {
out.String(string(t))
}
// MarshalJSON satisfies json.Marshaler.
func (t StyleSheetOrigin) MarshalJSON() ([]byte, error) {
return easyjson.Marshal(t)
}
// UnmarshalEasyJSON satisfies easyjson.Unmarshaler.
func (t *StyleSheetOrigin) UnmarshalEasyJSON(in *jlexer.Lexer) {
switch StyleSheetOrigin(in.String()) {
case StyleSheetOriginInjected:
*t = StyleSheetOriginInjected
case StyleSheetOriginUserAgent:
*t = StyleSheetOriginUserAgent
case StyleSheetOriginInspector:
*t = StyleSheetOriginInspector
case StyleSheetOriginRegular:
*t = StyleSheetOriginRegular
default:
in.AddError(errors.New("unknown StyleSheetOrigin value"))
}
}
// UnmarshalJSON satisfies json.Unmarshaler.
func (t *StyleSheetOrigin) UnmarshalJSON(buf []byte) error {
return easyjson.Unmarshal(buf, t)
}
// PseudoElementMatches cSS rule collection for a single pseudo style.
type PseudoElementMatches struct {
PseudoType PseudoType `json:"pseudoType,omitempty"` // Pseudo element type.
Matches []*RuleMatch `json:"matches,omitempty"` // Matches of CSS rules applicable to the pseudo style.
}
// InheritedStyleEntry inherited CSS rule collection from ancestor node.
type InheritedStyleEntry struct {
InlineStyle *Style `json:"inlineStyle,omitempty"` // The ancestor node's inline style, if any, in the style inheritance chain.
MatchedCSSRules []*RuleMatch `json:"matchedCSSRules,omitempty"` // Matches of CSS rules matching the ancestor node in the style inheritance chain.
}
// RuleMatch match data for a CSS rule.
type RuleMatch struct {
Rule *Rule `json:"rule,omitempty"` // CSS rule in the match.
MatchingSelectors []int64 `json:"matchingSelectors,omitempty"` // Matching selector indices in the rule's selectorList selectors (0-based).
}
// Value data for a simple selector (these are delimited by commas in a
// selector list).
type Value struct {
Text string `json:"text,omitempty"` // Value text.
Range *SourceRange `json:"range,omitempty"` // Value range in the underlying resource (if available).
}
// SelectorList selector list data.
type SelectorList struct {
Selectors []*Value `json:"selectors,omitempty"` // Selectors in the list.
Text string `json:"text,omitempty"` // Rule selector text.
}
// StyleSheetHeader cSS stylesheet metainformation.
type StyleSheetHeader struct {
StyleSheetID StyleSheetID `json:"styleSheetId,omitempty"` // The stylesheet identifier.
FrameID FrameID `json:"frameId,omitempty"` // Owner frame identifier.
SourceURL string `json:"sourceURL,omitempty"` // Stylesheet resource URL.
SourceMapURL string `json:"sourceMapURL,omitempty"` // URL of source map associated with the stylesheet (if any).
Origin StyleSheetOrigin `json:"origin,omitempty"` // Stylesheet origin.
Title string `json:"title,omitempty"` // Stylesheet title.
OwnerNode BackendNodeID `json:"ownerNode,omitempty"` // The backend id for the owner node of the stylesheet.
Disabled bool `json:"disabled,omitempty"` // Denotes whether the stylesheet is disabled.
HasSourceURL bool `json:"hasSourceURL,omitempty"` // Whether the sourceURL field value comes from the sourceURL comment.
IsInline bool `json:"isInline,omitempty"` // Whether this stylesheet is created for STYLE tag by parser. This flag is not set for document.written STYLE tags.
StartLine float64 `json:"startLine,omitempty"` // Line offset of the stylesheet within the resource (zero based).
StartColumn float64 `json:"startColumn,omitempty"` // Column offset of the stylesheet within the resource (zero based).
}
// Rule cSS rule representation.
type Rule struct {
StyleSheetID StyleSheetID `json:"styleSheetId,omitempty"` // The css style sheet identifier (absent for user agent stylesheet and user-specified stylesheet rules) this rule came from.
SelectorList *SelectorList `json:"selectorList,omitempty"` // Rule selector data.
Origin StyleSheetOrigin `json:"origin,omitempty"` // Parent stylesheet's origin.
Style *Style `json:"style,omitempty"` // Associated style declaration.
Media []*Media `json:"media,omitempty"` // Media list array (for rules involving media queries). The array enumerates media queries starting with the innermost one, going outwards.
}
// RuleUsage cSS rule usage information.
type RuleUsage struct {
StyleSheetID StyleSheetID `json:"styleSheetId,omitempty"` // The css style sheet identifier (absent for user agent stylesheet and user-specified stylesheet rules) this rule came from.
Range *SourceRange `json:"range,omitempty"` // Style declaration range in the enclosing stylesheet (if available).
Used bool `json:"used,omitempty"` // Indicates whether the rule was actually used by some element in the page.
}
// SourceRange text range within a resource. All numbers are zero-based.
type SourceRange struct {
StartLine int64 `json:"startLine,omitempty"` // Start line of range.
StartColumn int64 `json:"startColumn,omitempty"` // Start column of range (inclusive).
EndLine int64 `json:"endLine,omitempty"` // End line of range
EndColumn int64 `json:"endColumn,omitempty"` // End column of range (exclusive).
}
type ShorthandEntry struct {
Name string `json:"name,omitempty"` // Shorthand name.
Value string `json:"value,omitempty"` // Shorthand value.
Important bool `json:"important,omitempty"` // Whether the property has "!important" annotation (implies false if absent).
}
// Style cSS style representation.
type Style struct {
StyleSheetID StyleSheetID `json:"styleSheetId,omitempty"` // The css style sheet identifier (absent for user agent stylesheet and user-specified stylesheet rules) this rule came from.
CSSProperties []*Property `json:"cssProperties,omitempty"` // CSS properties in the style.
ShorthandEntries []*ShorthandEntry `json:"shorthandEntries,omitempty"` // Computed values for all shorthands found in the style.
CSSText string `json:"cssText,omitempty"` // Style declaration text (if available).
Range *SourceRange `json:"range,omitempty"` // Style declaration range in the enclosing stylesheet (if available).
}
// Property cSS property declaration data.
type Property struct {
Name string `json:"name,omitempty"` // The property name.
Value string `json:"value,omitempty"` // The property value.
Important bool `json:"important,omitempty"` // Whether the property has "!important" annotation (implies false if absent).
Implicit bool `json:"implicit,omitempty"` // Whether the property is implicit (implies false if absent).
Text string `json:"text,omitempty"` // The full property text as specified in the style.
ParsedOk bool `json:"parsedOk,omitempty"` // Whether the property is understood by the browser (implies true if absent).
Disabled bool `json:"disabled,omitempty"` // Whether the property is disabled by the user (present for source-based properties only).
Range *SourceRange `json:"range,omitempty"` // The entire property range in the enclosing style declaration (if available).
}
// Media cSS media rule descriptor.
type Media struct {
Text string `json:"text,omitempty"` // Media query text.
Source MediaSource `json:"source,omitempty"` // Source of the media query: "mediaRule" if specified by a @media rule, "importRule" if specified by an @import rule, "linkedSheet" if specified by a "media" attribute in a linked stylesheet's LINK tag, "inlineSheet" if specified by a "media" attribute in an inline stylesheet's STYLE tag.
SourceURL string `json:"sourceURL,omitempty"` // URL of the document containing the media query description.
Range *SourceRange `json:"range,omitempty"` // The associated rule (@media or @import) header range in the enclosing stylesheet (if available).
StyleSheetID StyleSheetID `json:"styleSheetId,omitempty"` // Identifier of the stylesheet containing this object (if exists).
MediaList []*MediaQuery `json:"mediaList,omitempty"` // Array of media queries.
}
// MediaQuery media query descriptor.
type MediaQuery struct {
Expressions []*MediaQueryExpression `json:"expressions,omitempty"` // Array of media query expressions.
Active bool `json:"active,omitempty"` // Whether the media query condition is satisfied.
}
// MediaQueryExpression media query expression descriptor.
type MediaQueryExpression struct {
Value float64 `json:"value,omitempty"` // Media query expression value.
Unit string `json:"unit,omitempty"` // Media query expression units.
Feature string `json:"feature,omitempty"` // Media query expression feature.
ValueRange *SourceRange `json:"valueRange,omitempty"` // The associated range of the value text in the enclosing stylesheet (if available).
ComputedLength float64 `json:"computedLength,omitempty"` // Computed length of media query expression (if applicable).
}
// PlatformFontUsage information about amount of glyphs that were rendered
// with given font.
type PlatformFontUsage struct {
FamilyName string `json:"familyName,omitempty"` // Font's family name reported by platform.
IsCustomFont bool `json:"isCustomFont,omitempty"` // Indicates if the font was downloaded or resolved locally.
GlyphCount float64 `json:"glyphCount,omitempty"` // Amount of glyphs that were rendered with this font.
}
// KeyframesRule cSS keyframes rule representation.
type KeyframesRule struct {
AnimationName *Value `json:"animationName,omitempty"` // Animation name.
Keyframes []*KeyframeRule `json:"keyframes,omitempty"` // List of keyframes.
}
// KeyframeRule cSS keyframe rule representation.
type KeyframeRule struct {
StyleSheetID StyleSheetID `json:"styleSheetId,omitempty"` // The css style sheet identifier (absent for user agent stylesheet and user-specified stylesheet rules) this rule came from.
Origin StyleSheetOrigin `json:"origin,omitempty"` // Parent stylesheet's origin.
KeyText *Value `json:"keyText,omitempty"` // Associated key text.
Style *Style `json:"style,omitempty"` // Associated style declaration.
}
// StyleDeclarationEdit a descriptor of operation to mutate style declaration
// text.
type StyleDeclarationEdit struct {
StyleSheetID StyleSheetID `json:"styleSheetId,omitempty"` // The css style sheet identifier.
Range *SourceRange `json:"range,omitempty"` // The range of the style text in the enclosing stylesheet.
Text string `json:"text,omitempty"` // New style text.
}
// InlineTextBox details of post layout rendered text positions. The exact
// layout should not be regarded as stable and may change between versions.
type InlineTextBox struct {
BoundingBox *dom.Rect `json:"boundingBox,omitempty"` // The absolute position bounding box.
StartCharacterIndex int64 `json:"startCharacterIndex,omitempty"` // The starting index in characters, for this post layout textbox substring.
NumCharacters int64 `json:"numCharacters,omitempty"` // The number of characters in this post layout textbox substring.
}
// LayoutTreeNode details of an element in the DOM tree with a LayoutObject.
type LayoutTreeNode struct {
NodeID NodeID `json:"nodeId,omitempty"` // The id of the related DOM node matching one from DOM.GetDocument.
BoundingBox *dom.Rect `json:"boundingBox,omitempty"` // The absolute position bounding box.
LayoutText string `json:"layoutText,omitempty"` // Contents of the LayoutText if any
InlineTextNodes []*InlineTextBox `json:"inlineTextNodes,omitempty"` // The post layout inline text nodes, if any.
StyleIndex int64 `json:"styleIndex,omitempty"` // Index into the computedStyles array returned by getLayoutTreeAndStyles.
}
// ComputedStyle a subset of the full ComputedStyle as defined by the request
// whitelist.
type ComputedStyle struct {
Properties []*ComputedProperty `json:"properties,omitempty"`
}
// MediaSource source of the media query: "mediaRule" if specified by a
// @media rule, "importRule" if specified by an @import rule, "linkedSheet" if
// specified by a "media" attribute in a linked stylesheet's LINK tag,
// "inlineSheet" if specified by a "media" attribute in an inline stylesheet's
// STYLE tag.
type MediaSource string
// String returns the MediaSource as string value.
func (t MediaSource) String() string {
return string(t)
}
// MediaSource values.
const (
MediaSourceMediaRule MediaSource = "mediaRule"
MediaSourceImportRule MediaSource = "importRule"
MediaSourceLinkedSheet MediaSource = "linkedSheet"
MediaSourceInlineSheet MediaSource = "inlineSheet"
)
// MarshalEasyJSON satisfies easyjson.Marshaler.
func (t MediaSource) MarshalEasyJSON(out *jwriter.Writer) {
out.String(string(t))
}
// MarshalJSON satisfies json.Marshaler.
func (t MediaSource) MarshalJSON() ([]byte, error) {
return easyjson.Marshal(t)
}
// UnmarshalEasyJSON satisfies easyjson.Unmarshaler.
func (t *MediaSource) UnmarshalEasyJSON(in *jlexer.Lexer) {
switch MediaSource(in.String()) {
case MediaSourceMediaRule:
*t = MediaSourceMediaRule
case MediaSourceImportRule:
*t = MediaSourceImportRule
case MediaSourceLinkedSheet:
*t = MediaSourceLinkedSheet
case MediaSourceInlineSheet:
*t = MediaSourceInlineSheet
default:
in.AddError(errors.New("unknown MediaSource value"))
}
}
// UnmarshalJSON satisfies json.Unmarshaler.
func (t *MediaSource) UnmarshalJSON(buf []byte) error {
return easyjson.Unmarshal(buf, t)
}
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)
}

251
cdp/database/database.go Normal file
View File

@ -0,0 +1,251 @@
// Package database provides the Chrome Debugging Protocol
// commands, types, and events for the Chrome Database domain.
//
// Generated by the chromedp-gen command.
package database
// AUTOGENERATED. DO NOT EDIT.
import (
"context"
. "github.com/knq/chromedp/cdp"
"github.com/mailru/easyjson"
)
var (
_ BackendNode
_ BackendNodeID
_ ComputedProperty
_ ErrorType
_ Frame
_ FrameID
_ LoaderID
_ Message
_ MessageError
_ MethodType
_ Node
_ NodeID
_ NodeType
_ PseudoType
_ RGBA
_ ShadowRootType
_ Timestamp
)
// 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.
func (p *EnableParams) Do(ctxt context.Context, h FrameHandler) (err error) {
if ctxt == nil {
ctxt = context.Background()
}
// execute
ch := h.Execute(ctxt, CommandDatabaseEnable, Empty)
// read response
select {
case res := <-ch:
if res == nil {
return ErrChannelClosed
}
switch v := res.(type) {
case easyjson.RawMessage:
return nil
case error:
return v
}
case <-ctxt.Done():
return ErrContextDone
}
return ErrUnknownResult
}
// DisableParams disables database tracking, prevents database events from
// being sent to the client.
type DisableParams struct{}
// Disable disables database tracking, prevents database events from being
// sent to the client.
func Disable() *DisableParams {
return &DisableParams{}
}
// Do executes Database.disable.
func (p *DisableParams) Do(ctxt context.Context, h FrameHandler) (err error) {
if ctxt == nil {
ctxt = context.Background()
}
// execute
ch := h.Execute(ctxt, CommandDatabaseDisable, Empty)
// read response
select {
case res := <-ch:
if res == nil {
return ErrChannelClosed
}
switch v := res.(type) {
case easyjson.RawMessage:
return nil
case error:
return v
}
case <-ctxt.Done():
return ErrContextDone
}
return ErrUnknownResult
}
type GetDatabaseTableNamesParams struct {
DatabaseID DatabaseID `json:"databaseId"`
}
// parameters:
// databaseId
func GetDatabaseTableNames(databaseId DatabaseID) *GetDatabaseTableNamesParams {
return &GetDatabaseTableNamesParams{
DatabaseID: databaseId,
}
}
// GetDatabaseTableNamesReturns return values.
type GetDatabaseTableNamesReturns struct {
TableNames []string `json:"tableNames,omitempty"`
}
// Do executes Database.getDatabaseTableNames.
//
// returns:
// tableNames
func (p *GetDatabaseTableNamesParams) Do(ctxt context.Context, h FrameHandler) (tableNames []string, err error) {
if ctxt == nil {
ctxt = context.Background()
}
// marshal
buf, err := easyjson.Marshal(p)
if err != nil {
return nil, err
}
// execute
ch := h.Execute(ctxt, CommandDatabaseGetDatabaseTableNames, easyjson.RawMessage(buf))
// read response
select {
case res := <-ch:
if res == nil {
return nil, ErrChannelClosed
}
switch v := res.(type) {
case easyjson.RawMessage:
// unmarshal
var r GetDatabaseTableNamesReturns
err = easyjson.Unmarshal(v, &r)
if err != nil {
return nil, ErrInvalidResult
}
return r.TableNames, nil
case error:
return nil, v
}
case <-ctxt.Done():
return nil, ErrContextDone
}
return nil, ErrUnknownResult
}
type ExecuteSQLParams struct {
DatabaseID DatabaseID `json:"databaseId"`
Query string `json:"query"`
}
// parameters:
// databaseId
// query
func ExecuteSQL(databaseId DatabaseID, query string) *ExecuteSQLParams {
return &ExecuteSQLParams{
DatabaseID: databaseId,
Query: query,
}
}
// ExecuteSQLReturns return values.
type ExecuteSQLReturns struct {
ColumnNames []string `json:"columnNames,omitempty"`
Values []easyjson.RawMessage `json:"values,omitempty"`
SQLError *Error `json:"sqlError,omitempty"`
}
// Do executes Database.executeSQL.
//
// returns:
// columnNames
// values
// sqlError
func (p *ExecuteSQLParams) Do(ctxt context.Context, h FrameHandler) (columnNames []string, values []easyjson.RawMessage, sqlError *Error, err error) {
if ctxt == nil {
ctxt = context.Background()
}
// marshal
buf, err := easyjson.Marshal(p)
if err != nil {
return nil, nil, nil, err
}
// execute
ch := h.Execute(ctxt, CommandDatabaseExecuteSQL, easyjson.RawMessage(buf))
// read response
select {
case res := <-ch:
if res == nil {
return nil, nil, nil, ErrChannelClosed
}
switch v := res.(type) {
case easyjson.RawMessage:
// unmarshal
var r ExecuteSQLReturns
err = easyjson.Unmarshal(v, &r)
if err != nil {
return nil, nil, nil, ErrInvalidResult
}
return r.ColumnNames, r.Values, r.SQLError, nil
case error:
return nil, nil, nil, v
}
case <-ctxt.Done():
return nil, nil, nil, ErrContextDone
}
return nil, nil, nil, ErrUnknownResult
}

792
cdp/database/easyjson.go Normal file
View File

@ -0,0 +1,792 @@
// AUTOGENERATED FILE: easyjson marshaler/unmarshalers.
package database
import (
json "encoding/json"
easyjson "github.com/mailru/easyjson"
jlexer "github.com/mailru/easyjson/jlexer"
jwriter "github.com/mailru/easyjson/jwriter"
)
// suppress unused package warning
var (
_ *json.RawMessage
_ *jlexer.Lexer
_ *jwriter.Writer
_ easyjson.Marshaler
)
func easyjsonC5a4559bDecodeGithubComKnqChromedpCdpDatabase(in *jlexer.Lexer, out *GetDatabaseTableNamesReturns) {
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 "tableNames":
if in.IsNull() {
in.Skip()
out.TableNames = nil
} else {
in.Delim('[')
if !in.IsDelim(']') {
out.TableNames = make([]string, 0, 4)
} else {
out.TableNames = []string{}
}
for !in.IsDelim(']') {
var v1 string
v1 = string(in.String())
out.TableNames = append(out.TableNames, v1)
in.WantComma()
}
in.Delim(']')
}
default:
in.SkipRecursive()
}
in.WantComma()
}
in.Delim('}')
if isTopLevel {
in.Consumed()
}
}
func easyjsonC5a4559bEncodeGithubComKnqChromedpCdpDatabase(out *jwriter.Writer, in GetDatabaseTableNamesReturns) {
out.RawByte('{')
first := true
_ = first
if len(in.TableNames) != 0 {
if !first {
out.RawByte(',')
}
first = false
out.RawString("\"tableNames\":")
if in.TableNames == nil && (out.Flags&jwriter.NilSliceAsEmpty) == 0 {
out.RawString("null")
} else {
out.RawByte('[')
for v2, v3 := range in.TableNames {
if v2 > 0 {
out.RawByte(',')
}
out.String(string(v3))
}
out.RawByte(']')
}
}
out.RawByte('}')
}
// MarshalJSON supports json.Marshaler interface
func (v GetDatabaseTableNamesReturns) MarshalJSON() ([]byte, error) {
w := jwriter.Writer{}
easyjsonC5a4559bEncodeGithubComKnqChromedpCdpDatabase(&w, v)
return w.Buffer.BuildBytes(), w.Error
}
// MarshalEasyJSON supports easyjson.Marshaler interface
func (v GetDatabaseTableNamesReturns) MarshalEasyJSON(w *jwriter.Writer) {
easyjsonC5a4559bEncodeGithubComKnqChromedpCdpDatabase(w, v)
}
// UnmarshalJSON supports json.Unmarshaler interface
func (v *GetDatabaseTableNamesReturns) UnmarshalJSON(data []byte) error {
r := jlexer.Lexer{Data: data}
easyjsonC5a4559bDecodeGithubComKnqChromedpCdpDatabase(&r, v)
return r.Error()
}
// UnmarshalEasyJSON supports easyjson.Unmarshaler interface
func (v *GetDatabaseTableNamesReturns) UnmarshalEasyJSON(l *jlexer.Lexer) {
easyjsonC5a4559bDecodeGithubComKnqChromedpCdpDatabase(l, v)
}
func easyjsonC5a4559bDecodeGithubComKnqChromedpCdpDatabase1(in *jlexer.Lexer, out *GetDatabaseTableNamesParams) {
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 "databaseId":
out.DatabaseID = DatabaseID(in.String())
default:
in.SkipRecursive()
}
in.WantComma()
}
in.Delim('}')
if isTopLevel {
in.Consumed()
}
}
func easyjsonC5a4559bEncodeGithubComKnqChromedpCdpDatabase1(out *jwriter.Writer, in GetDatabaseTableNamesParams) {
out.RawByte('{')
first := true
_ = first
if !first {
out.RawByte(',')
}
first = false
out.RawString("\"databaseId\":")
out.String(string(in.DatabaseID))
out.RawByte('}')
}
// MarshalJSON supports json.Marshaler interface
func (v GetDatabaseTableNamesParams) MarshalJSON() ([]byte, error) {
w := jwriter.Writer{}
easyjsonC5a4559bEncodeGithubComKnqChromedpCdpDatabase1(&w, v)
return w.Buffer.BuildBytes(), w.Error
}
// MarshalEasyJSON supports easyjson.Marshaler interface
func (v GetDatabaseTableNamesParams) MarshalEasyJSON(w *jwriter.Writer) {
easyjsonC5a4559bEncodeGithubComKnqChromedpCdpDatabase1(w, v)
}
// UnmarshalJSON supports json.Unmarshaler interface
func (v *GetDatabaseTableNamesParams) UnmarshalJSON(data []byte) error {
r := jlexer.Lexer{Data: data}
easyjsonC5a4559bDecodeGithubComKnqChromedpCdpDatabase1(&r, v)
return r.Error()
}
// UnmarshalEasyJSON supports easyjson.Unmarshaler interface
func (v *GetDatabaseTableNamesParams) UnmarshalEasyJSON(l *jlexer.Lexer) {
easyjsonC5a4559bDecodeGithubComKnqChromedpCdpDatabase1(l, v)
}
func easyjsonC5a4559bDecodeGithubComKnqChromedpCdpDatabase2(in *jlexer.Lexer, out *ExecuteSQLReturns) {
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 "columnNames":
if in.IsNull() {
in.Skip()
out.ColumnNames = nil
} else {
in.Delim('[')
if !in.IsDelim(']') {
out.ColumnNames = make([]string, 0, 4)
} else {
out.ColumnNames = []string{}
}
for !in.IsDelim(']') {
var v4 string
v4 = string(in.String())
out.ColumnNames = append(out.ColumnNames, v4)
in.WantComma()
}
in.Delim(']')
}
case "values":
if in.IsNull() {
in.Skip()
out.Values = nil
} else {
in.Delim('[')
if !in.IsDelim(']') {
out.Values = make([]easyjson.RawMessage, 0, 2)
} else {
out.Values = []easyjson.RawMessage{}
}
for !in.IsDelim(']') {
var v5 easyjson.RawMessage
(v5).UnmarshalEasyJSON(in)
out.Values = append(out.Values, v5)
in.WantComma()
}
in.Delim(']')
}
case "sqlError":
if in.IsNull() {
in.Skip()
out.SQLError = nil
} else {
if out.SQLError == nil {
out.SQLError = new(Error)
}
(*out.SQLError).UnmarshalEasyJSON(in)
}
default:
in.SkipRecursive()
}
in.WantComma()
}
in.Delim('}')
if isTopLevel {
in.Consumed()
}
}
func easyjsonC5a4559bEncodeGithubComKnqChromedpCdpDatabase2(out *jwriter.Writer, in ExecuteSQLReturns) {
out.RawByte('{')
first := true
_ = first
if len(in.ColumnNames) != 0 {
if !first {
out.RawByte(',')
}
first = false
out.RawString("\"columnNames\":")
if in.ColumnNames == nil && (out.Flags&jwriter.NilSliceAsEmpty) == 0 {
out.RawString("null")
} else {
out.RawByte('[')
for v6, v7 := range in.ColumnNames {
if v6 > 0 {
out.RawByte(',')
}
out.String(string(v7))
}
out.RawByte(']')
}
}
if len(in.Values) != 0 {
if !first {
out.RawByte(',')
}
first = false
out.RawString("\"values\":")
if in.Values == nil && (out.Flags&jwriter.NilSliceAsEmpty) == 0 {
out.RawString("null")
} else {
out.RawByte('[')
for v8, v9 := range in.Values {
if v8 > 0 {
out.RawByte(',')
}
(v9).MarshalEasyJSON(out)
}
out.RawByte(']')
}
}
if in.SQLError != nil {
if !first {
out.RawByte(',')
}
first = false
out.RawString("\"sqlError\":")
if in.SQLError == nil {
out.RawString("null")
} else {
(*in.SQLError).MarshalEasyJSON(out)
}
}
out.RawByte('}')
}
// MarshalJSON supports json.Marshaler interface
func (v ExecuteSQLReturns) MarshalJSON() ([]byte, error) {
w := jwriter.Writer{}
easyjsonC5a4559bEncodeGithubComKnqChromedpCdpDatabase2(&w, v)
return w.Buffer.BuildBytes(), w.Error
}
// MarshalEasyJSON supports easyjson.Marshaler interface
func (v ExecuteSQLReturns) MarshalEasyJSON(w *jwriter.Writer) {
easyjsonC5a4559bEncodeGithubComKnqChromedpCdpDatabase2(w, v)
}
// UnmarshalJSON supports json.Unmarshaler interface
func (v *ExecuteSQLReturns) UnmarshalJSON(data []byte) error {
r := jlexer.Lexer{Data: data}
easyjsonC5a4559bDecodeGithubComKnqChromedpCdpDatabase2(&r, v)
return r.Error()
}
// UnmarshalEasyJSON supports easyjson.Unmarshaler interface
func (v *ExecuteSQLReturns) UnmarshalEasyJSON(l *jlexer.Lexer) {
easyjsonC5a4559bDecodeGithubComKnqChromedpCdpDatabase2(l, v)
}
func easyjsonC5a4559bDecodeGithubComKnqChromedpCdpDatabase3(in *jlexer.Lexer, out *ExecuteSQLParams) {
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 "databaseId":
out.DatabaseID = DatabaseID(in.String())
case "query":
out.Query = string(in.String())
default:
in.SkipRecursive()
}
in.WantComma()
}
in.Delim('}')
if isTopLevel {
in.Consumed()
}
}
func easyjsonC5a4559bEncodeGithubComKnqChromedpCdpDatabase3(out *jwriter.Writer, in ExecuteSQLParams) {
out.RawByte('{')
first := true
_ = first
if !first {
out.RawByte(',')
}
first = false
out.RawString("\"databaseId\":")
out.String(string(in.DatabaseID))
if !first {
out.RawByte(',')
}
first = false
out.RawString("\"query\":")
out.String(string(in.Query))
out.RawByte('}')
}
// MarshalJSON supports json.Marshaler interface
func (v ExecuteSQLParams) MarshalJSON() ([]byte, error) {
w := jwriter.Writer{}
easyjsonC5a4559bEncodeGithubComKnqChromedpCdpDatabase3(&w, v)
return w.Buffer.BuildBytes(), w.Error
}
// MarshalEasyJSON supports easyjson.Marshaler interface
func (v ExecuteSQLParams) MarshalEasyJSON(w *jwriter.Writer) {
easyjsonC5a4559bEncodeGithubComKnqChromedpCdpDatabase3(w, v)
}
// UnmarshalJSON supports json.Unmarshaler interface
func (v *ExecuteSQLParams) UnmarshalJSON(data []byte) error {
r := jlexer.Lexer{Data: data}
easyjsonC5a4559bDecodeGithubComKnqChromedpCdpDatabase3(&r, v)
return r.Error()
}
// UnmarshalEasyJSON supports easyjson.Unmarshaler interface
func (v *ExecuteSQLParams) UnmarshalEasyJSON(l *jlexer.Lexer) {
easyjsonC5a4559bDecodeGithubComKnqChromedpCdpDatabase3(l, v)
}
func easyjsonC5a4559bDecodeGithubComKnqChromedpCdpDatabase4(in *jlexer.Lexer, out *EventAddDatabase) {
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 "database":
if in.IsNull() {
in.Skip()
out.Database = nil
} else {
if out.Database == nil {
out.Database = new(Database)
}
(*out.Database).UnmarshalEasyJSON(in)
}
default:
in.SkipRecursive()
}
in.WantComma()
}
in.Delim('}')
if isTopLevel {
in.Consumed()
}
}
func easyjsonC5a4559bEncodeGithubComKnqChromedpCdpDatabase4(out *jwriter.Writer, in EventAddDatabase) {
out.RawByte('{')
first := true
_ = first
if in.Database != nil {
if !first {
out.RawByte(',')
}
first = false
out.RawString("\"database\":")
if in.Database == nil {
out.RawString("null")
} else {
(*in.Database).MarshalEasyJSON(out)
}
}
out.RawByte('}')
}
// MarshalJSON supports json.Marshaler interface
func (v EventAddDatabase) MarshalJSON() ([]byte, error) {
w := jwriter.Writer{}
easyjsonC5a4559bEncodeGithubComKnqChromedpCdpDatabase4(&w, v)
return w.Buffer.BuildBytes(), w.Error
}
// MarshalEasyJSON supports easyjson.Marshaler interface
func (v EventAddDatabase) MarshalEasyJSON(w *jwriter.Writer) {
easyjsonC5a4559bEncodeGithubComKnqChromedpCdpDatabase4(w, v)
}
// UnmarshalJSON supports json.Unmarshaler interface
func (v *EventAddDatabase) UnmarshalJSON(data []byte) error {
r := jlexer.Lexer{Data: data}
easyjsonC5a4559bDecodeGithubComKnqChromedpCdpDatabase4(&r, v)
return r.Error()
}
// UnmarshalEasyJSON supports easyjson.Unmarshaler interface
func (v *EventAddDatabase) UnmarshalEasyJSON(l *jlexer.Lexer) {
easyjsonC5a4559bDecodeGithubComKnqChromedpCdpDatabase4(l, v)
}
func easyjsonC5a4559bDecodeGithubComKnqChromedpCdpDatabase5(in *jlexer.Lexer, out *Error) {
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 "message":
out.Message = string(in.String())
case "code":
out.Code = int64(in.Int64())
default:
in.SkipRecursive()
}
in.WantComma()
}
in.Delim('}')
if isTopLevel {
in.Consumed()
}
}
func easyjsonC5a4559bEncodeGithubComKnqChromedpCdpDatabase5(out *jwriter.Writer, in Error) {
out.RawByte('{')
first := true
_ = first
if in.Message != "" {
if !first {
out.RawByte(',')
}
first = false
out.RawString("\"message\":")
out.String(string(in.Message))
}
if in.Code != 0 {
if !first {
out.RawByte(',')
}
first = false
out.RawString("\"code\":")
out.Int64(int64(in.Code))
}
out.RawByte('}')
}
// MarshalJSON supports json.Marshaler interface
func (v Error) MarshalJSON() ([]byte, error) {
w := jwriter.Writer{}
easyjsonC5a4559bEncodeGithubComKnqChromedpCdpDatabase5(&w, v)
return w.Buffer.BuildBytes(), w.Error
}
// MarshalEasyJSON supports easyjson.Marshaler interface
func (v Error) MarshalEasyJSON(w *jwriter.Writer) {
easyjsonC5a4559bEncodeGithubComKnqChromedpCdpDatabase5(w, v)
}
// UnmarshalJSON supports json.Unmarshaler interface
func (v *Error) UnmarshalJSON(data []byte) error {
r := jlexer.Lexer{Data: data}
easyjsonC5a4559bDecodeGithubComKnqChromedpCdpDatabase5(&r, v)
return r.Error()
}
// UnmarshalEasyJSON supports easyjson.Unmarshaler interface
func (v *Error) UnmarshalEasyJSON(l *jlexer.Lexer) {
easyjsonC5a4559bDecodeGithubComKnqChromedpCdpDatabase5(l, v)
}
func easyjsonC5a4559bDecodeGithubComKnqChromedpCdpDatabase6(in *jlexer.Lexer, out *EnableParams) {
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 {
default:
in.SkipRecursive()
}
in.WantComma()
}
in.Delim('}')
if isTopLevel {
in.Consumed()
}
}
func easyjsonC5a4559bEncodeGithubComKnqChromedpCdpDatabase6(out *jwriter.Writer, in EnableParams) {
out.RawByte('{')
first := true
_ = first
out.RawByte('}')
}
// MarshalJSON supports json.Marshaler interface
func (v EnableParams) MarshalJSON() ([]byte, error) {
w := jwriter.Writer{}
easyjsonC5a4559bEncodeGithubComKnqChromedpCdpDatabase6(&w, v)
return w.Buffer.BuildBytes(), w.Error
}
// MarshalEasyJSON supports easyjson.Marshaler interface
func (v EnableParams) MarshalEasyJSON(w *jwriter.Writer) {
easyjsonC5a4559bEncodeGithubComKnqChromedpCdpDatabase6(w, v)
}
// UnmarshalJSON supports json.Unmarshaler interface
func (v *EnableParams) UnmarshalJSON(data []byte) error {
r := jlexer.Lexer{Data: data}
easyjsonC5a4559bDecodeGithubComKnqChromedpCdpDatabase6(&r, v)
return r.Error()
}
// UnmarshalEasyJSON supports easyjson.Unmarshaler interface
func (v *EnableParams) UnmarshalEasyJSON(l *jlexer.Lexer) {
easyjsonC5a4559bDecodeGithubComKnqChromedpCdpDatabase6(l, v)
}
func easyjsonC5a4559bDecodeGithubComKnqChromedpCdpDatabase7(in *jlexer.Lexer, out *DisableParams) {
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 {
default:
in.SkipRecursive()
}
in.WantComma()
}
in.Delim('}')
if isTopLevel {
in.Consumed()
}
}
func easyjsonC5a4559bEncodeGithubComKnqChromedpCdpDatabase7(out *jwriter.Writer, in DisableParams) {
out.RawByte('{')
first := true
_ = first
out.RawByte('}')
}
// MarshalJSON supports json.Marshaler interface
func (v DisableParams) MarshalJSON() ([]byte, error) {
w := jwriter.Writer{}
easyjsonC5a4559bEncodeGithubComKnqChromedpCdpDatabase7(&w, v)
return w.Buffer.BuildBytes(), w.Error
}
// MarshalEasyJSON supports easyjson.Marshaler interface
func (v DisableParams) MarshalEasyJSON(w *jwriter.Writer) {
easyjsonC5a4559bEncodeGithubComKnqChromedpCdpDatabase7(w, v)
}
// UnmarshalJSON supports json.Unmarshaler interface
func (v *DisableParams) UnmarshalJSON(data []byte) error {
r := jlexer.Lexer{Data: data}
easyjsonC5a4559bDecodeGithubComKnqChromedpCdpDatabase7(&r, v)
return r.Error()
}
// UnmarshalEasyJSON supports easyjson.Unmarshaler interface
func (v *DisableParams) UnmarshalEasyJSON(l *jlexer.Lexer) {
easyjsonC5a4559bDecodeGithubComKnqChromedpCdpDatabase7(l, v)
}
func easyjsonC5a4559bDecodeGithubComKnqChromedpCdpDatabase8(in *jlexer.Lexer, out *Database) {
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 "id":
out.ID = DatabaseID(in.String())
case "domain":
out.Domain = string(in.String())
case "name":
out.Name = string(in.String())
case "version":
out.Version = string(in.String())
default:
in.SkipRecursive()
}
in.WantComma()
}
in.Delim('}')
if isTopLevel {
in.Consumed()
}
}
func easyjsonC5a4559bEncodeGithubComKnqChromedpCdpDatabase8(out *jwriter.Writer, in Database) {
out.RawByte('{')
first := true
_ = first
if in.ID != "" {
if !first {
out.RawByte(',')
}
first = false
out.RawString("\"id\":")
out.String(string(in.ID))
}
if in.Domain != "" {
if !first {
out.RawByte(',')
}
first = false
out.RawString("\"domain\":")
out.String(string(in.Domain))
}
if in.Name != "" {
if !first {
out.RawByte(',')
}
first = false
out.RawString("\"name\":")
out.String(string(in.Name))
}
if in.Version != "" {
if !first {
out.RawByte(',')
}
first = false
out.RawString("\"version\":")
out.String(string(in.Version))
}
out.RawByte('}')
}
// MarshalJSON supports json.Marshaler interface
func (v Database) MarshalJSON() ([]byte, error) {
w := jwriter.Writer{}
easyjsonC5a4559bEncodeGithubComKnqChromedpCdpDatabase8(&w, v)
return w.Buffer.BuildBytes(), w.Error
}
// MarshalEasyJSON supports easyjson.Marshaler interface
func (v Database) MarshalEasyJSON(w *jwriter.Writer) {
easyjsonC5a4559bEncodeGithubComKnqChromedpCdpDatabase8(w, v)
}
// UnmarshalJSON supports json.Unmarshaler interface
func (v *Database) UnmarshalJSON(data []byte) error {
r := jlexer.Lexer{Data: data}
easyjsonC5a4559bDecodeGithubComKnqChromedpCdpDatabase8(&r, v)
return r.Error()
}
// UnmarshalEasyJSON supports easyjson.Unmarshaler interface
func (v *Database) UnmarshalEasyJSON(l *jlexer.Lexer) {
easyjsonC5a4559bDecodeGithubComKnqChromedpCdpDatabase8(l, v)
}

36
cdp/database/events.go Normal file
View File

@ -0,0 +1,36 @@
package database
// AUTOGENERATED. DO NOT EDIT.
import (
. "github.com/knq/chromedp/cdp"
)
var (
_ BackendNode
_ BackendNodeID
_ ComputedProperty
_ ErrorType
_ Frame
_ FrameID
_ LoaderID
_ Message
_ MessageError
_ MethodType
_ Node
_ NodeID
_ NodeType
_ PseudoType
_ RGBA
_ ShadowRootType
_ Timestamp
)
type EventAddDatabase struct {
Database *Database `json:"database,omitempty"`
}
// EventTypes is all event types in the domain.
var EventTypes = []MethodType{
EventDatabaseAddDatabase,
}

49
cdp/database/types.go Normal file
View File

@ -0,0 +1,49 @@
package database
// AUTOGENERATED. DO NOT EDIT.
import (
. "github.com/knq/chromedp/cdp"
)
var (
_ BackendNode
_ BackendNodeID
_ ComputedProperty
_ ErrorType
_ Frame
_ FrameID
_ LoaderID
_ Message
_ MessageError
_ MethodType
_ Node
_ NodeID
_ NodeType
_ PseudoType
_ RGBA
_ ShadowRootType
_ Timestamp
)
// DatabaseID unique identifier of Database object.
type DatabaseID string
// String returns the DatabaseID as string value.
func (t DatabaseID) String() string {
return string(t)
}
// Database database object.
type Database struct {
ID DatabaseID `json:"id,omitempty"` // Database ID.
Domain string `json:"domain,omitempty"` // Database domain.
Name string `json:"name,omitempty"` // Database name.
Version string `json:"version,omitempty"` // Database version.
}
// Error database error.
type Error struct {
Message string `json:"message,omitempty"` // Error message.
Code int64 `json:"code,omitempty"` // Error code.
}

1499
cdp/debugger/debugger.go Normal file

File diff suppressed because it is too large Load Diff

4086
cdp/debugger/easyjson.go Normal file

File diff suppressed because it is too large Load Diff

91
cdp/debugger/events.go Normal file
View File

@ -0,0 +1,91 @@
package debugger
// AUTOGENERATED. DO NOT EDIT.
import (
. "github.com/knq/chromedp/cdp"
"github.com/knq/chromedp/cdp/runtime"
"github.com/mailru/easyjson"
)
var (
_ BackendNode
_ BackendNodeID
_ ComputedProperty
_ ErrorType
_ Frame
_ FrameID
_ LoaderID
_ Message
_ MessageError
_ MethodType
_ Node
_ NodeID
_ NodeType
_ PseudoType
_ RGBA
_ ShadowRootType
_ Timestamp
)
// 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,omitempty"` // Identifier of the script parsed.
URL string `json:"url,omitempty"` // URL or name of the script parsed (if any).
StartLine int64 `json:"startLine,omitempty"` // Line offset of the script within the resource with given URL (for script tags).
StartColumn int64 `json:"startColumn,omitempty"` // Column offset of the script within the resource with given URL.
EndLine int64 `json:"endLine,omitempty"` // Last line of the script.
EndColumn int64 `json:"endColumn,omitempty"` // Length of the last line of the script.
ExecutionContextID runtime.ExecutionContextID `json:"executionContextId,omitempty"` // Specifies script creation context.
Hash string `json:"hash,omitempty"` // 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.
}
// EventScriptFailedToParse fired when virtual machine fails to parse the
// script.
type EventScriptFailedToParse struct {
ScriptID runtime.ScriptID `json:"scriptId,omitempty"` // Identifier of the script parsed.
URL string `json:"url,omitempty"` // URL or name of the script parsed (if any).
StartLine int64 `json:"startLine,omitempty"` // Line offset of the script within the resource with given URL (for script tags).
StartColumn int64 `json:"startColumn,omitempty"` // Column offset of the script within the resource with given URL.
EndLine int64 `json:"endLine,omitempty"` // Last line of the script.
EndColumn int64 `json:"endColumn,omitempty"` // Length of the last line of the script.
ExecutionContextID runtime.ExecutionContextID `json:"executionContextId,omitempty"` // Specifies script creation context.
Hash string `json:"hash,omitempty"` // 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.
}
// EventBreakpointResolved fired when breakpoint is resolved to an actual
// script and location.
type EventBreakpointResolved struct {
BreakpointID BreakpointID `json:"breakpointId,omitempty"` // Breakpoint unique identifier.
Location *Location `json:"location,omitempty"` // Actual breakpoint location.
}
// EventPaused fired when the virtual machine stopped on breakpoint or
// exception or any other stop criteria.
type EventPaused struct {
CallFrames []*CallFrame `json:"callFrames,omitempty"` // Call stack the virtual machine stopped on.
Reason PausedReason `json:"reason,omitempty"` // Pause reason.
Data easyjson.RawMessage `json:"data,omitempty"`
HitBreakpoints []string `json:"hitBreakpoints,omitempty"` // Hit breakpoints IDs
AsyncStackTrace *runtime.StackTrace `json:"asyncStackTrace,omitempty"` // Async stack trace, if any.
}
// EventResumed fired when the virtual machine resumed execution.
type EventResumed struct{}
// EventTypes is all event types in the domain.
var EventTypes = []MethodType{
EventDebuggerScriptParsed,
EventDebuggerScriptFailedToParse,
EventDebuggerBreakpointResolved,
EventDebuggerPaused,
EventDebuggerResumed,
}

259
cdp/debugger/types.go Normal file
View File

@ -0,0 +1,259 @@
package debugger
// AUTOGENERATED. DO NOT EDIT.
import (
"errors"
. "github.com/knq/chromedp/cdp"
"github.com/knq/chromedp/cdp/runtime"
"github.com/mailru/easyjson"
"github.com/mailru/easyjson/jlexer"
"github.com/mailru/easyjson/jwriter"
)
var (
_ BackendNode
_ BackendNodeID
_ ComputedProperty
_ ErrorType
_ Frame
_ FrameID
_ LoaderID
_ Message
_ MessageError
_ MethodType
_ Node
_ NodeID
_ NodeType
_ PseudoType
_ RGBA
_ ShadowRootType
_ Timestamp
)
// BreakpointID breakpoint identifier.
type BreakpointID string
// String returns the BreakpointID as string value.
func (t BreakpointID) String() string {
return string(t)
}
// CallFrameID call frame identifier.
type CallFrameID string
// String returns the CallFrameID as string value.
func (t CallFrameID) String() string {
return string(t)
}
// Location location in the source code.
type Location struct {
ScriptID runtime.ScriptID `json:"scriptId,omitempty"` // Script identifier as reported in the Debugger.scriptParsed.
LineNumber int64 `json:"lineNumber,omitempty"` // Line number in the script (0-based).
ColumnNumber int64 `json:"columnNumber,omitempty"` // Column number in the script (0-based).
}
// ScriptPosition location in the source code.
type ScriptPosition struct {
LineNumber int64 `json:"lineNumber,omitempty"`
ColumnNumber int64 `json:"columnNumber,omitempty"`
}
// CallFrame javaScript call frame. Array of call frames form the call stack.
type CallFrame struct {
CallFrameID CallFrameID `json:"callFrameId,omitempty"` // Call frame identifier. This identifier is only valid while the virtual machine is paused.
FunctionName string `json:"functionName,omitempty"` // Name of the JavaScript function called on this call frame.
FunctionLocation *Location `json:"functionLocation,omitempty"` // Location in the source code.
Location *Location `json:"location,omitempty"` // Location in the source code.
ScopeChain []*Scope `json:"scopeChain,omitempty"` // Scope chain for this call frame.
This *runtime.RemoteObject `json:"this,omitempty"` // this object for this call frame.
ReturnValue *runtime.RemoteObject `json:"returnValue,omitempty"` // The value being returned, if the function is at return point.
}
// Scope scope description.
type Scope struct {
Type ScopeType `json:"type,omitempty"` // Scope type.
Object *runtime.RemoteObject `json:"object,omitempty"` // Object representing the scope. For global and with scopes it represents the actual object; for the rest of the scopes, it is artificial transient object enumerating scope variables as its properties.
Name string `json:"name,omitempty"`
StartLocation *Location `json:"startLocation,omitempty"` // Location in the source code where scope starts
EndLocation *Location `json:"endLocation,omitempty"` // Location in the source code where scope ends
}
// SearchMatch search match for resource.
type SearchMatch struct {
LineNumber float64 `json:"lineNumber,omitempty"` // Line number in resource content.
LineContent string `json:"lineContent,omitempty"` // Line with match content.
}
// ScopeType scope type.
type ScopeType string
// String returns the ScopeType as string value.
func (t ScopeType) String() string {
return string(t)
}
// ScopeType values.
const (
ScopeTypeGlobal ScopeType = "global"
ScopeTypeLocal ScopeType = "local"
ScopeTypeWith ScopeType = "with"
ScopeTypeClosure ScopeType = "closure"
ScopeTypeCatch ScopeType = "catch"
ScopeTypeBlock ScopeType = "block"
ScopeTypeScript ScopeType = "script"
ScopeTypeEval ScopeType = "eval"
ScopeTypeModule ScopeType = "module"
)
// MarshalEasyJSON satisfies easyjson.Marshaler.
func (t ScopeType) MarshalEasyJSON(out *jwriter.Writer) {
out.String(string(t))
}
// MarshalJSON satisfies json.Marshaler.
func (t ScopeType) MarshalJSON() ([]byte, error) {
return easyjson.Marshal(t)
}
// UnmarshalEasyJSON satisfies easyjson.Unmarshaler.
func (t *ScopeType) UnmarshalEasyJSON(in *jlexer.Lexer) {
switch ScopeType(in.String()) {
case ScopeTypeGlobal:
*t = ScopeTypeGlobal
case ScopeTypeLocal:
*t = ScopeTypeLocal
case ScopeTypeWith:
*t = ScopeTypeWith
case ScopeTypeClosure:
*t = ScopeTypeClosure
case ScopeTypeCatch:
*t = ScopeTypeCatch
case ScopeTypeBlock:
*t = ScopeTypeBlock
case ScopeTypeScript:
*t = ScopeTypeScript
case ScopeTypeEval:
*t = ScopeTypeEval
case ScopeTypeModule:
*t = ScopeTypeModule
default:
in.AddError(errors.New("unknown ScopeType value"))
}
}
// UnmarshalJSON satisfies json.Unmarshaler.
func (t *ScopeType) UnmarshalJSON(buf []byte) error {
return easyjson.Unmarshal(buf, t)
}
// PausedReason pause reason.
type PausedReason string
// String returns the PausedReason as string value.
func (t PausedReason) String() string {
return string(t)
}
// PausedReason values.
const (
PausedReasonXHR PausedReason = "XHR"
PausedReasonDOM PausedReason = "DOM"
PausedReasonEventListener PausedReason = "EventListener"
PausedReasonException PausedReason = "exception"
PausedReasonAssert PausedReason = "assert"
PausedReasonDebugCommand PausedReason = "debugCommand"
PausedReasonPromiseRejection PausedReason = "promiseRejection"
PausedReasonOOM PausedReason = "OOM"
PausedReasonOther PausedReason = "other"
)
// MarshalEasyJSON satisfies easyjson.Marshaler.
func (t PausedReason) MarshalEasyJSON(out *jwriter.Writer) {
out.String(string(t))
}
// MarshalJSON satisfies json.Marshaler.
func (t PausedReason) MarshalJSON() ([]byte, error) {
return easyjson.Marshal(t)
}
// UnmarshalEasyJSON satisfies easyjson.Unmarshaler.
func (t *PausedReason) UnmarshalEasyJSON(in *jlexer.Lexer) {
switch PausedReason(in.String()) {
case PausedReasonXHR:
*t = PausedReasonXHR
case PausedReasonDOM:
*t = PausedReasonDOM
case PausedReasonEventListener:
*t = PausedReasonEventListener
case PausedReasonException:
*t = PausedReasonException
case PausedReasonAssert:
*t = PausedReasonAssert
case PausedReasonDebugCommand:
*t = PausedReasonDebugCommand
case PausedReasonPromiseRejection:
*t = PausedReasonPromiseRejection
case PausedReasonOOM:
*t = PausedReasonOOM
case PausedReasonOther:
*t = PausedReasonOther
default:
in.AddError(errors.New("unknown PausedReason value"))
}
}
// UnmarshalJSON satisfies json.Unmarshaler.
func (t *PausedReason) UnmarshalJSON(buf []byte) error {
return easyjson.Unmarshal(buf, t)
}
// ExceptionsState pause on exceptions mode.
type ExceptionsState string
// String returns the ExceptionsState as string value.
func (t ExceptionsState) String() string {
return string(t)
}
// ExceptionsState values.
const (
ExceptionsStateNone ExceptionsState = "none"
ExceptionsStateUncaught ExceptionsState = "uncaught"
ExceptionsStateAll ExceptionsState = "all"
)
// MarshalEasyJSON satisfies easyjson.Marshaler.
func (t ExceptionsState) MarshalEasyJSON(out *jwriter.Writer) {
out.String(string(t))
}
// MarshalJSON satisfies json.Marshaler.
func (t ExceptionsState) MarshalJSON() ([]byte, error) {
return easyjson.Marshal(t)
}
// UnmarshalEasyJSON satisfies easyjson.Unmarshaler.
func (t *ExceptionsState) UnmarshalEasyJSON(in *jlexer.Lexer) {
switch ExceptionsState(in.String()) {
case ExceptionsStateNone:
*t = ExceptionsStateNone
case ExceptionsStateUncaught:
*t = ExceptionsStateUncaught
case ExceptionsStateAll:
*t = ExceptionsStateAll
default:
in.AddError(errors.New("unknown ExceptionsState value"))
}
}
// UnmarshalJSON satisfies json.Unmarshaler.
func (t *ExceptionsState) UnmarshalJSON(buf []byte) error {
return easyjson.Unmarshal(buf, t)
}

View File

@ -0,0 +1,132 @@
// Package deviceorientation provides the Chrome Debugging Protocol
// commands, types, and events for the Chrome DeviceOrientation domain.
//
// Generated by the chromedp-gen command.
package deviceorientation
// AUTOGENERATED. DO NOT EDIT.
import (
"context"
. "github.com/knq/chromedp/cdp"
"github.com/mailru/easyjson"
)
var (
_ BackendNode
_ BackendNodeID
_ ComputedProperty
_ ErrorType
_ Frame
_ FrameID
_ LoaderID
_ Message
_ MessageError
_ MethodType
_ Node
_ NodeID
_ NodeType
_ PseudoType
_ RGBA
_ ShadowRootType
_ Timestamp
)
// SetDeviceOrientationOverrideParams overrides the Device Orientation.
type SetDeviceOrientationOverrideParams struct {
Alpha float64 `json:"alpha"` // Mock alpha
Beta float64 `json:"beta"` // Mock beta
Gamma float64 `json:"gamma"` // Mock gamma
}
// SetDeviceOrientationOverride overrides the Device Orientation.
//
// parameters:
// alpha - Mock alpha
// beta - Mock beta
// gamma - Mock gamma
func SetDeviceOrientationOverride(alpha float64, beta float64, gamma float64) *SetDeviceOrientationOverrideParams {
return &SetDeviceOrientationOverrideParams{
Alpha: alpha,
Beta: beta,
Gamma: gamma,
}
}
// Do executes DeviceOrientation.setDeviceOrientationOverride.
func (p *SetDeviceOrientationOverrideParams) Do(ctxt context.Context, h FrameHandler) (err error) {
if ctxt == nil {
ctxt = context.Background()
}
// marshal
buf, err := easyjson.Marshal(p)
if err != nil {
return err
}
// execute
ch := h.Execute(ctxt, CommandDeviceOrientationSetDeviceOrientationOverride, easyjson.RawMessage(buf))
// read response
select {
case res := <-ch:
if res == nil {
return ErrChannelClosed
}
switch v := res.(type) {
case easyjson.RawMessage:
return nil
case error:
return v
}
case <-ctxt.Done():
return ErrContextDone
}
return ErrUnknownResult
}
// ClearDeviceOrientationOverrideParams clears the overridden Device
// Orientation.
type ClearDeviceOrientationOverrideParams struct{}
// ClearDeviceOrientationOverride clears the overridden Device Orientation.
func ClearDeviceOrientationOverride() *ClearDeviceOrientationOverrideParams {
return &ClearDeviceOrientationOverrideParams{}
}
// Do executes DeviceOrientation.clearDeviceOrientationOverride.
func (p *ClearDeviceOrientationOverrideParams) Do(ctxt context.Context, h FrameHandler) (err error) {
if ctxt == nil {
ctxt = context.Background()
}
// execute
ch := h.Execute(ctxt, CommandDeviceOrientationClearDeviceOrientationOverride, Empty)
// read response
select {
case res := <-ch:
if res == nil {
return ErrChannelClosed
}
switch v := res.(type) {
case easyjson.RawMessage:
return nil
case error:
return v
}
case <-ctxt.Done():
return ErrContextDone
}
return ErrUnknownResult
}

View File

@ -0,0 +1,161 @@
// AUTOGENERATED FILE: easyjson marshaler/unmarshalers.
package deviceorientation
import (
json "encoding/json"
easyjson "github.com/mailru/easyjson"
jlexer "github.com/mailru/easyjson/jlexer"
jwriter "github.com/mailru/easyjson/jwriter"
)
// suppress unused package warning
var (
_ *json.RawMessage
_ *jlexer.Lexer
_ *jwriter.Writer
_ easyjson.Marshaler
)
func easyjsonC5a4559bDecodeGithubComKnqChromedpCdpDeviceorientation(in *jlexer.Lexer, out *SetDeviceOrientationOverrideParams) {
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 "alpha":
out.Alpha = float64(in.Float64())
case "beta":
out.Beta = float64(in.Float64())
case "gamma":
out.Gamma = float64(in.Float64())
default:
in.SkipRecursive()
}
in.WantComma()
}
in.Delim('}')
if isTopLevel {
in.Consumed()
}
}
func easyjsonC5a4559bEncodeGithubComKnqChromedpCdpDeviceorientation(out *jwriter.Writer, in SetDeviceOrientationOverrideParams) {
out.RawByte('{')
first := true
_ = first
if !first {
out.RawByte(',')
}
first = false
out.RawString("\"alpha\":")
out.Float64(float64(in.Alpha))
if !first {
out.RawByte(',')
}
first = false
out.RawString("\"beta\":")
out.Float64(float64(in.Beta))
if !first {
out.RawByte(',')
}
first = false
out.RawString("\"gamma\":")
out.Float64(float64(in.Gamma))
out.RawByte('}')
}
// MarshalJSON supports json.Marshaler interface
func (v SetDeviceOrientationOverrideParams) MarshalJSON() ([]byte, error) {
w := jwriter.Writer{}
easyjsonC5a4559bEncodeGithubComKnqChromedpCdpDeviceorientation(&w, v)
return w.Buffer.BuildBytes(), w.Error
}
// MarshalEasyJSON supports easyjson.Marshaler interface
func (v SetDeviceOrientationOverrideParams) MarshalEasyJSON(w *jwriter.Writer) {
easyjsonC5a4559bEncodeGithubComKnqChromedpCdpDeviceorientation(w, v)
}
// UnmarshalJSON supports json.Unmarshaler interface
func (v *SetDeviceOrientationOverrideParams) UnmarshalJSON(data []byte) error {
r := jlexer.Lexer{Data: data}
easyjsonC5a4559bDecodeGithubComKnqChromedpCdpDeviceorientation(&r, v)
return r.Error()
}
// UnmarshalEasyJSON supports easyjson.Unmarshaler interface
func (v *SetDeviceOrientationOverrideParams) UnmarshalEasyJSON(l *jlexer.Lexer) {
easyjsonC5a4559bDecodeGithubComKnqChromedpCdpDeviceorientation(l, v)
}
func easyjsonC5a4559bDecodeGithubComKnqChromedpCdpDeviceorientation1(in *jlexer.Lexer, out *ClearDeviceOrientationOverrideParams) {
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 {
default:
in.SkipRecursive()
}
in.WantComma()
}
in.Delim('}')
if isTopLevel {
in.Consumed()
}
}
func easyjsonC5a4559bEncodeGithubComKnqChromedpCdpDeviceorientation1(out *jwriter.Writer, in ClearDeviceOrientationOverrideParams) {
out.RawByte('{')
first := true
_ = first
out.RawByte('}')
}
// MarshalJSON supports json.Marshaler interface
func (v ClearDeviceOrientationOverrideParams) MarshalJSON() ([]byte, error) {
w := jwriter.Writer{}
easyjsonC5a4559bEncodeGithubComKnqChromedpCdpDeviceorientation1(&w, v)
return w.Buffer.BuildBytes(), w.Error
}
// MarshalEasyJSON supports easyjson.Marshaler interface
func (v ClearDeviceOrientationOverrideParams) MarshalEasyJSON(w *jwriter.Writer) {
easyjsonC5a4559bEncodeGithubComKnqChromedpCdpDeviceorientation1(w, v)
}
// UnmarshalJSON supports json.Unmarshaler interface
func (v *ClearDeviceOrientationOverrideParams) UnmarshalJSON(data []byte) error {
r := jlexer.Lexer{Data: data}
easyjsonC5a4559bDecodeGithubComKnqChromedpCdpDeviceorientation1(&r, v)
return r.Error()
}
// UnmarshalEasyJSON supports easyjson.Unmarshaler interface
func (v *ClearDeviceOrientationOverrideParams) UnmarshalEasyJSON(l *jlexer.Lexer) {
easyjsonC5a4559bDecodeGithubComKnqChromedpCdpDeviceorientation1(l, v)
}

2634
cdp/dom/dom.go Normal file

File diff suppressed because it is too large Load Diff

6889
cdp/dom/easyjson.go Normal file

File diff suppressed because it is too large Load Diff

146
cdp/dom/events.go Normal file
View File

@ -0,0 +1,146 @@
package dom
// AUTOGENERATED. DO NOT EDIT.
import (
. "github.com/knq/chromedp/cdp"
)
var (
_ BackendNode
_ BackendNodeID
_ ComputedProperty
_ ErrorType
_ Frame
_ FrameID
_ LoaderID
_ Message
_ MessageError
_ MethodType
_ Node
_ NodeID
_ NodeType
_ PseudoType
_ RGBA
_ ShadowRootType
_ Timestamp
)
// EventDocumentUpdated fired when Document has been totally updated. Node
// ids are no longer valid.
type EventDocumentUpdated struct{}
// EventInspectNodeRequested fired when the node should be inspected. This
// happens after call to setInspectMode.
type EventInspectNodeRequested struct {
BackendNodeID BackendNodeID `json:"backendNodeId,omitempty"` // Id of the node to inspect.
}
// 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 NodeID `json:"parentId,omitempty"` // Parent node id to populate with children.
Nodes []*Node `json:"nodes,omitempty"` // Child nodes array.
}
// EventAttributeModified fired when Element's attribute is modified.
type EventAttributeModified struct {
NodeID NodeID `json:"nodeId,omitempty"` // Id of the node that has changed.
Name string `json:"name,omitempty"` // Attribute name.
Value string `json:"value,omitempty"` // Attribute value.
}
// EventAttributeRemoved fired when Element's attribute is removed.
type EventAttributeRemoved struct {
NodeID NodeID `json:"nodeId,omitempty"` // Id of the node that has changed.
Name string `json:"name,omitempty"` // A ttribute name.
}
// EventInlineStyleInvalidated fired when Element's inline style is modified
// via a CSS property modification.
type EventInlineStyleInvalidated struct {
NodeIds []NodeID `json:"nodeIds,omitempty"` // Ids of the nodes for which the inline styles have been invalidated.
}
// EventCharacterDataModified mirrors DOMCharacterDataModified event.
type EventCharacterDataModified struct {
NodeID NodeID `json:"nodeId,omitempty"` // Id of the node that has changed.
CharacterData string `json:"characterData,omitempty"` // New text value.
}
// EventChildNodeCountUpdated fired when Container's child node count has
// changed.
type EventChildNodeCountUpdated struct {
NodeID NodeID `json:"nodeId,omitempty"` // Id of the node that has changed.
ChildNodeCount int64 `json:"childNodeCount,omitempty"` // New node count.
}
// EventChildNodeInserted mirrors DOMNodeInserted event.
type EventChildNodeInserted struct {
ParentNodeID NodeID `json:"parentNodeId,omitempty"` // Id of the node that has changed.
PreviousNodeID NodeID `json:"previousNodeId,omitempty"` // If of the previous siblint.
Node *Node `json:"node,omitempty"` // Inserted node data.
}
// EventChildNodeRemoved mirrors DOMNodeRemoved event.
type EventChildNodeRemoved struct {
ParentNodeID NodeID `json:"parentNodeId,omitempty"` // Parent id.
NodeID NodeID `json:"nodeId,omitempty"` // Id of the node that has been removed.
}
// EventShadowRootPushed called when shadow root is pushed into the element.
type EventShadowRootPushed struct {
HostID NodeID `json:"hostId,omitempty"` // Host element id.
Root *Node `json:"root,omitempty"` // Shadow root.
}
// EventShadowRootPopped called when shadow root is popped from the element.
type EventShadowRootPopped struct {
HostID NodeID `json:"hostId,omitempty"` // Host element id.
RootID NodeID `json:"rootId,omitempty"` // Shadow root id.
}
// EventPseudoElementAdded called when a pseudo element is added to an
// element.
type EventPseudoElementAdded struct {
ParentID NodeID `json:"parentId,omitempty"` // Pseudo element's parent element id.
PseudoElement *Node `json:"pseudoElement,omitempty"` // The added pseudo element.
}
// EventPseudoElementRemoved called when a pseudo element is removed from an
// element.
type EventPseudoElementRemoved struct {
ParentID NodeID `json:"parentId,omitempty"` // Pseudo element's parent element id.
PseudoElementID NodeID `json:"pseudoElementId,omitempty"` // The removed pseudo element id.
}
// EventDistributedNodesUpdated called when distrubution is changed.
type EventDistributedNodesUpdated struct {
InsertionPointID NodeID `json:"insertionPointId,omitempty"` // Insertion point where distrubuted nodes were updated.
DistributedNodes []*BackendNode `json:"distributedNodes,omitempty"` // Distributed nodes for given insertion point.
}
type EventNodeHighlightRequested struct {
NodeID NodeID `json:"nodeId,omitempty"`
}
// EventTypes is all event types in the domain.
var EventTypes = []MethodType{
EventDOMDocumentUpdated,
EventDOMInspectNodeRequested,
EventDOMSetChildNodes,
EventDOMAttributeModified,
EventDOMAttributeRemoved,
EventDOMInlineStyleInvalidated,
EventDOMCharacterDataModified,
EventDOMChildNodeCountUpdated,
EventDOMChildNodeInserted,
EventDOMChildNodeRemoved,
EventDOMShadowRootPushed,
EventDOMShadowRootPopped,
EventDOMPseudoElementAdded,
EventDOMPseudoElementRemoved,
EventDOMDistributedNodesUpdated,
EventDOMNodeHighlightRequested,
}

122
cdp/dom/types.go Normal file
View File

@ -0,0 +1,122 @@
package dom
// AUTOGENERATED. DO NOT EDIT.
import (
"errors"
. "github.com/knq/chromedp/cdp"
"github.com/mailru/easyjson"
"github.com/mailru/easyjson/jlexer"
"github.com/mailru/easyjson/jwriter"
)
var (
_ BackendNode
_ BackendNodeID
_ ComputedProperty
_ ErrorType
_ Frame
_ FrameID
_ LoaderID
_ Message
_ MessageError
_ MethodType
_ Node
_ NodeID
_ NodeType
_ PseudoType
_ RGBA
_ ShadowRootType
_ Timestamp
)
// Quad an array of quad vertices, x immediately followed by y for each
// point, points clock-wise.
type Quad []float64
// BoxModel box model.
type BoxModel struct {
Content Quad `json:"content,omitempty"` // Content box
Padding Quad `json:"padding,omitempty"` // Padding box
Border Quad `json:"border,omitempty"` // Border box
Margin Quad `json:"margin,omitempty"` // Margin box
Width int64 `json:"width,omitempty"` // Node width
Height int64 `json:"height,omitempty"` // Node height
ShapeOutside *ShapeOutsideInfo `json:"shapeOutside,omitempty"` // Shape outside coordinates
}
// ShapeOutsideInfo cSS Shape Outside details.
type ShapeOutsideInfo struct {
Bounds Quad `json:"bounds,omitempty"` // Shape bounds
Shape []easyjson.RawMessage `json:"shape,omitempty"` // Shape coordinate details
MarginShape []easyjson.RawMessage `json:"marginShape,omitempty"` // Margin shape bounds
}
// Rect rectangle.
type Rect struct {
X float64 `json:"x,omitempty"` // X coordinate
Y float64 `json:"y,omitempty"` // Y coordinate
Width float64 `json:"width,omitempty"` // Rectangle width
Height float64 `json:"height,omitempty"` // Rectangle height
}
// HighlightConfig configuration data for the highlighting of page elements.
type HighlightConfig struct {
ShowInfo bool `json:"showInfo,omitempty"` // Whether the node info tooltip should be shown (default: false).
ShowRulers bool `json:"showRulers,omitempty"` // Whether the rulers should be shown (default: false).
ShowExtensionLines bool `json:"showExtensionLines,omitempty"` // Whether the extension lines from node to the rulers should be shown (default: false).
DisplayAsMaterial bool `json:"displayAsMaterial,omitempty"`
ContentColor *RGBA `json:"contentColor,omitempty"` // The content box highlight fill color (default: transparent).
PaddingColor *RGBA `json:"paddingColor,omitempty"` // The padding highlight fill color (default: transparent).
BorderColor *RGBA `json:"borderColor,omitempty"` // The border highlight fill color (default: transparent).
MarginColor *RGBA `json:"marginColor,omitempty"` // The margin highlight fill color (default: transparent).
EventTargetColor *RGBA `json:"eventTargetColor,omitempty"` // The event target element highlight fill color (default: transparent).
ShapeColor *RGBA `json:"shapeColor,omitempty"` // The shape outside fill color (default: transparent).
ShapeMarginColor *RGBA `json:"shapeMarginColor,omitempty"` // The shape margin fill color (default: transparent).
SelectorList string `json:"selectorList,omitempty"` // Selectors to highlight relevant nodes.
}
type InspectMode string
// String returns the InspectMode as string value.
func (t InspectMode) String() string {
return string(t)
}
// InspectMode values.
const (
InspectModeSearchForNode InspectMode = "searchForNode"
InspectModeSearchForUAShadowDOM InspectMode = "searchForUAShadowDOM"
InspectModeNone InspectMode = "none"
)
// MarshalEasyJSON satisfies easyjson.Marshaler.
func (t InspectMode) MarshalEasyJSON(out *jwriter.Writer) {
out.String(string(t))
}
// MarshalJSON satisfies json.Marshaler.
func (t InspectMode) MarshalJSON() ([]byte, error) {
return easyjson.Marshal(t)
}
// UnmarshalEasyJSON satisfies easyjson.Unmarshaler.
func (t *InspectMode) UnmarshalEasyJSON(in *jlexer.Lexer) {
switch InspectMode(in.String()) {
case InspectModeSearchForNode:
*t = InspectModeSearchForNode
case InspectModeSearchForUAShadowDOM:
*t = InspectModeSearchForUAShadowDOM
case InspectModeNone:
*t = InspectModeNone
default:
in.AddError(errors.New("unknown InspectMode value"))
}
}
// UnmarshalJSON satisfies json.Unmarshaler.
func (t *InspectMode) UnmarshalJSON(buf []byte) error {
return easyjson.Unmarshal(buf, t)
}

View File

@ -0,0 +1,549 @@
// Package domdebugger provides the Chrome Debugging Protocol
// commands, types, and events for the Chrome DOMDebugger domain.
//
// DOM debugging allows setting breakpoints on particular DOM operations and
// events. JavaScript execution will stop on these operations as if there was a
// regular breakpoint set.
//
// Generated by the chromedp-gen command.
package domdebugger
// AUTOGENERATED. DO NOT EDIT.
import (
"context"
. "github.com/knq/chromedp/cdp"
"github.com/knq/chromedp/cdp/runtime"
"github.com/mailru/easyjson"
)
var (
_ BackendNode
_ BackendNodeID
_ ComputedProperty
_ ErrorType
_ Frame
_ FrameID
_ LoaderID
_ Message
_ MessageError
_ MethodType
_ Node
_ NodeID
_ NodeType
_ PseudoType
_ RGBA
_ ShadowRootType
_ Timestamp
)
// SetDOMBreakpointParams sets breakpoint on particular operation with DOM.
type SetDOMBreakpointParams struct {
NodeID 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 NodeID, type_ DOMBreakpointType) *SetDOMBreakpointParams {
return &SetDOMBreakpointParams{
NodeID: nodeId,
Type: type_,
}
}
// Do executes DOMDebugger.setDOMBreakpoint.
func (p *SetDOMBreakpointParams) Do(ctxt context.Context, h FrameHandler) (err error) {
if ctxt == nil {
ctxt = context.Background()
}
// marshal
buf, err := easyjson.Marshal(p)
if err != nil {
return err
}
// execute
ch := h.Execute(ctxt, CommandDOMDebuggerSetDOMBreakpoint, easyjson.RawMessage(buf))
// read response
select {
case res := <-ch:
if res == nil {
return ErrChannelClosed
}
switch v := res.(type) {
case easyjson.RawMessage:
return nil
case error:
return v
}
case <-ctxt.Done():
return ErrContextDone
}
return ErrUnknownResult
}
// RemoveDOMBreakpointParams removes DOM breakpoint that was set using
// setDOMBreakpoint.
type RemoveDOMBreakpointParams struct {
NodeID 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 NodeID, type_ DOMBreakpointType) *RemoveDOMBreakpointParams {
return &RemoveDOMBreakpointParams{
NodeID: nodeId,
Type: type_,
}
}
// Do executes DOMDebugger.removeDOMBreakpoint.
func (p *RemoveDOMBreakpointParams) Do(ctxt context.Context, h FrameHandler) (err error) {
if ctxt == nil {
ctxt = context.Background()
}
// marshal
buf, err := easyjson.Marshal(p)
if err != nil {
return err
}
// execute
ch := h.Execute(ctxt, CommandDOMDebuggerRemoveDOMBreakpoint, easyjson.RawMessage(buf))
// read response
select {
case res := <-ch:
if res == nil {
return ErrChannelClosed
}
switch v := res.(type) {
case easyjson.RawMessage:
return nil
case error:
return v
}
case <-ctxt.Done():
return ErrContextDone
}
return ErrUnknownResult
}
// 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.
func (p *SetEventListenerBreakpointParams) Do(ctxt context.Context, h FrameHandler) (err error) {
if ctxt == nil {
ctxt = context.Background()
}
// marshal
buf, err := easyjson.Marshal(p)
if err != nil {
return err
}
// execute
ch := h.Execute(ctxt, CommandDOMDebuggerSetEventListenerBreakpoint, easyjson.RawMessage(buf))
// read response
select {
case res := <-ch:
if res == nil {
return ErrChannelClosed
}
switch v := res.(type) {
case easyjson.RawMessage:
return nil
case error:
return v
}
case <-ctxt.Done():
return ErrContextDone
}
return ErrUnknownResult
}
// 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.
func (p *RemoveEventListenerBreakpointParams) Do(ctxt context.Context, h FrameHandler) (err error) {
if ctxt == nil {
ctxt = context.Background()
}
// marshal
buf, err := easyjson.Marshal(p)
if err != nil {
return err
}
// execute
ch := h.Execute(ctxt, CommandDOMDebuggerRemoveEventListenerBreakpoint, easyjson.RawMessage(buf))
// read response
select {
case res := <-ch:
if res == nil {
return ErrChannelClosed
}
switch v := res.(type) {
case easyjson.RawMessage:
return nil
case error:
return v
}
case <-ctxt.Done():
return ErrContextDone
}
return ErrUnknownResult
}
// 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.
func (p *SetInstrumentationBreakpointParams) Do(ctxt context.Context, h FrameHandler) (err error) {
if ctxt == nil {
ctxt = context.Background()
}
// marshal
buf, err := easyjson.Marshal(p)
if err != nil {
return err
}
// execute
ch := h.Execute(ctxt, CommandDOMDebuggerSetInstrumentationBreakpoint, easyjson.RawMessage(buf))
// read response
select {
case res := <-ch:
if res == nil {
return ErrChannelClosed
}
switch v := res.(type) {
case easyjson.RawMessage:
return nil
case error:
return v
}
case <-ctxt.Done():
return ErrContextDone
}
return ErrUnknownResult
}
// 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.
func (p *RemoveInstrumentationBreakpointParams) Do(ctxt context.Context, h FrameHandler) (err error) {
if ctxt == nil {
ctxt = context.Background()
}
// marshal
buf, err := easyjson.Marshal(p)
if err != nil {
return err
}
// execute
ch := h.Execute(ctxt, CommandDOMDebuggerRemoveInstrumentationBreakpoint, easyjson.RawMessage(buf))
// read response
select {
case res := <-ch:
if res == nil {
return ErrChannelClosed
}
switch v := res.(type) {
case easyjson.RawMessage:
return nil
case error:
return v
}
case <-ctxt.Done():
return ErrContextDone
}
return ErrUnknownResult
}
// 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.
func (p *SetXHRBreakpointParams) Do(ctxt context.Context, h FrameHandler) (err error) {
if ctxt == nil {
ctxt = context.Background()
}
// marshal
buf, err := easyjson.Marshal(p)
if err != nil {
return err
}
// execute
ch := h.Execute(ctxt, CommandDOMDebuggerSetXHRBreakpoint, easyjson.RawMessage(buf))
// read response
select {
case res := <-ch:
if res == nil {
return ErrChannelClosed
}
switch v := res.(type) {
case easyjson.RawMessage:
return nil
case error:
return v
}
case <-ctxt.Done():
return ErrContextDone
}
return ErrUnknownResult
}
// 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.
func (p *RemoveXHRBreakpointParams) Do(ctxt context.Context, h FrameHandler) (err error) {
if ctxt == nil {
ctxt = context.Background()
}
// marshal
buf, err := easyjson.Marshal(p)
if err != nil {
return err
}
// execute
ch := h.Execute(ctxt, CommandDOMDebuggerRemoveXHRBreakpoint, easyjson.RawMessage(buf))
// read response
select {
case res := <-ch:
if res == nil {
return ErrChannelClosed
}
switch v := res.(type) {
case easyjson.RawMessage:
return nil
case error:
return v
}
case <-ctxt.Done():
return ErrContextDone
}
return ErrUnknownResult
}
// GetEventListenersParams returns event listeners of the given object.
type GetEventListenersParams struct {
ObjectID runtime.RemoteObjectID `json:"objectId"` // Identifier of the object to return listeners for.
}
// GetEventListeners returns event listeners of the given object.
//
// parameters:
// objectId - Identifier of the object to return listeners for.
func GetEventListeners(objectId runtime.RemoteObjectID) *GetEventListenersParams {
return &GetEventListenersParams{
ObjectID: objectId,
}
}
// GetEventListenersReturns return values.
type GetEventListenersReturns struct {
Listeners []*EventListener `json:"listeners,omitempty"` // Array of relevant listeners.
}
// Do executes DOMDebugger.getEventListeners.
//
// returns:
// listeners - Array of relevant listeners.
func (p *GetEventListenersParams) Do(ctxt context.Context, h FrameHandler) (listeners []*EventListener, err error) {
if ctxt == nil {
ctxt = context.Background()
}
// marshal
buf, err := easyjson.Marshal(p)
if err != nil {
return nil, err
}
// execute
ch := h.Execute(ctxt, CommandDOMDebuggerGetEventListeners, easyjson.RawMessage(buf))
// read response
select {
case res := <-ch:
if res == nil {
return nil, ErrChannelClosed
}
switch v := res.(type) {
case easyjson.RawMessage:
// unmarshal
var r GetEventListenersReturns
err = easyjson.Unmarshal(v, &r)
if err != nil {
return nil, ErrInvalidResult
}
return r.Listeners, nil
case error:
return nil, v
}
case <-ctxt.Done():
return nil, ErrContextDone
}
return nil, ErrUnknownResult
}

963
cdp/domdebugger/easyjson.go Normal file
View File

@ -0,0 +1,963 @@
// AUTOGENERATED FILE: easyjson marshaler/unmarshalers.
package domdebugger
import (
json "encoding/json"
runtime "github.com/knq/chromedp/cdp/runtime"
easyjson "github.com/mailru/easyjson"
jlexer "github.com/mailru/easyjson/jlexer"
jwriter "github.com/mailru/easyjson/jwriter"
)
// suppress unused package warning
var (
_ *json.RawMessage
_ *jlexer.Lexer
_ *jwriter.Writer
_ easyjson.Marshaler
)
func easyjsonC5a4559bDecodeGithubComKnqChromedpCdpDomdebugger(in *jlexer.Lexer, out *SetXHRBreakpointParams) {
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 "url":
out.URL = string(in.String())
default:
in.SkipRecursive()
}
in.WantComma()
}
in.Delim('}')
if isTopLevel {
in.Consumed()
}
}
func easyjsonC5a4559bEncodeGithubComKnqChromedpCdpDomdebugger(out *jwriter.Writer, in SetXHRBreakpointParams) {
out.RawByte('{')
first := true
_ = first
if !first {
out.RawByte(',')
}
first = false
out.RawString("\"url\":")
out.String(string(in.URL))
out.RawByte('}')
}
// MarshalJSON supports json.Marshaler interface
func (v SetXHRBreakpointParams) MarshalJSON() ([]byte, error) {
w := jwriter.Writer{}
easyjsonC5a4559bEncodeGithubComKnqChromedpCdpDomdebugger(&w, v)
return w.Buffer.BuildBytes(), w.Error
}
// MarshalEasyJSON supports easyjson.Marshaler interface
func (v SetXHRBreakpointParams) MarshalEasyJSON(w *jwriter.Writer) {
easyjsonC5a4559bEncodeGithubComKnqChromedpCdpDomdebugger(w, v)
}
// UnmarshalJSON supports json.Unmarshaler interface
func (v *SetXHRBreakpointParams) UnmarshalJSON(data []byte) error {
r := jlexer.Lexer{Data: data}
easyjsonC5a4559bDecodeGithubComKnqChromedpCdpDomdebugger(&r, v)
return r.Error()
}
// UnmarshalEasyJSON supports easyjson.Unmarshaler interface
func (v *SetXHRBreakpointParams) UnmarshalEasyJSON(l *jlexer.Lexer) {
easyjsonC5a4559bDecodeGithubComKnqChromedpCdpDomdebugger(l, v)
}
func easyjsonC5a4559bDecodeGithubComKnqChromedpCdpDomdebugger1(in *jlexer.Lexer, out *SetInstrumentationBreakpointParams) {
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 "eventName":
out.EventName = string(in.String())
default:
in.SkipRecursive()
}
in.WantComma()
}
in.Delim('}')
if isTopLevel {
in.Consumed()
}
}
func easyjsonC5a4559bEncodeGithubComKnqChromedpCdpDomdebugger1(out *jwriter.Writer, in SetInstrumentationBreakpointParams) {
out.RawByte('{')
first := true
_ = first
if !first {
out.RawByte(',')
}
first = false
out.RawString("\"eventName\":")
out.String(string(in.EventName))
out.RawByte('}')
}
// MarshalJSON supports json.Marshaler interface
func (v SetInstrumentationBreakpointParams) MarshalJSON() ([]byte, error) {
w := jwriter.Writer{}
easyjsonC5a4559bEncodeGithubComKnqChromedpCdpDomdebugger1(&w, v)
return w.Buffer.BuildBytes(), w.Error
}
// MarshalEasyJSON supports easyjson.Marshaler interface
func (v SetInstrumentationBreakpointParams) MarshalEasyJSON(w *jwriter.Writer) {
easyjsonC5a4559bEncodeGithubComKnqChromedpCdpDomdebugger1(w, v)
}
// UnmarshalJSON supports json.Unmarshaler interface
func (v *SetInstrumentationBreakpointParams) UnmarshalJSON(data []byte) error {
r := jlexer.Lexer{Data: data}
easyjsonC5a4559bDecodeGithubComKnqChromedpCdpDomdebugger1(&r, v)
return r.Error()
}
// UnmarshalEasyJSON supports easyjson.Unmarshaler interface
func (v *SetInstrumentationBreakpointParams) UnmarshalEasyJSON(l *jlexer.Lexer) {
easyjsonC5a4559bDecodeGithubComKnqChromedpCdpDomdebugger1(l, v)
}
func easyjsonC5a4559bDecodeGithubComKnqChromedpCdpDomdebugger2(in *jlexer.Lexer, out *SetEventListenerBreakpointParams) {
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 "eventName":
out.EventName = string(in.String())
case "targetName":
out.TargetName = string(in.String())
default:
in.SkipRecursive()
}
in.WantComma()
}
in.Delim('}')
if isTopLevel {
in.Consumed()
}
}
func easyjsonC5a4559bEncodeGithubComKnqChromedpCdpDomdebugger2(out *jwriter.Writer, in SetEventListenerBreakpointParams) {
out.RawByte('{')
first := true
_ = first
if !first {
out.RawByte(',')
}
first = false
out.RawString("\"eventName\":")
out.String(string(in.EventName))
if in.TargetName != "" {
if !first {
out.RawByte(',')
}
first = false
out.RawString("\"targetName\":")
out.String(string(in.TargetName))
}
out.RawByte('}')
}
// MarshalJSON supports json.Marshaler interface
func (v SetEventListenerBreakpointParams) MarshalJSON() ([]byte, error) {
w := jwriter.Writer{}
easyjsonC5a4559bEncodeGithubComKnqChromedpCdpDomdebugger2(&w, v)
return w.Buffer.BuildBytes(), w.Error
}
// MarshalEasyJSON supports easyjson.Marshaler interface
func (v SetEventListenerBreakpointParams) MarshalEasyJSON(w *jwriter.Writer) {
easyjsonC5a4559bEncodeGithubComKnqChromedpCdpDomdebugger2(w, v)
}
// UnmarshalJSON supports json.Unmarshaler interface
func (v *SetEventListenerBreakpointParams) UnmarshalJSON(data []byte) error {
r := jlexer.Lexer{Data: data}
easyjsonC5a4559bDecodeGithubComKnqChromedpCdpDomdebugger2(&r, v)
return r.Error()
}
// UnmarshalEasyJSON supports easyjson.Unmarshaler interface
func (v *SetEventListenerBreakpointParams) UnmarshalEasyJSON(l *jlexer.Lexer) {
easyjsonC5a4559bDecodeGithubComKnqChromedpCdpDomdebugger2(l, v)
}
func easyjsonC5a4559bDecodeGithubComKnqChromedpCdpDomdebugger3(in *jlexer.Lexer, out *SetDOMBreakpointParams) {
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 "nodeId":
(out.NodeID).UnmarshalEasyJSON(in)
case "type":
(out.Type).UnmarshalEasyJSON(in)
default:
in.SkipRecursive()
}
in.WantComma()
}
in.Delim('}')
if isTopLevel {
in.Consumed()
}
}
func easyjsonC5a4559bEncodeGithubComKnqChromedpCdpDomdebugger3(out *jwriter.Writer, in SetDOMBreakpointParams) {
out.RawByte('{')
first := true
_ = first
if !first {
out.RawByte(',')
}
first = false
out.RawString("\"nodeId\":")
out.Int64(int64(in.NodeID))
if !first {
out.RawByte(',')
}
first = false
out.RawString("\"type\":")
(in.Type).MarshalEasyJSON(out)
out.RawByte('}')
}
// MarshalJSON supports json.Marshaler interface
func (v SetDOMBreakpointParams) MarshalJSON() ([]byte, error) {
w := jwriter.Writer{}
easyjsonC5a4559bEncodeGithubComKnqChromedpCdpDomdebugger3(&w, v)
return w.Buffer.BuildBytes(), w.Error
}
// MarshalEasyJSON supports easyjson.Marshaler interface
func (v SetDOMBreakpointParams) MarshalEasyJSON(w *jwriter.Writer) {
easyjsonC5a4559bEncodeGithubComKnqChromedpCdpDomdebugger3(w, v)
}
// UnmarshalJSON supports json.Unmarshaler interface
func (v *SetDOMBreakpointParams) UnmarshalJSON(data []byte) error {
r := jlexer.Lexer{Data: data}
easyjsonC5a4559bDecodeGithubComKnqChromedpCdpDomdebugger3(&r, v)
return r.Error()
}
// UnmarshalEasyJSON supports easyjson.Unmarshaler interface
func (v *SetDOMBreakpointParams) UnmarshalEasyJSON(l *jlexer.Lexer) {
easyjsonC5a4559bDecodeGithubComKnqChromedpCdpDomdebugger3(l, v)
}
func easyjsonC5a4559bDecodeGithubComKnqChromedpCdpDomdebugger4(in *jlexer.Lexer, out *RemoveXHRBreakpointParams) {
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 "url":
out.URL = string(in.String())
default:
in.SkipRecursive()
}
in.WantComma()
}
in.Delim('}')
if isTopLevel {
in.Consumed()
}
}
func easyjsonC5a4559bEncodeGithubComKnqChromedpCdpDomdebugger4(out *jwriter.Writer, in RemoveXHRBreakpointParams) {
out.RawByte('{')
first := true
_ = first
if !first {
out.RawByte(',')
}
first = false
out.RawString("\"url\":")
out.String(string(in.URL))
out.RawByte('}')
}
// MarshalJSON supports json.Marshaler interface
func (v RemoveXHRBreakpointParams) MarshalJSON() ([]byte, error) {
w := jwriter.Writer{}
easyjsonC5a4559bEncodeGithubComKnqChromedpCdpDomdebugger4(&w, v)
return w.Buffer.BuildBytes(), w.Error
}
// MarshalEasyJSON supports easyjson.Marshaler interface
func (v RemoveXHRBreakpointParams) MarshalEasyJSON(w *jwriter.Writer) {
easyjsonC5a4559bEncodeGithubComKnqChromedpCdpDomdebugger4(w, v)
}
// UnmarshalJSON supports json.Unmarshaler interface
func (v *RemoveXHRBreakpointParams) UnmarshalJSON(data []byte) error {
r := jlexer.Lexer{Data: data}
easyjsonC5a4559bDecodeGithubComKnqChromedpCdpDomdebugger4(&r, v)
return r.Error()
}
// UnmarshalEasyJSON supports easyjson.Unmarshaler interface
func (v *RemoveXHRBreakpointParams) UnmarshalEasyJSON(l *jlexer.Lexer) {
easyjsonC5a4559bDecodeGithubComKnqChromedpCdpDomdebugger4(l, v)
}
func easyjsonC5a4559bDecodeGithubComKnqChromedpCdpDomdebugger5(in *jlexer.Lexer, out *RemoveInstrumentationBreakpointParams) {
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 "eventName":
out.EventName = string(in.String())
default:
in.SkipRecursive()
}
in.WantComma()
}
in.Delim('}')
if isTopLevel {
in.Consumed()
}
}
func easyjsonC5a4559bEncodeGithubComKnqChromedpCdpDomdebugger5(out *jwriter.Writer, in RemoveInstrumentationBreakpointParams) {
out.RawByte('{')
first := true
_ = first
if !first {
out.RawByte(',')
}
first = false
out.RawString("\"eventName\":")
out.String(string(in.EventName))
out.RawByte('}')
}
// MarshalJSON supports json.Marshaler interface
func (v RemoveInstrumentationBreakpointParams) MarshalJSON() ([]byte, error) {
w := jwriter.Writer{}
easyjsonC5a4559bEncodeGithubComKnqChromedpCdpDomdebugger5(&w, v)
return w.Buffer.BuildBytes(), w.Error
}
// MarshalEasyJSON supports easyjson.Marshaler interface
func (v RemoveInstrumentationBreakpointParams) MarshalEasyJSON(w *jwriter.Writer) {
easyjsonC5a4559bEncodeGithubComKnqChromedpCdpDomdebugger5(w, v)
}
// UnmarshalJSON supports json.Unmarshaler interface
func (v *RemoveInstrumentationBreakpointParams) UnmarshalJSON(data []byte) error {
r := jlexer.Lexer{Data: data}
easyjsonC5a4559bDecodeGithubComKnqChromedpCdpDomdebugger5(&r, v)
return r.Error()
}
// UnmarshalEasyJSON supports easyjson.Unmarshaler interface
func (v *RemoveInstrumentationBreakpointParams) UnmarshalEasyJSON(l *jlexer.Lexer) {
easyjsonC5a4559bDecodeGithubComKnqChromedpCdpDomdebugger5(l, v)
}
func easyjsonC5a4559bDecodeGithubComKnqChromedpCdpDomdebugger6(in *jlexer.Lexer, out *RemoveEventListenerBreakpointParams) {
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 "eventName":
out.EventName = string(in.String())
case "targetName":
out.TargetName = string(in.String())
default:
in.SkipRecursive()
}
in.WantComma()
}
in.Delim('}')
if isTopLevel {
in.Consumed()
}
}
func easyjsonC5a4559bEncodeGithubComKnqChromedpCdpDomdebugger6(out *jwriter.Writer, in RemoveEventListenerBreakpointParams) {
out.RawByte('{')
first := true
_ = first
if !first {
out.RawByte(',')
}
first = false
out.RawString("\"eventName\":")
out.String(string(in.EventName))
if in.TargetName != "" {
if !first {
out.RawByte(',')
}
first = false
out.RawString("\"targetName\":")
out.String(string(in.TargetName))
}
out.RawByte('}')
}
// MarshalJSON supports json.Marshaler interface
func (v RemoveEventListenerBreakpointParams) MarshalJSON() ([]byte, error) {
w := jwriter.Writer{}
easyjsonC5a4559bEncodeGithubComKnqChromedpCdpDomdebugger6(&w, v)
return w.Buffer.BuildBytes(), w.Error
}
// MarshalEasyJSON supports easyjson.Marshaler interface
func (v RemoveEventListenerBreakpointParams) MarshalEasyJSON(w *jwriter.Writer) {
easyjsonC5a4559bEncodeGithubComKnqChromedpCdpDomdebugger6(w, v)
}
// UnmarshalJSON supports json.Unmarshaler interface
func (v *RemoveEventListenerBreakpointParams) UnmarshalJSON(data []byte) error {
r := jlexer.Lexer{Data: data}
easyjsonC5a4559bDecodeGithubComKnqChromedpCdpDomdebugger6(&r, v)
return r.Error()
}
// UnmarshalEasyJSON supports easyjson.Unmarshaler interface
func (v *RemoveEventListenerBreakpointParams) UnmarshalEasyJSON(l *jlexer.Lexer) {
easyjsonC5a4559bDecodeGithubComKnqChromedpCdpDomdebugger6(l, v)
}
func easyjsonC5a4559bDecodeGithubComKnqChromedpCdpDomdebugger7(in *jlexer.Lexer, out *RemoveDOMBreakpointParams) {
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 "nodeId":
(out.NodeID).UnmarshalEasyJSON(in)
case "type":
(out.Type).UnmarshalEasyJSON(in)
default:
in.SkipRecursive()
}
in.WantComma()
}
in.Delim('}')
if isTopLevel {
in.Consumed()
}
}
func easyjsonC5a4559bEncodeGithubComKnqChromedpCdpDomdebugger7(out *jwriter.Writer, in RemoveDOMBreakpointParams) {
out.RawByte('{')
first := true
_ = first
if !first {
out.RawByte(',')
}
first = false
out.RawString("\"nodeId\":")
out.Int64(int64(in.NodeID))
if !first {
out.RawByte(',')
}
first = false
out.RawString("\"type\":")
(in.Type).MarshalEasyJSON(out)
out.RawByte('}')
}
// MarshalJSON supports json.Marshaler interface
func (v RemoveDOMBreakpointParams) MarshalJSON() ([]byte, error) {
w := jwriter.Writer{}
easyjsonC5a4559bEncodeGithubComKnqChromedpCdpDomdebugger7(&w, v)
return w.Buffer.BuildBytes(), w.Error
}
// MarshalEasyJSON supports easyjson.Marshaler interface
func (v RemoveDOMBreakpointParams) MarshalEasyJSON(w *jwriter.Writer) {
easyjsonC5a4559bEncodeGithubComKnqChromedpCdpDomdebugger7(w, v)
}
// UnmarshalJSON supports json.Unmarshaler interface
func (v *RemoveDOMBreakpointParams) UnmarshalJSON(data []byte) error {
r := jlexer.Lexer{Data: data}
easyjsonC5a4559bDecodeGithubComKnqChromedpCdpDomdebugger7(&r, v)
return r.Error()
}
// UnmarshalEasyJSON supports easyjson.Unmarshaler interface
func (v *RemoveDOMBreakpointParams) UnmarshalEasyJSON(l *jlexer.Lexer) {
easyjsonC5a4559bDecodeGithubComKnqChromedpCdpDomdebugger7(l, v)
}
func easyjsonC5a4559bDecodeGithubComKnqChromedpCdpDomdebugger8(in *jlexer.Lexer, out *GetEventListenersReturns) {
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 "listeners":
if in.IsNull() {
in.Skip()
out.Listeners = nil
} else {
in.Delim('[')
if !in.IsDelim(']') {
out.Listeners = make([]*EventListener, 0, 8)
} else {
out.Listeners = []*EventListener{}
}
for !in.IsDelim(']') {
var v1 *EventListener
if in.IsNull() {
in.Skip()
v1 = nil
} else {
if v1 == nil {
v1 = new(EventListener)
}
(*v1).UnmarshalEasyJSON(in)
}
out.Listeners = append(out.Listeners, v1)
in.WantComma()
}
in.Delim(']')
}
default:
in.SkipRecursive()
}
in.WantComma()
}
in.Delim('}')
if isTopLevel {
in.Consumed()
}
}
func easyjsonC5a4559bEncodeGithubComKnqChromedpCdpDomdebugger8(out *jwriter.Writer, in GetEventListenersReturns) {
out.RawByte('{')
first := true
_ = first
if len(in.Listeners) != 0 {
if !first {
out.RawByte(',')
}
first = false
out.RawString("\"listeners\":")
if in.Listeners == nil && (out.Flags&jwriter.NilSliceAsEmpty) == 0 {
out.RawString("null")
} else {
out.RawByte('[')
for v2, v3 := range in.Listeners {
if v2 > 0 {
out.RawByte(',')
}
if v3 == nil {
out.RawString("null")
} else {
(*v3).MarshalEasyJSON(out)
}
}
out.RawByte(']')
}
}
out.RawByte('}')
}
// MarshalJSON supports json.Marshaler interface
func (v GetEventListenersReturns) MarshalJSON() ([]byte, error) {
w := jwriter.Writer{}
easyjsonC5a4559bEncodeGithubComKnqChromedpCdpDomdebugger8(&w, v)
return w.Buffer.BuildBytes(), w.Error
}
// MarshalEasyJSON supports easyjson.Marshaler interface
func (v GetEventListenersReturns) MarshalEasyJSON(w *jwriter.Writer) {
easyjsonC5a4559bEncodeGithubComKnqChromedpCdpDomdebugger8(w, v)
}
// UnmarshalJSON supports json.Unmarshaler interface
func (v *GetEventListenersReturns) UnmarshalJSON(data []byte) error {
r := jlexer.Lexer{Data: data}
easyjsonC5a4559bDecodeGithubComKnqChromedpCdpDomdebugger8(&r, v)
return r.Error()
}
// UnmarshalEasyJSON supports easyjson.Unmarshaler interface
func (v *GetEventListenersReturns) UnmarshalEasyJSON(l *jlexer.Lexer) {
easyjsonC5a4559bDecodeGithubComKnqChromedpCdpDomdebugger8(l, v)
}
func easyjsonC5a4559bDecodeGithubComKnqChromedpCdpDomdebugger9(in *jlexer.Lexer, out *GetEventListenersParams) {
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 "objectId":
out.ObjectID = runtime.RemoteObjectID(in.String())
default:
in.SkipRecursive()
}
in.WantComma()
}
in.Delim('}')
if isTopLevel {
in.Consumed()
}
}
func easyjsonC5a4559bEncodeGithubComKnqChromedpCdpDomdebugger9(out *jwriter.Writer, in GetEventListenersParams) {
out.RawByte('{')
first := true
_ = first
if !first {
out.RawByte(',')
}
first = false
out.RawString("\"objectId\":")
out.String(string(in.ObjectID))
out.RawByte('}')
}
// MarshalJSON supports json.Marshaler interface
func (v GetEventListenersParams) MarshalJSON() ([]byte, error) {
w := jwriter.Writer{}
easyjsonC5a4559bEncodeGithubComKnqChromedpCdpDomdebugger9(&w, v)
return w.Buffer.BuildBytes(), w.Error
}
// MarshalEasyJSON supports easyjson.Marshaler interface
func (v GetEventListenersParams) MarshalEasyJSON(w *jwriter.Writer) {
easyjsonC5a4559bEncodeGithubComKnqChromedpCdpDomdebugger9(w, v)
}
// UnmarshalJSON supports json.Unmarshaler interface
func (v *GetEventListenersParams) UnmarshalJSON(data []byte) error {
r := jlexer.Lexer{Data: data}
easyjsonC5a4559bDecodeGithubComKnqChromedpCdpDomdebugger9(&r, v)
return r.Error()
}
// UnmarshalEasyJSON supports easyjson.Unmarshaler interface
func (v *GetEventListenersParams) UnmarshalEasyJSON(l *jlexer.Lexer) {
easyjsonC5a4559bDecodeGithubComKnqChromedpCdpDomdebugger9(l, v)
}
func easyjsonC5a4559bDecodeGithubComKnqChromedpCdpDomdebugger10(in *jlexer.Lexer, out *EventListener) {
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 "type":
out.Type = string(in.String())
case "useCapture":
out.UseCapture = bool(in.Bool())
case "passive":
out.Passive = bool(in.Bool())
case "once":
out.Once = bool(in.Bool())
case "scriptId":
out.ScriptID = runtime.ScriptID(in.String())
case "lineNumber":
out.LineNumber = int64(in.Int64())
case "columnNumber":
out.ColumnNumber = int64(in.Int64())
case "handler":
if in.IsNull() {
in.Skip()
out.Handler = nil
} else {
if out.Handler == nil {
out.Handler = new(runtime.RemoteObject)
}
(*out.Handler).UnmarshalEasyJSON(in)
}
case "originalHandler":
if in.IsNull() {
in.Skip()
out.OriginalHandler = nil
} else {
if out.OriginalHandler == nil {
out.OriginalHandler = new(runtime.RemoteObject)
}
(*out.OriginalHandler).UnmarshalEasyJSON(in)
}
case "removeFunction":
if in.IsNull() {
in.Skip()
out.RemoveFunction = nil
} else {
if out.RemoveFunction == nil {
out.RemoveFunction = new(runtime.RemoteObject)
}
(*out.RemoveFunction).UnmarshalEasyJSON(in)
}
default:
in.SkipRecursive()
}
in.WantComma()
}
in.Delim('}')
if isTopLevel {
in.Consumed()
}
}
func easyjsonC5a4559bEncodeGithubComKnqChromedpCdpDomdebugger10(out *jwriter.Writer, in EventListener) {
out.RawByte('{')
first := true
_ = first
if in.Type != "" {
if !first {
out.RawByte(',')
}
first = false
out.RawString("\"type\":")
out.String(string(in.Type))
}
if in.UseCapture {
if !first {
out.RawByte(',')
}
first = false
out.RawString("\"useCapture\":")
out.Bool(bool(in.UseCapture))
}
if in.Passive {
if !first {
out.RawByte(',')
}
first = false
out.RawString("\"passive\":")
out.Bool(bool(in.Passive))
}
if in.Once {
if !first {
out.RawByte(',')
}
first = false
out.RawString("\"once\":")
out.Bool(bool(in.Once))
}
if in.ScriptID != "" {
if !first {
out.RawByte(',')
}
first = false
out.RawString("\"scriptId\":")
out.String(string(in.ScriptID))
}
if in.LineNumber != 0 {
if !first {
out.RawByte(',')
}
first = false
out.RawString("\"lineNumber\":")
out.Int64(int64(in.LineNumber))
}
if in.ColumnNumber != 0 {
if !first {
out.RawByte(',')
}
first = false
out.RawString("\"columnNumber\":")
out.Int64(int64(in.ColumnNumber))
}
if in.Handler != nil {
if !first {
out.RawByte(',')
}
first = false
out.RawString("\"handler\":")
if in.Handler == nil {
out.RawString("null")
} else {
(*in.Handler).MarshalEasyJSON(out)
}
}
if in.OriginalHandler != nil {
if !first {
out.RawByte(',')
}
first = false
out.RawString("\"originalHandler\":")
if in.OriginalHandler == nil {
out.RawString("null")
} else {
(*in.OriginalHandler).MarshalEasyJSON(out)
}
}
if in.RemoveFunction != nil {
if !first {
out.RawByte(',')
}
first = false
out.RawString("\"removeFunction\":")
if in.RemoveFunction == nil {
out.RawString("null")
} else {
(*in.RemoveFunction).MarshalEasyJSON(out)
}
}
out.RawByte('}')
}
// MarshalJSON supports json.Marshaler interface
func (v EventListener) MarshalJSON() ([]byte, error) {
w := jwriter.Writer{}
easyjsonC5a4559bEncodeGithubComKnqChromedpCdpDomdebugger10(&w, v)
return w.Buffer.BuildBytes(), w.Error
}
// MarshalEasyJSON supports easyjson.Marshaler interface
func (v EventListener) MarshalEasyJSON(w *jwriter.Writer) {
easyjsonC5a4559bEncodeGithubComKnqChromedpCdpDomdebugger10(w, v)
}
// UnmarshalJSON supports json.Unmarshaler interface
func (v *EventListener) UnmarshalJSON(data []byte) error {
r := jlexer.Lexer{Data: data}
easyjsonC5a4559bDecodeGithubComKnqChromedpCdpDomdebugger10(&r, v)
return r.Error()
}
// UnmarshalEasyJSON supports easyjson.Unmarshaler interface
func (v *EventListener) UnmarshalEasyJSON(l *jlexer.Lexer) {
easyjsonC5a4559bDecodeGithubComKnqChromedpCdpDomdebugger10(l, v)
}

92
cdp/domdebugger/types.go Normal file
View File

@ -0,0 +1,92 @@
package domdebugger
// AUTOGENERATED. DO NOT EDIT.
import (
"errors"
. "github.com/knq/chromedp/cdp"
"github.com/knq/chromedp/cdp/runtime"
"github.com/mailru/easyjson"
"github.com/mailru/easyjson/jlexer"
"github.com/mailru/easyjson/jwriter"
)
var (
_ BackendNode
_ BackendNodeID
_ ComputedProperty
_ ErrorType
_ Frame
_ FrameID
_ LoaderID
_ Message
_ MessageError
_ MethodType
_ Node
_ NodeID
_ NodeType
_ PseudoType
_ RGBA
_ ShadowRootType
_ Timestamp
)
// DOMBreakpointType dOM breakpoint type.
type DOMBreakpointType string
// String returns the DOMBreakpointType as string value.
func (t DOMBreakpointType) String() string {
return string(t)
}
// DOMBreakpointType values.
const (
DOMBreakpointTypeSubtreeModified DOMBreakpointType = "subtree-modified"
DOMBreakpointTypeAttributeModified DOMBreakpointType = "attribute-modified"
DOMBreakpointTypeNodeRemoved DOMBreakpointType = "node-removed"
)
// MarshalEasyJSON satisfies easyjson.Marshaler.
func (t DOMBreakpointType) MarshalEasyJSON(out *jwriter.Writer) {
out.String(string(t))
}
// MarshalJSON satisfies json.Marshaler.
func (t DOMBreakpointType) MarshalJSON() ([]byte, error) {
return easyjson.Marshal(t)
}
// UnmarshalEasyJSON satisfies easyjson.Unmarshaler.
func (t *DOMBreakpointType) UnmarshalEasyJSON(in *jlexer.Lexer) {
switch DOMBreakpointType(in.String()) {
case DOMBreakpointTypeSubtreeModified:
*t = DOMBreakpointTypeSubtreeModified
case DOMBreakpointTypeAttributeModified:
*t = DOMBreakpointTypeAttributeModified
case DOMBreakpointTypeNodeRemoved:
*t = DOMBreakpointTypeNodeRemoved
default:
in.AddError(errors.New("unknown DOMBreakpointType value"))
}
}
// UnmarshalJSON satisfies json.Unmarshaler.
func (t *DOMBreakpointType) UnmarshalJSON(buf []byte) error {
return easyjson.Unmarshal(buf, t)
}
// EventListener object event listener.
type EventListener struct {
Type string `json:"type,omitempty"` // EventListener's type.
UseCapture bool `json:"useCapture,omitempty"` // EventListener's useCapture.
Passive bool `json:"passive,omitempty"` // EventListener's passive flag.
Once bool `json:"once,omitempty"` // EventListener's once flag.
ScriptID runtime.ScriptID `json:"scriptId,omitempty"` // Script id of the handler code.
LineNumber int64 `json:"lineNumber,omitempty"` // Line number in the script (0-based).
ColumnNumber int64 `json:"columnNumber,omitempty"` // Column number in the script (0-based).
Handler *runtime.RemoteObject `json:"handler,omitempty"` // Event handler function value.
OriginalHandler *runtime.RemoteObject `json:"originalHandler,omitempty"` // Event original handler function value.
RemoveFunction *runtime.RemoteObject `json:"removeFunction,omitempty"` // Event listener remove function.
}

View File

@ -0,0 +1,338 @@
// Package domstorage provides the Chrome Debugging Protocol
// commands, types, and events for the Chrome DOMStorage domain.
//
// Query and modify DOM storage.
//
// Generated by the chromedp-gen command.
package domstorage
// AUTOGENERATED. DO NOT EDIT.
import (
"context"
. "github.com/knq/chromedp/cdp"
"github.com/mailru/easyjson"
)
var (
_ BackendNode
_ BackendNodeID
_ ComputedProperty
_ ErrorType
_ Frame
_ FrameID
_ LoaderID
_ Message
_ MessageError
_ MethodType
_ Node
_ NodeID
_ NodeType
_ PseudoType
_ RGBA
_ ShadowRootType
_ Timestamp
)
// 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.
func (p *EnableParams) Do(ctxt context.Context, h FrameHandler) (err error) {
if ctxt == nil {
ctxt = context.Background()
}
// execute
ch := h.Execute(ctxt, CommandDOMStorageEnable, Empty)
// read response
select {
case res := <-ch:
if res == nil {
return ErrChannelClosed
}
switch v := res.(type) {
case easyjson.RawMessage:
return nil
case error:
return v
}
case <-ctxt.Done():
return ErrContextDone
}
return ErrUnknownResult
}
// 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.
func (p *DisableParams) Do(ctxt context.Context, h FrameHandler) (err error) {
if ctxt == nil {
ctxt = context.Background()
}
// execute
ch := h.Execute(ctxt, CommandDOMStorageDisable, Empty)
// read response
select {
case res := <-ch:
if res == nil {
return ErrChannelClosed
}
switch v := res.(type) {
case easyjson.RawMessage:
return nil
case error:
return v
}
case <-ctxt.Done():
return ErrContextDone
}
return ErrUnknownResult
}
type ClearParams struct {
StorageID *StorageID `json:"storageId"`
}
// parameters:
// storageId
func Clear(storageId *StorageID) *ClearParams {
return &ClearParams{
StorageID: storageId,
}
}
// Do executes DOMStorage.clear.
func (p *ClearParams) Do(ctxt context.Context, h FrameHandler) (err error) {
if ctxt == nil {
ctxt = context.Background()
}
// marshal
buf, err := easyjson.Marshal(p)
if err != nil {
return err
}
// execute
ch := h.Execute(ctxt, CommandDOMStorageClear, easyjson.RawMessage(buf))
// read response
select {
case res := <-ch:
if res == nil {
return ErrChannelClosed
}
switch v := res.(type) {
case easyjson.RawMessage:
return nil
case error:
return v
}
case <-ctxt.Done():
return ErrContextDone
}
return ErrUnknownResult
}
type GetDOMStorageItemsParams struct {
StorageID *StorageID `json:"storageId"`
}
// parameters:
// storageId
func GetDOMStorageItems(storageId *StorageID) *GetDOMStorageItemsParams {
return &GetDOMStorageItemsParams{
StorageID: storageId,
}
}
// GetDOMStorageItemsReturns return values.
type GetDOMStorageItemsReturns struct {
Entries []Item `json:"entries,omitempty"`
}
// Do executes DOMStorage.getDOMStorageItems.
//
// returns:
// entries
func (p *GetDOMStorageItemsParams) Do(ctxt context.Context, h FrameHandler) (entries []Item, err error) {
if ctxt == nil {
ctxt = context.Background()
}
// marshal
buf, err := easyjson.Marshal(p)
if err != nil {
return nil, err
}
// execute
ch := h.Execute(ctxt, CommandDOMStorageGetDOMStorageItems, easyjson.RawMessage(buf))
// read response
select {
case res := <-ch:
if res == nil {
return nil, ErrChannelClosed
}
switch v := res.(type) {
case easyjson.RawMessage:
// unmarshal
var r GetDOMStorageItemsReturns
err = easyjson.Unmarshal(v, &r)
if err != nil {
return nil, ErrInvalidResult
}
return r.Entries, nil
case error:
return nil, v
}
case <-ctxt.Done():
return nil, ErrContextDone
}
return nil, ErrUnknownResult
}
type SetDOMStorageItemParams struct {
StorageID *StorageID `json:"storageId"`
Key string `json:"key"`
Value string `json:"value"`
}
// parameters:
// storageId
// key
// value
func SetDOMStorageItem(storageId *StorageID, key string, value string) *SetDOMStorageItemParams {
return &SetDOMStorageItemParams{
StorageID: storageId,
Key: key,
Value: value,
}
}
// Do executes DOMStorage.setDOMStorageItem.
func (p *SetDOMStorageItemParams) Do(ctxt context.Context, h FrameHandler) (err error) {
if ctxt == nil {
ctxt = context.Background()
}
// marshal
buf, err := easyjson.Marshal(p)
if err != nil {
return err
}
// execute
ch := h.Execute(ctxt, CommandDOMStorageSetDOMStorageItem, easyjson.RawMessage(buf))
// read response
select {
case res := <-ch:
if res == nil {
return ErrChannelClosed
}
switch v := res.(type) {
case easyjson.RawMessage:
return nil
case error:
return v
}
case <-ctxt.Done():
return ErrContextDone
}
return ErrUnknownResult
}
type RemoveDOMStorageItemParams struct {
StorageID *StorageID `json:"storageId"`
Key string `json:"key"`
}
// parameters:
// storageId
// key
func RemoveDOMStorageItem(storageId *StorageID, key string) *RemoveDOMStorageItemParams {
return &RemoveDOMStorageItemParams{
StorageID: storageId,
Key: key,
}
}
// Do executes DOMStorage.removeDOMStorageItem.
func (p *RemoveDOMStorageItemParams) Do(ctxt context.Context, h FrameHandler) (err error) {
if ctxt == nil {
ctxt = context.Background()
}
// marshal
buf, err := easyjson.Marshal(p)
if err != nil {
return err
}
// execute
ch := h.Execute(ctxt, CommandDOMStorageRemoveDOMStorageItem, easyjson.RawMessage(buf))
// read response
select {
case res := <-ch:
if res == nil {
return ErrChannelClosed
}
switch v := res.(type) {
case easyjson.RawMessage:
return nil
case error:
return v
}
case <-ctxt.Done():
return ErrContextDone
}
return ErrUnknownResult
}

1065
cdp/domstorage/easyjson.go Normal file

File diff suppressed because it is too large Load Diff

57
cdp/domstorage/events.go Normal file
View File

@ -0,0 +1,57 @@
package domstorage
// AUTOGENERATED. DO NOT EDIT.
import (
. "github.com/knq/chromedp/cdp"
)
var (
_ BackendNode
_ BackendNodeID
_ ComputedProperty
_ ErrorType
_ Frame
_ FrameID
_ LoaderID
_ Message
_ MessageError
_ MethodType
_ Node
_ NodeID
_ NodeType
_ PseudoType
_ RGBA
_ ShadowRootType
_ Timestamp
)
type EventDomStorageItemsCleared struct {
StorageID *StorageID `json:"storageId,omitempty"`
}
type EventDomStorageItemRemoved struct {
StorageID *StorageID `json:"storageId,omitempty"`
Key string `json:"key,omitempty"`
}
type EventDomStorageItemAdded struct {
StorageID *StorageID `json:"storageId,omitempty"`
Key string `json:"key,omitempty"`
NewValue string `json:"newValue,omitempty"`
}
type EventDomStorageItemUpdated struct {
StorageID *StorageID `json:"storageId,omitempty"`
Key string `json:"key,omitempty"`
OldValue string `json:"oldValue,omitempty"`
NewValue string `json:"newValue,omitempty"`
}
// EventTypes is all event types in the domain.
var EventTypes = []MethodType{
EventDOMStorageDomStorageItemsCleared,
EventDOMStorageDomStorageItemRemoved,
EventDOMStorageDomStorageItemAdded,
EventDOMStorageDomStorageItemUpdated,
}

36
cdp/domstorage/types.go Normal file
View File

@ -0,0 +1,36 @@
package domstorage
// AUTOGENERATED. DO NOT EDIT.
import (
. "github.com/knq/chromedp/cdp"
)
var (
_ BackendNode
_ BackendNodeID
_ ComputedProperty
_ ErrorType
_ Frame
_ FrameID
_ LoaderID
_ Message
_ MessageError
_ MethodType
_ Node
_ NodeID
_ NodeType
_ PseudoType
_ RGBA
_ ShadowRootType
_ Timestamp
)
// StorageID dOM Storage identifier.
type StorageID struct {
SecurityOrigin string `json:"securityOrigin,omitempty"` // Security origin for the storage.
IsLocalStorage bool `json:"isLocalStorage,omitempty"` // Whether the storage is local storage (not session storage).
}
// Item dOM Storage item.
type Item []string

1168
cdp/easyjson.go Normal file

File diff suppressed because it is too large Load Diff

1361
cdp/emulation/easyjson.go Normal file

File diff suppressed because it is too large Load Diff

896
cdp/emulation/emulation.go Normal file
View File

@ -0,0 +1,896 @@
// Package emulation provides the Chrome Debugging Protocol
// commands, types, and events for the Chrome Emulation domain.
//
// This domain emulates different environments for the page.
//
// Generated by the chromedp-gen command.
package emulation
// AUTOGENERATED. DO NOT EDIT.
import (
"context"
. "github.com/knq/chromedp/cdp"
"github.com/mailru/easyjson"
)
var (
_ BackendNode
_ BackendNodeID
_ ComputedProperty
_ ErrorType
_ Frame
_ FrameID
_ LoaderID
_ Message
_ MessageError
_ MethodType
_ Node
_ NodeID
_ NodeType
_ PseudoType
_ RGBA
_ ShadowRootType
_ Timestamp
)
// 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
// query results).
type SetDeviceMetricsOverrideParams struct {
Width int64 `json:"width"` // Overriding width value in pixels (minimum 0, maximum 10000000). 0 disables the override.
Height int64 `json:"height"` // Overriding height value in pixels (minimum 0, maximum 10000000). 0 disables the override.
DeviceScaleFactor float64 `json:"deviceScaleFactor"` // Overriding device scale factor value. 0 disables the override.
Mobile bool `json:"mobile"` // Whether to emulate mobile device. This includes viewport meta tag, overlay scrollbars, text autosizing and more.
FitWindow bool `json:"fitWindow"` // Whether a view that exceeds the available browser window area should be scaled down to fit.
Scale float64 `json:"scale,omitempty"` // Scale to apply to resulting view image. Ignored in |fitWindow| mode.
ScreenWidth int64 `json:"screenWidth,omitempty"` // Overriding screen width value in pixels (minimum 0, maximum 10000000). Only used for |mobile==true|.
ScreenHeight int64 `json:"screenHeight,omitempty"` // Overriding screen height value in pixels (minimum 0, maximum 10000000). Only used for |mobile==true|.
PositionX int64 `json:"positionX,omitempty"` // Overriding view X position on screen in pixels (minimum 0, maximum 10000000). Only used for |mobile==true|.
PositionY int64 `json:"positionY,omitempty"` // Overriding view Y position on screen in pixels (minimum 0, maximum 10000000). Only used for |mobile==true|.
ScreenOrientation *ScreenOrientation `json:"screenOrientation,omitempty"` // Screen orientation override.
}
// SetDeviceMetricsOverride 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
// query results).
//
// parameters:
// width - Overriding width value in pixels (minimum 0, maximum 10000000). 0 disables the override.
// height - Overriding height value in pixels (minimum 0, maximum 10000000). 0 disables the override.
// deviceScaleFactor - Overriding device scale factor value. 0 disables the override.
// mobile - Whether to emulate mobile device. This includes viewport meta tag, overlay scrollbars, text autosizing and more.
// fitWindow - Whether a view that exceeds the available browser window area should be scaled down to fit.
func SetDeviceMetricsOverride(width int64, height int64, deviceScaleFactor float64, mobile bool, fitWindow bool) *SetDeviceMetricsOverrideParams {
return &SetDeviceMetricsOverrideParams{
Width: width,
Height: height,
DeviceScaleFactor: deviceScaleFactor,
Mobile: mobile,
FitWindow: fitWindow,
}
}
// WithScale scale to apply to resulting view image. Ignored in |fitWindow|
// mode.
func (p SetDeviceMetricsOverrideParams) WithScale(scale float64) *SetDeviceMetricsOverrideParams {
p.Scale = scale
return &p
}
// WithScreenWidth overriding screen width value in pixels (minimum 0,
// maximum 10000000). Only used for |mobile==true|.
func (p SetDeviceMetricsOverrideParams) WithScreenWidth(screenWidth int64) *SetDeviceMetricsOverrideParams {
p.ScreenWidth = screenWidth
return &p
}
// WithScreenHeight overriding screen height value in pixels (minimum 0,
// maximum 10000000). Only used for |mobile==true|.
func (p SetDeviceMetricsOverrideParams) WithScreenHeight(screenHeight int64) *SetDeviceMetricsOverrideParams {
p.ScreenHeight = screenHeight
return &p
}
// WithPositionX overriding view X position on screen in pixels (minimum 0,
// maximum 10000000). Only used for |mobile==true|.
func (p SetDeviceMetricsOverrideParams) WithPositionX(positionX int64) *SetDeviceMetricsOverrideParams {
p.PositionX = positionX
return &p
}
// WithPositionY overriding view Y position on screen in pixels (minimum 0,
// maximum 10000000). Only used for |mobile==true|.
func (p SetDeviceMetricsOverrideParams) WithPositionY(positionY int64) *SetDeviceMetricsOverrideParams {
p.PositionY = positionY
return &p
}
// WithScreenOrientation screen orientation override.
func (p SetDeviceMetricsOverrideParams) WithScreenOrientation(screenOrientation *ScreenOrientation) *SetDeviceMetricsOverrideParams {
p.ScreenOrientation = screenOrientation
return &p
}
// Do executes Emulation.setDeviceMetricsOverride.
func (p *SetDeviceMetricsOverrideParams) Do(ctxt context.Context, h FrameHandler) (err error) {
if ctxt == nil {
ctxt = context.Background()
}
// marshal
buf, err := easyjson.Marshal(p)
if err != nil {
return err
}
// execute
ch := h.Execute(ctxt, CommandEmulationSetDeviceMetricsOverride, easyjson.RawMessage(buf))
// read response
select {
case res := <-ch:
if res == nil {
return ErrChannelClosed
}
switch v := res.(type) {
case easyjson.RawMessage:
return nil
case error:
return v
}
case <-ctxt.Done():
return ErrContextDone
}
return ErrUnknownResult
}
// ClearDeviceMetricsOverrideParams clears the overriden device metrics.
type ClearDeviceMetricsOverrideParams struct{}
// ClearDeviceMetricsOverride clears the overriden device metrics.
func ClearDeviceMetricsOverride() *ClearDeviceMetricsOverrideParams {
return &ClearDeviceMetricsOverrideParams{}
}
// Do executes Emulation.clearDeviceMetricsOverride.
func (p *ClearDeviceMetricsOverrideParams) Do(ctxt context.Context, h FrameHandler) (err error) {
if ctxt == nil {
ctxt = context.Background()
}
// execute
ch := h.Execute(ctxt, CommandEmulationClearDeviceMetricsOverride, Empty)
// read response
select {
case res := <-ch:
if res == nil {
return ErrChannelClosed
}
switch v := res.(type) {
case easyjson.RawMessage:
return nil
case error:
return v
}
case <-ctxt.Done():
return ErrContextDone
}
return ErrUnknownResult
}
// ForceViewportParams overrides the visible area of the page. The change is
// hidden from the page, i.e. the observable scroll position and page scale does
// not change. In effect, the command moves the specified area of the page into
// the top-left corner of the frame.
type ForceViewportParams struct {
X float64 `json:"x"` // X coordinate of top-left corner of the area (CSS pixels).
Y float64 `json:"y"` // Y coordinate of top-left corner of the area (CSS pixels).
Scale float64 `json:"scale"` // Scale to apply to the area (relative to a page scale of 1.0).
}
// ForceViewport overrides the visible area of the page. The change is hidden
// from the page, i.e. the observable scroll position and page scale does not
// change. In effect, the command moves the specified area of the page into the
// top-left corner of the frame.
//
// parameters:
// x - X coordinate of top-left corner of the area (CSS pixels).
// y - Y coordinate of top-left corner of the area (CSS pixels).
// scale - Scale to apply to the area (relative to a page scale of 1.0).
func ForceViewport(x float64, y float64, scale float64) *ForceViewportParams {
return &ForceViewportParams{
X: x,
Y: y,
Scale: scale,
}
}
// Do executes Emulation.forceViewport.
func (p *ForceViewportParams) Do(ctxt context.Context, h FrameHandler) (err error) {
if ctxt == nil {
ctxt = context.Background()
}
// marshal
buf, err := easyjson.Marshal(p)
if err != nil {
return err
}
// execute
ch := h.Execute(ctxt, CommandEmulationForceViewport, easyjson.RawMessage(buf))
// read response
select {
case res := <-ch:
if res == nil {
return ErrChannelClosed
}
switch v := res.(type) {
case easyjson.RawMessage:
return nil
case error:
return v
}
case <-ctxt.Done():
return ErrContextDone
}
return ErrUnknownResult
}
// ResetViewportParams resets the visible area of the page to the original
// viewport, undoing any effects of the forceViewport command.
type ResetViewportParams struct{}
// ResetViewport resets the visible area of the page to the original
// viewport, undoing any effects of the forceViewport command.
func ResetViewport() *ResetViewportParams {
return &ResetViewportParams{}
}
// Do executes Emulation.resetViewport.
func (p *ResetViewportParams) Do(ctxt context.Context, h FrameHandler) (err error) {
if ctxt == nil {
ctxt = context.Background()
}
// execute
ch := h.Execute(ctxt, CommandEmulationResetViewport, Empty)
// read response
select {
case res := <-ch:
if res == nil {
return ErrChannelClosed
}
switch v := res.(type) {
case easyjson.RawMessage:
return nil
case error:
return v
}
case <-ctxt.Done():
return ErrContextDone
}
return ErrUnknownResult
}
// 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.
func (p *ResetPageScaleFactorParams) Do(ctxt context.Context, h FrameHandler) (err error) {
if ctxt == nil {
ctxt = context.Background()
}
// execute
ch := h.Execute(ctxt, CommandEmulationResetPageScaleFactor, Empty)
// read response
select {
case res := <-ch:
if res == nil {
return ErrChannelClosed
}
switch v := res.(type) {
case easyjson.RawMessage:
return nil
case error:
return v
}
case <-ctxt.Done():
return ErrContextDone
}
return ErrUnknownResult
}
// 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.
func (p *SetPageScaleFactorParams) Do(ctxt context.Context, h FrameHandler) (err error) {
if ctxt == nil {
ctxt = context.Background()
}
// marshal
buf, err := easyjson.Marshal(p)
if err != nil {
return err
}
// execute
ch := h.Execute(ctxt, CommandEmulationSetPageScaleFactor, easyjson.RawMessage(buf))
// read response
select {
case res := <-ch:
if res == nil {
return ErrChannelClosed
}
switch v := res.(type) {
case easyjson.RawMessage:
return nil
case error:
return v
}
case <-ctxt.Done():
return ErrContextDone
}
return ErrUnknownResult
}
// SetVisibleSizeParams resizes the frame/viewport of the page. Note that
// this does not affect the frame's container (e.g. browser window). Can be used
// to produce screenshots of the specified size. Not supported on Android.
type SetVisibleSizeParams struct {
Width int64 `json:"width"` // Frame width (DIP).
Height int64 `json:"height"` // Frame height (DIP).
}
// SetVisibleSize resizes the frame/viewport of the page. Note that this does
// not affect the frame's container (e.g. browser window). Can be used to
// produce screenshots of the specified size. Not supported on Android.
//
// parameters:
// width - Frame width (DIP).
// height - Frame height (DIP).
func SetVisibleSize(width int64, height int64) *SetVisibleSizeParams {
return &SetVisibleSizeParams{
Width: width,
Height: height,
}
}
// Do executes Emulation.setVisibleSize.
func (p *SetVisibleSizeParams) Do(ctxt context.Context, h FrameHandler) (err error) {
if ctxt == nil {
ctxt = context.Background()
}
// marshal
buf, err := easyjson.Marshal(p)
if err != nil {
return err
}
// execute
ch := h.Execute(ctxt, CommandEmulationSetVisibleSize, easyjson.RawMessage(buf))
// read response
select {
case res := <-ch:
if res == nil {
return ErrChannelClosed
}
switch v := res.(type) {
case easyjson.RawMessage:
return nil
case error:
return v
}
case <-ctxt.Done():
return ErrContextDone
}
return ErrUnknownResult
}
// 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.
func (p *SetScriptExecutionDisabledParams) Do(ctxt context.Context, h FrameHandler) (err error) {
if ctxt == nil {
ctxt = context.Background()
}
// marshal
buf, err := easyjson.Marshal(p)
if err != nil {
return err
}
// execute
ch := h.Execute(ctxt, CommandEmulationSetScriptExecutionDisabled, easyjson.RawMessage(buf))
// read response
select {
case res := <-ch:
if res == nil {
return ErrChannelClosed
}
switch v := res.(type) {
case easyjson.RawMessage:
return nil
case error:
return v
}
case <-ctxt.Done():
return ErrContextDone
}
return ErrUnknownResult
}
// 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.
func (p *SetGeolocationOverrideParams) Do(ctxt context.Context, h FrameHandler) (err error) {
if ctxt == nil {
ctxt = context.Background()
}
// marshal
buf, err := easyjson.Marshal(p)
if err != nil {
return err
}
// execute
ch := h.Execute(ctxt, CommandEmulationSetGeolocationOverride, easyjson.RawMessage(buf))
// read response
select {
case res := <-ch:
if res == nil {
return ErrChannelClosed
}
switch v := res.(type) {
case easyjson.RawMessage:
return nil
case error:
return v
}
case <-ctxt.Done():
return ErrContextDone
}
return ErrUnknownResult
}
// ClearGeolocationOverrideParams clears the overriden Geolocation Position
// and Error.
type ClearGeolocationOverrideParams struct{}
// ClearGeolocationOverride clears the overriden Geolocation Position and
// Error.
func ClearGeolocationOverride() *ClearGeolocationOverrideParams {
return &ClearGeolocationOverrideParams{}
}
// Do executes Emulation.clearGeolocationOverride.
func (p *ClearGeolocationOverrideParams) Do(ctxt context.Context, h FrameHandler) (err error) {
if ctxt == nil {
ctxt = context.Background()
}
// execute
ch := h.Execute(ctxt, CommandEmulationClearGeolocationOverride, Empty)
// read response
select {
case res := <-ch:
if res == nil {
return ErrChannelClosed
}
switch v := res.(type) {
case easyjson.RawMessage:
return nil
case error:
return v
}
case <-ctxt.Done():
return ErrContextDone
}
return ErrUnknownResult
}
// SetTouchEmulationEnabledParams toggles mouse event-based touch event
// emulation.
type SetTouchEmulationEnabledParams struct {
Enabled bool `json:"enabled"` // Whether the touch event emulation should be enabled.
Configuration EnabledConfiguration `json:"configuration,omitempty"` // Touch/gesture events configuration. Default: current platform.
}
// SetTouchEmulationEnabled toggles mouse event-based touch event emulation.
//
// parameters:
// enabled - Whether the touch event emulation should be enabled.
func SetTouchEmulationEnabled(enabled bool) *SetTouchEmulationEnabledParams {
return &SetTouchEmulationEnabledParams{
Enabled: enabled,
}
}
// WithConfiguration touch/gesture events configuration. Default: current
// platform.
func (p SetTouchEmulationEnabledParams) WithConfiguration(configuration EnabledConfiguration) *SetTouchEmulationEnabledParams {
p.Configuration = configuration
return &p
}
// Do executes Emulation.setTouchEmulationEnabled.
func (p *SetTouchEmulationEnabledParams) Do(ctxt context.Context, h FrameHandler) (err error) {
if ctxt == nil {
ctxt = context.Background()
}
// marshal
buf, err := easyjson.Marshal(p)
if err != nil {
return err
}
// execute
ch := h.Execute(ctxt, CommandEmulationSetTouchEmulationEnabled, easyjson.RawMessage(buf))
// read response
select {
case res := <-ch:
if res == nil {
return ErrChannelClosed
}
switch v := res.(type) {
case easyjson.RawMessage:
return nil
case error:
return v
}
case <-ctxt.Done():
return ErrContextDone
}
return ErrUnknownResult
}
// SetEmulatedMediaParams emulates the given media for CSS media queries.
type SetEmulatedMediaParams struct {
Media string `json:"media"` // Media type to emulate. Empty string disables the override.
}
// SetEmulatedMedia emulates the given media for CSS media queries.
//
// parameters:
// media - Media type to emulate. Empty string disables the override.
func SetEmulatedMedia(media string) *SetEmulatedMediaParams {
return &SetEmulatedMediaParams{
Media: media,
}
}
// Do executes Emulation.setEmulatedMedia.
func (p *SetEmulatedMediaParams) Do(ctxt context.Context, h FrameHandler) (err error) {
if ctxt == nil {
ctxt = context.Background()
}
// marshal
buf, err := easyjson.Marshal(p)
if err != nil {
return err
}
// execute
ch := h.Execute(ctxt, CommandEmulationSetEmulatedMedia, easyjson.RawMessage(buf))
// read response
select {
case res := <-ch:
if res == nil {
return ErrChannelClosed
}
switch v := res.(type) {
case easyjson.RawMessage:
return nil
case error:
return v
}
case <-ctxt.Done():
return ErrContextDone
}
return ErrUnknownResult
}
// 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.
func (p *SetCPUThrottlingRateParams) Do(ctxt context.Context, h FrameHandler) (err error) {
if ctxt == nil {
ctxt = context.Background()
}
// marshal
buf, err := easyjson.Marshal(p)
if err != nil {
return err
}
// execute
ch := h.Execute(ctxt, CommandEmulationSetCPUThrottlingRate, easyjson.RawMessage(buf))
// read response
select {
case res := <-ch:
if res == nil {
return ErrChannelClosed
}
switch v := res.(type) {
case easyjson.RawMessage:
return nil
case error:
return v
}
case <-ctxt.Done():
return ErrContextDone
}
return ErrUnknownResult
}
// 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.
//
// returns:
// result - True if emulation is supported.
func (p *CanEmulateParams) Do(ctxt context.Context, h FrameHandler) (result bool, err error) {
if ctxt == nil {
ctxt = context.Background()
}
// execute
ch := h.Execute(ctxt, CommandEmulationCanEmulate, Empty)
// read response
select {
case res := <-ch:
if res == nil {
return false, ErrChannelClosed
}
switch v := res.(type) {
case easyjson.RawMessage:
// unmarshal
var r CanEmulateReturns
err = easyjson.Unmarshal(v, &r)
if err != nil {
return false, ErrInvalidResult
}
return r.Result, nil
case error:
return false, v
}
case <-ctxt.Done():
return false, ErrContextDone
}
return false, ErrUnknownResult
}
// SetVirtualTimePolicyParams turns on virtual time for all frames (replacing
// real-time with a synthetic time source) and sets the current virtual time
// policy. Note this supersedes any previous time budget.
type SetVirtualTimePolicyParams struct {
Policy VirtualTimePolicy `json:"policy"`
Budget int64 `json:"budget,omitempty"` // If set, after this many virtual milliseconds have elapsed virtual time will be paused and a virtualTimeBudgetExpired event is sent.
}
// SetVirtualTimePolicy turns on virtual time for all frames (replacing
// real-time with a synthetic time source) and sets the current virtual time
// policy. Note this supersedes any previous time budget.
//
// parameters:
// policy
func SetVirtualTimePolicy(policy VirtualTimePolicy) *SetVirtualTimePolicyParams {
return &SetVirtualTimePolicyParams{
Policy: policy,
}
}
// WithBudget if set, after this many virtual milliseconds have elapsed
// virtual time will be paused and a virtualTimeBudgetExpired event is sent.
func (p SetVirtualTimePolicyParams) WithBudget(budget int64) *SetVirtualTimePolicyParams {
p.Budget = budget
return &p
}
// Do executes Emulation.setVirtualTimePolicy.
func (p *SetVirtualTimePolicyParams) Do(ctxt context.Context, h FrameHandler) (err error) {
if ctxt == nil {
ctxt = context.Background()
}
// marshal
buf, err := easyjson.Marshal(p)
if err != nil {
return err
}
// execute
ch := h.Execute(ctxt, CommandEmulationSetVirtualTimePolicy, easyjson.RawMessage(buf))
// read response
select {
case res := <-ch:
if res == nil {
return ErrChannelClosed
}
switch v := res.(type) {
case easyjson.RawMessage:
return nil
case error:
return v
}
case <-ctxt.Done():
return ErrContextDone
}
return ErrUnknownResult
}

36
cdp/emulation/events.go Normal file
View File

@ -0,0 +1,36 @@
package emulation
// AUTOGENERATED. DO NOT EDIT.
import (
. "github.com/knq/chromedp/cdp"
)
var (
_ BackendNode
_ BackendNodeID
_ ComputedProperty
_ ErrorType
_ Frame
_ FrameID
_ LoaderID
_ Message
_ MessageError
_ MethodType
_ Node
_ NodeID
_ NodeType
_ PseudoType
_ RGBA
_ ShadowRootType
_ Timestamp
)
// EventVirtualTimeBudgetExpired notification sent after the virual time
// budget for the current VirtualTimePolicy has run out.
type EventVirtualTimeBudgetExpired struct{}
// EventTypes is all event types in the domain.
var EventTypes = []MethodType{
EventEmulationVirtualTimeBudgetExpired,
}

178
cdp/emulation/types.go Normal file
View File

@ -0,0 +1,178 @@
package emulation
// AUTOGENERATED. DO NOT EDIT.
import (
"errors"
. "github.com/knq/chromedp/cdp"
"github.com/mailru/easyjson"
"github.com/mailru/easyjson/jlexer"
"github.com/mailru/easyjson/jwriter"
)
var (
_ BackendNode
_ BackendNodeID
_ ComputedProperty
_ ErrorType
_ Frame
_ FrameID
_ LoaderID
_ Message
_ MessageError
_ MethodType
_ Node
_ NodeID
_ NodeType
_ PseudoType
_ RGBA
_ ShadowRootType
_ Timestamp
)
// ScreenOrientation screen orientation.
type ScreenOrientation struct {
Type OrientationType `json:"type,omitempty"` // Orientation type.
Angle int64 `json:"angle,omitempty"` // Orientation angle.
}
// VirtualTimePolicy advance: If the scheduler runs out of immediate work,
// the virtual time base may fast forward to allow the next delayed task (if
// any) to run; pause: The virtual time base may not advance;
// pauseIfNetworkFetchesPending: The virtual time base may not advance if there
// are any pending resource fetches.
type VirtualTimePolicy string
// String returns the VirtualTimePolicy as string value.
func (t VirtualTimePolicy) String() string {
return string(t)
}
// VirtualTimePolicy values.
const (
VirtualTimePolicyAdvance VirtualTimePolicy = "advance"
VirtualTimePolicyPause VirtualTimePolicy = "pause"
VirtualTimePolicyPauseIfNetworkFetchesPending VirtualTimePolicy = "pauseIfNetworkFetchesPending"
)
// MarshalEasyJSON satisfies easyjson.Marshaler.
func (t VirtualTimePolicy) MarshalEasyJSON(out *jwriter.Writer) {
out.String(string(t))
}
// MarshalJSON satisfies json.Marshaler.
func (t VirtualTimePolicy) MarshalJSON() ([]byte, error) {
return easyjson.Marshal(t)
}
// UnmarshalEasyJSON satisfies easyjson.Unmarshaler.
func (t *VirtualTimePolicy) UnmarshalEasyJSON(in *jlexer.Lexer) {
switch VirtualTimePolicy(in.String()) {
case VirtualTimePolicyAdvance:
*t = VirtualTimePolicyAdvance
case VirtualTimePolicyPause:
*t = VirtualTimePolicyPause
case VirtualTimePolicyPauseIfNetworkFetchesPending:
*t = VirtualTimePolicyPauseIfNetworkFetchesPending
default:
in.AddError(errors.New("unknown VirtualTimePolicy value"))
}
}
// UnmarshalJSON satisfies json.Unmarshaler.
func (t *VirtualTimePolicy) UnmarshalJSON(buf []byte) error {
return easyjson.Unmarshal(buf, t)
}
// OrientationType orientation type.
type OrientationType string
// String returns the OrientationType as string value.
func (t OrientationType) String() string {
return string(t)
}
// OrientationType values.
const (
OrientationTypePortraitPrimary OrientationType = "portraitPrimary"
OrientationTypePortraitSecondary OrientationType = "portraitSecondary"
OrientationTypeLandscapePrimary OrientationType = "landscapePrimary"
OrientationTypeLandscapeSecondary OrientationType = "landscapeSecondary"
)
// MarshalEasyJSON satisfies easyjson.Marshaler.
func (t OrientationType) MarshalEasyJSON(out *jwriter.Writer) {
out.String(string(t))
}
// MarshalJSON satisfies json.Marshaler.
func (t OrientationType) MarshalJSON() ([]byte, error) {
return easyjson.Marshal(t)
}
// UnmarshalEasyJSON satisfies easyjson.Unmarshaler.
func (t *OrientationType) UnmarshalEasyJSON(in *jlexer.Lexer) {
switch OrientationType(in.String()) {
case OrientationTypePortraitPrimary:
*t = OrientationTypePortraitPrimary
case OrientationTypePortraitSecondary:
*t = OrientationTypePortraitSecondary
case OrientationTypeLandscapePrimary:
*t = OrientationTypeLandscapePrimary
case OrientationTypeLandscapeSecondary:
*t = OrientationTypeLandscapeSecondary
default:
in.AddError(errors.New("unknown OrientationType value"))
}
}
// UnmarshalJSON satisfies json.Unmarshaler.
func (t *OrientationType) UnmarshalJSON(buf []byte) error {
return easyjson.Unmarshal(buf, t)
}
// EnabledConfiguration touch/gesture events configuration. Default: current
// platform.
type EnabledConfiguration string
// String returns the EnabledConfiguration as string value.
func (t EnabledConfiguration) String() string {
return string(t)
}
// EnabledConfiguration values.
const (
EnabledConfigurationMobile EnabledConfiguration = "mobile"
EnabledConfigurationDesktop EnabledConfiguration = "desktop"
)
// MarshalEasyJSON satisfies easyjson.Marshaler.
func (t EnabledConfiguration) MarshalEasyJSON(out *jwriter.Writer) {
out.String(string(t))
}
// MarshalJSON satisfies json.Marshaler.
func (t EnabledConfiguration) MarshalJSON() ([]byte, error) {
return easyjson.Marshal(t)
}
// UnmarshalEasyJSON satisfies easyjson.Unmarshaler.
func (t *EnabledConfiguration) UnmarshalEasyJSON(in *jlexer.Lexer) {
switch EnabledConfiguration(in.String()) {
case EnabledConfigurationMobile:
*t = EnabledConfigurationMobile
case EnabledConfigurationDesktop:
*t = EnabledConfigurationDesktop
default:
in.AddError(errors.New("unknown EnabledConfiguration value"))
}
}
// UnmarshalJSON satisfies json.Unmarshaler.
func (t *EnabledConfiguration) UnmarshalJSON(buf []byte) error {
return easyjson.Unmarshal(buf, t)
}

1589
cdp/heapprofiler/easyjson.go Normal file

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,64 @@
package heapprofiler
// AUTOGENERATED. DO NOT EDIT.
import (
. "github.com/knq/chromedp/cdp"
)
var (
_ BackendNode
_ BackendNodeID
_ ComputedProperty
_ ErrorType
_ Frame
_ FrameID
_ LoaderID
_ Message
_ MessageError
_ MethodType
_ Node
_ NodeID
_ NodeType
_ PseudoType
_ RGBA
_ ShadowRootType
_ Timestamp
)
type EventAddHeapSnapshotChunk struct {
Chunk string `json:"chunk,omitempty"`
}
type EventResetProfiles struct{}
type EventReportHeapSnapshotProgress struct {
Done int64 `json:"done,omitempty"`
Total int64 `json:"total,omitempty"`
Finished bool `json:"finished,omitempty"`
}
// EventLastSeenObjectID if heap objects tracking has been started then
// backend regulary sends a current value for last seen object id and
// corresponding timestamp. If the were changes in the heap since last event
// then one or more heapStatsUpdate events will be sent before a new
// lastSeenObjectId event.
type EventLastSeenObjectID struct {
LastSeenObjectID int64 `json:"lastSeenObjectId,omitempty"`
Timestamp Timestamp `json:"timestamp,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,omitempty"` // 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.
}
// EventTypes is all event types in the domain.
var EventTypes = []MethodType{
EventHeapProfilerAddHeapSnapshotChunk,
EventHeapProfilerResetProfiles,
EventHeapProfilerReportHeapSnapshotProgress,
EventHeapProfilerLastSeenObjectID,
EventHeapProfilerHeapStatsUpdate,
}

View File

@ -0,0 +1,598 @@
// Package heapprofiler provides the Chrome Debugging Protocol
// commands, types, and events for the Chrome HeapProfiler domain.
//
// Generated by the chromedp-gen command.
package heapprofiler
// AUTOGENERATED. DO NOT EDIT.
import (
"context"
. "github.com/knq/chromedp/cdp"
"github.com/knq/chromedp/cdp/runtime"
"github.com/mailru/easyjson"
)
var (
_ BackendNode
_ BackendNodeID
_ ComputedProperty
_ ErrorType
_ Frame
_ FrameID
_ LoaderID
_ Message
_ MessageError
_ MethodType
_ Node
_ NodeID
_ NodeType
_ PseudoType
_ RGBA
_ ShadowRootType
_ Timestamp
)
type EnableParams struct{}
func Enable() *EnableParams {
return &EnableParams{}
}
// Do executes HeapProfiler.enable.
func (p *EnableParams) Do(ctxt context.Context, h FrameHandler) (err error) {
if ctxt == nil {
ctxt = context.Background()
}
// execute
ch := h.Execute(ctxt, CommandHeapProfilerEnable, Empty)
// read response
select {
case res := <-ch:
if res == nil {
return ErrChannelClosed
}
switch v := res.(type) {
case easyjson.RawMessage:
return nil
case error:
return v
}
case <-ctxt.Done():
return ErrContextDone
}
return ErrUnknownResult
}
type DisableParams struct{}
func Disable() *DisableParams {
return &DisableParams{}
}
// Do executes HeapProfiler.disable.
func (p *DisableParams) Do(ctxt context.Context, h FrameHandler) (err error) {
if ctxt == nil {
ctxt = context.Background()
}
// execute
ch := h.Execute(ctxt, CommandHeapProfilerDisable, Empty)
// read response
select {
case res := <-ch:
if res == nil {
return ErrChannelClosed
}
switch v := res.(type) {
case easyjson.RawMessage:
return nil
case error:
return v
}
case <-ctxt.Done():
return ErrContextDone
}
return ErrUnknownResult
}
type StartTrackingHeapObjectsParams struct {
TrackAllocations bool `json:"trackAllocations,omitempty"`
}
// parameters:
func StartTrackingHeapObjects() *StartTrackingHeapObjectsParams {
return &StartTrackingHeapObjectsParams{}
}
func (p StartTrackingHeapObjectsParams) WithTrackAllocations(trackAllocations bool) *StartTrackingHeapObjectsParams {
p.TrackAllocations = trackAllocations
return &p
}
// Do executes HeapProfiler.startTrackingHeapObjects.
func (p *StartTrackingHeapObjectsParams) Do(ctxt context.Context, h FrameHandler) (err error) {
if ctxt == nil {
ctxt = context.Background()
}
// marshal
buf, err := easyjson.Marshal(p)
if err != nil {
return err
}
// execute
ch := h.Execute(ctxt, CommandHeapProfilerStartTrackingHeapObjects, easyjson.RawMessage(buf))
// read response
select {
case res := <-ch:
if res == nil {
return ErrChannelClosed
}
switch v := res.(type) {
case easyjson.RawMessage:
return nil
case error:
return v
}
case <-ctxt.Done():
return ErrContextDone
}
return ErrUnknownResult
}
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.
}
// parameters:
func StopTrackingHeapObjects() *StopTrackingHeapObjectsParams {
return &StopTrackingHeapObjectsParams{}
}
// WithReportProgress if true 'reportHeapSnapshotProgress' events will be
// generated while snapshot is being taken when the tracking is stopped.
func (p StopTrackingHeapObjectsParams) WithReportProgress(reportProgress bool) *StopTrackingHeapObjectsParams {
p.ReportProgress = reportProgress
return &p
}
// Do executes HeapProfiler.stopTrackingHeapObjects.
func (p *StopTrackingHeapObjectsParams) Do(ctxt context.Context, h FrameHandler) (err error) {
if ctxt == nil {
ctxt = context.Background()
}
// marshal
buf, err := easyjson.Marshal(p)
if err != nil {
return err
}
// execute
ch := h.Execute(ctxt, CommandHeapProfilerStopTrackingHeapObjects, easyjson.RawMessage(buf))
// read response
select {
case res := <-ch:
if res == nil {
return ErrChannelClosed
}
switch v := res.(type) {
case easyjson.RawMessage:
return nil
case error:
return v
}
case <-ctxt.Done():
return ErrContextDone
}
return ErrUnknownResult
}
type TakeHeapSnapshotParams struct {
ReportProgress bool `json:"reportProgress,omitempty"` // If true 'reportHeapSnapshotProgress' events will be generated while snapshot is being taken.
}
// parameters:
func TakeHeapSnapshot() *TakeHeapSnapshotParams {
return &TakeHeapSnapshotParams{}
}
// WithReportProgress if true 'reportHeapSnapshotProgress' events will be
// generated while snapshot is being taken.
func (p TakeHeapSnapshotParams) WithReportProgress(reportProgress bool) *TakeHeapSnapshotParams {
p.ReportProgress = reportProgress
return &p
}
// Do executes HeapProfiler.takeHeapSnapshot.
func (p *TakeHeapSnapshotParams) Do(ctxt context.Context, h FrameHandler) (err error) {
if ctxt == nil {
ctxt = context.Background()
}
// marshal
buf, err := easyjson.Marshal(p)
if err != nil {
return err
}
// execute
ch := h.Execute(ctxt, CommandHeapProfilerTakeHeapSnapshot, easyjson.RawMessage(buf))
// read response
select {
case res := <-ch:
if res == nil {
return ErrChannelClosed
}
switch v := res.(type) {
case easyjson.RawMessage:
return nil
case error:
return v
}
case <-ctxt.Done():
return ErrContextDone
}
return ErrUnknownResult
}
type CollectGarbageParams struct{}
func CollectGarbage() *CollectGarbageParams {
return &CollectGarbageParams{}
}
// Do executes HeapProfiler.collectGarbage.
func (p *CollectGarbageParams) Do(ctxt context.Context, h FrameHandler) (err error) {
if ctxt == nil {
ctxt = context.Background()
}
// execute
ch := h.Execute(ctxt, CommandHeapProfilerCollectGarbage, Empty)
// read response
select {
case res := <-ch:
if res == nil {
return ErrChannelClosed
}
switch v := res.(type) {
case easyjson.RawMessage:
return nil
case error:
return v
}
case <-ctxt.Done():
return ErrContextDone
}
return ErrUnknownResult
}
type GetObjectByHeapObjectIDParams struct {
ObjectID HeapSnapshotObjectID `json:"objectId"`
ObjectGroup string `json:"objectGroup,omitempty"` // Symbolic group name that can be used to release multiple objects.
}
// 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.
//
// returns:
// result - Evaluation result.
func (p *GetObjectByHeapObjectIDParams) Do(ctxt context.Context, h FrameHandler) (result *runtime.RemoteObject, err error) {
if ctxt == nil {
ctxt = context.Background()
}
// marshal
buf, err := easyjson.Marshal(p)
if err != nil {
return nil, err
}
// execute
ch := h.Execute(ctxt, CommandHeapProfilerGetObjectByHeapObjectID, easyjson.RawMessage(buf))
// read response
select {
case res := <-ch:
if res == nil {
return nil, ErrChannelClosed
}
switch v := res.(type) {
case easyjson.RawMessage:
// unmarshal
var r GetObjectByHeapObjectIDReturns
err = easyjson.Unmarshal(v, &r)
if err != nil {
return nil, ErrInvalidResult
}
return r.Result, nil
case error:
return nil, v
}
case <-ctxt.Done():
return nil, ErrContextDone
}
return nil, ErrUnknownResult
}
// 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.
func (p *AddInspectedHeapObjectParams) Do(ctxt context.Context, h FrameHandler) (err error) {
if ctxt == nil {
ctxt = context.Background()
}
// marshal
buf, err := easyjson.Marshal(p)
if err != nil {
return err
}
// execute
ch := h.Execute(ctxt, CommandHeapProfilerAddInspectedHeapObject, easyjson.RawMessage(buf))
// read response
select {
case res := <-ch:
if res == nil {
return ErrChannelClosed
}
switch v := res.(type) {
case easyjson.RawMessage:
return nil
case error:
return v
}
case <-ctxt.Done():
return ErrContextDone
}
return ErrUnknownResult
}
type GetHeapObjectIDParams struct {
ObjectID runtime.RemoteObjectID `json:"objectId"` // Identifier of the object to get heap object id for.
}
// 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.
//
// returns:
// heapSnapshotObjectId - Id of the heap snapshot object corresponding to the passed remote object id.
func (p *GetHeapObjectIDParams) Do(ctxt context.Context, h FrameHandler) (heapSnapshotObjectId HeapSnapshotObjectID, err error) {
if ctxt == nil {
ctxt = context.Background()
}
// marshal
buf, err := easyjson.Marshal(p)
if err != nil {
return "", err
}
// execute
ch := h.Execute(ctxt, CommandHeapProfilerGetHeapObjectID, easyjson.RawMessage(buf))
// read response
select {
case res := <-ch:
if res == nil {
return "", ErrChannelClosed
}
switch v := res.(type) {
case easyjson.RawMessage:
// unmarshal
var r GetHeapObjectIDReturns
err = easyjson.Unmarshal(v, &r)
if err != nil {
return "", ErrInvalidResult
}
return r.HeapSnapshotObjectID, nil
case error:
return "", v
}
case <-ctxt.Done():
return "", ErrContextDone
}
return "", ErrUnknownResult
}
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.
}
// 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.
func (p *StartSamplingParams) Do(ctxt context.Context, h FrameHandler) (err error) {
if ctxt == nil {
ctxt = context.Background()
}
// marshal
buf, err := easyjson.Marshal(p)
if err != nil {
return err
}
// execute
ch := h.Execute(ctxt, CommandHeapProfilerStartSampling, easyjson.RawMessage(buf))
// read response
select {
case res := <-ch:
if res == nil {
return ErrChannelClosed
}
switch v := res.(type) {
case easyjson.RawMessage:
return nil
case error:
return v
}
case <-ctxt.Done():
return ErrContextDone
}
return ErrUnknownResult
}
type StopSamplingParams struct{}
func StopSampling() *StopSamplingParams {
return &StopSamplingParams{}
}
// StopSamplingReturns return values.
type StopSamplingReturns struct {
Profile *SamplingHeapProfile `json:"profile,omitempty"` // Recorded sampling heap profile.
}
// Do executes HeapProfiler.stopSampling.
//
// returns:
// profile - Recorded sampling heap profile.
func (p *StopSamplingParams) Do(ctxt context.Context, h FrameHandler) (profile *SamplingHeapProfile, err error) {
if ctxt == nil {
ctxt = context.Background()
}
// execute
ch := h.Execute(ctxt, CommandHeapProfilerStopSampling, Empty)
// read response
select {
case res := <-ch:
if res == nil {
return nil, ErrChannelClosed
}
switch v := res.(type) {
case easyjson.RawMessage:
// unmarshal
var r StopSamplingReturns
err = easyjson.Unmarshal(v, &r)
if err != nil {
return nil, ErrInvalidResult
}
return r.Profile, nil
case error:
return nil, v
}
case <-ctxt.Done():
return nil, ErrContextDone
}
return nil, ErrUnknownResult
}

49
cdp/heapprofiler/types.go Normal file
View File

@ -0,0 +1,49 @@
package heapprofiler
// AUTOGENERATED. DO NOT EDIT.
import (
. "github.com/knq/chromedp/cdp"
"github.com/knq/chromedp/cdp/runtime"
)
var (
_ BackendNode
_ BackendNodeID
_ ComputedProperty
_ ErrorType
_ Frame
_ FrameID
_ LoaderID
_ Message
_ MessageError
_ MethodType
_ Node
_ NodeID
_ NodeType
_ PseudoType
_ RGBA
_ ShadowRootType
_ Timestamp
)
// HeapSnapshotObjectID heap snapshot object id.
type HeapSnapshotObjectID string
// String returns the HeapSnapshotObjectID as string value.
func (t HeapSnapshotObjectID) String() string {
return string(t)
}
// SamplingHeapProfileNode sampling Heap Profile node. Holds callsite
// information, allocation statistics and child nodes.
type SamplingHeapProfileNode struct {
CallFrame *runtime.CallFrame `json:"callFrame,omitempty"` // Function location.
SelfSize float64 `json:"selfSize,omitempty"` // Allocations size in bytes for the node excluding children.
Children []*SamplingHeapProfileNode `json:"children,omitempty"` // Child nodes.
}
// SamplingHeapProfile profile.
type SamplingHeapProfile struct {
Head *SamplingHeapProfileNode `json:"head,omitempty"`
}

1694
cdp/indexeddb/easyjson.go Normal file

File diff suppressed because it is too large Load Diff

399
cdp/indexeddb/indexeddb.go Normal file
View File

@ -0,0 +1,399 @@
// Package indexeddb provides the Chrome Debugging Protocol
// commands, types, and events for the Chrome IndexedDB domain.
//
// Generated by the chromedp-gen command.
package indexeddb
// AUTOGENERATED. DO NOT EDIT.
import (
"context"
. "github.com/knq/chromedp/cdp"
"github.com/mailru/easyjson"
)
var (
_ BackendNode
_ BackendNodeID
_ ComputedProperty
_ ErrorType
_ Frame
_ FrameID
_ LoaderID
_ Message
_ MessageError
_ MethodType
_ Node
_ NodeID
_ NodeType
_ PseudoType
_ RGBA
_ ShadowRootType
_ Timestamp
)
// EnableParams enables events from backend.
type EnableParams struct{}
// Enable enables events from backend.
func Enable() *EnableParams {
return &EnableParams{}
}
// Do executes IndexedDB.enable.
func (p *EnableParams) Do(ctxt context.Context, h FrameHandler) (err error) {
if ctxt == nil {
ctxt = context.Background()
}
// execute
ch := h.Execute(ctxt, CommandIndexedDBEnable, Empty)
// read response
select {
case res := <-ch:
if res == nil {
return ErrChannelClosed
}
switch v := res.(type) {
case easyjson.RawMessage:
return nil
case error:
return v
}
case <-ctxt.Done():
return ErrContextDone
}
return ErrUnknownResult
}
// DisableParams disables events from backend.
type DisableParams struct{}
// Disable disables events from backend.
func Disable() *DisableParams {
return &DisableParams{}
}
// Do executes IndexedDB.disable.
func (p *DisableParams) Do(ctxt context.Context, h FrameHandler) (err error) {
if ctxt == nil {
ctxt = context.Background()
}
// execute
ch := h.Execute(ctxt, CommandIndexedDBDisable, Empty)
// read response
select {
case res := <-ch:
if res == nil {
return ErrChannelClosed
}
switch v := res.(type) {
case easyjson.RawMessage:
return nil
case error:
return v
}
case <-ctxt.Done():
return ErrContextDone
}
return ErrUnknownResult
}
// 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.
//
// returns:
// databaseNames - Database names for origin.
func (p *RequestDatabaseNamesParams) Do(ctxt context.Context, h FrameHandler) (databaseNames []string, err error) {
if ctxt == nil {
ctxt = context.Background()
}
// marshal
buf, err := easyjson.Marshal(p)
if err != nil {
return nil, err
}
// execute
ch := h.Execute(ctxt, CommandIndexedDBRequestDatabaseNames, easyjson.RawMessage(buf))
// read response
select {
case res := <-ch:
if res == nil {
return nil, ErrChannelClosed
}
switch v := res.(type) {
case easyjson.RawMessage:
// unmarshal
var r RequestDatabaseNamesReturns
err = easyjson.Unmarshal(v, &r)
if err != nil {
return nil, ErrInvalidResult
}
return r.DatabaseNames, nil
case error:
return nil, v
}
case <-ctxt.Done():
return nil, ErrContextDone
}
return nil, ErrUnknownResult
}
// 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.
//
// returns:
// databaseWithObjectStores - Database with an array of object stores.
func (p *RequestDatabaseParams) Do(ctxt context.Context, h FrameHandler) (databaseWithObjectStores *DatabaseWithObjectStores, err error) {
if ctxt == nil {
ctxt = context.Background()
}
// marshal
buf, err := easyjson.Marshal(p)
if err != nil {
return nil, err
}
// execute
ch := h.Execute(ctxt, CommandIndexedDBRequestDatabase, easyjson.RawMessage(buf))
// read response
select {
case res := <-ch:
if res == nil {
return nil, ErrChannelClosed
}
switch v := res.(type) {
case easyjson.RawMessage:
// unmarshal
var r RequestDatabaseReturns
err = easyjson.Unmarshal(v, &r)
if err != nil {
return nil, ErrInvalidResult
}
return r.DatabaseWithObjectStores, nil
case error:
return nil, v
}
case <-ctxt.Done():
return nil, ErrContextDone
}
return nil, ErrUnknownResult
}
// RequestDataParams requests data from object store or index.
type RequestDataParams struct {
SecurityOrigin string `json:"securityOrigin"` // Security origin.
DatabaseName string `json:"databaseName"` // Database name.
ObjectStoreName string `json:"objectStoreName"` // Object store name.
IndexName string `json:"indexName"` // Index name, empty string for object store data requests.
SkipCount int64 `json:"skipCount"` // Number of records to skip.
PageSize int64 `json:"pageSize"` // Number of records to fetch.
KeyRange *KeyRange `json:"keyRange,omitempty"` // Key range.
}
// RequestData requests data from object store or index.
//
// parameters:
// securityOrigin - Security origin.
// databaseName - Database name.
// objectStoreName - Object store name.
// indexName - Index name, empty string for object store data requests.
// skipCount - Number of records to skip.
// pageSize - Number of records to fetch.
func RequestData(securityOrigin string, databaseName string, objectStoreName string, indexName string, skipCount int64, pageSize int64) *RequestDataParams {
return &RequestDataParams{
SecurityOrigin: securityOrigin,
DatabaseName: databaseName,
ObjectStoreName: objectStoreName,
IndexName: indexName,
SkipCount: skipCount,
PageSize: pageSize,
}
}
// WithKeyRange key range.
func (p RequestDataParams) WithKeyRange(keyRange *KeyRange) *RequestDataParams {
p.KeyRange = keyRange
return &p
}
// RequestDataReturns return values.
type RequestDataReturns struct {
ObjectStoreDataEntries []*DataEntry `json:"objectStoreDataEntries,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 IndexedDB.requestData.
//
// returns:
// objectStoreDataEntries - Array of object store data entries.
// hasMore - If true, there are more entries to fetch in the given range.
func (p *RequestDataParams) Do(ctxt context.Context, h FrameHandler) (objectStoreDataEntries []*DataEntry, hasMore bool, err error) {
if ctxt == nil {
ctxt = context.Background()
}
// marshal
buf, err := easyjson.Marshal(p)
if err != nil {
return nil, false, err
}
// execute
ch := h.Execute(ctxt, CommandIndexedDBRequestData, easyjson.RawMessage(buf))
// read response
select {
case res := <-ch:
if res == nil {
return nil, false, ErrChannelClosed
}
switch v := res.(type) {
case easyjson.RawMessage:
// unmarshal
var r RequestDataReturns
err = easyjson.Unmarshal(v, &r)
if err != nil {
return nil, false, ErrInvalidResult
}
return r.ObjectStoreDataEntries, r.HasMore, nil
case error:
return nil, false, v
}
case <-ctxt.Done():
return nil, false, ErrContextDone
}
return nil, false, ErrUnknownResult
}
// 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.
func (p *ClearObjectStoreParams) Do(ctxt context.Context, h FrameHandler) (err error) {
if ctxt == nil {
ctxt = context.Background()
}
// marshal
buf, err := easyjson.Marshal(p)
if err != nil {
return err
}
// execute
ch := h.Execute(ctxt, CommandIndexedDBClearObjectStore, easyjson.RawMessage(buf))
// read response
select {
case res := <-ch:
if res == nil {
return ErrChannelClosed
}
switch v := res.(type) {
case easyjson.RawMessage:
return nil
case error:
return v
}
case <-ctxt.Done():
return ErrContextDone
}
return ErrUnknownResult
}

180
cdp/indexeddb/types.go Normal file
View File

@ -0,0 +1,180 @@
package indexeddb
// AUTOGENERATED. DO NOT EDIT.
import (
"errors"
. "github.com/knq/chromedp/cdp"
"github.com/knq/chromedp/cdp/runtime"
"github.com/mailru/easyjson"
"github.com/mailru/easyjson/jlexer"
"github.com/mailru/easyjson/jwriter"
)
var (
_ BackendNode
_ BackendNodeID
_ ComputedProperty
_ ErrorType
_ Frame
_ FrameID
_ LoaderID
_ Message
_ MessageError
_ MethodType
_ Node
_ NodeID
_ NodeType
_ PseudoType
_ RGBA
_ ShadowRootType
_ Timestamp
)
// DatabaseWithObjectStores database with an array of object stores.
type DatabaseWithObjectStores struct {
Name string `json:"name,omitempty"` // Database name.
Version int64 `json:"version,omitempty"` // Database version.
ObjectStores []*ObjectStore `json:"objectStores,omitempty"` // Object stores in this database.
}
// ObjectStore object store.
type ObjectStore struct {
Name string `json:"name,omitempty"` // Object store name.
KeyPath *KeyPath `json:"keyPath,omitempty"` // Object store key path.
AutoIncrement bool `json:"autoIncrement,omitempty"` // If true, object store has auto increment flag set.
Indexes []*ObjectStoreIndex `json:"indexes,omitempty"` // Indexes in this object store.
}
// ObjectStoreIndex object store index.
type ObjectStoreIndex struct {
Name string `json:"name,omitempty"` // Index name.
KeyPath *KeyPath `json:"keyPath,omitempty"` // Index key path.
Unique bool `json:"unique,omitempty"` // If true, index is unique.
MultiEntry bool `json:"multiEntry,omitempty"` // If true, index allows multiple entries for a key.
}
// Key key.
type Key struct {
Type KeyType `json:"type,omitempty"` // Key type.
Number float64 `json:"number,omitempty"` // Number value.
String string `json:"string,omitempty"` // String value.
Date float64 `json:"date,omitempty"` // Date value.
Array []*Key `json:"array,omitempty"` // Array value.
}
// KeyRange key range.
type KeyRange struct {
Lower *Key `json:"lower,omitempty"` // Lower bound.
Upper *Key `json:"upper,omitempty"` // Upper bound.
LowerOpen bool `json:"lowerOpen,omitempty"` // If true lower bound is open.
UpperOpen bool `json:"upperOpen,omitempty"` // If true upper bound is open.
}
// DataEntry data entry.
type DataEntry struct {
Key *runtime.RemoteObject `json:"key,omitempty"` // Key object.
PrimaryKey *runtime.RemoteObject `json:"primaryKey,omitempty"` // Primary key object.
Value *runtime.RemoteObject `json:"value,omitempty"` // Value object.
}
// KeyPath key path.
type KeyPath struct {
Type KeyPathType `json:"type,omitempty"` // Key path type.
String string `json:"string,omitempty"` // String value.
Array []string `json:"array,omitempty"` // Array value.
}
// KeyType key type.
type KeyType string
// String returns the KeyType as string value.
func (t KeyType) String() string {
return string(t)
}
// KeyType values.
const (
KeyTypeNumber KeyType = "number"
KeyTypeString KeyType = "string"
KeyTypeDate KeyType = "date"
KeyTypeArray KeyType = "array"
)
// MarshalEasyJSON satisfies easyjson.Marshaler.
func (t KeyType) MarshalEasyJSON(out *jwriter.Writer) {
out.String(string(t))
}
// MarshalJSON satisfies json.Marshaler.
func (t KeyType) MarshalJSON() ([]byte, error) {
return easyjson.Marshal(t)
}
// UnmarshalEasyJSON satisfies easyjson.Unmarshaler.
func (t *KeyType) UnmarshalEasyJSON(in *jlexer.Lexer) {
switch KeyType(in.String()) {
case KeyTypeNumber:
*t = KeyTypeNumber
case KeyTypeString:
*t = KeyTypeString
case KeyTypeDate:
*t = KeyTypeDate
case KeyTypeArray:
*t = KeyTypeArray
default:
in.AddError(errors.New("unknown KeyType value"))
}
}
// UnmarshalJSON satisfies json.Unmarshaler.
func (t *KeyType) UnmarshalJSON(buf []byte) error {
return easyjson.Unmarshal(buf, t)
}
// KeyPathType key path type.
type KeyPathType string
// String returns the KeyPathType as string value.
func (t KeyPathType) String() string {
return string(t)
}
// KeyPathType values.
const (
KeyPathTypeNull KeyPathType = "null"
KeyPathTypeString KeyPathType = "string"
KeyPathTypeArray KeyPathType = "array"
)
// MarshalEasyJSON satisfies easyjson.Marshaler.
func (t KeyPathType) MarshalEasyJSON(out *jwriter.Writer) {
out.String(string(t))
}
// MarshalJSON satisfies json.Marshaler.
func (t KeyPathType) MarshalJSON() ([]byte, error) {
return easyjson.Marshal(t)
}
// UnmarshalEasyJSON satisfies easyjson.Unmarshaler.
func (t *KeyPathType) UnmarshalEasyJSON(in *jlexer.Lexer) {
switch KeyPathType(in.String()) {
case KeyPathTypeNull:
*t = KeyPathTypeNull
case KeyPathTypeString:
*t = KeyPathTypeString
case KeyPathTypeArray:
*t = KeyPathTypeArray
default:
in.AddError(errors.New("unknown KeyPathType value"))
}
}
// UnmarshalJSON satisfies json.Unmarshaler.
func (t *KeyPathType) UnmarshalJSON(buf []byte) error {
return easyjson.Unmarshal(buf, t)
}

1125
cdp/input/easyjson.go Normal file

File diff suppressed because it is too large Load Diff

726
cdp/input/input.go Normal file
View File

@ -0,0 +1,726 @@
// Package input provides the Chrome Debugging Protocol
// commands, types, and events for the Chrome Input domain.
//
// Generated by the chromedp-gen command.
package input
// AUTOGENERATED. DO NOT EDIT.
import (
"context"
. "github.com/knq/chromedp/cdp"
"github.com/mailru/easyjson"
)
var (
_ BackendNode
_ BackendNodeID
_ ComputedProperty
_ ErrorType
_ Frame
_ FrameID
_ LoaderID
_ Message
_ MessageError
_ MethodType
_ Node
_ NodeID
_ NodeType
_ PseudoType
_ RGBA
_ ShadowRootType
_ Timestamp
)
// DispatchKeyEventParams dispatches a key event to the page.
type DispatchKeyEventParams struct {
Type KeyType `json:"type"` // Type of the key event.
Modifiers Modifier `json:"modifiers,omitempty"` // Bit field representing pressed modifier keys. Alt=1, Ctrl=2, Meta/Command=4, Shift=8 (default: 0).
Timestamp float64 `json:"timestamp,omitempty"` // Time at which the event occurred. Measured in UTC time in seconds since January 1, 1970 (default: current time).
Text string `json:"text,omitempty"` // Text as generated by processing a virtual key code with a keyboard layout. Not needed for for keyUp and rawKeyDown events (default: "")
UnmodifiedText string `json:"unmodifiedText,omitempty"` // Text that would have been generated by the keyboard if no modifiers were pressed (except for shift). Useful for shortcut (accelerator) key handling (default: "").
KeyIdentifier string `json:"keyIdentifier,omitempty"` // Unique key identifier (e.g., 'U+0041') (default: "").
Code string `json:"code,omitempty"` // Unique DOM defined string value for each physical key (e.g., 'KeyA') (default: "").
Key string `json:"key,omitempty"` // Unique DOM defined string value describing the meaning of the key in the context of active modifiers, keyboard layout, etc (e.g., 'AltGr') (default: "").
WindowsVirtualKeyCode int64 `json:"windowsVirtualKeyCode,omitempty"` // Windows virtual key code (default: 0).
NativeVirtualKeyCode int64 `json:"nativeVirtualKeyCode,omitempty"` // Native virtual key code (default: 0).
AutoRepeat bool `json:"autoRepeat,omitempty"` // Whether the event was generated from auto repeat (default: false).
IsKeypad bool `json:"isKeypad,omitempty"` // Whether the event was generated from the keypad (default: false).
IsSystemKey bool `json:"isSystemKey,omitempty"` // Whether the event was a system key event (default: false).
}
// DispatchKeyEvent dispatches a key event to the page.
//
// parameters:
// type - Type of the key event.
func DispatchKeyEvent(type_ KeyType) *DispatchKeyEventParams {
return &DispatchKeyEventParams{
Type: type_,
}
}
// WithModifiers bit field representing pressed modifier keys. Alt=1, Ctrl=2,
// Meta/Command=4, Shift=8 (default: 0).
func (p DispatchKeyEventParams) WithModifiers(modifiers Modifier) *DispatchKeyEventParams {
p.Modifiers = modifiers
return &p
}
// WithTimestamp time at which the event occurred. Measured in UTC time in
// seconds since January 1, 1970 (default: current time).
func (p DispatchKeyEventParams) WithTimestamp(timestamp float64) *DispatchKeyEventParams {
p.Timestamp = timestamp
return &p
}
// WithText text as generated by processing a virtual key code with a
// keyboard layout. Not needed for for keyUp and rawKeyDown events (default:
// "").
func (p DispatchKeyEventParams) WithText(text string) *DispatchKeyEventParams {
p.Text = text
return &p
}
// WithUnmodifiedText text that would have been generated by the keyboard if
// no modifiers were pressed (except for shift). Useful for shortcut
// (accelerator) key handling (default: "").
func (p DispatchKeyEventParams) WithUnmodifiedText(unmodifiedText string) *DispatchKeyEventParams {
p.UnmodifiedText = unmodifiedText
return &p
}
// WithKeyIdentifier unique key identifier (e.g., 'U+0041') (default: "").
func (p DispatchKeyEventParams) WithKeyIdentifier(keyIdentifier string) *DispatchKeyEventParams {
p.KeyIdentifier = keyIdentifier
return &p
}
// WithCode unique DOM defined string value for each physical key (e.g.,
// 'KeyA') (default: "").
func (p DispatchKeyEventParams) WithCode(code string) *DispatchKeyEventParams {
p.Code = code
return &p
}
// WithKey unique DOM defined string value describing the meaning of the key
// in the context of active modifiers, keyboard layout, etc (e.g., 'AltGr')
// (default: "").
func (p DispatchKeyEventParams) WithKey(key string) *DispatchKeyEventParams {
p.Key = key
return &p
}
// WithWindowsVirtualKeyCode windows virtual key code (default: 0).
func (p DispatchKeyEventParams) WithWindowsVirtualKeyCode(windowsVirtualKeyCode int64) *DispatchKeyEventParams {
p.WindowsVirtualKeyCode = windowsVirtualKeyCode
return &p
}
// WithNativeVirtualKeyCode native virtual key code (default: 0).
func (p DispatchKeyEventParams) WithNativeVirtualKeyCode(nativeVirtualKeyCode int64) *DispatchKeyEventParams {
p.NativeVirtualKeyCode = nativeVirtualKeyCode
return &p
}
// WithAutoRepeat whether the event was generated from auto repeat (default:
// false).
func (p DispatchKeyEventParams) WithAutoRepeat(autoRepeat bool) *DispatchKeyEventParams {
p.AutoRepeat = autoRepeat
return &p
}
// WithIsKeypad whether the event was generated from the keypad (default:
// false).
func (p DispatchKeyEventParams) WithIsKeypad(isKeypad bool) *DispatchKeyEventParams {
p.IsKeypad = isKeypad
return &p
}
// WithIsSystemKey whether the event was a system key event (default: false).
func (p DispatchKeyEventParams) WithIsSystemKey(isSystemKey bool) *DispatchKeyEventParams {
p.IsSystemKey = isSystemKey
return &p
}
// Do executes Input.dispatchKeyEvent.
func (p *DispatchKeyEventParams) Do(ctxt context.Context, h FrameHandler) (err error) {
if ctxt == nil {
ctxt = context.Background()
}
// marshal
buf, err := easyjson.Marshal(p)
if err != nil {
return err
}
// execute
ch := h.Execute(ctxt, CommandInputDispatchKeyEvent, easyjson.RawMessage(buf))
// read response
select {
case res := <-ch:
if res == nil {
return ErrChannelClosed
}
switch v := res.(type) {
case easyjson.RawMessage:
return nil
case error:
return v
}
case <-ctxt.Done():
return ErrContextDone
}
return ErrUnknownResult
}
// DispatchMouseEventParams dispatches a mouse event to the page.
type DispatchMouseEventParams struct {
Type MouseType `json:"type"` // Type of the mouse event.
X int64 `json:"x"` // X coordinate of the event relative to the main frame's viewport.
Y int64 `json:"y"` // Y coordinate of the event relative to the main frame's viewport. 0 refers to the top of the viewport and Y increases as it proceeds towards the bottom of the viewport.
Modifiers Modifier `json:"modifiers,omitempty"` // Bit field representing pressed modifier keys. Alt=1, Ctrl=2, Meta/Command=4, Shift=8 (default: 0).
Timestamp float64 `json:"timestamp,omitempty"` // Time at which the event occurred. Measured in UTC time in seconds since January 1, 1970 (default: current time).
Button ButtonType `json:"button,omitempty"` // Mouse button (default: "none").
ClickCount int64 `json:"clickCount,omitempty"` // Number of times the mouse button was clicked (default: 0).
}
// DispatchMouseEvent dispatches a mouse event to the page.
//
// parameters:
// type - Type of the mouse event.
// x - X coordinate of the event relative to the main frame's viewport.
// y - Y coordinate of the event relative to the main frame's viewport. 0 refers to the top of the viewport and Y increases as it proceeds towards the bottom of the viewport.
func DispatchMouseEvent(type_ MouseType, x int64, y int64) *DispatchMouseEventParams {
return &DispatchMouseEventParams{
Type: type_,
X: x,
Y: y,
}
}
// WithModifiers bit field representing pressed modifier keys. Alt=1, Ctrl=2,
// Meta/Command=4, Shift=8 (default: 0).
func (p DispatchMouseEventParams) WithModifiers(modifiers Modifier) *DispatchMouseEventParams {
p.Modifiers = modifiers
return &p
}
// WithTimestamp time at which the event occurred. Measured in UTC time in
// seconds since January 1, 1970 (default: current time).
func (p DispatchMouseEventParams) WithTimestamp(timestamp float64) *DispatchMouseEventParams {
p.Timestamp = timestamp
return &p
}
// WithButton mouse button (default: "none").
func (p DispatchMouseEventParams) WithButton(button ButtonType) *DispatchMouseEventParams {
p.Button = button
return &p
}
// WithClickCount number of times the mouse button was clicked (default: 0).
func (p DispatchMouseEventParams) WithClickCount(clickCount int64) *DispatchMouseEventParams {
p.ClickCount = clickCount
return &p
}
// Do executes Input.dispatchMouseEvent.
func (p *DispatchMouseEventParams) Do(ctxt context.Context, h FrameHandler) (err error) {
if ctxt == nil {
ctxt = context.Background()
}
// marshal
buf, err := easyjson.Marshal(p)
if err != nil {
return err
}
// execute
ch := h.Execute(ctxt, CommandInputDispatchMouseEvent, easyjson.RawMessage(buf))
// read response
select {
case res := <-ch:
if res == nil {
return ErrChannelClosed
}
switch v := res.(type) {
case easyjson.RawMessage:
return nil
case error:
return v
}
case <-ctxt.Done():
return ErrContextDone
}
return ErrUnknownResult
}
// DispatchTouchEventParams dispatches a touch event to the page.
type DispatchTouchEventParams struct {
Type TouchType `json:"type"` // Type of the touch event.
TouchPoints []*TouchPoint `json:"touchPoints"` // Touch points.
Modifiers Modifier `json:"modifiers,omitempty"` // Bit field representing pressed modifier keys. Alt=1, Ctrl=2, Meta/Command=4, Shift=8 (default: 0).
Timestamp float64 `json:"timestamp,omitempty"` // Time at which the event occurred. Measured in UTC time in seconds since January 1, 1970 (default: current time).
}
// DispatchTouchEvent dispatches a touch event to the page.
//
// parameters:
// type - Type of the touch event.
// touchPoints - Touch points.
func DispatchTouchEvent(type_ TouchType, touchPoints []*TouchPoint) *DispatchTouchEventParams {
return &DispatchTouchEventParams{
Type: type_,
TouchPoints: touchPoints,
}
}
// WithModifiers bit field representing pressed modifier keys. Alt=1, Ctrl=2,
// Meta/Command=4, Shift=8 (default: 0).
func (p DispatchTouchEventParams) WithModifiers(modifiers Modifier) *DispatchTouchEventParams {
p.Modifiers = modifiers
return &p
}
// WithTimestamp time at which the event occurred. Measured in UTC time in
// seconds since January 1, 1970 (default: current time).
func (p DispatchTouchEventParams) WithTimestamp(timestamp float64) *DispatchTouchEventParams {
p.Timestamp = timestamp
return &p
}
// Do executes Input.dispatchTouchEvent.
func (p *DispatchTouchEventParams) Do(ctxt context.Context, h FrameHandler) (err error) {
if ctxt == nil {
ctxt = context.Background()
}
// marshal
buf, err := easyjson.Marshal(p)
if err != nil {
return err
}
// execute
ch := h.Execute(ctxt, CommandInputDispatchTouchEvent, easyjson.RawMessage(buf))
// read response
select {
case res := <-ch:
if res == nil {
return ErrChannelClosed
}
switch v := res.(type) {
case easyjson.RawMessage:
return nil
case error:
return v
}
case <-ctxt.Done():
return ErrContextDone
}
return ErrUnknownResult
}
// EmulateTouchFromMouseEventParams emulates touch event from the mouse event
// parameters.
type EmulateTouchFromMouseEventParams struct {
Type MouseType `json:"type"` // Type of the mouse event.
X int64 `json:"x"` // X coordinate of the mouse pointer in DIP.
Y int64 `json:"y"` // Y coordinate of the mouse pointer in DIP.
Timestamp float64 `json:"timestamp"` // Time at which the event occurred. Measured in UTC time in seconds since January 1, 1970.
Button ButtonType `json:"button"` // Mouse button.
DeltaX float64 `json:"deltaX,omitempty"` // X delta in DIP for mouse wheel event (default: 0).
DeltaY float64 `json:"deltaY,omitempty"` // Y delta in DIP for mouse wheel event (default: 0).
Modifiers Modifier `json:"modifiers,omitempty"` // Bit field representing pressed modifier keys. Alt=1, Ctrl=2, Meta/Command=4, Shift=8 (default: 0).
ClickCount int64 `json:"clickCount,omitempty"` // Number of times the mouse button was clicked (default: 0).
}
// EmulateTouchFromMouseEvent emulates touch event from the mouse event
// parameters.
//
// parameters:
// type - Type of the mouse event.
// x - X coordinate of the mouse pointer in DIP.
// y - Y coordinate of the mouse pointer in DIP.
// timestamp - Time at which the event occurred. Measured in UTC time in seconds since January 1, 1970.
// button - Mouse button.
func EmulateTouchFromMouseEvent(type_ MouseType, x int64, y int64, timestamp float64, button ButtonType) *EmulateTouchFromMouseEventParams {
return &EmulateTouchFromMouseEventParams{
Type: type_,
X: x,
Y: y,
Timestamp: timestamp,
Button: button,
}
}
// WithDeltaX x delta in DIP for mouse wheel event (default: 0).
func (p EmulateTouchFromMouseEventParams) WithDeltaX(deltaX float64) *EmulateTouchFromMouseEventParams {
p.DeltaX = deltaX
return &p
}
// WithDeltaY y delta in DIP for mouse wheel event (default: 0).
func (p EmulateTouchFromMouseEventParams) WithDeltaY(deltaY float64) *EmulateTouchFromMouseEventParams {
p.DeltaY = deltaY
return &p
}
// WithModifiers bit field representing pressed modifier keys. Alt=1, Ctrl=2,
// Meta/Command=4, Shift=8 (default: 0).
func (p EmulateTouchFromMouseEventParams) WithModifiers(modifiers Modifier) *EmulateTouchFromMouseEventParams {
p.Modifiers = modifiers
return &p
}
// WithClickCount number of times the mouse button was clicked (default: 0).
func (p EmulateTouchFromMouseEventParams) WithClickCount(clickCount int64) *EmulateTouchFromMouseEventParams {
p.ClickCount = clickCount
return &p
}
// Do executes Input.emulateTouchFromMouseEvent.
func (p *EmulateTouchFromMouseEventParams) Do(ctxt context.Context, h FrameHandler) (err error) {
if ctxt == nil {
ctxt = context.Background()
}
// marshal
buf, err := easyjson.Marshal(p)
if err != nil {
return err
}
// execute
ch := h.Execute(ctxt, CommandInputEmulateTouchFromMouseEvent, easyjson.RawMessage(buf))
// read response
select {
case res := <-ch:
if res == nil {
return ErrChannelClosed
}
switch v := res.(type) {
case easyjson.RawMessage:
return nil
case error:
return v
}
case <-ctxt.Done():
return ErrContextDone
}
return ErrUnknownResult
}
// SynthesizePinchGestureParams synthesizes a pinch gesture over a time
// period by issuing appropriate touch events.
type SynthesizePinchGestureParams struct {
X int64 `json:"x"` // X coordinate of the start of the gesture in CSS pixels.
Y int64 `json:"y"` // Y coordinate of the start of the gesture in CSS pixels.
ScaleFactor float64 `json:"scaleFactor"` // Relative scale factor after zooming (>1.0 zooms in, <1.0 zooms out).
RelativeSpeed int64 `json:"relativeSpeed,omitempty"` // Relative pointer speed in pixels per second (default: 800).
GestureSourceType GestureType `json:"gestureSourceType,omitempty"` // Which type of input events to be generated (default: 'default', which queries the platform for the preferred input type).
}
// SynthesizePinchGesture synthesizes a pinch gesture over a time period by
// issuing appropriate touch events.
//
// parameters:
// x - X coordinate of the start of the gesture in CSS pixels.
// y - Y coordinate of the start of the gesture in CSS pixels.
// scaleFactor - Relative scale factor after zooming (>1.0 zooms in, <1.0 zooms out).
func SynthesizePinchGesture(x int64, y int64, scaleFactor float64) *SynthesizePinchGestureParams {
return &SynthesizePinchGestureParams{
X: x,
Y: y,
ScaleFactor: scaleFactor,
}
}
// WithRelativeSpeed relative pointer speed in pixels per second (default:
// 800).
func (p SynthesizePinchGestureParams) WithRelativeSpeed(relativeSpeed int64) *SynthesizePinchGestureParams {
p.RelativeSpeed = relativeSpeed
return &p
}
// WithGestureSourceType which type of input events to be generated (default:
// 'default', which queries the platform for the preferred input type).
func (p SynthesizePinchGestureParams) WithGestureSourceType(gestureSourceType GestureType) *SynthesizePinchGestureParams {
p.GestureSourceType = gestureSourceType
return &p
}
// Do executes Input.synthesizePinchGesture.
func (p *SynthesizePinchGestureParams) Do(ctxt context.Context, h FrameHandler) (err error) {
if ctxt == nil {
ctxt = context.Background()
}
// marshal
buf, err := easyjson.Marshal(p)
if err != nil {
return err
}
// execute
ch := h.Execute(ctxt, CommandInputSynthesizePinchGesture, easyjson.RawMessage(buf))
// read response
select {
case res := <-ch:
if res == nil {
return ErrChannelClosed
}
switch v := res.(type) {
case easyjson.RawMessage:
return nil
case error:
return v
}
case <-ctxt.Done():
return ErrContextDone
}
return ErrUnknownResult
}
// SynthesizeScrollGestureParams synthesizes a scroll gesture over a time
// period by issuing appropriate touch events.
type SynthesizeScrollGestureParams struct {
X int64 `json:"x"` // X coordinate of the start of the gesture in CSS pixels.
Y int64 `json:"y"` // Y coordinate of the start of the gesture in CSS pixels.
XDistance int64 `json:"xDistance,omitempty"` // The distance to scroll along the X axis (positive to scroll left).
YDistance int64 `json:"yDistance,omitempty"` // The distance to scroll along the Y axis (positive to scroll up).
XOverscroll int64 `json:"xOverscroll,omitempty"` // The number of additional pixels to scroll back along the X axis, in addition to the given distance.
YOverscroll int64 `json:"yOverscroll,omitempty"` // The number of additional pixels to scroll back along the Y axis, in addition to the given distance.
PreventFling bool `json:"preventFling,omitempty"` // Prevent fling (default: true).
Speed int64 `json:"speed,omitempty"` // Swipe speed in pixels per second (default: 800).
GestureSourceType GestureType `json:"gestureSourceType,omitempty"` // Which type of input events to be generated (default: 'default', which queries the platform for the preferred input type).
RepeatCount int64 `json:"repeatCount,omitempty"` // The number of times to repeat the gesture (default: 0).
RepeatDelayMs int64 `json:"repeatDelayMs,omitempty"` // The number of milliseconds delay between each repeat. (default: 250).
InteractionMarkerName string `json:"interactionMarkerName,omitempty"` // The name of the interaction markers to generate, if not empty (default: "").
}
// SynthesizeScrollGesture synthesizes a scroll gesture over a time period by
// issuing appropriate touch events.
//
// parameters:
// x - X coordinate of the start of the gesture in CSS pixels.
// y - Y coordinate of the start of the gesture in CSS pixels.
func SynthesizeScrollGesture(x int64, y int64) *SynthesizeScrollGestureParams {
return &SynthesizeScrollGestureParams{
X: x,
Y: y,
}
}
// WithXDistance the distance to scroll along the X axis (positive to scroll
// left).
func (p SynthesizeScrollGestureParams) WithXDistance(xDistance int64) *SynthesizeScrollGestureParams {
p.XDistance = xDistance
return &p
}
// WithYDistance the distance to scroll along the Y axis (positive to scroll
// up).
func (p SynthesizeScrollGestureParams) WithYDistance(yDistance int64) *SynthesizeScrollGestureParams {
p.YDistance = yDistance
return &p
}
// WithXOverscroll the number of additional pixels to scroll back along the X
// axis, in addition to the given distance.
func (p SynthesizeScrollGestureParams) WithXOverscroll(xOverscroll int64) *SynthesizeScrollGestureParams {
p.XOverscroll = xOverscroll
return &p
}
// WithYOverscroll the number of additional pixels to scroll back along the Y
// axis, in addition to the given distance.
func (p SynthesizeScrollGestureParams) WithYOverscroll(yOverscroll int64) *SynthesizeScrollGestureParams {
p.YOverscroll = yOverscroll
return &p
}
// WithPreventFling prevent fling (default: true).
func (p SynthesizeScrollGestureParams) WithPreventFling(preventFling bool) *SynthesizeScrollGestureParams {
p.PreventFling = preventFling
return &p
}
// WithSpeed swipe speed in pixels per second (default: 800).
func (p SynthesizeScrollGestureParams) WithSpeed(speed int64) *SynthesizeScrollGestureParams {
p.Speed = speed
return &p
}
// WithGestureSourceType which type of input events to be generated (default:
// 'default', which queries the platform for the preferred input type).
func (p SynthesizeScrollGestureParams) WithGestureSourceType(gestureSourceType GestureType) *SynthesizeScrollGestureParams {
p.GestureSourceType = gestureSourceType
return &p
}
// WithRepeatCount the number of times to repeat the gesture (default: 0).
func (p SynthesizeScrollGestureParams) WithRepeatCount(repeatCount int64) *SynthesizeScrollGestureParams {
p.RepeatCount = repeatCount
return &p
}
// WithRepeatDelayMs the number of milliseconds delay between each repeat.
// (default: 250).
func (p SynthesizeScrollGestureParams) WithRepeatDelayMs(repeatDelayMs int64) *SynthesizeScrollGestureParams {
p.RepeatDelayMs = repeatDelayMs
return &p
}
// WithInteractionMarkerName the name of the interaction markers to generate,
// if not empty (default: "").
func (p SynthesizeScrollGestureParams) WithInteractionMarkerName(interactionMarkerName string) *SynthesizeScrollGestureParams {
p.InteractionMarkerName = interactionMarkerName
return &p
}
// Do executes Input.synthesizeScrollGesture.
func (p *SynthesizeScrollGestureParams) Do(ctxt context.Context, h FrameHandler) (err error) {
if ctxt == nil {
ctxt = context.Background()
}
// marshal
buf, err := easyjson.Marshal(p)
if err != nil {
return err
}
// execute
ch := h.Execute(ctxt, CommandInputSynthesizeScrollGesture, easyjson.RawMessage(buf))
// read response
select {
case res := <-ch:
if res == nil {
return ErrChannelClosed
}
switch v := res.(type) {
case easyjson.RawMessage:
return nil
case error:
return v
}
case <-ctxt.Done():
return ErrContextDone
}
return ErrUnknownResult
}
// SynthesizeTapGestureParams synthesizes a tap gesture over a time period by
// issuing appropriate touch events.
type SynthesizeTapGestureParams struct {
X int64 `json:"x"` // X coordinate of the start of the gesture in CSS pixels.
Y int64 `json:"y"` // Y coordinate of the start of the gesture in CSS pixels.
Duration int64 `json:"duration,omitempty"` // Duration between touchdown and touchup events in ms (default: 50).
TapCount int64 `json:"tapCount,omitempty"` // Number of times to perform the tap (e.g. 2 for double tap, default: 1).
GestureSourceType GestureType `json:"gestureSourceType,omitempty"` // Which type of input events to be generated (default: 'default', which queries the platform for the preferred input type).
}
// SynthesizeTapGesture synthesizes a tap gesture over a time period by
// issuing appropriate touch events.
//
// parameters:
// x - X coordinate of the start of the gesture in CSS pixels.
// y - Y coordinate of the start of the gesture in CSS pixels.
func SynthesizeTapGesture(x int64, y int64) *SynthesizeTapGestureParams {
return &SynthesizeTapGestureParams{
X: x,
Y: y,
}
}
// WithDuration duration between touchdown and touchup events in ms (default:
// 50).
func (p SynthesizeTapGestureParams) WithDuration(duration int64) *SynthesizeTapGestureParams {
p.Duration = duration
return &p
}
// WithTapCount number of times to perform the tap (e.g. 2 for double tap,
// default: 1).
func (p SynthesizeTapGestureParams) WithTapCount(tapCount int64) *SynthesizeTapGestureParams {
p.TapCount = tapCount
return &p
}
// WithGestureSourceType which type of input events to be generated (default:
// 'default', which queries the platform for the preferred input type).
func (p SynthesizeTapGestureParams) WithGestureSourceType(gestureSourceType GestureType) *SynthesizeTapGestureParams {
p.GestureSourceType = gestureSourceType
return &p
}
// Do executes Input.synthesizeTapGesture.
func (p *SynthesizeTapGestureParams) Do(ctxt context.Context, h FrameHandler) (err error) {
if ctxt == nil {
ctxt = context.Background()
}
// marshal
buf, err := easyjson.Marshal(p)
if err != nil {
return err
}
// execute
ch := h.Execute(ctxt, CommandInputSynthesizeTapGesture, easyjson.RawMessage(buf))
// read response
select {
case res := <-ch:
if res == nil {
return ErrChannelClosed
}
switch v := res.(type) {
case easyjson.RawMessage:
return nil
case error:
return v
}
case <-ctxt.Done():
return ErrContextDone
}
return ErrUnknownResult
}

400
cdp/input/types.go Normal file
View File

@ -0,0 +1,400 @@
package input
// AUTOGENERATED. DO NOT EDIT.
import (
"errors"
"fmt"
. "github.com/knq/chromedp/cdp"
"github.com/mailru/easyjson"
"github.com/mailru/easyjson/jlexer"
"github.com/mailru/easyjson/jwriter"
)
var (
_ BackendNode
_ BackendNodeID
_ ComputedProperty
_ ErrorType
_ Frame
_ FrameID
_ LoaderID
_ Message
_ MessageError
_ MethodType
_ Node
_ NodeID
_ NodeType
_ PseudoType
_ RGBA
_ ShadowRootType
_ Timestamp
)
type TouchPoint struct {
State TouchState `json:"state,omitempty"` // State of the touch point.
X int64 `json:"x,omitempty"` // X coordinate of the event relative to the main frame's viewport.
Y int64 `json:"y,omitempty"` // Y coordinate of the event relative to the main frame's viewport. 0 refers to the top of the viewport and Y increases as it proceeds towards the bottom of the viewport.
RadiusX int64 `json:"radiusX,omitempty"` // X radius of the touch area (default: 1).
RadiusY int64 `json:"radiusY,omitempty"` // Y radius of the touch area (default: 1).
RotationAngle float64 `json:"rotationAngle,omitempty"` // Rotation angle (default: 0.0).
Force float64 `json:"force,omitempty"` // Force (default: 1.0).
ID float64 `json:"id,omitempty"` // Identifier used to track touch sources between events, must be unique within an event.
}
type GestureType string
// String returns the GestureType as string value.
func (t GestureType) String() string {
return string(t)
}
// GestureType values.
const (
GestureDefault GestureType = "default"
GestureTouch GestureType = "touch"
GestureMouse GestureType = "mouse"
)
// MarshalEasyJSON satisfies easyjson.Marshaler.
func (t GestureType) MarshalEasyJSON(out *jwriter.Writer) {
out.String(string(t))
}
// MarshalJSON satisfies json.Marshaler.
func (t GestureType) MarshalJSON() ([]byte, error) {
return easyjson.Marshal(t)
}
// UnmarshalEasyJSON satisfies easyjson.Unmarshaler.
func (t *GestureType) UnmarshalEasyJSON(in *jlexer.Lexer) {
switch GestureType(in.String()) {
case GestureDefault:
*t = GestureDefault
case GestureTouch:
*t = GestureTouch
case GestureMouse:
*t = GestureMouse
default:
in.AddError(errors.New("unknown GestureType value"))
}
}
// UnmarshalJSON satisfies json.Unmarshaler.
func (t *GestureType) UnmarshalJSON(buf []byte) error {
return easyjson.Unmarshal(buf, t)
}
// Modifier input key modifier type.
type Modifier int64
// Int64 returns the Modifier as int64 value.
func (t Modifier) Int64() int64 {
return int64(t)
}
// Modifier values.
const (
ModifierNone Modifier = 0
ModifierAlt Modifier = 1
ModifierCtrl Modifier = 2
ModifierMeta Modifier = 4
ModifierShift Modifier = 8
)
// String returns the Modifier as string value.
func (t Modifier) String() string {
switch t {
case ModifierNone:
return "None"
case ModifierAlt:
return "Alt"
case ModifierCtrl:
return "Ctrl"
case ModifierMeta:
return "Meta"
case ModifierShift:
return "Shift"
}
return fmt.Sprintf("Modifier(%d)", t)
}
// MarshalEasyJSON satisfies easyjson.Marshaler.
func (t Modifier) MarshalEasyJSON(out *jwriter.Writer) {
out.Int64(int64(t))
}
// MarshalJSON satisfies json.Marshaler.
func (t Modifier) MarshalJSON() ([]byte, error) {
return easyjson.Marshal(t)
}
// UnmarshalEasyJSON satisfies easyjson.Unmarshaler.
func (t *Modifier) UnmarshalEasyJSON(in *jlexer.Lexer) {
switch Modifier(in.Int64()) {
case ModifierNone:
*t = ModifierNone
case ModifierAlt:
*t = ModifierAlt
case ModifierCtrl:
*t = ModifierCtrl
case ModifierMeta:
*t = ModifierMeta
case ModifierShift:
*t = ModifierShift
default:
in.AddError(errors.New("unknown Modifier value"))
}
}
// UnmarshalJSON satisfies json.Unmarshaler.
func (t *Modifier) UnmarshalJSON(buf []byte) error {
return easyjson.Unmarshal(buf, t)
}
// ModifierCommand is an alias for ModifierMeta.
const ModifierCommand Modifier = ModifierMeta
// TouchState state of the touch point.
type TouchState string
// String returns the TouchState as string value.
func (t TouchState) String() string {
return string(t)
}
// TouchState values.
const (
TouchPressed TouchState = "touchPressed"
TouchReleased TouchState = "touchReleased"
TouchMoved TouchState = "touchMoved"
TouchStationary TouchState = "touchStationary"
TouchCanceled TouchState = "touchCancelled"
)
// MarshalEasyJSON satisfies easyjson.Marshaler.
func (t TouchState) MarshalEasyJSON(out *jwriter.Writer) {
out.String(string(t))
}
// MarshalJSON satisfies json.Marshaler.
func (t TouchState) MarshalJSON() ([]byte, error) {
return easyjson.Marshal(t)
}
// UnmarshalEasyJSON satisfies easyjson.Unmarshaler.
func (t *TouchState) UnmarshalEasyJSON(in *jlexer.Lexer) {
switch TouchState(in.String()) {
case TouchPressed:
*t = TouchPressed
case TouchReleased:
*t = TouchReleased
case TouchMoved:
*t = TouchMoved
case TouchStationary:
*t = TouchStationary
case TouchCanceled:
*t = TouchCanceled
default:
in.AddError(errors.New("unknown TouchState value"))
}
}
// UnmarshalJSON satisfies json.Unmarshaler.
func (t *TouchState) UnmarshalJSON(buf []byte) error {
return easyjson.Unmarshal(buf, t)
}
// KeyType type of the key event.
type KeyType string
// String returns the KeyType as string value.
func (t KeyType) String() string {
return string(t)
}
// KeyType values.
const (
KeyDown KeyType = "keyDown"
KeyUp KeyType = "keyUp"
KeyRawDown KeyType = "rawKeyDown"
KeyChar KeyType = "char"
)
// MarshalEasyJSON satisfies easyjson.Marshaler.
func (t KeyType) MarshalEasyJSON(out *jwriter.Writer) {
out.String(string(t))
}
// MarshalJSON satisfies json.Marshaler.
func (t KeyType) MarshalJSON() ([]byte, error) {
return easyjson.Marshal(t)
}
// UnmarshalEasyJSON satisfies easyjson.Unmarshaler.
func (t *KeyType) UnmarshalEasyJSON(in *jlexer.Lexer) {
switch KeyType(in.String()) {
case KeyDown:
*t = KeyDown
case KeyUp:
*t = KeyUp
case KeyRawDown:
*t = KeyRawDown
case KeyChar:
*t = KeyChar
default:
in.AddError(errors.New("unknown KeyType value"))
}
}
// UnmarshalJSON satisfies json.Unmarshaler.
func (t *KeyType) UnmarshalJSON(buf []byte) error {
return easyjson.Unmarshal(buf, t)
}
// MouseType type of the mouse event.
type MouseType string
// String returns the MouseType as string value.
func (t MouseType) String() string {
return string(t)
}
// MouseType values.
const (
MousePressed MouseType = "mousePressed"
MouseReleased MouseType = "mouseReleased"
MouseMoved MouseType = "mouseMoved"
MouseWheel MouseType = "mouseWheel"
)
// MarshalEasyJSON satisfies easyjson.Marshaler.
func (t MouseType) MarshalEasyJSON(out *jwriter.Writer) {
out.String(string(t))
}
// MarshalJSON satisfies json.Marshaler.
func (t MouseType) MarshalJSON() ([]byte, error) {
return easyjson.Marshal(t)
}
// UnmarshalEasyJSON satisfies easyjson.Unmarshaler.
func (t *MouseType) UnmarshalEasyJSON(in *jlexer.Lexer) {
switch MouseType(in.String()) {
case MousePressed:
*t = MousePressed
case MouseReleased:
*t = MouseReleased
case MouseMoved:
*t = MouseMoved
case MouseWheel:
*t = MouseWheel
default:
in.AddError(errors.New("unknown MouseType value"))
}
}
// UnmarshalJSON satisfies json.Unmarshaler.
func (t *MouseType) UnmarshalJSON(buf []byte) error {
return easyjson.Unmarshal(buf, t)
}
// ButtonType mouse button (default: "none").
type ButtonType string
// String returns the ButtonType as string value.
func (t ButtonType) String() string {
return string(t)
}
// ButtonType values.
const (
ButtonNone ButtonType = "none"
ButtonLeft ButtonType = "left"
ButtonMiddle ButtonType = "middle"
ButtonRight ButtonType = "right"
)
// MarshalEasyJSON satisfies easyjson.Marshaler.
func (t ButtonType) MarshalEasyJSON(out *jwriter.Writer) {
out.String(string(t))
}
// MarshalJSON satisfies json.Marshaler.
func (t ButtonType) MarshalJSON() ([]byte, error) {
return easyjson.Marshal(t)
}
// UnmarshalEasyJSON satisfies easyjson.Unmarshaler.
func (t *ButtonType) UnmarshalEasyJSON(in *jlexer.Lexer) {
switch ButtonType(in.String()) {
case ButtonNone:
*t = ButtonNone
case ButtonLeft:
*t = ButtonLeft
case ButtonMiddle:
*t = ButtonMiddle
case ButtonRight:
*t = ButtonRight
default:
in.AddError(errors.New("unknown ButtonType value"))
}
}
// UnmarshalJSON satisfies json.Unmarshaler.
func (t *ButtonType) UnmarshalJSON(buf []byte) error {
return easyjson.Unmarshal(buf, t)
}
// TouchType type of the touch event.
type TouchType string
// String returns the TouchType as string value.
func (t TouchType) String() string {
return string(t)
}
// TouchType values.
const (
TouchStart TouchType = "touchStart"
TouchEnd TouchType = "touchEnd"
TouchMove TouchType = "touchMove"
)
// MarshalEasyJSON satisfies easyjson.Marshaler.
func (t TouchType) MarshalEasyJSON(out *jwriter.Writer) {
out.String(string(t))
}
// MarshalJSON satisfies json.Marshaler.
func (t TouchType) MarshalJSON() ([]byte, error) {
return easyjson.Marshal(t)
}
// UnmarshalEasyJSON satisfies easyjson.Unmarshaler.
func (t *TouchType) UnmarshalEasyJSON(in *jlexer.Lexer) {
switch TouchType(in.String()) {
case TouchStart:
*t = TouchStart
case TouchEnd:
*t = TouchEnd
case TouchMove:
*t = TouchMove
default:
in.AddError(errors.New("unknown TouchType value"))
}
}
// UnmarshalJSON satisfies json.Unmarshaler.
func (t *TouchType) UnmarshalJSON(buf []byte) error {
return easyjson.Unmarshal(buf, t)
}

265
cdp/inspector/easyjson.go Normal file
View File

@ -0,0 +1,265 @@
// AUTOGENERATED FILE: easyjson marshaler/unmarshalers.
package inspector
import (
json "encoding/json"
easyjson "github.com/mailru/easyjson"
jlexer "github.com/mailru/easyjson/jlexer"
jwriter "github.com/mailru/easyjson/jwriter"
)
// suppress unused package warning
var (
_ *json.RawMessage
_ *jlexer.Lexer
_ *jwriter.Writer
_ easyjson.Marshaler
)
func easyjsonC5a4559bDecodeGithubComKnqChromedpCdpInspector(in *jlexer.Lexer, out *EventTargetCrashed) {
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 {
default:
in.SkipRecursive()
}
in.WantComma()
}
in.Delim('}')
if isTopLevel {
in.Consumed()
}
}
func easyjsonC5a4559bEncodeGithubComKnqChromedpCdpInspector(out *jwriter.Writer, in EventTargetCrashed) {
out.RawByte('{')
first := true
_ = first
out.RawByte('}')
}
// MarshalJSON supports json.Marshaler interface
func (v EventTargetCrashed) MarshalJSON() ([]byte, error) {
w := jwriter.Writer{}
easyjsonC5a4559bEncodeGithubComKnqChromedpCdpInspector(&w, v)
return w.Buffer.BuildBytes(), w.Error
}
// MarshalEasyJSON supports easyjson.Marshaler interface
func (v EventTargetCrashed) MarshalEasyJSON(w *jwriter.Writer) {
easyjsonC5a4559bEncodeGithubComKnqChromedpCdpInspector(w, v)
}
// UnmarshalJSON supports json.Unmarshaler interface
func (v *EventTargetCrashed) UnmarshalJSON(data []byte) error {
r := jlexer.Lexer{Data: data}
easyjsonC5a4559bDecodeGithubComKnqChromedpCdpInspector(&r, v)
return r.Error()
}
// UnmarshalEasyJSON supports easyjson.Unmarshaler interface
func (v *EventTargetCrashed) UnmarshalEasyJSON(l *jlexer.Lexer) {
easyjsonC5a4559bDecodeGithubComKnqChromedpCdpInspector(l, v)
}
func easyjsonC5a4559bDecodeGithubComKnqChromedpCdpInspector1(in *jlexer.Lexer, out *EventDetached) {
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 "reason":
(out.Reason).UnmarshalEasyJSON(in)
default:
in.SkipRecursive()
}
in.WantComma()
}
in.Delim('}')
if isTopLevel {
in.Consumed()
}
}
func easyjsonC5a4559bEncodeGithubComKnqChromedpCdpInspector1(out *jwriter.Writer, in EventDetached) {
out.RawByte('{')
first := true
_ = first
if in.Reason != "" {
if !first {
out.RawByte(',')
}
first = false
out.RawString("\"reason\":")
(in.Reason).MarshalEasyJSON(out)
}
out.RawByte('}')
}
// MarshalJSON supports json.Marshaler interface
func (v EventDetached) MarshalJSON() ([]byte, error) {
w := jwriter.Writer{}
easyjsonC5a4559bEncodeGithubComKnqChromedpCdpInspector1(&w, v)
return w.Buffer.BuildBytes(), w.Error
}
// MarshalEasyJSON supports easyjson.Marshaler interface
func (v EventDetached) MarshalEasyJSON(w *jwriter.Writer) {
easyjsonC5a4559bEncodeGithubComKnqChromedpCdpInspector1(w, v)
}
// UnmarshalJSON supports json.Unmarshaler interface
func (v *EventDetached) UnmarshalJSON(data []byte) error {
r := jlexer.Lexer{Data: data}
easyjsonC5a4559bDecodeGithubComKnqChromedpCdpInspector1(&r, v)
return r.Error()
}
// UnmarshalEasyJSON supports easyjson.Unmarshaler interface
func (v *EventDetached) UnmarshalEasyJSON(l *jlexer.Lexer) {
easyjsonC5a4559bDecodeGithubComKnqChromedpCdpInspector1(l, v)
}
func easyjsonC5a4559bDecodeGithubComKnqChromedpCdpInspector2(in *jlexer.Lexer, out *EnableParams) {
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 {
default:
in.SkipRecursive()
}
in.WantComma()
}
in.Delim('}')
if isTopLevel {
in.Consumed()
}
}
func easyjsonC5a4559bEncodeGithubComKnqChromedpCdpInspector2(out *jwriter.Writer, in EnableParams) {
out.RawByte('{')
first := true
_ = first
out.RawByte('}')
}
// MarshalJSON supports json.Marshaler interface
func (v EnableParams) MarshalJSON() ([]byte, error) {
w := jwriter.Writer{}
easyjsonC5a4559bEncodeGithubComKnqChromedpCdpInspector2(&w, v)
return w.Buffer.BuildBytes(), w.Error
}
// MarshalEasyJSON supports easyjson.Marshaler interface
func (v EnableParams) MarshalEasyJSON(w *jwriter.Writer) {
easyjsonC5a4559bEncodeGithubComKnqChromedpCdpInspector2(w, v)
}
// UnmarshalJSON supports json.Unmarshaler interface
func (v *EnableParams) UnmarshalJSON(data []byte) error {
r := jlexer.Lexer{Data: data}
easyjsonC5a4559bDecodeGithubComKnqChromedpCdpInspector2(&r, v)
return r.Error()
}
// UnmarshalEasyJSON supports easyjson.Unmarshaler interface
func (v *EnableParams) UnmarshalEasyJSON(l *jlexer.Lexer) {
easyjsonC5a4559bDecodeGithubComKnqChromedpCdpInspector2(l, v)
}
func easyjsonC5a4559bDecodeGithubComKnqChromedpCdpInspector3(in *jlexer.Lexer, out *DisableParams) {
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 {
default:
in.SkipRecursive()
}
in.WantComma()
}
in.Delim('}')
if isTopLevel {
in.Consumed()
}
}
func easyjsonC5a4559bEncodeGithubComKnqChromedpCdpInspector3(out *jwriter.Writer, in DisableParams) {
out.RawByte('{')
first := true
_ = first
out.RawByte('}')
}
// MarshalJSON supports json.Marshaler interface
func (v DisableParams) MarshalJSON() ([]byte, error) {
w := jwriter.Writer{}
easyjsonC5a4559bEncodeGithubComKnqChromedpCdpInspector3(&w, v)
return w.Buffer.BuildBytes(), w.Error
}
// MarshalEasyJSON supports easyjson.Marshaler interface
func (v DisableParams) MarshalEasyJSON(w *jwriter.Writer) {
easyjsonC5a4559bEncodeGithubComKnqChromedpCdpInspector3(w, v)
}
// UnmarshalJSON supports json.Unmarshaler interface
func (v *DisableParams) UnmarshalJSON(data []byte) error {
r := jlexer.Lexer{Data: data}
easyjsonC5a4559bDecodeGithubComKnqChromedpCdpInspector3(&r, v)
return r.Error()
}
// UnmarshalEasyJSON supports easyjson.Unmarshaler interface
func (v *DisableParams) UnmarshalEasyJSON(l *jlexer.Lexer) {
easyjsonC5a4559bDecodeGithubComKnqChromedpCdpInspector3(l, v)
}

42
cdp/inspector/events.go Normal file
View File

@ -0,0 +1,42 @@
package inspector
// AUTOGENERATED. DO NOT EDIT.
import (
. "github.com/knq/chromedp/cdp"
)
var (
_ BackendNode
_ BackendNodeID
_ ComputedProperty
_ ErrorType
_ Frame
_ FrameID
_ LoaderID
_ Message
_ MessageError
_ MethodType
_ Node
_ NodeID
_ NodeType
_ PseudoType
_ RGBA
_ ShadowRootType
_ Timestamp
)
// EventDetached fired when remote debugging connection is about to be
// terminated. Contains detach reason.
type EventDetached struct {
Reason DetachReason `json:"reason,omitempty"` // The reason why connection has been terminated.
}
// EventTargetCrashed fired when debugging target has crashed.
type EventTargetCrashed struct{}
// EventTypes is all event types in the domain.
var EventTypes = []MethodType{
EventInspectorDetached,
EventInspectorTargetCrashed,
}

112
cdp/inspector/inspector.go Normal file
View File

@ -0,0 +1,112 @@
// Package inspector provides the Chrome Debugging Protocol
// commands, types, and events for the Chrome Inspector domain.
//
// Generated by the chromedp-gen command.
package inspector
// AUTOGENERATED. DO NOT EDIT.
import (
"context"
. "github.com/knq/chromedp/cdp"
"github.com/mailru/easyjson"
)
var (
_ BackendNode
_ BackendNodeID
_ ComputedProperty
_ ErrorType
_ Frame
_ FrameID
_ LoaderID
_ Message
_ MessageError
_ MethodType
_ Node
_ NodeID
_ NodeType
_ PseudoType
_ RGBA
_ ShadowRootType
_ Timestamp
)
// EnableParams enables inspector domain notifications.
type EnableParams struct{}
// Enable enables inspector domain notifications.
func Enable() *EnableParams {
return &EnableParams{}
}
// Do executes Inspector.enable.
func (p *EnableParams) Do(ctxt context.Context, h FrameHandler) (err error) {
if ctxt == nil {
ctxt = context.Background()
}
// execute
ch := h.Execute(ctxt, CommandInspectorEnable, Empty)
// read response
select {
case res := <-ch:
if res == nil {
return ErrChannelClosed
}
switch v := res.(type) {
case easyjson.RawMessage:
return nil
case error:
return v
}
case <-ctxt.Done():
return ErrContextDone
}
return ErrUnknownResult
}
// DisableParams disables inspector domain notifications.
type DisableParams struct{}
// Disable disables inspector domain notifications.
func Disable() *DisableParams {
return &DisableParams{}
}
// Do executes Inspector.disable.
func (p *DisableParams) Do(ctxt context.Context, h FrameHandler) (err error) {
if ctxt == nil {
ctxt = context.Background()
}
// execute
ch := h.Execute(ctxt, CommandInspectorDisable, Empty)
// read response
select {
case res := <-ch:
if res == nil {
return ErrChannelClosed
}
switch v := res.(type) {
case easyjson.RawMessage:
return nil
case error:
return v
}
case <-ctxt.Done():
return ErrContextDone
}
return ErrUnknownResult
}

80
cdp/inspector/types.go Normal file
View File

@ -0,0 +1,80 @@
package inspector
// AUTOGENERATED. DO NOT EDIT.
import (
"errors"
. "github.com/knq/chromedp/cdp"
"github.com/mailru/easyjson"
"github.com/mailru/easyjson/jlexer"
"github.com/mailru/easyjson/jwriter"
)
var (
_ BackendNode
_ BackendNodeID
_ ComputedProperty
_ ErrorType
_ Frame
_ FrameID
_ LoaderID
_ Message
_ MessageError
_ MethodType
_ Node
_ NodeID
_ NodeType
_ PseudoType
_ RGBA
_ ShadowRootType
_ Timestamp
)
// DetachReason detach reason.
type DetachReason string
// String returns the DetachReason as string value.
func (t DetachReason) String() string {
return string(t)
}
// DetachReason values.
const (
DetachReasonTargetClosed DetachReason = "target_closed"
DetachReasonCanceledByUser DetachReason = "canceled_by_user"
DetachReasonReplacedWithDevtools DetachReason = "replaced_with_devtools"
DetachReasonRenderProcessGone DetachReason = "Render process gone."
)
// MarshalEasyJSON satisfies easyjson.Marshaler.
func (t DetachReason) MarshalEasyJSON(out *jwriter.Writer) {
out.String(string(t))
}
// MarshalJSON satisfies json.Marshaler.
func (t DetachReason) MarshalJSON() ([]byte, error) {
return easyjson.Marshal(t)
}
// UnmarshalEasyJSON satisfies easyjson.Unmarshaler.
func (t *DetachReason) UnmarshalEasyJSON(in *jlexer.Lexer) {
switch DetachReason(in.String()) {
case DetachReasonTargetClosed:
*t = DetachReasonTargetClosed
case DetachReasonCanceledByUser:
*t = DetachReasonCanceledByUser
case DetachReasonReplacedWithDevtools:
*t = DetachReasonReplacedWithDevtools
case DetachReasonRenderProcessGone:
*t = DetachReasonRenderProcessGone
default:
in.AddError(errors.New("unknown DetachReason value"))
}
}
// UnmarshalJSON satisfies json.Unmarshaler.
func (t *DetachReason) UnmarshalJSON(buf []byte) error {
return easyjson.Unmarshal(buf, t)
}

252
cdp/io/easyjson.go Normal file
View File

@ -0,0 +1,252 @@
// AUTOGENERATED FILE: easyjson marshaler/unmarshalers.
package io
import (
json "encoding/json"
easyjson "github.com/mailru/easyjson"
jlexer "github.com/mailru/easyjson/jlexer"
jwriter "github.com/mailru/easyjson/jwriter"
)
// suppress unused package warning
var (
_ *json.RawMessage
_ *jlexer.Lexer
_ *jwriter.Writer
_ easyjson.Marshaler
)
func easyjsonC5a4559bDecodeGithubComKnqChromedpCdpIo(in *jlexer.Lexer, out *ReadReturns) {
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 "data":
out.Data = string(in.String())
case "eof":
out.EOF = bool(in.Bool())
default:
in.SkipRecursive()
}
in.WantComma()
}
in.Delim('}')
if isTopLevel {
in.Consumed()
}
}
func easyjsonC5a4559bEncodeGithubComKnqChromedpCdpIo(out *jwriter.Writer, in ReadReturns) {
out.RawByte('{')
first := true
_ = first
if in.Data != "" {
if !first {
out.RawByte(',')
}
first = false
out.RawString("\"data\":")
out.String(string(in.Data))
}
if in.EOF {
if !first {
out.RawByte(',')
}
first = false
out.RawString("\"eof\":")
out.Bool(bool(in.EOF))
}
out.RawByte('}')
}
// MarshalJSON supports json.Marshaler interface
func (v ReadReturns) MarshalJSON() ([]byte, error) {
w := jwriter.Writer{}
easyjsonC5a4559bEncodeGithubComKnqChromedpCdpIo(&w, v)
return w.Buffer.BuildBytes(), w.Error
}
// MarshalEasyJSON supports easyjson.Marshaler interface
func (v ReadReturns) MarshalEasyJSON(w *jwriter.Writer) {
easyjsonC5a4559bEncodeGithubComKnqChromedpCdpIo(w, v)
}
// UnmarshalJSON supports json.Unmarshaler interface
func (v *ReadReturns) UnmarshalJSON(data []byte) error {
r := jlexer.Lexer{Data: data}
easyjsonC5a4559bDecodeGithubComKnqChromedpCdpIo(&r, v)
return r.Error()
}
// UnmarshalEasyJSON supports easyjson.Unmarshaler interface
func (v *ReadReturns) UnmarshalEasyJSON(l *jlexer.Lexer) {
easyjsonC5a4559bDecodeGithubComKnqChromedpCdpIo(l, v)
}
func easyjsonC5a4559bDecodeGithubComKnqChromedpCdpIo1(in *jlexer.Lexer, out *ReadParams) {
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 "handle":
out.Handle = StreamHandle(in.String())
case "offset":
out.Offset = int64(in.Int64())
case "size":
out.Size = int64(in.Int64())
default:
in.SkipRecursive()
}
in.WantComma()
}
in.Delim('}')
if isTopLevel {
in.Consumed()
}
}
func easyjsonC5a4559bEncodeGithubComKnqChromedpCdpIo1(out *jwriter.Writer, in ReadParams) {
out.RawByte('{')
first := true
_ = first
if !first {
out.RawByte(',')
}
first = false
out.RawString("\"handle\":")
out.String(string(in.Handle))
if in.Offset != 0 {
if !first {
out.RawByte(',')
}
first = false
out.RawString("\"offset\":")
out.Int64(int64(in.Offset))
}
if in.Size != 0 {
if !first {
out.RawByte(',')
}
first = false
out.RawString("\"size\":")
out.Int64(int64(in.Size))
}
out.RawByte('}')
}
// MarshalJSON supports json.Marshaler interface
func (v ReadParams) MarshalJSON() ([]byte, error) {
w := jwriter.Writer{}
easyjsonC5a4559bEncodeGithubComKnqChromedpCdpIo1(&w, v)
return w.Buffer.BuildBytes(), w.Error
}
// MarshalEasyJSON supports easyjson.Marshaler interface
func (v ReadParams) MarshalEasyJSON(w *jwriter.Writer) {
easyjsonC5a4559bEncodeGithubComKnqChromedpCdpIo1(w, v)
}
// UnmarshalJSON supports json.Unmarshaler interface
func (v *ReadParams) UnmarshalJSON(data []byte) error {
r := jlexer.Lexer{Data: data}
easyjsonC5a4559bDecodeGithubComKnqChromedpCdpIo1(&r, v)
return r.Error()
}
// UnmarshalEasyJSON supports easyjson.Unmarshaler interface
func (v *ReadParams) UnmarshalEasyJSON(l *jlexer.Lexer) {
easyjsonC5a4559bDecodeGithubComKnqChromedpCdpIo1(l, v)
}
func easyjsonC5a4559bDecodeGithubComKnqChromedpCdpIo2(in *jlexer.Lexer, out *CloseParams) {
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 "handle":
out.Handle = StreamHandle(in.String())
default:
in.SkipRecursive()
}
in.WantComma()
}
in.Delim('}')
if isTopLevel {
in.Consumed()
}
}
func easyjsonC5a4559bEncodeGithubComKnqChromedpCdpIo2(out *jwriter.Writer, in CloseParams) {
out.RawByte('{')
first := true
_ = first
if !first {
out.RawByte(',')
}
first = false
out.RawString("\"handle\":")
out.String(string(in.Handle))
out.RawByte('}')
}
// MarshalJSON supports json.Marshaler interface
func (v CloseParams) MarshalJSON() ([]byte, error) {
w := jwriter.Writer{}
easyjsonC5a4559bEncodeGithubComKnqChromedpCdpIo2(&w, v)
return w.Buffer.BuildBytes(), w.Error
}
// MarshalEasyJSON supports easyjson.Marshaler interface
func (v CloseParams) MarshalEasyJSON(w *jwriter.Writer) {
easyjsonC5a4559bEncodeGithubComKnqChromedpCdpIo2(w, v)
}
// UnmarshalJSON supports json.Unmarshaler interface
func (v *CloseParams) UnmarshalJSON(data []byte) error {
r := jlexer.Lexer{Data: data}
easyjsonC5a4559bDecodeGithubComKnqChromedpCdpIo2(&r, v)
return r.Error()
}
// UnmarshalEasyJSON supports easyjson.Unmarshaler interface
func (v *CloseParams) UnmarshalEasyJSON(l *jlexer.Lexer) {
easyjsonC5a4559bDecodeGithubComKnqChromedpCdpIo2(l, v)
}

173
cdp/io/io.go Normal file
View File

@ -0,0 +1,173 @@
// Package io provides the Chrome Debugging Protocol
// commands, types, and events for the Chrome IO domain.
//
// Input/Output operations for streams produced by DevTools.
//
// Generated by the chromedp-gen command.
package io
// AUTOGENERATED. DO NOT EDIT.
import (
"context"
. "github.com/knq/chromedp/cdp"
"github.com/mailru/easyjson"
)
var (
_ BackendNode
_ BackendNodeID
_ ComputedProperty
_ ErrorType
_ Frame
_ FrameID
_ LoaderID
_ Message
_ MessageError
_ MethodType
_ Node
_ NodeID
_ NodeType
_ PseudoType
_ RGBA
_ ShadowRootType
_ Timestamp
)
// ReadParams read a chunk of the stream.
type ReadParams struct {
Handle StreamHandle `json:"handle"` // Handle of the stream to read.
Offset int64 `json:"offset,omitempty"` // Seek to the specified offset before reading (if not specificed, proceed with offset following the last read).
Size int64 `json:"size,omitempty"` // Maximum number of bytes to read (left upon the agent discretion if not specified).
}
// Read read a chunk of the stream.
//
// parameters:
// handle - Handle of the stream to read.
func Read(handle StreamHandle) *ReadParams {
return &ReadParams{
Handle: handle,
}
}
// WithOffset seek to the specified offset before reading (if not specificed,
// proceed with offset following the last read).
func (p ReadParams) WithOffset(offset int64) *ReadParams {
p.Offset = offset
return &p
}
// WithSize maximum number of bytes to read (left upon the agent discretion
// if not specified).
func (p ReadParams) WithSize(size int64) *ReadParams {
p.Size = size
return &p
}
// ReadReturns return values.
type ReadReturns struct {
Data string `json:"data,omitempty"` // Data that were read.
EOF bool `json:"eof,omitempty"` // Set if the end-of-file condition occured while reading.
}
// Do executes IO.read.
//
// returns:
// data - Data that were read.
// eof - Set if the end-of-file condition occured while reading.
func (p *ReadParams) Do(ctxt context.Context, h FrameHandler) (data string, eof bool, err error) {
if ctxt == nil {
ctxt = context.Background()
}
// marshal
buf, err := easyjson.Marshal(p)
if err != nil {
return "", false, err
}
// execute
ch := h.Execute(ctxt, CommandIORead, easyjson.RawMessage(buf))
// read response
select {
case res := <-ch:
if res == nil {
return "", false, ErrChannelClosed
}
switch v := res.(type) {
case easyjson.RawMessage:
// unmarshal
var r ReadReturns
err = easyjson.Unmarshal(v, &r)
if err != nil {
return "", false, ErrInvalidResult
}
return r.Data, r.EOF, nil
case error:
return "", false, v
}
case <-ctxt.Done():
return "", false, ErrContextDone
}
return "", false, ErrUnknownResult
}
// 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.
func (p *CloseParams) Do(ctxt context.Context, h FrameHandler) (err error) {
if ctxt == nil {
ctxt = context.Background()
}
// marshal
buf, err := easyjson.Marshal(p)
if err != nil {
return err
}
// execute
ch := h.Execute(ctxt, CommandIOClose, easyjson.RawMessage(buf))
// read response
select {
case res := <-ch:
if res == nil {
return ErrChannelClosed
}
switch v := res.(type) {
case easyjson.RawMessage:
return nil
case error:
return v
}
case <-ctxt.Done():
return ErrContextDone
}
return ErrUnknownResult
}

34
cdp/io/types.go Normal file
View File

@ -0,0 +1,34 @@
package io
// AUTOGENERATED. DO NOT EDIT.
import (
. "github.com/knq/chromedp/cdp"
)
var (
_ BackendNode
_ BackendNodeID
_ ComputedProperty
_ ErrorType
_ Frame
_ FrameID
_ LoaderID
_ Message
_ MessageError
_ MethodType
_ Node
_ NodeID
_ NodeType
_ PseudoType
_ RGBA
_ ShadowRootType
_ Timestamp
)
type StreamHandle string
// String returns the StreamHandle as string value.
func (t StreamHandle) String() string {
return string(t)
}

1902
cdp/layertree/easyjson.go Normal file

File diff suppressed because it is too large Load Diff

43
cdp/layertree/events.go Normal file
View File

@ -0,0 +1,43 @@
package layertree
// AUTOGENERATED. DO NOT EDIT.
import (
. "github.com/knq/chromedp/cdp"
"github.com/knq/chromedp/cdp/dom"
)
var (
_ BackendNode
_ BackendNodeID
_ ComputedProperty
_ ErrorType
_ Frame
_ FrameID
_ LoaderID
_ Message
_ MessageError
_ MethodType
_ Node
_ NodeID
_ NodeType
_ PseudoType
_ RGBA
_ ShadowRootType
_ Timestamp
)
type EventLayerTreeDidChange struct {
Layers []*Layer `json:"layers,omitempty"` // Layer tree, absent if not in the comspositing mode.
}
type EventLayerPainted struct {
LayerID LayerID `json:"layerId,omitempty"` // The id of the painted layer.
Clip *dom.Rect `json:"clip,omitempty"` // Clip rectangle.
}
// EventTypes is all event types in the domain.
var EventTypes = []MethodType{
EventLayerTreeLayerTreeDidChange,
EventLayerTreeLayerPainted,
}

614
cdp/layertree/layertree.go Normal file
View File

@ -0,0 +1,614 @@
// Package layertree provides the Chrome Debugging Protocol
// commands, types, and events for the Chrome LayerTree domain.
//
// Generated by the chromedp-gen command.
package layertree
// AUTOGENERATED. DO NOT EDIT.
import (
"context"
. "github.com/knq/chromedp/cdp"
"github.com/knq/chromedp/cdp/dom"
"github.com/mailru/easyjson"
)
var (
_ BackendNode
_ BackendNodeID
_ ComputedProperty
_ ErrorType
_ Frame
_ FrameID
_ LoaderID
_ Message
_ MessageError
_ MethodType
_ Node
_ NodeID
_ NodeType
_ PseudoType
_ RGBA
_ ShadowRootType
_ Timestamp
)
// EnableParams enables compositing tree inspection.
type EnableParams struct{}
// Enable enables compositing tree inspection.
func Enable() *EnableParams {
return &EnableParams{}
}
// Do executes LayerTree.enable.
func (p *EnableParams) Do(ctxt context.Context, h FrameHandler) (err error) {
if ctxt == nil {
ctxt = context.Background()
}
// execute
ch := h.Execute(ctxt, CommandLayerTreeEnable, Empty)
// read response
select {
case res := <-ch:
if res == nil {
return ErrChannelClosed
}
switch v := res.(type) {
case easyjson.RawMessage:
return nil
case error:
return v
}
case <-ctxt.Done():
return ErrContextDone
}
return ErrUnknownResult
}
// DisableParams disables compositing tree inspection.
type DisableParams struct{}
// Disable disables compositing tree inspection.
func Disable() *DisableParams {
return &DisableParams{}
}
// Do executes LayerTree.disable.
func (p *DisableParams) Do(ctxt context.Context, h FrameHandler) (err error) {
if ctxt == nil {
ctxt = context.Background()
}
// execute
ch := h.Execute(ctxt, CommandLayerTreeDisable, Empty)
// read response
select {
case res := <-ch:
if res == nil {
return ErrChannelClosed
}
switch v := res.(type) {
case easyjson.RawMessage:
return nil
case error:
return v
}
case <-ctxt.Done():
return ErrContextDone
}
return ErrUnknownResult
}
// CompositingReasonsParams provides the reasons why the given layer was
// composited.
type CompositingReasonsParams struct {
LayerID LayerID `json:"layerId"` // The id of the layer for which we want to get the reasons it was composited.
}
// CompositingReasons provides the reasons why the given layer was
// composited.
//
// parameters:
// layerId - The id of the layer for which we want to get the reasons it was composited.
func CompositingReasons(layerId LayerID) *CompositingReasonsParams {
return &CompositingReasonsParams{
LayerID: layerId,
}
}
// CompositingReasonsReturns return values.
type CompositingReasonsReturns struct {
CompositingReasons []string `json:"compositingReasons,omitempty"` // A list of strings specifying reasons for the given layer to become composited.
}
// Do executes LayerTree.compositingReasons.
//
// returns:
// compositingReasons - A list of strings specifying reasons for the given layer to become composited.
func (p *CompositingReasonsParams) Do(ctxt context.Context, h FrameHandler) (compositingReasons []string, err error) {
if ctxt == nil {
ctxt = context.Background()
}
// marshal
buf, err := easyjson.Marshal(p)
if err != nil {
return nil, err
}
// execute
ch := h.Execute(ctxt, CommandLayerTreeCompositingReasons, easyjson.RawMessage(buf))
// read response
select {
case res := <-ch:
if res == nil {
return nil, ErrChannelClosed
}
switch v := res.(type) {
case easyjson.RawMessage:
// unmarshal
var r CompositingReasonsReturns
err = easyjson.Unmarshal(v, &r)
if err != nil {
return nil, ErrInvalidResult
}
return r.CompositingReasons, nil
case error:
return nil, v
}
case <-ctxt.Done():
return nil, ErrContextDone
}
return nil, ErrUnknownResult
}
// MakeSnapshotParams returns the layer snapshot identifier.
type MakeSnapshotParams struct {
LayerID LayerID `json:"layerId"` // The id of the layer.
}
// 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.
//
// returns:
// snapshotId - The id of the layer snapshot.
func (p *MakeSnapshotParams) Do(ctxt context.Context, h FrameHandler) (snapshotId SnapshotID, err error) {
if ctxt == nil {
ctxt = context.Background()
}
// marshal
buf, err := easyjson.Marshal(p)
if err != nil {
return "", err
}
// execute
ch := h.Execute(ctxt, CommandLayerTreeMakeSnapshot, easyjson.RawMessage(buf))
// read response
select {
case res := <-ch:
if res == nil {
return "", ErrChannelClosed
}
switch v := res.(type) {
case easyjson.RawMessage:
// unmarshal
var r MakeSnapshotReturns
err = easyjson.Unmarshal(v, &r)
if err != nil {
return "", ErrInvalidResult
}
return r.SnapshotID, nil
case error:
return "", v
}
case <-ctxt.Done():
return "", ErrContextDone
}
return "", ErrUnknownResult
}
// LoadSnapshotParams returns the snapshot identifier.
type LoadSnapshotParams struct {
Tiles []*PictureTile `json:"tiles"` // An array of tiles composing the snapshot.
}
// LoadSnapshot returns the snapshot identifier.
//
// parameters:
// tiles - An array of tiles composing the snapshot.
func LoadSnapshot(tiles []*PictureTile) *LoadSnapshotParams {
return &LoadSnapshotParams{
Tiles: tiles,
}
}
// LoadSnapshotReturns return values.
type LoadSnapshotReturns struct {
SnapshotID SnapshotID `json:"snapshotId,omitempty"` // The id of the snapshot.
}
// Do executes LayerTree.loadSnapshot.
//
// returns:
// snapshotId - The id of the snapshot.
func (p *LoadSnapshotParams) Do(ctxt context.Context, h FrameHandler) (snapshotId SnapshotID, err error) {
if ctxt == nil {
ctxt = context.Background()
}
// marshal
buf, err := easyjson.Marshal(p)
if err != nil {
return "", err
}
// execute
ch := h.Execute(ctxt, CommandLayerTreeLoadSnapshot, easyjson.RawMessage(buf))
// read response
select {
case res := <-ch:
if res == nil {
return "", ErrChannelClosed
}
switch v := res.(type) {
case easyjson.RawMessage:
// unmarshal
var r LoadSnapshotReturns
err = easyjson.Unmarshal(v, &r)
if err != nil {
return "", ErrInvalidResult
}
return r.SnapshotID, nil
case error:
return "", v
}
case <-ctxt.Done():
return "", ErrContextDone
}
return "", ErrUnknownResult
}
// 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.
func (p *ReleaseSnapshotParams) Do(ctxt context.Context, h FrameHandler) (err error) {
if ctxt == nil {
ctxt = context.Background()
}
// marshal
buf, err := easyjson.Marshal(p)
if err != nil {
return err
}
// execute
ch := h.Execute(ctxt, CommandLayerTreeReleaseSnapshot, easyjson.RawMessage(buf))
// read response
select {
case res := <-ch:
if res == nil {
return ErrChannelClosed
}
switch v := res.(type) {
case easyjson.RawMessage:
return nil
case error:
return v
}
case <-ctxt.Done():
return ErrContextDone
}
return ErrUnknownResult
}
type ProfileSnapshotParams struct {
SnapshotID SnapshotID `json:"snapshotId"` // The id of the layer snapshot.
MinRepeatCount int64 `json:"minRepeatCount,omitempty"` // The maximum number of times to replay the snapshot (1, if not specified).
MinDuration float64 `json:"minDuration,omitempty"` // The minimum duration (in seconds) to replay the snapshot.
ClipRect *dom.Rect `json:"clipRect,omitempty"` // The clip rectangle to apply when replaying the snapshot.
}
// parameters:
// snapshotId - The id of the layer snapshot.
func ProfileSnapshot(snapshotId SnapshotID) *ProfileSnapshotParams {
return &ProfileSnapshotParams{
SnapshotID: snapshotId,
}
}
// WithMinRepeatCount the maximum number of times to replay the snapshot (1,
// if not specified).
func (p ProfileSnapshotParams) WithMinRepeatCount(minRepeatCount int64) *ProfileSnapshotParams {
p.MinRepeatCount = minRepeatCount
return &p
}
// WithMinDuration the minimum duration (in seconds) to replay the snapshot.
func (p ProfileSnapshotParams) WithMinDuration(minDuration float64) *ProfileSnapshotParams {
p.MinDuration = minDuration
return &p
}
// WithClipRect the clip rectangle to apply when replaying the snapshot.
func (p ProfileSnapshotParams) WithClipRect(clipRect *dom.Rect) *ProfileSnapshotParams {
p.ClipRect = clipRect
return &p
}
// ProfileSnapshotReturns return values.
type ProfileSnapshotReturns struct {
Timings []PaintProfile `json:"timings,omitempty"` // The array of paint profiles, one per run.
}
// Do executes LayerTree.profileSnapshot.
//
// returns:
// timings - The array of paint profiles, one per run.
func (p *ProfileSnapshotParams) Do(ctxt context.Context, h FrameHandler) (timings []PaintProfile, err error) {
if ctxt == nil {
ctxt = context.Background()
}
// marshal
buf, err := easyjson.Marshal(p)
if err != nil {
return nil, err
}
// execute
ch := h.Execute(ctxt, CommandLayerTreeProfileSnapshot, easyjson.RawMessage(buf))
// read response
select {
case res := <-ch:
if res == nil {
return nil, ErrChannelClosed
}
switch v := res.(type) {
case easyjson.RawMessage:
// unmarshal
var r ProfileSnapshotReturns
err = easyjson.Unmarshal(v, &r)
if err != nil {
return nil, ErrInvalidResult
}
return r.Timings, nil
case error:
return nil, v
}
case <-ctxt.Done():
return nil, ErrContextDone
}
return nil, ErrUnknownResult
}
// ReplaySnapshotParams replays the layer snapshot and returns the resulting
// bitmap.
type ReplaySnapshotParams struct {
SnapshotID SnapshotID `json:"snapshotId"` // The id of the layer snapshot.
FromStep int64 `json:"fromStep,omitempty"` // The first step to replay from (replay from the very start if not specified).
ToStep int64 `json:"toStep,omitempty"` // The last step to replay to (replay till the end if not specified).
Scale float64 `json:"scale,omitempty"` // The scale to apply while replaying (defaults to 1).
}
// ReplaySnapshot replays the layer snapshot and returns the resulting
// bitmap.
//
// parameters:
// snapshotId - The id of the layer snapshot.
func ReplaySnapshot(snapshotId SnapshotID) *ReplaySnapshotParams {
return &ReplaySnapshotParams{
SnapshotID: snapshotId,
}
}
// WithFromStep the first step to replay from (replay from the very start if
// not specified).
func (p ReplaySnapshotParams) WithFromStep(fromStep int64) *ReplaySnapshotParams {
p.FromStep = fromStep
return &p
}
// WithToStep the last step to replay to (replay till the end if not
// specified).
func (p ReplaySnapshotParams) WithToStep(toStep int64) *ReplaySnapshotParams {
p.ToStep = toStep
return &p
}
// WithScale the scale to apply while replaying (defaults to 1).
func (p ReplaySnapshotParams) WithScale(scale float64) *ReplaySnapshotParams {
p.Scale = scale
return &p
}
// ReplaySnapshotReturns return values.
type ReplaySnapshotReturns struct {
DataURL string `json:"dataURL,omitempty"` // A data: URL for resulting image.
}
// Do executes LayerTree.replaySnapshot.
//
// returns:
// dataURL - A data: URL for resulting image.
func (p *ReplaySnapshotParams) Do(ctxt context.Context, h FrameHandler) (dataURL string, err error) {
if ctxt == nil {
ctxt = context.Background()
}
// marshal
buf, err := easyjson.Marshal(p)
if err != nil {
return "", err
}
// execute
ch := h.Execute(ctxt, CommandLayerTreeReplaySnapshot, easyjson.RawMessage(buf))
// read response
select {
case res := <-ch:
if res == nil {
return "", ErrChannelClosed
}
switch v := res.(type) {
case easyjson.RawMessage:
// unmarshal
var r ReplaySnapshotReturns
err = easyjson.Unmarshal(v, &r)
if err != nil {
return "", ErrInvalidResult
}
return r.DataURL, nil
case error:
return "", v
}
case <-ctxt.Done():
return "", ErrContextDone
}
return "", ErrUnknownResult
}
// SnapshotCommandLogParams replays the layer snapshot and returns canvas
// log.
type SnapshotCommandLogParams struct {
SnapshotID SnapshotID `json:"snapshotId"` // The id of the layer snapshot.
}
// SnapshotCommandLog replays the layer snapshot and returns canvas log.
//
// parameters:
// snapshotId - The id of the layer snapshot.
func SnapshotCommandLog(snapshotId SnapshotID) *SnapshotCommandLogParams {
return &SnapshotCommandLogParams{
SnapshotID: snapshotId,
}
}
// SnapshotCommandLogReturns return values.
type SnapshotCommandLogReturns struct {
CommandLog []easyjson.RawMessage `json:"commandLog,omitempty"` // The array of canvas function calls.
}
// Do executes LayerTree.snapshotCommandLog.
//
// returns:
// commandLog - The array of canvas function calls.
func (p *SnapshotCommandLogParams) Do(ctxt context.Context, h FrameHandler) (commandLog []easyjson.RawMessage, err error) {
if ctxt == nil {
ctxt = context.Background()
}
// marshal
buf, err := easyjson.Marshal(p)
if err != nil {
return nil, err
}
// execute
ch := h.Execute(ctxt, CommandLayerTreeSnapshotCommandLog, easyjson.RawMessage(buf))
// read response
select {
case res := <-ch:
if res == nil {
return nil, ErrChannelClosed
}
switch v := res.(type) {
case easyjson.RawMessage:
// unmarshal
var r SnapshotCommandLogReturns
err = easyjson.Unmarshal(v, &r)
if err != nil {
return nil, ErrInvalidResult
}
return r.CommandLog, nil
case error:
return nil, v
}
case <-ctxt.Done():
return nil, ErrContextDone
}
return nil, ErrUnknownResult
}

130
cdp/layertree/types.go Normal file
View File

@ -0,0 +1,130 @@
package layertree
// AUTOGENERATED. DO NOT EDIT.
import (
"errors"
. "github.com/knq/chromedp/cdp"
"github.com/knq/chromedp/cdp/dom"
"github.com/mailru/easyjson"
"github.com/mailru/easyjson/jlexer"
"github.com/mailru/easyjson/jwriter"
)
var (
_ BackendNode
_ BackendNodeID
_ ComputedProperty
_ ErrorType
_ Frame
_ FrameID
_ LoaderID
_ Message
_ MessageError
_ MethodType
_ Node
_ NodeID
_ NodeType
_ PseudoType
_ RGBA
_ ShadowRootType
_ Timestamp
)
// LayerID unique Layer identifier.
type LayerID string
// String returns the LayerID as string value.
func (t LayerID) String() string {
return string(t)
}
// SnapshotID unique snapshot identifier.
type SnapshotID string
// String returns the SnapshotID as string value.
func (t SnapshotID) String() string {
return string(t)
}
// ScrollRect rectangle where scrolling happens on the main thread.
type ScrollRect struct {
Rect *dom.Rect `json:"rect,omitempty"` // Rectangle itself.
Type ScrollRectType `json:"type,omitempty"` // Reason for rectangle to force scrolling on the main thread
}
// PictureTile serialized fragment of layer picture along with its offset
// within the layer.
type PictureTile struct {
X float64 `json:"x,omitempty"` // Offset from owning layer left boundary
Y float64 `json:"y,omitempty"` // Offset from owning layer top boundary
Picture string `json:"picture,omitempty"` // Base64-encoded snapshot data.
}
// Layer information about a compositing layer.
type Layer struct {
LayerID LayerID `json:"layerId,omitempty"` // The unique id for this layer.
ParentLayerID LayerID `json:"parentLayerId,omitempty"` // The id of parent (not present for root).
BackendNodeID BackendNodeID `json:"backendNodeId,omitempty"` // The backend id for the node associated with this layer.
OffsetX float64 `json:"offsetX,omitempty"` // Offset from parent layer, X coordinate.
OffsetY float64 `json:"offsetY,omitempty"` // Offset from parent layer, Y coordinate.
Width float64 `json:"width,omitempty"` // Layer width.
Height float64 `json:"height,omitempty"` // Layer height.
Transform []float64 `json:"transform,omitempty"` // Transformation matrix for layer, default is identity matrix
AnchorX float64 `json:"anchorX,omitempty"` // Transform anchor point X, absent if no transform specified
AnchorY float64 `json:"anchorY,omitempty"` // Transform anchor point Y, absent if no transform specified
AnchorZ float64 `json:"anchorZ,omitempty"` // Transform anchor point Z, absent if no transform specified
PaintCount int64 `json:"paintCount,omitempty"` // Indicates how many time this layer has painted.
DrawsContent bool `json:"drawsContent,omitempty"` // Indicates whether this layer hosts any content, rather than being used for transform/scrolling purposes only.
Invisible bool `json:"invisible,omitempty"` // Set if layer is not visible.
ScrollRects []*ScrollRect `json:"scrollRects,omitempty"` // Rectangles scrolling on main thread only.
}
// PaintProfile array of timings, one per paint step.
type PaintProfile []float64
// ScrollRectType reason for rectangle to force scrolling on the main thread.
type ScrollRectType string
// String returns the ScrollRectType as string value.
func (t ScrollRectType) String() string {
return string(t)
}
// ScrollRectType values.
const (
ScrollRectTypeRepaintsOnScroll ScrollRectType = "RepaintsOnScroll"
ScrollRectTypeTouchEventHandler ScrollRectType = "TouchEventHandler"
ScrollRectTypeWheelEventHandler ScrollRectType = "WheelEventHandler"
)
// MarshalEasyJSON satisfies easyjson.Marshaler.
func (t ScrollRectType) MarshalEasyJSON(out *jwriter.Writer) {
out.String(string(t))
}
// MarshalJSON satisfies json.Marshaler.
func (t ScrollRectType) MarshalJSON() ([]byte, error) {
return easyjson.Marshal(t)
}
// UnmarshalEasyJSON satisfies easyjson.Unmarshaler.
func (t *ScrollRectType) UnmarshalEasyJSON(in *jlexer.Lexer) {
switch ScrollRectType(in.String()) {
case ScrollRectTypeRepaintsOnScroll:
*t = ScrollRectTypeRepaintsOnScroll
case ScrollRectTypeTouchEventHandler:
*t = ScrollRectTypeTouchEventHandler
case ScrollRectTypeWheelEventHandler:
*t = ScrollRectTypeWheelEventHandler
default:
in.AddError(errors.New("unknown ScrollRectType value"))
}
}
// UnmarshalJSON satisfies json.Unmarshaler.
func (t *ScrollRectType) UnmarshalJSON(buf []byte) error {
return easyjson.Unmarshal(buf, t)
}

685
cdp/log/easyjson.go Normal file
View File

@ -0,0 +1,685 @@
// AUTOGENERATED FILE: easyjson marshaler/unmarshalers.
package log
import (
json "encoding/json"
network "github.com/knq/chromedp/cdp/network"
runtime "github.com/knq/chromedp/cdp/runtime"
easyjson "github.com/mailru/easyjson"
jlexer "github.com/mailru/easyjson/jlexer"
jwriter "github.com/mailru/easyjson/jwriter"
)
// suppress unused package warning
var (
_ *json.RawMessage
_ *jlexer.Lexer
_ *jwriter.Writer
_ easyjson.Marshaler
)
func easyjsonC5a4559bDecodeGithubComKnqChromedpCdpLog(in *jlexer.Lexer, out *ViolationSetting) {
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 "name":
(out.Name).UnmarshalEasyJSON(in)
case "threshold":
out.Threshold = float64(in.Float64())
default:
in.SkipRecursive()
}
in.WantComma()
}
in.Delim('}')
if isTopLevel {
in.Consumed()
}
}
func easyjsonC5a4559bEncodeGithubComKnqChromedpCdpLog(out *jwriter.Writer, in ViolationSetting) {
out.RawByte('{')
first := true
_ = first
if in.Name != "" {
if !first {
out.RawByte(',')
}
first = false
out.RawString("\"name\":")
(in.Name).MarshalEasyJSON(out)
}
if in.Threshold != 0 {
if !first {
out.RawByte(',')
}
first = false
out.RawString("\"threshold\":")
out.Float64(float64(in.Threshold))
}
out.RawByte('}')
}
// MarshalJSON supports json.Marshaler interface
func (v ViolationSetting) MarshalJSON() ([]byte, error) {
w := jwriter.Writer{}
easyjsonC5a4559bEncodeGithubComKnqChromedpCdpLog(&w, v)
return w.Buffer.BuildBytes(), w.Error
}
// MarshalEasyJSON supports easyjson.Marshaler interface
func (v ViolationSetting) MarshalEasyJSON(w *jwriter.Writer) {
easyjsonC5a4559bEncodeGithubComKnqChromedpCdpLog(w, v)
}
// UnmarshalJSON supports json.Unmarshaler interface
func (v *ViolationSetting) UnmarshalJSON(data []byte) error {
r := jlexer.Lexer{Data: data}
easyjsonC5a4559bDecodeGithubComKnqChromedpCdpLog(&r, v)
return r.Error()
}
// UnmarshalEasyJSON supports easyjson.Unmarshaler interface
func (v *ViolationSetting) UnmarshalEasyJSON(l *jlexer.Lexer) {
easyjsonC5a4559bDecodeGithubComKnqChromedpCdpLog(l, v)
}
func easyjsonC5a4559bDecodeGithubComKnqChromedpCdpLog1(in *jlexer.Lexer, out *StopViolationsReportParams) {
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 {
default:
in.SkipRecursive()
}
in.WantComma()
}
in.Delim('}')
if isTopLevel {
in.Consumed()
}
}
func easyjsonC5a4559bEncodeGithubComKnqChromedpCdpLog1(out *jwriter.Writer, in StopViolationsReportParams) {
out.RawByte('{')
first := true
_ = first
out.RawByte('}')
}
// MarshalJSON supports json.Marshaler interface
func (v StopViolationsReportParams) MarshalJSON() ([]byte, error) {
w := jwriter.Writer{}
easyjsonC5a4559bEncodeGithubComKnqChromedpCdpLog1(&w, v)
return w.Buffer.BuildBytes(), w.Error
}
// MarshalEasyJSON supports easyjson.Marshaler interface
func (v StopViolationsReportParams) MarshalEasyJSON(w *jwriter.Writer) {
easyjsonC5a4559bEncodeGithubComKnqChromedpCdpLog1(w, v)
}
// UnmarshalJSON supports json.Unmarshaler interface
func (v *StopViolationsReportParams) UnmarshalJSON(data []byte) error {
r := jlexer.Lexer{Data: data}
easyjsonC5a4559bDecodeGithubComKnqChromedpCdpLog1(&r, v)
return r.Error()
}
// UnmarshalEasyJSON supports easyjson.Unmarshaler interface
func (v *StopViolationsReportParams) UnmarshalEasyJSON(l *jlexer.Lexer) {
easyjsonC5a4559bDecodeGithubComKnqChromedpCdpLog1(l, v)
}
func easyjsonC5a4559bDecodeGithubComKnqChromedpCdpLog2(in *jlexer.Lexer, out *StartViolationsReportParams) {
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 "config":
if in.IsNull() {
in.Skip()
out.Config = nil
} else {
in.Delim('[')
if !in.IsDelim(']') {
out.Config = make([]*ViolationSetting, 0, 8)
} else {
out.Config = []*ViolationSetting{}
}
for !in.IsDelim(']') {
var v1 *ViolationSetting
if in.IsNull() {
in.Skip()
v1 = nil
} else {
if v1 == nil {
v1 = new(ViolationSetting)
}
(*v1).UnmarshalEasyJSON(in)
}
out.Config = append(out.Config, v1)
in.WantComma()
}
in.Delim(']')
}
default:
in.SkipRecursive()
}
in.WantComma()
}
in.Delim('}')
if isTopLevel {
in.Consumed()
}
}
func easyjsonC5a4559bEncodeGithubComKnqChromedpCdpLog2(out *jwriter.Writer, in StartViolationsReportParams) {
out.RawByte('{')
first := true
_ = first
if !first {
out.RawByte(',')
}
first = false
out.RawString("\"config\":")
if in.Config == nil && (out.Flags&jwriter.NilSliceAsEmpty) == 0 {
out.RawString("null")
} else {
out.RawByte('[')
for v2, v3 := range in.Config {
if v2 > 0 {
out.RawByte(',')
}
if v3 == nil {
out.RawString("null")
} else {
(*v3).MarshalEasyJSON(out)
}
}
out.RawByte(']')
}
out.RawByte('}')
}
// MarshalJSON supports json.Marshaler interface
func (v StartViolationsReportParams) MarshalJSON() ([]byte, error) {
w := jwriter.Writer{}
easyjsonC5a4559bEncodeGithubComKnqChromedpCdpLog2(&w, v)
return w.Buffer.BuildBytes(), w.Error
}
// MarshalEasyJSON supports easyjson.Marshaler interface
func (v StartViolationsReportParams) MarshalEasyJSON(w *jwriter.Writer) {
easyjsonC5a4559bEncodeGithubComKnqChromedpCdpLog2(w, v)
}
// UnmarshalJSON supports json.Unmarshaler interface
func (v *StartViolationsReportParams) UnmarshalJSON(data []byte) error {
r := jlexer.Lexer{Data: data}
easyjsonC5a4559bDecodeGithubComKnqChromedpCdpLog2(&r, v)
return r.Error()
}
// UnmarshalEasyJSON supports easyjson.Unmarshaler interface
func (v *StartViolationsReportParams) UnmarshalEasyJSON(l *jlexer.Lexer) {
easyjsonC5a4559bDecodeGithubComKnqChromedpCdpLog2(l, v)
}
func easyjsonC5a4559bDecodeGithubComKnqChromedpCdpLog3(in *jlexer.Lexer, out *LogEntry) {
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 "source":
(out.Source).UnmarshalEasyJSON(in)
case "level":
(out.Level).UnmarshalEasyJSON(in)
case "text":
out.Text = string(in.String())
case "timestamp":
(out.Timestamp).UnmarshalEasyJSON(in)
case "url":
out.URL = string(in.String())
case "lineNumber":
out.LineNumber = int64(in.Int64())
case "stackTrace":
if in.IsNull() {
in.Skip()
out.StackTrace = nil
} else {
if out.StackTrace == nil {
out.StackTrace = new(runtime.StackTrace)
}
(*out.StackTrace).UnmarshalEasyJSON(in)
}
case "networkRequestId":
out.NetworkRequestID = network.RequestID(in.String())
case "workerId":
out.WorkerID = string(in.String())
default:
in.SkipRecursive()
}
in.WantComma()
}
in.Delim('}')
if isTopLevel {
in.Consumed()
}
}
func easyjsonC5a4559bEncodeGithubComKnqChromedpCdpLog3(out *jwriter.Writer, in LogEntry) {
out.RawByte('{')
first := true
_ = first
if in.Source != "" {
if !first {
out.RawByte(',')
}
first = false
out.RawString("\"source\":")
(in.Source).MarshalEasyJSON(out)
}
if in.Level != "" {
if !first {
out.RawByte(',')
}
first = false
out.RawString("\"level\":")
(in.Level).MarshalEasyJSON(out)
}
if in.Text != "" {
if !first {
out.RawByte(',')
}
first = false
out.RawString("\"text\":")
out.String(string(in.Text))
}
if true {
if !first {
out.RawByte(',')
}
first = false
out.RawString("\"timestamp\":")
(in.Timestamp).MarshalEasyJSON(out)
}
if in.URL != "" {
if !first {
out.RawByte(',')
}
first = false
out.RawString("\"url\":")
out.String(string(in.URL))
}
if in.LineNumber != 0 {
if !first {
out.RawByte(',')
}
first = false
out.RawString("\"lineNumber\":")
out.Int64(int64(in.LineNumber))
}
if in.StackTrace != nil {
if !first {
out.RawByte(',')
}
first = false
out.RawString("\"stackTrace\":")
if in.StackTrace == nil {
out.RawString("null")
} else {
(*in.StackTrace).MarshalEasyJSON(out)
}
}
if in.NetworkRequestID != "" {
if !first {
out.RawByte(',')
}
first = false
out.RawString("\"networkRequestId\":")
out.String(string(in.NetworkRequestID))
}
if in.WorkerID != "" {
if !first {
out.RawByte(',')
}
first = false
out.RawString("\"workerId\":")
out.String(string(in.WorkerID))
}
out.RawByte('}')
}
// MarshalJSON supports json.Marshaler interface
func (v LogEntry) MarshalJSON() ([]byte, error) {
w := jwriter.Writer{}
easyjsonC5a4559bEncodeGithubComKnqChromedpCdpLog3(&w, v)
return w.Buffer.BuildBytes(), w.Error
}
// MarshalEasyJSON supports easyjson.Marshaler interface
func (v LogEntry) MarshalEasyJSON(w *jwriter.Writer) {
easyjsonC5a4559bEncodeGithubComKnqChromedpCdpLog3(w, v)
}
// UnmarshalJSON supports json.Unmarshaler interface
func (v *LogEntry) UnmarshalJSON(data []byte) error {
r := jlexer.Lexer{Data: data}
easyjsonC5a4559bDecodeGithubComKnqChromedpCdpLog3(&r, v)
return r.Error()
}
// UnmarshalEasyJSON supports easyjson.Unmarshaler interface
func (v *LogEntry) UnmarshalEasyJSON(l *jlexer.Lexer) {
easyjsonC5a4559bDecodeGithubComKnqChromedpCdpLog3(l, v)
}
func easyjsonC5a4559bDecodeGithubComKnqChromedpCdpLog4(in *jlexer.Lexer, out *EventEntryAdded) {
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 "entry":
if in.IsNull() {
in.Skip()
out.Entry = nil
} else {
if out.Entry == nil {
out.Entry = new(LogEntry)
}
(*out.Entry).UnmarshalEasyJSON(in)
}
default:
in.SkipRecursive()
}
in.WantComma()
}
in.Delim('}')
if isTopLevel {
in.Consumed()
}
}
func easyjsonC5a4559bEncodeGithubComKnqChromedpCdpLog4(out *jwriter.Writer, in EventEntryAdded) {
out.RawByte('{')
first := true
_ = first
if in.Entry != nil {
if !first {
out.RawByte(',')
}
first = false
out.RawString("\"entry\":")
if in.Entry == nil {
out.RawString("null")
} else {
(*in.Entry).MarshalEasyJSON(out)
}
}
out.RawByte('}')
}
// MarshalJSON supports json.Marshaler interface
func (v EventEntryAdded) MarshalJSON() ([]byte, error) {
w := jwriter.Writer{}
easyjsonC5a4559bEncodeGithubComKnqChromedpCdpLog4(&w, v)
return w.Buffer.BuildBytes(), w.Error
}
// MarshalEasyJSON supports easyjson.Marshaler interface
func (v EventEntryAdded) MarshalEasyJSON(w *jwriter.Writer) {
easyjsonC5a4559bEncodeGithubComKnqChromedpCdpLog4(w, v)
}
// UnmarshalJSON supports json.Unmarshaler interface
func (v *EventEntryAdded) UnmarshalJSON(data []byte) error {
r := jlexer.Lexer{Data: data}
easyjsonC5a4559bDecodeGithubComKnqChromedpCdpLog4(&r, v)
return r.Error()
}
// UnmarshalEasyJSON supports easyjson.Unmarshaler interface
func (v *EventEntryAdded) UnmarshalEasyJSON(l *jlexer.Lexer) {
easyjsonC5a4559bDecodeGithubComKnqChromedpCdpLog4(l, v)
}
func easyjsonC5a4559bDecodeGithubComKnqChromedpCdpLog5(in *jlexer.Lexer, out *EnableParams) {
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 {
default:
in.SkipRecursive()
}
in.WantComma()
}
in.Delim('}')
if isTopLevel {
in.Consumed()
}
}
func easyjsonC5a4559bEncodeGithubComKnqChromedpCdpLog5(out *jwriter.Writer, in EnableParams) {
out.RawByte('{')
first := true
_ = first
out.RawByte('}')
}
// MarshalJSON supports json.Marshaler interface
func (v EnableParams) MarshalJSON() ([]byte, error) {
w := jwriter.Writer{}
easyjsonC5a4559bEncodeGithubComKnqChromedpCdpLog5(&w, v)
return w.Buffer.BuildBytes(), w.Error
}
// MarshalEasyJSON supports easyjson.Marshaler interface
func (v EnableParams) MarshalEasyJSON(w *jwriter.Writer) {
easyjsonC5a4559bEncodeGithubComKnqChromedpCdpLog5(w, v)
}
// UnmarshalJSON supports json.Unmarshaler interface
func (v *EnableParams) UnmarshalJSON(data []byte) error {
r := jlexer.Lexer{Data: data}
easyjsonC5a4559bDecodeGithubComKnqChromedpCdpLog5(&r, v)
return r.Error()
}
// UnmarshalEasyJSON supports easyjson.Unmarshaler interface
func (v *EnableParams) UnmarshalEasyJSON(l *jlexer.Lexer) {
easyjsonC5a4559bDecodeGithubComKnqChromedpCdpLog5(l, v)
}
func easyjsonC5a4559bDecodeGithubComKnqChromedpCdpLog6(in *jlexer.Lexer, out *DisableParams) {
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 {
default:
in.SkipRecursive()
}
in.WantComma()
}
in.Delim('}')
if isTopLevel {
in.Consumed()
}
}
func easyjsonC5a4559bEncodeGithubComKnqChromedpCdpLog6(out *jwriter.Writer, in DisableParams) {
out.RawByte('{')
first := true
_ = first
out.RawByte('}')
}
// MarshalJSON supports json.Marshaler interface
func (v DisableParams) MarshalJSON() ([]byte, error) {
w := jwriter.Writer{}
easyjsonC5a4559bEncodeGithubComKnqChromedpCdpLog6(&w, v)
return w.Buffer.BuildBytes(), w.Error
}
// MarshalEasyJSON supports easyjson.Marshaler interface
func (v DisableParams) MarshalEasyJSON(w *jwriter.Writer) {
easyjsonC5a4559bEncodeGithubComKnqChromedpCdpLog6(w, v)
}
// UnmarshalJSON supports json.Unmarshaler interface
func (v *DisableParams) UnmarshalJSON(data []byte) error {
r := jlexer.Lexer{Data: data}
easyjsonC5a4559bDecodeGithubComKnqChromedpCdpLog6(&r, v)
return r.Error()
}
// UnmarshalEasyJSON supports easyjson.Unmarshaler interface
func (v *DisableParams) UnmarshalEasyJSON(l *jlexer.Lexer) {
easyjsonC5a4559bDecodeGithubComKnqChromedpCdpLog6(l, v)
}
func easyjsonC5a4559bDecodeGithubComKnqChromedpCdpLog7(in *jlexer.Lexer, out *ClearParams) {
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 {
default:
in.SkipRecursive()
}
in.WantComma()
}
in.Delim('}')
if isTopLevel {
in.Consumed()
}
}
func easyjsonC5a4559bEncodeGithubComKnqChromedpCdpLog7(out *jwriter.Writer, in ClearParams) {
out.RawByte('{')
first := true
_ = first
out.RawByte('}')
}
// MarshalJSON supports json.Marshaler interface
func (v ClearParams) MarshalJSON() ([]byte, error) {
w := jwriter.Writer{}
easyjsonC5a4559bEncodeGithubComKnqChromedpCdpLog7(&w, v)
return w.Buffer.BuildBytes(), w.Error
}
// MarshalEasyJSON supports easyjson.Marshaler interface
func (v ClearParams) MarshalEasyJSON(w *jwriter.Writer) {
easyjsonC5a4559bEncodeGithubComKnqChromedpCdpLog7(w, v)
}
// UnmarshalJSON supports json.Unmarshaler interface
func (v *ClearParams) UnmarshalJSON(data []byte) error {
r := jlexer.Lexer{Data: data}
easyjsonC5a4559bDecodeGithubComKnqChromedpCdpLog7(&r, v)
return r.Error()
}
// UnmarshalEasyJSON supports easyjson.Unmarshaler interface
func (v *ClearParams) UnmarshalEasyJSON(l *jlexer.Lexer) {
easyjsonC5a4559bDecodeGithubComKnqChromedpCdpLog7(l, v)
}

37
cdp/log/events.go Normal file
View File

@ -0,0 +1,37 @@
package log
// AUTOGENERATED. DO NOT EDIT.
import (
. "github.com/knq/chromedp/cdp"
)
var (
_ BackendNode
_ BackendNodeID
_ ComputedProperty
_ ErrorType
_ Frame
_ FrameID
_ LoaderID
_ Message
_ MessageError
_ MethodType
_ Node
_ NodeID
_ NodeType
_ PseudoType
_ RGBA
_ ShadowRootType
_ Timestamp
)
// EventEntryAdded issued when new message was logged.
type EventEntryAdded struct {
Entry *LogEntry `json:"entry,omitempty"` // The entry.
}
// EventTypes is all event types in the domain.
var EventTypes = []MethodType{
EventLogEntryAdded,
}

248
cdp/log/log.go Normal file
View File

@ -0,0 +1,248 @@
// Package log provides the Chrome Debugging Protocol
// commands, types, and events for the Chrome Log domain.
//
// Provides access to log entries.
//
// Generated by the chromedp-gen command.
package log
// AUTOGENERATED. DO NOT EDIT.
import (
"context"
. "github.com/knq/chromedp/cdp"
"github.com/mailru/easyjson"
)
var (
_ BackendNode
_ BackendNodeID
_ ComputedProperty
_ ErrorType
_ Frame
_ FrameID
_ LoaderID
_ Message
_ MessageError
_ MethodType
_ Node
_ NodeID
_ NodeType
_ PseudoType
_ RGBA
_ ShadowRootType
_ Timestamp
)
// EnableParams enables log domain, sends the entries collected so far to the
// client by means of the entryAdded notification.
type EnableParams 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{}
}
// Do executes Log.enable.
func (p *EnableParams) Do(ctxt context.Context, h FrameHandler) (err error) {
if ctxt == nil {
ctxt = context.Background()
}
// execute
ch := h.Execute(ctxt, CommandLogEnable, Empty)
// read response
select {
case res := <-ch:
if res == nil {
return ErrChannelClosed
}
switch v := res.(type) {
case easyjson.RawMessage:
return nil
case error:
return v
}
case <-ctxt.Done():
return ErrContextDone
}
return ErrUnknownResult
}
// DisableParams disables log domain, prevents further log entries from being
// reported to the client.
type DisableParams struct{}
// Disable disables log domain, prevents further log entries from being
// reported to the client.
func Disable() *DisableParams {
return &DisableParams{}
}
// Do executes Log.disable.
func (p *DisableParams) Do(ctxt context.Context, h FrameHandler) (err error) {
if ctxt == nil {
ctxt = context.Background()
}
// execute
ch := h.Execute(ctxt, CommandLogDisable, Empty)
// read response
select {
case res := <-ch:
if res == nil {
return ErrChannelClosed
}
switch v := res.(type) {
case easyjson.RawMessage:
return nil
case error:
return v
}
case <-ctxt.Done():
return ErrContextDone
}
return ErrUnknownResult
}
// ClearParams clears the log.
type ClearParams struct{}
// Clear clears the log.
func Clear() *ClearParams {
return &ClearParams{}
}
// Do executes Log.clear.
func (p *ClearParams) Do(ctxt context.Context, h FrameHandler) (err error) {
if ctxt == nil {
ctxt = context.Background()
}
// execute
ch := h.Execute(ctxt, CommandLogClear, Empty)
// read response
select {
case res := <-ch:
if res == nil {
return ErrChannelClosed
}
switch v := res.(type) {
case easyjson.RawMessage:
return nil
case error:
return v
}
case <-ctxt.Done():
return ErrContextDone
}
return ErrUnknownResult
}
// StartViolationsReportParams start violation reporting.
type StartViolationsReportParams struct {
Config []*ViolationSetting `json:"config"` // Configuration for violations.
}
// StartViolationsReport start violation reporting.
//
// parameters:
// config - Configuration for violations.
func StartViolationsReport(config []*ViolationSetting) *StartViolationsReportParams {
return &StartViolationsReportParams{
Config: config,
}
}
// Do executes Log.startViolationsReport.
func (p *StartViolationsReportParams) Do(ctxt context.Context, h FrameHandler) (err error) {
if ctxt == nil {
ctxt = context.Background()
}
// marshal
buf, err := easyjson.Marshal(p)
if err != nil {
return err
}
// execute
ch := h.Execute(ctxt, CommandLogStartViolationsReport, easyjson.RawMessage(buf))
// read response
select {
case res := <-ch:
if res == nil {
return ErrChannelClosed
}
switch v := res.(type) {
case easyjson.RawMessage:
return nil
case error:
return v
}
case <-ctxt.Done():
return ErrContextDone
}
return ErrUnknownResult
}
// StopViolationsReportParams stop violation reporting.
type StopViolationsReportParams struct{}
// StopViolationsReport stop violation reporting.
func StopViolationsReport() *StopViolationsReportParams {
return &StopViolationsReportParams{}
}
// Do executes Log.stopViolationsReport.
func (p *StopViolationsReportParams) Do(ctxt context.Context, h FrameHandler) (err error) {
if ctxt == nil {
ctxt = context.Background()
}
// execute
ch := h.Execute(ctxt, CommandLogStopViolationsReport, Empty)
// read response
select {
case res := <-ch:
if res == nil {
return ErrChannelClosed
}
switch v := res.(type) {
case easyjson.RawMessage:
return nil
case error:
return v
}
case <-ctxt.Done():
return ErrContextDone
}
return ErrUnknownResult
}

227
cdp/log/types.go Normal file
View File

@ -0,0 +1,227 @@
package log
// AUTOGENERATED. DO NOT EDIT.
import (
"errors"
. "github.com/knq/chromedp/cdp"
"github.com/knq/chromedp/cdp/network"
"github.com/knq/chromedp/cdp/runtime"
"github.com/mailru/easyjson"
"github.com/mailru/easyjson/jlexer"
"github.com/mailru/easyjson/jwriter"
)
var (
_ BackendNode
_ BackendNodeID
_ ComputedProperty
_ ErrorType
_ Frame
_ FrameID
_ LoaderID
_ Message
_ MessageError
_ MethodType
_ Node
_ NodeID
_ NodeType
_ PseudoType
_ RGBA
_ ShadowRootType
_ Timestamp
)
// LogEntry log entry.
type LogEntry struct {
Source Source `json:"source,omitempty"` // Log entry source.
Level Level `json:"level,omitempty"` // Log entry severity.
Text string `json:"text,omitempty"` // Logged text.
Timestamp Timestamp `json:"timestamp,omitempty"` // Timestamp when this entry was added.
URL string `json:"url,omitempty"` // URL of the resource if known.
LineNumber int64 `json:"lineNumber,omitempty"` // Line number in the resource.
StackTrace *runtime.StackTrace `json:"stackTrace,omitempty"` // JavaScript stack trace.
NetworkRequestID network.RequestID `json:"networkRequestId,omitempty"` // Identifier of the network request associated with this entry.
WorkerID string `json:"workerId,omitempty"` // Identifier of the worker associated with this entry.
}
// ViolationSetting violation configuration setting.
type ViolationSetting struct {
Name Violation `json:"name,omitempty"` // Violation type.
Threshold float64 `json:"threshold,omitempty"` // Time threshold to trigger upon.
}
// Source log entry source.
type Source string
// String returns the Source as string value.
func (t Source) String() string {
return string(t)
}
// Source values.
const (
SourceXML Source = "xml"
SourceJavascript Source = "javascript"
SourceNetwork Source = "network"
SourceStorage Source = "storage"
SourceAppcache Source = "appcache"
SourceRendering Source = "rendering"
SourceSecurity Source = "security"
SourceDeprecation Source = "deprecation"
SourceWorker Source = "worker"
SourceViolation Source = "violation"
SourceIntervention Source = "intervention"
SourceOther Source = "other"
)
// MarshalEasyJSON satisfies easyjson.Marshaler.
func (t Source) MarshalEasyJSON(out *jwriter.Writer) {
out.String(string(t))
}
// MarshalJSON satisfies json.Marshaler.
func (t Source) MarshalJSON() ([]byte, error) {
return easyjson.Marshal(t)
}
// UnmarshalEasyJSON satisfies easyjson.Unmarshaler.
func (t *Source) UnmarshalEasyJSON(in *jlexer.Lexer) {
switch Source(in.String()) {
case SourceXML:
*t = SourceXML
case SourceJavascript:
*t = SourceJavascript
case SourceNetwork:
*t = SourceNetwork
case SourceStorage:
*t = SourceStorage
case SourceAppcache:
*t = SourceAppcache
case SourceRendering:
*t = SourceRendering
case SourceSecurity:
*t = SourceSecurity
case SourceDeprecation:
*t = SourceDeprecation
case SourceWorker:
*t = SourceWorker
case SourceViolation:
*t = SourceViolation
case SourceIntervention:
*t = SourceIntervention
case SourceOther:
*t = SourceOther
default:
in.AddError(errors.New("unknown Source value"))
}
}
// UnmarshalJSON satisfies json.Unmarshaler.
func (t *Source) UnmarshalJSON(buf []byte) error {
return easyjson.Unmarshal(buf, t)
}
// Level log entry severity.
type Level string
// String returns the Level as string value.
func (t Level) String() string {
return string(t)
}
// Level values.
const (
LevelVerbose Level = "verbose"
LevelInfo Level = "info"
LevelWarning Level = "warning"
LevelError Level = "error"
)
// MarshalEasyJSON satisfies easyjson.Marshaler.
func (t Level) MarshalEasyJSON(out *jwriter.Writer) {
out.String(string(t))
}
// MarshalJSON satisfies json.Marshaler.
func (t Level) MarshalJSON() ([]byte, error) {
return easyjson.Marshal(t)
}
// UnmarshalEasyJSON satisfies easyjson.Unmarshaler.
func (t *Level) UnmarshalEasyJSON(in *jlexer.Lexer) {
switch Level(in.String()) {
case LevelVerbose:
*t = LevelVerbose
case LevelInfo:
*t = LevelInfo
case LevelWarning:
*t = LevelWarning
case LevelError:
*t = LevelError
default:
in.AddError(errors.New("unknown Level value"))
}
}
// UnmarshalJSON satisfies json.Unmarshaler.
func (t *Level) UnmarshalJSON(buf []byte) error {
return easyjson.Unmarshal(buf, t)
}
// Violation violation type.
type Violation string
// String returns the Violation as string value.
func (t Violation) String() string {
return string(t)
}
// Violation values.
const (
ViolationLongTask Violation = "longTask"
ViolationLongLayout Violation = "longLayout"
ViolationBlockedEvent Violation = "blockedEvent"
ViolationBlockedParser Violation = "blockedParser"
ViolationHandler Violation = "handler"
ViolationRecurringHandler Violation = "recurringHandler"
)
// MarshalEasyJSON satisfies easyjson.Marshaler.
func (t Violation) MarshalEasyJSON(out *jwriter.Writer) {
out.String(string(t))
}
// MarshalJSON satisfies json.Marshaler.
func (t Violation) MarshalJSON() ([]byte, error) {
return easyjson.Marshal(t)
}
// UnmarshalEasyJSON satisfies easyjson.Unmarshaler.
func (t *Violation) UnmarshalEasyJSON(in *jlexer.Lexer) {
switch Violation(in.String()) {
case ViolationLongTask:
*t = ViolationLongTask
case ViolationLongLayout:
*t = ViolationLongLayout
case ViolationBlockedEvent:
*t = ViolationBlockedEvent
case ViolationBlockedParser:
*t = ViolationBlockedParser
case ViolationHandler:
*t = ViolationHandler
case ViolationRecurringHandler:
*t = ViolationRecurringHandler
default:
in.AddError(errors.New("unknown Violation value"))
}
}
// UnmarshalJSON satisfies json.Unmarshaler.
func (t *Violation) UnmarshalJSON(buf []byte) error {
return easyjson.Unmarshal(buf, t)
}

301
cdp/memory/easyjson.go Normal file
View File

@ -0,0 +1,301 @@
// AUTOGENERATED FILE: easyjson marshaler/unmarshalers.
package memory
import (
json "encoding/json"
easyjson "github.com/mailru/easyjson"
jlexer "github.com/mailru/easyjson/jlexer"
jwriter "github.com/mailru/easyjson/jwriter"
)
// suppress unused package warning
var (
_ *json.RawMessage
_ *jlexer.Lexer
_ *jwriter.Writer
_ easyjson.Marshaler
)
func easyjsonC5a4559bDecodeGithubComKnqChromedpCdpMemory(in *jlexer.Lexer, out *SimulatePressureNotificationParams) {
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 "level":
(out.Level).UnmarshalEasyJSON(in)
default:
in.SkipRecursive()
}
in.WantComma()
}
in.Delim('}')
if isTopLevel {
in.Consumed()
}
}
func easyjsonC5a4559bEncodeGithubComKnqChromedpCdpMemory(out *jwriter.Writer, in SimulatePressureNotificationParams) {
out.RawByte('{')
first := true
_ = first
if !first {
out.RawByte(',')
}
first = false
out.RawString("\"level\":")
(in.Level).MarshalEasyJSON(out)
out.RawByte('}')
}
// MarshalJSON supports json.Marshaler interface
func (v SimulatePressureNotificationParams) MarshalJSON() ([]byte, error) {
w := jwriter.Writer{}
easyjsonC5a4559bEncodeGithubComKnqChromedpCdpMemory(&w, v)
return w.Buffer.BuildBytes(), w.Error
}
// MarshalEasyJSON supports easyjson.Marshaler interface
func (v SimulatePressureNotificationParams) MarshalEasyJSON(w *jwriter.Writer) {
easyjsonC5a4559bEncodeGithubComKnqChromedpCdpMemory(w, v)
}
// UnmarshalJSON supports json.Unmarshaler interface
func (v *SimulatePressureNotificationParams) UnmarshalJSON(data []byte) error {
r := jlexer.Lexer{Data: data}
easyjsonC5a4559bDecodeGithubComKnqChromedpCdpMemory(&r, v)
return r.Error()
}
// UnmarshalEasyJSON supports easyjson.Unmarshaler interface
func (v *SimulatePressureNotificationParams) UnmarshalEasyJSON(l *jlexer.Lexer) {
easyjsonC5a4559bDecodeGithubComKnqChromedpCdpMemory(l, v)
}
func easyjsonC5a4559bDecodeGithubComKnqChromedpCdpMemory1(in *jlexer.Lexer, out *SetPressureNotificationsSuppressedParams) {
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 "suppressed":
out.Suppressed = bool(in.Bool())
default:
in.SkipRecursive()
}
in.WantComma()
}
in.Delim('}')
if isTopLevel {
in.Consumed()
}
}
func easyjsonC5a4559bEncodeGithubComKnqChromedpCdpMemory1(out *jwriter.Writer, in SetPressureNotificationsSuppressedParams) {
out.RawByte('{')
first := true
_ = first
if !first {
out.RawByte(',')
}
first = false
out.RawString("\"suppressed\":")
out.Bool(bool(in.Suppressed))
out.RawByte('}')
}
// MarshalJSON supports json.Marshaler interface
func (v SetPressureNotificationsSuppressedParams) MarshalJSON() ([]byte, error) {
w := jwriter.Writer{}
easyjsonC5a4559bEncodeGithubComKnqChromedpCdpMemory1(&w, v)
return w.Buffer.BuildBytes(), w.Error
}
// MarshalEasyJSON supports easyjson.Marshaler interface
func (v SetPressureNotificationsSuppressedParams) MarshalEasyJSON(w *jwriter.Writer) {
easyjsonC5a4559bEncodeGithubComKnqChromedpCdpMemory1(w, v)
}
// UnmarshalJSON supports json.Unmarshaler interface
func (v *SetPressureNotificationsSuppressedParams) UnmarshalJSON(data []byte) error {
r := jlexer.Lexer{Data: data}
easyjsonC5a4559bDecodeGithubComKnqChromedpCdpMemory1(&r, v)
return r.Error()
}
// UnmarshalEasyJSON supports easyjson.Unmarshaler interface
func (v *SetPressureNotificationsSuppressedParams) UnmarshalEasyJSON(l *jlexer.Lexer) {
easyjsonC5a4559bDecodeGithubComKnqChromedpCdpMemory1(l, v)
}
func easyjsonC5a4559bDecodeGithubComKnqChromedpCdpMemory2(in *jlexer.Lexer, out *GetDOMCountersReturns) {
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 "documents":
out.Documents = int64(in.Int64())
case "nodes":
out.Nodes = int64(in.Int64())
case "jsEventListeners":
out.JsEventListeners = int64(in.Int64())
default:
in.SkipRecursive()
}
in.WantComma()
}
in.Delim('}')
if isTopLevel {
in.Consumed()
}
}
func easyjsonC5a4559bEncodeGithubComKnqChromedpCdpMemory2(out *jwriter.Writer, in GetDOMCountersReturns) {
out.RawByte('{')
first := true
_ = first
if in.Documents != 0 {
if !first {
out.RawByte(',')
}
first = false
out.RawString("\"documents\":")
out.Int64(int64(in.Documents))
}
if in.Nodes != 0 {
if !first {
out.RawByte(',')
}
first = false
out.RawString("\"nodes\":")
out.Int64(int64(in.Nodes))
}
if in.JsEventListeners != 0 {
if !first {
out.RawByte(',')
}
first = false
out.RawString("\"jsEventListeners\":")
out.Int64(int64(in.JsEventListeners))
}
out.RawByte('}')
}
// MarshalJSON supports json.Marshaler interface
func (v GetDOMCountersReturns) MarshalJSON() ([]byte, error) {
w := jwriter.Writer{}
easyjsonC5a4559bEncodeGithubComKnqChromedpCdpMemory2(&w, v)
return w.Buffer.BuildBytes(), w.Error
}
// MarshalEasyJSON supports easyjson.Marshaler interface
func (v GetDOMCountersReturns) MarshalEasyJSON(w *jwriter.Writer) {
easyjsonC5a4559bEncodeGithubComKnqChromedpCdpMemory2(w, v)
}
// UnmarshalJSON supports json.Unmarshaler interface
func (v *GetDOMCountersReturns) UnmarshalJSON(data []byte) error {
r := jlexer.Lexer{Data: data}
easyjsonC5a4559bDecodeGithubComKnqChromedpCdpMemory2(&r, v)
return r.Error()
}
// UnmarshalEasyJSON supports easyjson.Unmarshaler interface
func (v *GetDOMCountersReturns) UnmarshalEasyJSON(l *jlexer.Lexer) {
easyjsonC5a4559bDecodeGithubComKnqChromedpCdpMemory2(l, v)
}
func easyjsonC5a4559bDecodeGithubComKnqChromedpCdpMemory3(in *jlexer.Lexer, out *GetDOMCountersParams) {
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 {
default:
in.SkipRecursive()
}
in.WantComma()
}
in.Delim('}')
if isTopLevel {
in.Consumed()
}
}
func easyjsonC5a4559bEncodeGithubComKnqChromedpCdpMemory3(out *jwriter.Writer, in GetDOMCountersParams) {
out.RawByte('{')
first := true
_ = first
out.RawByte('}')
}
// MarshalJSON supports json.Marshaler interface
func (v GetDOMCountersParams) MarshalJSON() ([]byte, error) {
w := jwriter.Writer{}
easyjsonC5a4559bEncodeGithubComKnqChromedpCdpMemory3(&w, v)
return w.Buffer.BuildBytes(), w.Error
}
// MarshalEasyJSON supports easyjson.Marshaler interface
func (v GetDOMCountersParams) MarshalEasyJSON(w *jwriter.Writer) {
easyjsonC5a4559bEncodeGithubComKnqChromedpCdpMemory3(w, v)
}
// UnmarshalJSON supports json.Unmarshaler interface
func (v *GetDOMCountersParams) UnmarshalJSON(data []byte) error {
r := jlexer.Lexer{Data: data}
easyjsonC5a4559bDecodeGithubComKnqChromedpCdpMemory3(&r, v)
return r.Error()
}
// UnmarshalEasyJSON supports easyjson.Unmarshaler interface
func (v *GetDOMCountersParams) UnmarshalEasyJSON(l *jlexer.Lexer) {
easyjsonC5a4559bDecodeGithubComKnqChromedpCdpMemory3(l, v)
}

198
cdp/memory/memory.go Normal file
View File

@ -0,0 +1,198 @@
// Package memory provides the Chrome Debugging Protocol
// commands, types, and events for the Chrome Memory domain.
//
// Generated by the chromedp-gen command.
package memory
// AUTOGENERATED. DO NOT EDIT.
import (
"context"
. "github.com/knq/chromedp/cdp"
"github.com/mailru/easyjson"
)
var (
_ BackendNode
_ BackendNodeID
_ ComputedProperty
_ ErrorType
_ Frame
_ FrameID
_ LoaderID
_ Message
_ MessageError
_ MethodType
_ Node
_ NodeID
_ NodeType
_ PseudoType
_ RGBA
_ ShadowRootType
_ Timestamp
)
type GetDOMCountersParams struct{}
func GetDOMCounters() *GetDOMCountersParams {
return &GetDOMCountersParams{}
}
// GetDOMCountersReturns return values.
type GetDOMCountersReturns struct {
Documents int64 `json:"documents,omitempty"`
Nodes int64 `json:"nodes,omitempty"`
JsEventListeners int64 `json:"jsEventListeners,omitempty"`
}
// Do executes Memory.getDOMCounters.
//
// returns:
// documents
// nodes
// jsEventListeners
func (p *GetDOMCountersParams) Do(ctxt context.Context, h FrameHandler) (documents int64, nodes int64, jsEventListeners int64, err error) {
if ctxt == nil {
ctxt = context.Background()
}
// execute
ch := h.Execute(ctxt, CommandMemoryGetDOMCounters, Empty)
// read response
select {
case res := <-ch:
if res == nil {
return 0, 0, 0, ErrChannelClosed
}
switch v := res.(type) {
case easyjson.RawMessage:
// unmarshal
var r GetDOMCountersReturns
err = easyjson.Unmarshal(v, &r)
if err != nil {
return 0, 0, 0, ErrInvalidResult
}
return r.Documents, r.Nodes, r.JsEventListeners, nil
case error:
return 0, 0, 0, v
}
case <-ctxt.Done():
return 0, 0, 0, ErrContextDone
}
return 0, 0, 0, ErrUnknownResult
}
// SetPressureNotificationsSuppressedParams enable/disable suppressing memory
// pressure notifications in all processes.
type SetPressureNotificationsSuppressedParams struct {
Suppressed bool `json:"suppressed"` // If true, memory pressure notifications will be suppressed.
}
// SetPressureNotificationsSuppressed enable/disable suppressing memory
// pressure notifications in all processes.
//
// parameters:
// suppressed - If true, memory pressure notifications will be suppressed.
func SetPressureNotificationsSuppressed(suppressed bool) *SetPressureNotificationsSuppressedParams {
return &SetPressureNotificationsSuppressedParams{
Suppressed: suppressed,
}
}
// Do executes Memory.setPressureNotificationsSuppressed.
func (p *SetPressureNotificationsSuppressedParams) Do(ctxt context.Context, h FrameHandler) (err error) {
if ctxt == nil {
ctxt = context.Background()
}
// marshal
buf, err := easyjson.Marshal(p)
if err != nil {
return err
}
// execute
ch := h.Execute(ctxt, CommandMemorySetPressureNotificationsSuppressed, easyjson.RawMessage(buf))
// read response
select {
case res := <-ch:
if res == nil {
return ErrChannelClosed
}
switch v := res.(type) {
case easyjson.RawMessage:
return nil
case error:
return v
}
case <-ctxt.Done():
return ErrContextDone
}
return ErrUnknownResult
}
// SimulatePressureNotificationParams simulate a memory pressure notification
// in all processes.
type SimulatePressureNotificationParams struct {
Level PressureLevel `json:"level"` // Memory pressure level of the notification.
}
// SimulatePressureNotification simulate a memory pressure notification in
// all processes.
//
// parameters:
// level - Memory pressure level of the notification.
func SimulatePressureNotification(level PressureLevel) *SimulatePressureNotificationParams {
return &SimulatePressureNotificationParams{
Level: level,
}
}
// Do executes Memory.simulatePressureNotification.
func (p *SimulatePressureNotificationParams) Do(ctxt context.Context, h FrameHandler) (err error) {
if ctxt == nil {
ctxt = context.Background()
}
// marshal
buf, err := easyjson.Marshal(p)
if err != nil {
return err
}
// execute
ch := h.Execute(ctxt, CommandMemorySimulatePressureNotification, easyjson.RawMessage(buf))
// read response
select {
case res := <-ch:
if res == nil {
return ErrChannelClosed
}
switch v := res.(type) {
case easyjson.RawMessage:
return nil
case error:
return v
}
case <-ctxt.Done():
return ErrContextDone
}
return ErrUnknownResult
}

74
cdp/memory/types.go Normal file
View File

@ -0,0 +1,74 @@
package memory
// AUTOGENERATED. DO NOT EDIT.
import (
"errors"
. "github.com/knq/chromedp/cdp"
"github.com/mailru/easyjson"
"github.com/mailru/easyjson/jlexer"
"github.com/mailru/easyjson/jwriter"
)
var (
_ BackendNode
_ BackendNodeID
_ ComputedProperty
_ ErrorType
_ Frame
_ FrameID
_ LoaderID
_ Message
_ MessageError
_ MethodType
_ Node
_ NodeID
_ NodeType
_ PseudoType
_ RGBA
_ ShadowRootType
_ Timestamp
)
// PressureLevel memory pressure level.
type PressureLevel string
// String returns the PressureLevel as string value.
func (t PressureLevel) String() string {
return string(t)
}
// PressureLevel values.
const (
PressureLevelModerate PressureLevel = "moderate"
PressureLevelCritical PressureLevel = "critical"
)
// MarshalEasyJSON satisfies easyjson.Marshaler.
func (t PressureLevel) MarshalEasyJSON(out *jwriter.Writer) {
out.String(string(t))
}
// MarshalJSON satisfies json.Marshaler.
func (t PressureLevel) MarshalJSON() ([]byte, error) {
return easyjson.Marshal(t)
}
// UnmarshalEasyJSON satisfies easyjson.Unmarshaler.
func (t *PressureLevel) UnmarshalEasyJSON(in *jlexer.Lexer) {
switch PressureLevel(in.String()) {
case PressureLevelModerate:
*t = PressureLevelModerate
case PressureLevelCritical:
*t = PressureLevelCritical
default:
in.AddError(errors.New("unknown PressureLevel value"))
}
}
// UnmarshalJSON satisfies json.Unmarshaler.
func (t *PressureLevel) UnmarshalJSON(buf []byte) error {
return easyjson.Unmarshal(buf, t)
}

5698
cdp/network/easyjson.go Normal file

File diff suppressed because it is too large Load Diff

170
cdp/network/events.go Normal file
View File

@ -0,0 +1,170 @@
package network
// AUTOGENERATED. DO NOT EDIT.
import (
. "github.com/knq/chromedp/cdp"
"github.com/knq/chromedp/cdp/page"
)
var (
_ BackendNode
_ BackendNodeID
_ ComputedProperty
_ ErrorType
_ Frame
_ FrameID
_ LoaderID
_ Message
_ MessageError
_ MethodType
_ Node
_ NodeID
_ NodeType
_ PseudoType
_ RGBA
_ ShadowRootType
_ Timestamp
)
// EventResourceChangedPriority fired when resource loading priority is
// changed.
type EventResourceChangedPriority struct {
RequestID RequestID `json:"requestId,omitempty"` // Request identifier.
NewPriority ResourcePriority `json:"newPriority,omitempty"` // New priority
Timestamp Timestamp `json:"timestamp,omitempty"` // Timestamp.
}
// EventRequestWillBeSent fired when page is about to send HTTP request.
type EventRequestWillBeSent struct {
RequestID RequestID `json:"requestId,omitempty"` // Request identifier.
FrameID FrameID `json:"frameId,omitempty"` // Frame identifier.
LoaderID LoaderID `json:"loaderId,omitempty"` // Loader identifier.
DocumentURL string `json:"documentURL,omitempty"` // URL of the document this request is loaded for.
Request *Request `json:"request,omitempty"` // Request data.
Timestamp Timestamp `json:"timestamp,omitempty"` // Timestamp.
WallTime Timestamp `json:"wallTime,omitempty"` // UTC Timestamp.
Initiator *Initiator `json:"initiator,omitempty"` // Request initiator.
RedirectResponse *Response `json:"redirectResponse,omitempty"` // Redirect response data.
Type page.ResourceType `json:"type,omitempty"` // Type of this resource.
}
// EventRequestServedFromCache fired if request ended up loading from cache.
type EventRequestServedFromCache struct {
RequestID RequestID `json:"requestId,omitempty"` // Request identifier.
}
// EventResponseReceived fired when HTTP response is available.
type EventResponseReceived struct {
RequestID RequestID `json:"requestId,omitempty"` // Request identifier.
FrameID FrameID `json:"frameId,omitempty"` // Frame identifier.
LoaderID LoaderID `json:"loaderId,omitempty"` // Loader identifier.
Timestamp Timestamp `json:"timestamp,omitempty"` // Timestamp.
Type page.ResourceType `json:"type,omitempty"` // Resource type.
Response *Response `json:"response,omitempty"` // Response data.
}
// EventDataReceived fired when data chunk was received over the network.
type EventDataReceived struct {
RequestID RequestID `json:"requestId,omitempty"` // Request identifier.
Timestamp Timestamp `json:"timestamp,omitempty"` // Timestamp.
DataLength int64 `json:"dataLength,omitempty"` // Data chunk length.
EncodedDataLength int64 `json:"encodedDataLength,omitempty"` // Actual bytes received (might be less than dataLength for compressed encodings).
}
// EventLoadingFinished fired when HTTP request has finished loading.
type EventLoadingFinished struct {
RequestID RequestID `json:"requestId,omitempty"` // Request identifier.
Timestamp Timestamp `json:"timestamp,omitempty"` // Timestamp.
EncodedDataLength float64 `json:"encodedDataLength,omitempty"` // Total number of bytes received for this request.
}
// EventLoadingFailed fired when HTTP request has failed to load.
type EventLoadingFailed struct {
RequestID RequestID `json:"requestId,omitempty"` // Request identifier.
Timestamp Timestamp `json:"timestamp,omitempty"` // Timestamp.
Type page.ResourceType `json:"type,omitempty"` // Resource type.
ErrorText string `json:"errorText,omitempty"` // User friendly error message.
Canceled bool `json:"canceled,omitempty"` // True if loading was canceled.
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,omitempty"` // Request identifier.
Timestamp Timestamp `json:"timestamp,omitempty"` // Timestamp.
WallTime Timestamp `json:"wallTime,omitempty"` // UTC Timestamp.
Request *WebSocketRequest `json:"request,omitempty"` // WebSocket request data.
}
// EventWebSocketHandshakeResponseReceived fired when WebSocket handshake
// response becomes available.
type EventWebSocketHandshakeResponseReceived struct {
RequestID RequestID `json:"requestId,omitempty"` // Request identifier.
Timestamp Timestamp `json:"timestamp,omitempty"` // Timestamp.
Response *WebSocketResponse `json:"response,omitempty"` // WebSocket response data.
}
// EventWebSocketCreated fired upon WebSocket creation.
type EventWebSocketCreated struct {
RequestID RequestID `json:"requestId,omitempty"` // Request identifier.
URL string `json:"url,omitempty"` // WebSocket request URL.
Initiator *Initiator `json:"initiator,omitempty"` // Request initiator.
}
// EventWebSocketClosed fired when WebSocket is closed.
type EventWebSocketClosed struct {
RequestID RequestID `json:"requestId,omitempty"` // Request identifier.
Timestamp Timestamp `json:"timestamp,omitempty"` // Timestamp.
}
// EventWebSocketFrameReceived fired when WebSocket frame is received.
type EventWebSocketFrameReceived struct {
RequestID RequestID `json:"requestId,omitempty"` // Request identifier.
Timestamp Timestamp `json:"timestamp,omitempty"` // Timestamp.
Response *WebSocketFrame `json:"response,omitempty"` // WebSocket response data.
}
// EventWebSocketFrameError fired when WebSocket frame error occurs.
type EventWebSocketFrameError struct {
RequestID RequestID `json:"requestId,omitempty"` // Request identifier.
Timestamp Timestamp `json:"timestamp,omitempty"` // Timestamp.
ErrorMessage string `json:"errorMessage,omitempty"` // WebSocket frame error message.
}
// EventWebSocketFrameSent fired when WebSocket frame is sent.
type EventWebSocketFrameSent struct {
RequestID RequestID `json:"requestId,omitempty"` // Request identifier.
Timestamp Timestamp `json:"timestamp,omitempty"` // Timestamp.
Response *WebSocketFrame `json:"response,omitempty"` // WebSocket response data.
}
// EventEventSourceMessageReceived fired when EventSource message is
// received.
type EventEventSourceMessageReceived struct {
RequestID RequestID `json:"requestId,omitempty"` // Request identifier.
Timestamp Timestamp `json:"timestamp,omitempty"` // Timestamp.
EventName string `json:"eventName,omitempty"` // Message type.
EventID string `json:"eventId,omitempty"` // Message identifier.
Data string `json:"data,omitempty"` // Message content.
}
// EventTypes is all event types in the domain.
var EventTypes = []MethodType{
EventNetworkResourceChangedPriority,
EventNetworkRequestWillBeSent,
EventNetworkRequestServedFromCache,
EventNetworkResponseReceived,
EventNetworkDataReceived,
EventNetworkLoadingFinished,
EventNetworkLoadingFailed,
EventNetworkWebSocketWillSendHandshakeRequest,
EventNetworkWebSocketHandshakeResponseReceived,
EventNetworkWebSocketCreated,
EventNetworkWebSocketClosed,
EventNetworkWebSocketFrameReceived,
EventNetworkWebSocketFrameError,
EventNetworkWebSocketFrameSent,
EventNetworkEventSourceMessageReceived,
}

1378
cdp/network/network.go Normal file

File diff suppressed because it is too large Load Diff

538
cdp/network/types.go Normal file
View File

@ -0,0 +1,538 @@
package network
// AUTOGENERATED. DO NOT EDIT.
import (
"errors"
. "github.com/knq/chromedp/cdp"
"github.com/knq/chromedp/cdp/page"
"github.com/knq/chromedp/cdp/runtime"
"github.com/knq/chromedp/cdp/security"
"github.com/mailru/easyjson"
"github.com/mailru/easyjson/jlexer"
"github.com/mailru/easyjson/jwriter"
)
var (
_ BackendNode
_ BackendNodeID
_ ComputedProperty
_ ErrorType
_ Frame
_ FrameID
_ LoaderID
_ Message
_ MessageError
_ MethodType
_ Node
_ NodeID
_ NodeType
_ PseudoType
_ RGBA
_ ShadowRootType
_ Timestamp
)
// RequestID unique request identifier.
type RequestID string
// String returns the RequestID as string value.
func (t RequestID) String() string {
return string(t)
}
// Headers request / response headers as keys / values of JSON object.
type Headers struct{}
// ConnectionType loading priority of a resource request.
type ConnectionType string
// String returns the ConnectionType as string value.
func (t ConnectionType) String() string {
return string(t)
}
// ConnectionType values.
const (
ConnectionTypeNone ConnectionType = "none"
ConnectionTypeCellular2g ConnectionType = "cellular2g"
ConnectionTypeCellular3g ConnectionType = "cellular3g"
ConnectionTypeCellular4g ConnectionType = "cellular4g"
ConnectionTypeBluetooth ConnectionType = "bluetooth"
ConnectionTypeEthernet ConnectionType = "ethernet"
ConnectionTypeWifi ConnectionType = "wifi"
ConnectionTypeWimax ConnectionType = "wimax"
ConnectionTypeOther ConnectionType = "other"
)
// MarshalEasyJSON satisfies easyjson.Marshaler.
func (t ConnectionType) MarshalEasyJSON(out *jwriter.Writer) {
out.String(string(t))
}
// MarshalJSON satisfies json.Marshaler.
func (t ConnectionType) MarshalJSON() ([]byte, error) {
return easyjson.Marshal(t)
}
// UnmarshalEasyJSON satisfies easyjson.Unmarshaler.
func (t *ConnectionType) UnmarshalEasyJSON(in *jlexer.Lexer) {
switch ConnectionType(in.String()) {
case ConnectionTypeNone:
*t = ConnectionTypeNone
case ConnectionTypeCellular2g:
*t = ConnectionTypeCellular2g
case ConnectionTypeCellular3g:
*t = ConnectionTypeCellular3g
case ConnectionTypeCellular4g:
*t = ConnectionTypeCellular4g
case ConnectionTypeBluetooth:
*t = ConnectionTypeBluetooth
case ConnectionTypeEthernet:
*t = ConnectionTypeEthernet
case ConnectionTypeWifi:
*t = ConnectionTypeWifi
case ConnectionTypeWimax:
*t = ConnectionTypeWimax
case ConnectionTypeOther:
*t = ConnectionTypeOther
default:
in.AddError(errors.New("unknown ConnectionType value"))
}
}
// UnmarshalJSON satisfies json.Unmarshaler.
func (t *ConnectionType) UnmarshalJSON(buf []byte) error {
return easyjson.Unmarshal(buf, t)
}
// CookieSameSite represents the cookie's 'SameSite' status:
// https://tools.ietf.org/html/draft-west-first-party-cookies.
type CookieSameSite string
// String returns the CookieSameSite as string value.
func (t CookieSameSite) String() string {
return string(t)
}
// CookieSameSite values.
const (
CookieSameSiteStrict CookieSameSite = "Strict"
CookieSameSiteLax CookieSameSite = "Lax"
)
// MarshalEasyJSON satisfies easyjson.Marshaler.
func (t CookieSameSite) MarshalEasyJSON(out *jwriter.Writer) {
out.String(string(t))
}
// MarshalJSON satisfies json.Marshaler.
func (t CookieSameSite) MarshalJSON() ([]byte, error) {
return easyjson.Marshal(t)
}
// UnmarshalEasyJSON satisfies easyjson.Unmarshaler.
func (t *CookieSameSite) UnmarshalEasyJSON(in *jlexer.Lexer) {
switch CookieSameSite(in.String()) {
case CookieSameSiteStrict:
*t = CookieSameSiteStrict
case CookieSameSiteLax:
*t = CookieSameSiteLax
default:
in.AddError(errors.New("unknown CookieSameSite value"))
}
}
// UnmarshalJSON satisfies json.Unmarshaler.
func (t *CookieSameSite) UnmarshalJSON(buf []byte) error {
return easyjson.Unmarshal(buf, t)
}
// ResourceTiming timing information for the request.
type ResourceTiming struct {
RequestTime float64 `json:"requestTime,omitempty"` // Timing's requestTime is a baseline in seconds, while the other numbers are ticks in milliseconds relatively to this requestTime.
ProxyStart float64 `json:"proxyStart,omitempty"` // Started resolving proxy.
ProxyEnd float64 `json:"proxyEnd,omitempty"` // Finished resolving proxy.
DNSStart float64 `json:"dnsStart,omitempty"` // Started DNS address resolve.
DNSEnd float64 `json:"dnsEnd,omitempty"` // Finished DNS address resolve.
ConnectStart float64 `json:"connectStart,omitempty"` // Started connecting to the remote host.
ConnectEnd float64 `json:"connectEnd,omitempty"` // Connected to the remote host.
SslStart float64 `json:"sslStart,omitempty"` // Started SSL handshake.
SslEnd float64 `json:"sslEnd,omitempty"` // Finished SSL handshake.
WorkerStart float64 `json:"workerStart,omitempty"` // Started running ServiceWorker.
WorkerReady float64 `json:"workerReady,omitempty"` // Finished Starting ServiceWorker.
SendStart float64 `json:"sendStart,omitempty"` // Started sending request.
SendEnd float64 `json:"sendEnd,omitempty"` // Finished sending request.
PushStart float64 `json:"pushStart,omitempty"` // Time the server started pushing request.
PushEnd float64 `json:"pushEnd,omitempty"` // Time the server finished pushing request.
ReceiveHeadersEnd float64 `json:"receiveHeadersEnd,omitempty"` // Finished receiving response headers.
}
// ResourcePriority loading priority of a resource request.
type ResourcePriority string
// String returns the ResourcePriority as string value.
func (t ResourcePriority) String() string {
return string(t)
}
// ResourcePriority values.
const (
ResourcePriorityVeryLow ResourcePriority = "VeryLow"
ResourcePriorityLow ResourcePriority = "Low"
ResourcePriorityMedium ResourcePriority = "Medium"
ResourcePriorityHigh ResourcePriority = "High"
ResourcePriorityVeryHigh ResourcePriority = "VeryHigh"
)
// MarshalEasyJSON satisfies easyjson.Marshaler.
func (t ResourcePriority) MarshalEasyJSON(out *jwriter.Writer) {
out.String(string(t))
}
// MarshalJSON satisfies json.Marshaler.
func (t ResourcePriority) MarshalJSON() ([]byte, error) {
return easyjson.Marshal(t)
}
// UnmarshalEasyJSON satisfies easyjson.Unmarshaler.
func (t *ResourcePriority) UnmarshalEasyJSON(in *jlexer.Lexer) {
switch ResourcePriority(in.String()) {
case ResourcePriorityVeryLow:
*t = ResourcePriorityVeryLow
case ResourcePriorityLow:
*t = ResourcePriorityLow
case ResourcePriorityMedium:
*t = ResourcePriorityMedium
case ResourcePriorityHigh:
*t = ResourcePriorityHigh
case ResourcePriorityVeryHigh:
*t = ResourcePriorityVeryHigh
default:
in.AddError(errors.New("unknown ResourcePriority value"))
}
}
// UnmarshalJSON satisfies json.Unmarshaler.
func (t *ResourcePriority) UnmarshalJSON(buf []byte) error {
return easyjson.Unmarshal(buf, t)
}
// Request hTTP request data.
type Request struct {
URL string `json:"url,omitempty"` // Request URL.
Method string `json:"method,omitempty"` // HTTP request method.
Headers *Headers `json:"headers,omitempty"` // HTTP request headers.
PostData string `json:"postData,omitempty"` // HTTP POST request data.
MixedContentType MixedContentType `json:"mixedContentType,omitempty"` // The mixed content status of the request, as defined in http://www.w3.org/TR/mixed-content/
InitialPriority ResourcePriority `json:"initialPriority,omitempty"` // Priority of the resource request at the time request is sent.
ReferrerPolicy ReferrerPolicy `json:"referrerPolicy,omitempty"` // The referrer policy of the request, as defined in https://www.w3.org/TR/referrer-policy/
}
// SignedCertificateTimestamp details of a signed certificate timestamp
// (SCT).
type SignedCertificateTimestamp struct {
Status string `json:"status,omitempty"` // Validation status.
Origin string `json:"origin,omitempty"` // Origin.
LogDescription string `json:"logDescription,omitempty"` // Log name / description.
LogID string `json:"logId,omitempty"` // Log ID.
Timestamp Timestamp `json:"timestamp,omitempty"` // Issuance date.
HashAlgorithm string `json:"hashAlgorithm,omitempty"` // Hash algorithm.
SignatureAlgorithm string `json:"signatureAlgorithm,omitempty"` // Signature algorithm.
SignatureData string `json:"signatureData,omitempty"` // Signature data.
}
// SecurityDetails security details about a request.
type SecurityDetails struct {
Protocol string `json:"protocol,omitempty"` // Protocol name (e.g. "TLS 1.2" or "QUIC").
KeyExchange string `json:"keyExchange,omitempty"` // Key Exchange used by the connection, or the empty string if not applicable.
KeyExchangeGroup string `json:"keyExchangeGroup,omitempty"` // (EC)DH group used by the connection, if applicable.
Cipher string `json:"cipher,omitempty"` // Cipher name.
Mac string `json:"mac,omitempty"` // TLS MAC. Note that AEAD ciphers do not have separate MACs.
CertificateID security.CertificateID `json:"certificateId,omitempty"` // Certificate ID value.
SubjectName string `json:"subjectName,omitempty"` // Certificate subject name.
SanList []string `json:"sanList,omitempty"` // Subject Alternative Name (SAN) DNS names and IP addresses.
Issuer string `json:"issuer,omitempty"` // Name of the issuing CA.
ValidFrom Timestamp `json:"validFrom,omitempty"` // Certificate valid from date.
ValidTo Timestamp `json:"validTo,omitempty"` // Certificate valid to (expiration) date
SignedCertificateTimestampList []*SignedCertificateTimestamp `json:"signedCertificateTimestampList,omitempty"` // List of signed certificate timestamps (SCTs).
}
// BlockedReason the reason why request was blocked.
type BlockedReason string
// String returns the BlockedReason as string value.
func (t BlockedReason) String() string {
return string(t)
}
// BlockedReason values.
const (
BlockedReasonCsp BlockedReason = "csp"
BlockedReasonMixedContent BlockedReason = "mixed-content"
BlockedReasonOrigin BlockedReason = "origin"
BlockedReasonInspector BlockedReason = "inspector"
BlockedReasonSubresourceFilter BlockedReason = "subresource-filter"
BlockedReasonOther BlockedReason = "other"
)
// MarshalEasyJSON satisfies easyjson.Marshaler.
func (t BlockedReason) MarshalEasyJSON(out *jwriter.Writer) {
out.String(string(t))
}
// MarshalJSON satisfies json.Marshaler.
func (t BlockedReason) MarshalJSON() ([]byte, error) {
return easyjson.Marshal(t)
}
// UnmarshalEasyJSON satisfies easyjson.Unmarshaler.
func (t *BlockedReason) UnmarshalEasyJSON(in *jlexer.Lexer) {
switch BlockedReason(in.String()) {
case BlockedReasonCsp:
*t = BlockedReasonCsp
case BlockedReasonMixedContent:
*t = BlockedReasonMixedContent
case BlockedReasonOrigin:
*t = BlockedReasonOrigin
case BlockedReasonInspector:
*t = BlockedReasonInspector
case BlockedReasonSubresourceFilter:
*t = BlockedReasonSubresourceFilter
case BlockedReasonOther:
*t = BlockedReasonOther
default:
in.AddError(errors.New("unknown BlockedReason value"))
}
}
// UnmarshalJSON satisfies json.Unmarshaler.
func (t *BlockedReason) UnmarshalJSON(buf []byte) error {
return easyjson.Unmarshal(buf, t)
}
// Response hTTP response data.
type Response struct {
URL string `json:"url,omitempty"` // Response URL. This URL can be different from CachedResource.url in case of redirect.
Status float64 `json:"status,omitempty"` // HTTP response status code.
StatusText string `json:"statusText,omitempty"` // HTTP response status text.
Headers *Headers `json:"headers,omitempty"` // HTTP response headers.
HeadersText string `json:"headersText,omitempty"` // HTTP response headers text.
MimeType string `json:"mimeType,omitempty"` // Resource mimeType as determined by the browser.
RequestHeaders *Headers `json:"requestHeaders,omitempty"` // Refined HTTP request headers that were actually transmitted over the network.
RequestHeadersText string `json:"requestHeadersText,omitempty"` // HTTP request headers text.
ConnectionReused bool `json:"connectionReused,omitempty"` // Specifies whether physical connection was actually reused for this request.
ConnectionID float64 `json:"connectionId,omitempty"` // Physical connection id that was actually used for this request.
RemoteIPAddress string `json:"remoteIPAddress,omitempty"` // Remote IP address.
RemotePort int64 `json:"remotePort,omitempty"` // Remote port.
FromDiskCache bool `json:"fromDiskCache,omitempty"` // Specifies that the request was served from the disk cache.
FromServiceWorker bool `json:"fromServiceWorker,omitempty"` // Specifies that the request was served from the ServiceWorker.
EncodedDataLength float64 `json:"encodedDataLength,omitempty"` // Total number of bytes received for this request so far.
Timing *ResourceTiming `json:"timing,omitempty"` // Timing information for the given request.
Protocol string `json:"protocol,omitempty"` // Protocol used to fetch this request.
SecurityState security.SecurityState `json:"securityState,omitempty"` // Security state of the request resource.
SecurityDetails *SecurityDetails `json:"securityDetails,omitempty"` // Security details for the request.
}
// WebSocketRequest webSocket request data.
type WebSocketRequest struct {
Headers *Headers `json:"headers,omitempty"` // HTTP request headers.
}
// WebSocketResponse webSocket response data.
type WebSocketResponse struct {
Status float64 `json:"status,omitempty"` // HTTP response status code.
StatusText string `json:"statusText,omitempty"` // HTTP response status text.
Headers *Headers `json:"headers,omitempty"` // HTTP response headers.
HeadersText string `json:"headersText,omitempty"` // HTTP response headers text.
RequestHeaders *Headers `json:"requestHeaders,omitempty"` // HTTP request headers.
RequestHeadersText string `json:"requestHeadersText,omitempty"` // HTTP request headers text.
}
// WebSocketFrame webSocket frame data.
type WebSocketFrame struct {
Opcode float64 `json:"opcode,omitempty"` // WebSocket frame opcode.
Mask bool `json:"mask,omitempty"` // WebSocke frame mask.
PayloadData string `json:"payloadData,omitempty"` // WebSocke frame payload data.
}
// CachedResource information about the cached resource.
type CachedResource struct {
URL string `json:"url,omitempty"` // Resource URL. This is the url of the original network request.
Type page.ResourceType `json:"type,omitempty"` // Type of this resource.
Response *Response `json:"response,omitempty"` // Cached response data.
BodySize float64 `json:"bodySize,omitempty"` // Cached response body size.
}
// Initiator information about the request initiator.
type Initiator struct {
Type InitiatorType `json:"type,omitempty"` // Type of this initiator.
Stack *runtime.StackTrace `json:"stack,omitempty"` // Initiator JavaScript stack trace, set for Script only.
URL string `json:"url,omitempty"` // Initiator URL, set for Parser type only.
LineNumber float64 `json:"lineNumber,omitempty"` // Initiator line number, set for Parser type only (0-based).
}
// Cookie cookie object.
type Cookie struct {
Name string `json:"name,omitempty"` // Cookie name.
Value string `json:"value,omitempty"` // Cookie value.
Domain string `json:"domain,omitempty"` // Cookie domain.
Path string `json:"path,omitempty"` // Cookie path.
Expires float64 `json:"expires,omitempty"` // Cookie expiration date as the number of seconds since the UNIX epoch.
Size int64 `json:"size,omitempty"` // Cookie size.
HTTPOnly bool `json:"httpOnly,omitempty"` // True if cookie is http-only.
Secure bool `json:"secure,omitempty"` // True if cookie is secure.
Session bool `json:"session,omitempty"` // True in case of session cookie.
SameSite CookieSameSite `json:"sameSite,omitempty"` // Cookie SameSite type.
}
// MixedContentType the mixed content status of the request, as defined in
// http://www.w3.org/TR/mixed-content/.
type MixedContentType string
// String returns the MixedContentType as string value.
func (t MixedContentType) String() string {
return string(t)
}
// MixedContentType values.
const (
MixedContentTypeBlockable MixedContentType = "blockable"
MixedContentTypeOptionallyBlockable MixedContentType = "optionally-blockable"
MixedContentTypeNone MixedContentType = "none"
)
// MarshalEasyJSON satisfies easyjson.Marshaler.
func (t MixedContentType) MarshalEasyJSON(out *jwriter.Writer) {
out.String(string(t))
}
// MarshalJSON satisfies json.Marshaler.
func (t MixedContentType) MarshalJSON() ([]byte, error) {
return easyjson.Marshal(t)
}
// UnmarshalEasyJSON satisfies easyjson.Unmarshaler.
func (t *MixedContentType) UnmarshalEasyJSON(in *jlexer.Lexer) {
switch MixedContentType(in.String()) {
case MixedContentTypeBlockable:
*t = MixedContentTypeBlockable
case MixedContentTypeOptionallyBlockable:
*t = MixedContentTypeOptionallyBlockable
case MixedContentTypeNone:
*t = MixedContentTypeNone
default:
in.AddError(errors.New("unknown MixedContentType value"))
}
}
// UnmarshalJSON satisfies json.Unmarshaler.
func (t *MixedContentType) UnmarshalJSON(buf []byte) error {
return easyjson.Unmarshal(buf, t)
}
// ReferrerPolicy the referrer policy of the request, as defined in
// https://www.w3.org/TR/referrer-policy/.
type ReferrerPolicy string
// String returns the ReferrerPolicy as string value.
func (t ReferrerPolicy) String() string {
return string(t)
}
// ReferrerPolicy values.
const (
ReferrerPolicyUnsafeURL ReferrerPolicy = "unsafe-url"
ReferrerPolicyNoReferrerWhenDowngrade ReferrerPolicy = "no-referrer-when-downgrade"
ReferrerPolicyNoReferrer ReferrerPolicy = "no-referrer"
ReferrerPolicyOrigin ReferrerPolicy = "origin"
ReferrerPolicyOriginWhenCrossOrigin ReferrerPolicy = "origin-when-cross-origin"
ReferrerPolicyNoReferrerWhenDowngradeOriginWhenCrossOrigin ReferrerPolicy = "no-referrer-when-downgrade-origin-when-cross-origin"
)
// MarshalEasyJSON satisfies easyjson.Marshaler.
func (t ReferrerPolicy) MarshalEasyJSON(out *jwriter.Writer) {
out.String(string(t))
}
// MarshalJSON satisfies json.Marshaler.
func (t ReferrerPolicy) MarshalJSON() ([]byte, error) {
return easyjson.Marshal(t)
}
// UnmarshalEasyJSON satisfies easyjson.Unmarshaler.
func (t *ReferrerPolicy) UnmarshalEasyJSON(in *jlexer.Lexer) {
switch ReferrerPolicy(in.String()) {
case ReferrerPolicyUnsafeURL:
*t = ReferrerPolicyUnsafeURL
case ReferrerPolicyNoReferrerWhenDowngrade:
*t = ReferrerPolicyNoReferrerWhenDowngrade
case ReferrerPolicyNoReferrer:
*t = ReferrerPolicyNoReferrer
case ReferrerPolicyOrigin:
*t = ReferrerPolicyOrigin
case ReferrerPolicyOriginWhenCrossOrigin:
*t = ReferrerPolicyOriginWhenCrossOrigin
case ReferrerPolicyNoReferrerWhenDowngradeOriginWhenCrossOrigin:
*t = ReferrerPolicyNoReferrerWhenDowngradeOriginWhenCrossOrigin
default:
in.AddError(errors.New("unknown ReferrerPolicy value"))
}
}
// UnmarshalJSON satisfies json.Unmarshaler.
func (t *ReferrerPolicy) UnmarshalJSON(buf []byte) error {
return easyjson.Unmarshal(buf, t)
}
// InitiatorType type of this initiator.
type InitiatorType string
// String returns the InitiatorType as string value.
func (t InitiatorType) String() string {
return string(t)
}
// InitiatorType values.
const (
InitiatorTypeParser InitiatorType = "parser"
InitiatorTypeScript InitiatorType = "script"
InitiatorTypeOther InitiatorType = "other"
)
// MarshalEasyJSON satisfies easyjson.Marshaler.
func (t InitiatorType) MarshalEasyJSON(out *jwriter.Writer) {
out.String(string(t))
}
// MarshalJSON satisfies json.Marshaler.
func (t InitiatorType) MarshalJSON() ([]byte, error) {
return easyjson.Marshal(t)
}
// UnmarshalEasyJSON satisfies easyjson.Unmarshaler.
func (t *InitiatorType) UnmarshalEasyJSON(in *jlexer.Lexer) {
switch InitiatorType(in.String()) {
case InitiatorTypeParser:
*t = InitiatorTypeParser
case InitiatorTypeScript:
*t = InitiatorTypeScript
case InitiatorTypeOther:
*t = InitiatorTypeOther
default:
in.AddError(errors.New("unknown InitiatorType value"))
}
}
// UnmarshalJSON satisfies json.Unmarshaler.
func (t *InitiatorType) UnmarshalJSON(buf []byte) error {
return easyjson.Unmarshal(buf, t)
}

4829
cdp/page/easyjson.go Normal file

File diff suppressed because it is too large Load Diff

147
cdp/page/events.go Normal file
View File

@ -0,0 +1,147 @@
package page
// AUTOGENERATED. DO NOT EDIT.
import (
. "github.com/knq/chromedp/cdp"
)
var (
_ BackendNode
_ BackendNodeID
_ ComputedProperty
_ ErrorType
_ Frame
_ FrameID
_ LoaderID
_ Message
_ MessageError
_ MethodType
_ Node
_ NodeID
_ NodeType
_ PseudoType
_ RGBA
_ ShadowRootType
_ Timestamp
)
type EventDomContentEventFired struct {
Timestamp Timestamp `json:"timestamp,omitempty"`
}
type EventLoadEventFired struct {
Timestamp Timestamp `json:"timestamp,omitempty"`
}
// EventFrameAttached fired when frame has been attached to its parent.
type EventFrameAttached struct {
FrameID FrameID `json:"frameId,omitempty"` // Id of the frame that has been attached.
ParentFrameID FrameID `json:"parentFrameId,omitempty"` // Parent frame identifier.
}
// EventFrameNavigated fired once navigation of the frame has completed.
// Frame is now associated with the new loader.
type EventFrameNavigated struct {
Frame *Frame `json:"frame,omitempty"` // Frame object.
}
// EventFrameDetached fired when frame has been detached from its parent.
type EventFrameDetached struct {
FrameID FrameID `json:"frameId,omitempty"` // Id of the frame that has been detached.
}
// EventFrameStartedLoading fired when frame has started loading.
type EventFrameStartedLoading struct {
FrameID FrameID `json:"frameId,omitempty"` // Id of the frame that has started loading.
}
// EventFrameStoppedLoading fired when frame has stopped loading.
type EventFrameStoppedLoading struct {
FrameID FrameID `json:"frameId,omitempty"` // Id of the frame that has stopped loading.
}
// EventFrameScheduledNavigation fired when frame schedules a potential
// navigation.
type EventFrameScheduledNavigation struct {
FrameID FrameID `json:"frameId,omitempty"` // Id of the frame that has scheduled a navigation.
Delay float64 `json:"delay,omitempty"` // Delay (in seconds) until the navigation is scheduled to begin. The navigation is not guaranteed to start.
}
// EventFrameClearedScheduledNavigation fired when frame no longer has a
// scheduled navigation.
type EventFrameClearedScheduledNavigation struct {
FrameID FrameID `json:"frameId,omitempty"` // Id of the frame that has cleared its scheduled navigation.
}
type EventFrameResized struct{}
// EventJavascriptDialogOpening fired when a JavaScript initiated dialog
// (alert, confirm, prompt, or onbeforeunload) is about to open.
type EventJavascriptDialogOpening struct {
Message string `json:"message,omitempty"` // Message that will be displayed by the dialog.
Type DialogType `json:"type,omitempty"` // Dialog type.
}
// EventJavascriptDialogClosed fired when a JavaScript initiated dialog
// (alert, confirm, prompt, or onbeforeunload) has been closed.
type EventJavascriptDialogClosed struct {
Result bool `json:"result,omitempty"` // Whether dialog was confirmed.
}
// EventScreencastFrame compressed image data requested by the
// startScreencast.
type EventScreencastFrame struct {
Data string `json:"data,omitempty"` // Base64-encoded compressed image.
Metadata *ScreencastFrameMetadata `json:"metadata,omitempty"` // Screencast frame metadata.
SessionID int64 `json:"sessionId,omitempty"` // Frame number.
}
// EventScreencastVisibilityChanged fired when the page with currently
// enabled screencast was shown or hidden .
type EventScreencastVisibilityChanged struct {
Visible bool `json:"visible,omitempty"` // True if the page is visible.
}
// EventColorPicked fired when a color has been picked.
type EventColorPicked struct {
Color *RGBA `json:"color,omitempty"` // RGBA of the picked color.
}
// EventInterstitialShown fired when interstitial page was shown.
type EventInterstitialShown struct{}
// EventInterstitialHidden fired when interstitial page was hidden.
type EventInterstitialHidden struct{}
// EventNavigationRequested fired when a navigation is started if navigation
// throttles are enabled. The navigation will be deferred until
// processNavigation is called.
type EventNavigationRequested struct {
IsInMainFrame bool `json:"isInMainFrame,omitempty"` // Whether the navigation is taking place in the main frame or in a subframe.
IsRedirect bool `json:"isRedirect,omitempty"` // Whether the navigation has encountered a server redirect or not.
NavigationID int64 `json:"navigationId,omitempty"`
URL string `json:"url,omitempty"` // URL of requested navigation.
}
// EventTypes is all event types in the domain.
var EventTypes = []MethodType{
EventPageDomContentEventFired,
EventPageLoadEventFired,
EventPageFrameAttached,
EventPageFrameNavigated,
EventPageFrameDetached,
EventPageFrameStartedLoading,
EventPageFrameStoppedLoading,
EventPageFrameScheduledNavigation,
EventPageFrameClearedScheduledNavigation,
EventPageFrameResized,
EventPageJavascriptDialogOpening,
EventPageJavascriptDialogClosed,
EventPageScreencastFrame,
EventPageScreencastVisibilityChanged,
EventPageColorPicked,
EventPageInterstitialShown,
EventPageInterstitialHidden,
EventPageNavigationRequested,
}

1522
cdp/page/page.go Normal file

File diff suppressed because it is too large Load Diff

316
cdp/page/types.go Normal file
View File

@ -0,0 +1,316 @@
package page
// AUTOGENERATED. DO NOT EDIT.
import (
"errors"
. "github.com/knq/chromedp/cdp"
"github.com/mailru/easyjson"
"github.com/mailru/easyjson/jlexer"
"github.com/mailru/easyjson/jwriter"
)
var (
_ BackendNode
_ BackendNodeID
_ ComputedProperty
_ ErrorType
_ Frame
_ FrameID
_ LoaderID
_ Message
_ MessageError
_ MethodType
_ Node
_ NodeID
_ NodeType
_ PseudoType
_ RGBA
_ ShadowRootType
_ Timestamp
)
// ResourceType resource type as it was perceived by the rendering engine.
type ResourceType string
// String returns the ResourceType as string value.
func (t ResourceType) String() string {
return string(t)
}
// ResourceType values.
const (
ResourceTypeDocument ResourceType = "Document"
ResourceTypeStylesheet ResourceType = "Stylesheet"
ResourceTypeImage ResourceType = "Image"
ResourceTypeMedia ResourceType = "Media"
ResourceTypeFont ResourceType = "Font"
ResourceTypeScript ResourceType = "Script"
ResourceTypeTextTrack ResourceType = "TextTrack"
ResourceTypeXHR ResourceType = "XHR"
ResourceTypeFetch ResourceType = "Fetch"
ResourceTypeEventSource ResourceType = "EventSource"
ResourceTypeWebSocket ResourceType = "WebSocket"
ResourceTypeManifest ResourceType = "Manifest"
ResourceTypeOther ResourceType = "Other"
)
// MarshalEasyJSON satisfies easyjson.Marshaler.
func (t ResourceType) MarshalEasyJSON(out *jwriter.Writer) {
out.String(string(t))
}
// MarshalJSON satisfies json.Marshaler.
func (t ResourceType) MarshalJSON() ([]byte, error) {
return easyjson.Marshal(t)
}
// UnmarshalEasyJSON satisfies easyjson.Unmarshaler.
func (t *ResourceType) UnmarshalEasyJSON(in *jlexer.Lexer) {
switch ResourceType(in.String()) {
case ResourceTypeDocument:
*t = ResourceTypeDocument
case ResourceTypeStylesheet:
*t = ResourceTypeStylesheet
case ResourceTypeImage:
*t = ResourceTypeImage
case ResourceTypeMedia:
*t = ResourceTypeMedia
case ResourceTypeFont:
*t = ResourceTypeFont
case ResourceTypeScript:
*t = ResourceTypeScript
case ResourceTypeTextTrack:
*t = ResourceTypeTextTrack
case ResourceTypeXHR:
*t = ResourceTypeXHR
case ResourceTypeFetch:
*t = ResourceTypeFetch
case ResourceTypeEventSource:
*t = ResourceTypeEventSource
case ResourceTypeWebSocket:
*t = ResourceTypeWebSocket
case ResourceTypeManifest:
*t = ResourceTypeManifest
case ResourceTypeOther:
*t = ResourceTypeOther
default:
in.AddError(errors.New("unknown ResourceType value"))
}
}
// UnmarshalJSON satisfies json.Unmarshaler.
func (t *ResourceType) UnmarshalJSON(buf []byte) error {
return easyjson.Unmarshal(buf, t)
}
// FrameResource information about the Resource on the page.
type FrameResource struct {
URL string `json:"url,omitempty"` // Resource URL.
Type ResourceType `json:"type,omitempty"` // Type of this resource.
MimeType string `json:"mimeType,omitempty"` // Resource mimeType as determined by the browser.
LastModified Timestamp `json:"lastModified,omitempty"` // last-modified timestamp as reported by server.
ContentSize float64 `json:"contentSize,omitempty"` // Resource content size.
Failed bool `json:"failed,omitempty"` // True if the resource failed to load.
Canceled bool `json:"canceled,omitempty"` // True if the resource was canceled during loading.
}
// FrameResourceTree information about the Frame hierarchy along with their
// cached resources.
type FrameResourceTree struct {
Frame *Frame `json:"frame,omitempty"` // Frame information for this tree item.
ChildFrames []*FrameResourceTree `json:"childFrames,omitempty"` // Child frames.
Resources []*FrameResource `json:"resources,omitempty"` // Information about frame resources.
}
// ScriptIdentifier unique script identifier.
type ScriptIdentifier string
// String returns the ScriptIdentifier as string value.
func (t ScriptIdentifier) String() string {
return string(t)
}
// NavigationEntry navigation history entry.
type NavigationEntry struct {
ID int64 `json:"id,omitempty"` // Unique id of the navigation history entry.
URL string `json:"url,omitempty"` // URL of the navigation history entry.
Title string `json:"title,omitempty"` // Title of the navigation history entry.
}
// ScreencastFrameMetadata screencast frame metadata.
type ScreencastFrameMetadata struct {
OffsetTop float64 `json:"offsetTop,omitempty"` // Top offset in DIP.
PageScaleFactor float64 `json:"pageScaleFactor,omitempty"` // Page scale factor.
DeviceWidth float64 `json:"deviceWidth,omitempty"` // Device screen width in DIP.
DeviceHeight float64 `json:"deviceHeight,omitempty"` // Device screen height in DIP.
ScrollOffsetX float64 `json:"scrollOffsetX,omitempty"` // Position of horizontal scroll in CSS pixels.
ScrollOffsetY float64 `json:"scrollOffsetY,omitempty"` // Position of vertical scroll in CSS pixels.
Timestamp Timestamp `json:"timestamp,omitempty"` // Frame swap timestamp.
}
// DialogType javascript dialog type.
type DialogType string
// String returns the DialogType as string value.
func (t DialogType) String() string {
return string(t)
}
// DialogType values.
const (
DialogTypeAlert DialogType = "alert"
DialogTypeConfirm DialogType = "confirm"
DialogTypePrompt DialogType = "prompt"
DialogTypeBeforeunload DialogType = "beforeunload"
)
// MarshalEasyJSON satisfies easyjson.Marshaler.
func (t DialogType) MarshalEasyJSON(out *jwriter.Writer) {
out.String(string(t))
}
// MarshalJSON satisfies json.Marshaler.
func (t DialogType) MarshalJSON() ([]byte, error) {
return easyjson.Marshal(t)
}
// UnmarshalEasyJSON satisfies easyjson.Unmarshaler.
func (t *DialogType) UnmarshalEasyJSON(in *jlexer.Lexer) {
switch DialogType(in.String()) {
case DialogTypeAlert:
*t = DialogTypeAlert
case DialogTypeConfirm:
*t = DialogTypeConfirm
case DialogTypePrompt:
*t = DialogTypePrompt
case DialogTypeBeforeunload:
*t = DialogTypeBeforeunload
default:
in.AddError(errors.New("unknown DialogType value"))
}
}
// UnmarshalJSON satisfies json.Unmarshaler.
func (t *DialogType) UnmarshalJSON(buf []byte) error {
return easyjson.Unmarshal(buf, t)
}
// AppManifestError error while paring app manifest.
type AppManifestError struct {
Message string `json:"message,omitempty"` // Error message.
Critical int64 `json:"critical,omitempty"` // If criticial, this is a non-recoverable parse error.
Line int64 `json:"line,omitempty"` // Error line.
Column int64 `json:"column,omitempty"` // Error column.
}
// NavigationResponse proceed: allow the navigation; Cancel: cancel the
// navigation; CancelAndIgnore: cancels the navigation and makes the requester
// of the navigation acts like the request was never made.
type NavigationResponse string
// String returns the NavigationResponse as string value.
func (t NavigationResponse) String() string {
return string(t)
}
// NavigationResponse values.
const (
NavigationResponseProceed NavigationResponse = "Proceed"
NavigationResponseCancel NavigationResponse = "Cancel"
NavigationResponseCancelAndIgnore NavigationResponse = "CancelAndIgnore"
)
// MarshalEasyJSON satisfies easyjson.Marshaler.
func (t NavigationResponse) MarshalEasyJSON(out *jwriter.Writer) {
out.String(string(t))
}
// MarshalJSON satisfies json.Marshaler.
func (t NavigationResponse) MarshalJSON() ([]byte, error) {
return easyjson.Marshal(t)
}
// UnmarshalEasyJSON satisfies easyjson.Unmarshaler.
func (t *NavigationResponse) UnmarshalEasyJSON(in *jlexer.Lexer) {
switch NavigationResponse(in.String()) {
case NavigationResponseProceed:
*t = NavigationResponseProceed
case NavigationResponseCancel:
*t = NavigationResponseCancel
case NavigationResponseCancelAndIgnore:
*t = NavigationResponseCancelAndIgnore
default:
in.AddError(errors.New("unknown NavigationResponse value"))
}
}
// UnmarshalJSON satisfies json.Unmarshaler.
func (t *NavigationResponse) UnmarshalJSON(buf []byte) error {
return easyjson.Unmarshal(buf, t)
}
// LayoutViewport layout viewport position and dimensions.
type LayoutViewport struct {
PageX int64 `json:"pageX,omitempty"` // Horizontal offset relative to the document (CSS pixels).
PageY int64 `json:"pageY,omitempty"` // Vertical offset relative to the document (CSS pixels).
ClientWidth int64 `json:"clientWidth,omitempty"` // Width (CSS pixels), excludes scrollbar if present.
ClientHeight int64 `json:"clientHeight,omitempty"` // Height (CSS pixels), excludes scrollbar if present.
}
// VisualViewport visual viewport position, dimensions, and scale.
type VisualViewport struct {
OffsetX float64 `json:"offsetX,omitempty"` // Horizontal offset relative to the layout viewport (CSS pixels).
OffsetY float64 `json:"offsetY,omitempty"` // Vertical offset relative to the layout viewport (CSS pixels).
PageX float64 `json:"pageX,omitempty"` // Horizontal offset relative to the document (CSS pixels).
PageY float64 `json:"pageY,omitempty"` // Vertical offset relative to the document (CSS pixels).
ClientWidth float64 `json:"clientWidth,omitempty"` // Width (CSS pixels), excludes scrollbar if present.
ClientHeight float64 `json:"clientHeight,omitempty"` // Height (CSS pixels), excludes scrollbar if present.
Scale float64 `json:"scale,omitempty"` // Scale relative to the ideal viewport (size at width=device-width).
}
// 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)
}

1112
cdp/profiler/easyjson.go Normal file

File diff suppressed because it is too large Load Diff

49
cdp/profiler/events.go Normal file
View File

@ -0,0 +1,49 @@
package profiler
// AUTOGENERATED. DO NOT EDIT.
import (
. "github.com/knq/chromedp/cdp"
"github.com/knq/chromedp/cdp/debugger"
)
var (
_ BackendNode
_ BackendNodeID
_ ComputedProperty
_ ErrorType
_ Frame
_ FrameID
_ LoaderID
_ Message
_ MessageError
_ MethodType
_ Node
_ NodeID
_ NodeType
_ PseudoType
_ RGBA
_ ShadowRootType
_ Timestamp
)
// EventConsoleProfileStarted sent when new profile recodring is started
// using console.profile() call.
type EventConsoleProfileStarted struct {
ID string `json:"id,omitempty"`
Location *debugger.Location `json:"location,omitempty"` // Location of console.profile().
Title string `json:"title,omitempty"` // Profile title passed as an argument to console.profile().
}
type EventConsoleProfileFinished struct {
ID string `json:"id,omitempty"`
Location *debugger.Location `json:"location,omitempty"` // Location of console.profileEnd().
Profile *Profile `json:"profile,omitempty"`
Title string `json:"title,omitempty"` // Profile title passed as an argument to console.profile().
}
// EventTypes is all event types in the domain.
var EventTypes = []MethodType{
EventProfilerConsoleProfileStarted,
EventProfilerConsoleProfileFinished,
}

251
cdp/profiler/profiler.go Normal file
View File

@ -0,0 +1,251 @@
// Package profiler provides the Chrome Debugging Protocol
// commands, types, and events for the Chrome Profiler domain.
//
// Generated by the chromedp-gen command.
package profiler
// AUTOGENERATED. DO NOT EDIT.
import (
"context"
. "github.com/knq/chromedp/cdp"
"github.com/mailru/easyjson"
)
var (
_ BackendNode
_ BackendNodeID
_ ComputedProperty
_ ErrorType
_ Frame
_ FrameID
_ LoaderID
_ Message
_ MessageError
_ MethodType
_ Node
_ NodeID
_ NodeType
_ PseudoType
_ RGBA
_ ShadowRootType
_ Timestamp
)
type EnableParams struct{}
func Enable() *EnableParams {
return &EnableParams{}
}
// Do executes Profiler.enable.
func (p *EnableParams) Do(ctxt context.Context, h FrameHandler) (err error) {
if ctxt == nil {
ctxt = context.Background()
}
// execute
ch := h.Execute(ctxt, CommandProfilerEnable, Empty)
// read response
select {
case res := <-ch:
if res == nil {
return ErrChannelClosed
}
switch v := res.(type) {
case easyjson.RawMessage:
return nil
case error:
return v
}
case <-ctxt.Done():
return ErrContextDone
}
return ErrUnknownResult
}
type DisableParams struct{}
func Disable() *DisableParams {
return &DisableParams{}
}
// Do executes Profiler.disable.
func (p *DisableParams) Do(ctxt context.Context, h FrameHandler) (err error) {
if ctxt == nil {
ctxt = context.Background()
}
// execute
ch := h.Execute(ctxt, CommandProfilerDisable, Empty)
// read response
select {
case res := <-ch:
if res == nil {
return ErrChannelClosed
}
switch v := res.(type) {
case easyjson.RawMessage:
return nil
case error:
return v
}
case <-ctxt.Done():
return ErrContextDone
}
return ErrUnknownResult
}
// SetSamplingIntervalParams changes CPU profiler sampling interval. Must be
// called before CPU profiles recording started.
type SetSamplingIntervalParams struct {
Interval int64 `json:"interval"` // New sampling interval in microseconds.
}
// SetSamplingInterval changes CPU profiler sampling interval. Must be called
// before CPU profiles recording started.
//
// parameters:
// interval - New sampling interval in microseconds.
func SetSamplingInterval(interval int64) *SetSamplingIntervalParams {
return &SetSamplingIntervalParams{
Interval: interval,
}
}
// Do executes Profiler.setSamplingInterval.
func (p *SetSamplingIntervalParams) Do(ctxt context.Context, h FrameHandler) (err error) {
if ctxt == nil {
ctxt = context.Background()
}
// marshal
buf, err := easyjson.Marshal(p)
if err != nil {
return err
}
// execute
ch := h.Execute(ctxt, CommandProfilerSetSamplingInterval, easyjson.RawMessage(buf))
// read response
select {
case res := <-ch:
if res == nil {
return ErrChannelClosed
}
switch v := res.(type) {
case easyjson.RawMessage:
return nil
case error:
return v
}
case <-ctxt.Done():
return ErrContextDone
}
return ErrUnknownResult
}
type StartParams struct{}
func Start() *StartParams {
return &StartParams{}
}
// Do executes Profiler.start.
func (p *StartParams) Do(ctxt context.Context, h FrameHandler) (err error) {
if ctxt == nil {
ctxt = context.Background()
}
// execute
ch := h.Execute(ctxt, CommandProfilerStart, Empty)
// read response
select {
case res := <-ch:
if res == nil {
return ErrChannelClosed
}
switch v := res.(type) {
case easyjson.RawMessage:
return nil
case error:
return v
}
case <-ctxt.Done():
return ErrContextDone
}
return ErrUnknownResult
}
type StopParams struct{}
func Stop() *StopParams {
return &StopParams{}
}
// StopReturns return values.
type StopReturns struct {
Profile *Profile `json:"profile,omitempty"` // Recorded profile.
}
// Do executes Profiler.stop.
//
// returns:
// profile - Recorded profile.
func (p *StopParams) Do(ctxt context.Context, h FrameHandler) (profile *Profile, err error) {
if ctxt == nil {
ctxt = context.Background()
}
// execute
ch := h.Execute(ctxt, CommandProfilerStop, Empty)
// read response
select {
case res := <-ch:
if res == nil {
return nil, ErrChannelClosed
}
switch v := res.(type) {
case easyjson.RawMessage:
// unmarshal
var r StopReturns
err = easyjson.Unmarshal(v, &r)
if err != nil {
return nil, ErrInvalidResult
}
return r.Profile, nil
case error:
return nil, v
}
case <-ctxt.Done():
return nil, ErrContextDone
}
return nil, ErrUnknownResult
}

55
cdp/profiler/types.go Normal file
View File

@ -0,0 +1,55 @@
package profiler
// AUTOGENERATED. DO NOT EDIT.
import (
. "github.com/knq/chromedp/cdp"
"github.com/knq/chromedp/cdp/runtime"
)
var (
_ BackendNode
_ BackendNodeID
_ ComputedProperty
_ ErrorType
_ Frame
_ FrameID
_ LoaderID
_ Message
_ MessageError
_ MethodType
_ Node
_ NodeID
_ NodeType
_ PseudoType
_ RGBA
_ ShadowRootType
_ Timestamp
)
// ProfileNode profile node. Holds callsite information, execution statistics
// and child nodes.
type ProfileNode struct {
ID int64 `json:"id,omitempty"` // Unique id of the node.
CallFrame *runtime.CallFrame `json:"callFrame,omitempty"` // Function location.
HitCount int64 `json:"hitCount,omitempty"` // Number of samples where this node was on top of the call stack.
Children []int64 `json:"children,omitempty"` // Child node ids.
DeoptReason string `json:"deoptReason,omitempty"` // The reason of being not optimized. The function may be deoptimized or marked as don't optimize.
PositionTicks []*PositionTickInfo `json:"positionTicks,omitempty"` // An array of source position ticks.
}
// Profile profile.
type Profile struct {
Nodes []*ProfileNode `json:"nodes,omitempty"` // The list of profile nodes. First item is the root node.
StartTime float64 `json:"startTime,omitempty"` // Profiling start timestamp in microseconds.
EndTime float64 `json:"endTime,omitempty"` // Profiling end timestamp in microseconds.
Samples []int64 `json:"samples,omitempty"` // Ids of samples top nodes.
TimeDeltas []int64 `json:"timeDeltas,omitempty"` // Time intervals between adjacent samples in microseconds. The first delta is relative to the profile startTime.
}
// PositionTickInfo specifies a number of samples attributed to a certain
// source position.
type PositionTickInfo struct {
Line int64 `json:"line,omitempty"` // Source line number (1-based).
Ticks int64 `json:"ticks,omitempty"` // Number of samples attributed to the source line.
}

354
cdp/rendering/easyjson.go Normal file
View File

@ -0,0 +1,354 @@
// AUTOGENERATED FILE: easyjson marshaler/unmarshalers.
package rendering
import (
json "encoding/json"
easyjson "github.com/mailru/easyjson"
jlexer "github.com/mailru/easyjson/jlexer"
jwriter "github.com/mailru/easyjson/jwriter"
)
// suppress unused package warning
var (
_ *json.RawMessage
_ *jlexer.Lexer
_ *jwriter.Writer
_ easyjson.Marshaler
)
func easyjsonC5a4559bDecodeGithubComKnqChromedpCdpRendering(in *jlexer.Lexer, out *SetShowViewportSizeOnResizeParams) {
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 "show":
out.Show = bool(in.Bool())
default:
in.SkipRecursive()
}
in.WantComma()
}
in.Delim('}')
if isTopLevel {
in.Consumed()
}
}
func easyjsonC5a4559bEncodeGithubComKnqChromedpCdpRendering(out *jwriter.Writer, in SetShowViewportSizeOnResizeParams) {
out.RawByte('{')
first := true
_ = first
if !first {
out.RawByte(',')
}
first = false
out.RawString("\"show\":")
out.Bool(bool(in.Show))
out.RawByte('}')
}
// MarshalJSON supports json.Marshaler interface
func (v SetShowViewportSizeOnResizeParams) MarshalJSON() ([]byte, error) {
w := jwriter.Writer{}
easyjsonC5a4559bEncodeGithubComKnqChromedpCdpRendering(&w, v)
return w.Buffer.BuildBytes(), w.Error
}
// MarshalEasyJSON supports easyjson.Marshaler interface
func (v SetShowViewportSizeOnResizeParams) MarshalEasyJSON(w *jwriter.Writer) {
easyjsonC5a4559bEncodeGithubComKnqChromedpCdpRendering(w, v)
}
// UnmarshalJSON supports json.Unmarshaler interface
func (v *SetShowViewportSizeOnResizeParams) UnmarshalJSON(data []byte) error {
r := jlexer.Lexer{Data: data}
easyjsonC5a4559bDecodeGithubComKnqChromedpCdpRendering(&r, v)
return r.Error()
}
// UnmarshalEasyJSON supports easyjson.Unmarshaler interface
func (v *SetShowViewportSizeOnResizeParams) UnmarshalEasyJSON(l *jlexer.Lexer) {
easyjsonC5a4559bDecodeGithubComKnqChromedpCdpRendering(l, v)
}
func easyjsonC5a4559bDecodeGithubComKnqChromedpCdpRendering1(in *jlexer.Lexer, out *SetShowScrollBottleneckRectsParams) {
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 "show":
out.Show = bool(in.Bool())
default:
in.SkipRecursive()
}
in.WantComma()
}
in.Delim('}')
if isTopLevel {
in.Consumed()
}
}
func easyjsonC5a4559bEncodeGithubComKnqChromedpCdpRendering1(out *jwriter.Writer, in SetShowScrollBottleneckRectsParams) {
out.RawByte('{')
first := true
_ = first
if !first {
out.RawByte(',')
}
first = false
out.RawString("\"show\":")
out.Bool(bool(in.Show))
out.RawByte('}')
}
// MarshalJSON supports json.Marshaler interface
func (v SetShowScrollBottleneckRectsParams) MarshalJSON() ([]byte, error) {
w := jwriter.Writer{}
easyjsonC5a4559bEncodeGithubComKnqChromedpCdpRendering1(&w, v)
return w.Buffer.BuildBytes(), w.Error
}
// MarshalEasyJSON supports easyjson.Marshaler interface
func (v SetShowScrollBottleneckRectsParams) MarshalEasyJSON(w *jwriter.Writer) {
easyjsonC5a4559bEncodeGithubComKnqChromedpCdpRendering1(w, v)
}
// UnmarshalJSON supports json.Unmarshaler interface
func (v *SetShowScrollBottleneckRectsParams) UnmarshalJSON(data []byte) error {
r := jlexer.Lexer{Data: data}
easyjsonC5a4559bDecodeGithubComKnqChromedpCdpRendering1(&r, v)
return r.Error()
}
// UnmarshalEasyJSON supports easyjson.Unmarshaler interface
func (v *SetShowScrollBottleneckRectsParams) UnmarshalEasyJSON(l *jlexer.Lexer) {
easyjsonC5a4559bDecodeGithubComKnqChromedpCdpRendering1(l, v)
}
func easyjsonC5a4559bDecodeGithubComKnqChromedpCdpRendering2(in *jlexer.Lexer, out *SetShowPaintRectsParams) {
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 "result":
out.Result = bool(in.Bool())
default:
in.SkipRecursive()
}
in.WantComma()
}
in.Delim('}')
if isTopLevel {
in.Consumed()
}
}
func easyjsonC5a4559bEncodeGithubComKnqChromedpCdpRendering2(out *jwriter.Writer, in SetShowPaintRectsParams) {
out.RawByte('{')
first := true
_ = first
if !first {
out.RawByte(',')
}
first = false
out.RawString("\"result\":")
out.Bool(bool(in.Result))
out.RawByte('}')
}
// MarshalJSON supports json.Marshaler interface
func (v SetShowPaintRectsParams) MarshalJSON() ([]byte, error) {
w := jwriter.Writer{}
easyjsonC5a4559bEncodeGithubComKnqChromedpCdpRendering2(&w, v)
return w.Buffer.BuildBytes(), w.Error
}
// MarshalEasyJSON supports easyjson.Marshaler interface
func (v SetShowPaintRectsParams) MarshalEasyJSON(w *jwriter.Writer) {
easyjsonC5a4559bEncodeGithubComKnqChromedpCdpRendering2(w, v)
}
// UnmarshalJSON supports json.Unmarshaler interface
func (v *SetShowPaintRectsParams) UnmarshalJSON(data []byte) error {
r := jlexer.Lexer{Data: data}
easyjsonC5a4559bDecodeGithubComKnqChromedpCdpRendering2(&r, v)
return r.Error()
}
// UnmarshalEasyJSON supports easyjson.Unmarshaler interface
func (v *SetShowPaintRectsParams) UnmarshalEasyJSON(l *jlexer.Lexer) {
easyjsonC5a4559bDecodeGithubComKnqChromedpCdpRendering2(l, v)
}
func easyjsonC5a4559bDecodeGithubComKnqChromedpCdpRendering3(in *jlexer.Lexer, out *SetShowFPSCounterParams) {
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 "show":
out.Show = bool(in.Bool())
default:
in.SkipRecursive()
}
in.WantComma()
}
in.Delim('}')
if isTopLevel {
in.Consumed()
}
}
func easyjsonC5a4559bEncodeGithubComKnqChromedpCdpRendering3(out *jwriter.Writer, in SetShowFPSCounterParams) {
out.RawByte('{')
first := true
_ = first
if !first {
out.RawByte(',')
}
first = false
out.RawString("\"show\":")
out.Bool(bool(in.Show))
out.RawByte('}')
}
// MarshalJSON supports json.Marshaler interface
func (v SetShowFPSCounterParams) MarshalJSON() ([]byte, error) {
w := jwriter.Writer{}
easyjsonC5a4559bEncodeGithubComKnqChromedpCdpRendering3(&w, v)
return w.Buffer.BuildBytes(), w.Error
}
// MarshalEasyJSON supports easyjson.Marshaler interface
func (v SetShowFPSCounterParams) MarshalEasyJSON(w *jwriter.Writer) {
easyjsonC5a4559bEncodeGithubComKnqChromedpCdpRendering3(w, v)
}
// UnmarshalJSON supports json.Unmarshaler interface
func (v *SetShowFPSCounterParams) UnmarshalJSON(data []byte) error {
r := jlexer.Lexer{Data: data}
easyjsonC5a4559bDecodeGithubComKnqChromedpCdpRendering3(&r, v)
return r.Error()
}
// UnmarshalEasyJSON supports easyjson.Unmarshaler interface
func (v *SetShowFPSCounterParams) UnmarshalEasyJSON(l *jlexer.Lexer) {
easyjsonC5a4559bDecodeGithubComKnqChromedpCdpRendering3(l, v)
}
func easyjsonC5a4559bDecodeGithubComKnqChromedpCdpRendering4(in *jlexer.Lexer, out *SetShowDebugBordersParams) {
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 "show":
out.Show = bool(in.Bool())
default:
in.SkipRecursive()
}
in.WantComma()
}
in.Delim('}')
if isTopLevel {
in.Consumed()
}
}
func easyjsonC5a4559bEncodeGithubComKnqChromedpCdpRendering4(out *jwriter.Writer, in SetShowDebugBordersParams) {
out.RawByte('{')
first := true
_ = first
if !first {
out.RawByte(',')
}
first = false
out.RawString("\"show\":")
out.Bool(bool(in.Show))
out.RawByte('}')
}
// MarshalJSON supports json.Marshaler interface
func (v SetShowDebugBordersParams) MarshalJSON() ([]byte, error) {
w := jwriter.Writer{}
easyjsonC5a4559bEncodeGithubComKnqChromedpCdpRendering4(&w, v)
return w.Buffer.BuildBytes(), w.Error
}
// MarshalEasyJSON supports easyjson.Marshaler interface
func (v SetShowDebugBordersParams) MarshalEasyJSON(w *jwriter.Writer) {
easyjsonC5a4559bEncodeGithubComKnqChromedpCdpRendering4(w, v)
}
// UnmarshalJSON supports json.Unmarshaler interface
func (v *SetShowDebugBordersParams) UnmarshalJSON(data []byte) error {
r := jlexer.Lexer{Data: data}
easyjsonC5a4559bDecodeGithubComKnqChromedpCdpRendering4(&r, v)
return r.Error()
}
// UnmarshalEasyJSON supports easyjson.Unmarshaler interface
func (v *SetShowDebugBordersParams) UnmarshalEasyJSON(l *jlexer.Lexer) {
easyjsonC5a4559bDecodeGithubComKnqChromedpCdpRendering4(l, v)
}

300
cdp/rendering/rendering.go Normal file
View File

@ -0,0 +1,300 @@
// Package rendering provides the Chrome Debugging Protocol
// commands, types, and events for the Chrome Rendering domain.
//
// This domain allows to control rendering of the page.
//
// Generated by the chromedp-gen command.
package rendering
// AUTOGENERATED. DO NOT EDIT.
import (
"context"
. "github.com/knq/chromedp/cdp"
"github.com/mailru/easyjson"
)
var (
_ BackendNode
_ BackendNodeID
_ ComputedProperty
_ ErrorType
_ Frame
_ FrameID
_ LoaderID
_ Message
_ MessageError
_ MethodType
_ Node
_ NodeID
_ NodeType
_ PseudoType
_ RGBA
_ ShadowRootType
_ Timestamp
)
// 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 Rendering.setShowPaintRects.
func (p *SetShowPaintRectsParams) Do(ctxt context.Context, h FrameHandler) (err error) {
if ctxt == nil {
ctxt = context.Background()
}
// marshal
buf, err := easyjson.Marshal(p)
if err != nil {
return err
}
// execute
ch := h.Execute(ctxt, CommandRenderingSetShowPaintRects, easyjson.RawMessage(buf))
// read response
select {
case res := <-ch:
if res == nil {
return ErrChannelClosed
}
switch v := res.(type) {
case easyjson.RawMessage:
return nil
case error:
return v
}
case <-ctxt.Done():
return ErrContextDone
}
return ErrUnknownResult
}
// SetShowDebugBordersParams requests that backend shows debug borders on
// layers.
type SetShowDebugBordersParams struct {
Show bool `json:"show"` // True for showing debug borders
}
// SetShowDebugBorders requests that backend shows debug borders on layers.
//
// parameters:
// show - True for showing debug borders
func SetShowDebugBorders(show bool) *SetShowDebugBordersParams {
return &SetShowDebugBordersParams{
Show: show,
}
}
// Do executes Rendering.setShowDebugBorders.
func (p *SetShowDebugBordersParams) Do(ctxt context.Context, h FrameHandler) (err error) {
if ctxt == nil {
ctxt = context.Background()
}
// marshal
buf, err := easyjson.Marshal(p)
if err != nil {
return err
}
// execute
ch := h.Execute(ctxt, CommandRenderingSetShowDebugBorders, easyjson.RawMessage(buf))
// read response
select {
case res := <-ch:
if res == nil {
return ErrChannelClosed
}
switch v := res.(type) {
case easyjson.RawMessage:
return nil
case error:
return v
}
case <-ctxt.Done():
return ErrContextDone
}
return ErrUnknownResult
}
// 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 Rendering.setShowFPSCounter.
func (p *SetShowFPSCounterParams) Do(ctxt context.Context, h FrameHandler) (err error) {
if ctxt == nil {
ctxt = context.Background()
}
// marshal
buf, err := easyjson.Marshal(p)
if err != nil {
return err
}
// execute
ch := h.Execute(ctxt, CommandRenderingSetShowFPSCounter, easyjson.RawMessage(buf))
// read response
select {
case res := <-ch:
if res == nil {
return ErrChannelClosed
}
switch v := res.(type) {
case easyjson.RawMessage:
return nil
case error:
return v
}
case <-ctxt.Done():
return ErrContextDone
}
return ErrUnknownResult
}
// 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 Rendering.setShowScrollBottleneckRects.
func (p *SetShowScrollBottleneckRectsParams) Do(ctxt context.Context, h FrameHandler) (err error) {
if ctxt == nil {
ctxt = context.Background()
}
// marshal
buf, err := easyjson.Marshal(p)
if err != nil {
return err
}
// execute
ch := h.Execute(ctxt, CommandRenderingSetShowScrollBottleneckRects, easyjson.RawMessage(buf))
// read response
select {
case res := <-ch:
if res == nil {
return ErrChannelClosed
}
switch v := res.(type) {
case easyjson.RawMessage:
return nil
case error:
return v
}
case <-ctxt.Done():
return ErrContextDone
}
return ErrUnknownResult
}
// 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 Rendering.setShowViewportSizeOnResize.
func (p *SetShowViewportSizeOnResizeParams) Do(ctxt context.Context, h FrameHandler) (err error) {
if ctxt == nil {
ctxt = context.Background()
}
// marshal
buf, err := easyjson.Marshal(p)
if err != nil {
return err
}
// execute
ch := h.Execute(ctxt, CommandRenderingSetShowViewportSizeOnResize, easyjson.RawMessage(buf))
// read response
select {
case res := <-ch:
if res == nil {
return ErrChannelClosed
}
switch v := res.(type) {
case easyjson.RawMessage:
return nil
case error:
return v
}
case <-ctxt.Done():
return ErrContextDone
}
return ErrUnknownResult
}

4121
cdp/runtime/easyjson.go Normal file

File diff suppressed because it is too large Load Diff

81
cdp/runtime/events.go Normal file
View File

@ -0,0 +1,81 @@
package runtime
// AUTOGENERATED. DO NOT EDIT.
import (
. "github.com/knq/chromedp/cdp"
"github.com/mailru/easyjson"
)
var (
_ BackendNode
_ BackendNodeID
_ ComputedProperty
_ ErrorType
_ Frame
_ FrameID
_ LoaderID
_ Message
_ MessageError
_ MethodType
_ Node
_ NodeID
_ NodeType
_ PseudoType
_ RGBA
_ ShadowRootType
_ Timestamp
)
// EventExecutionContextCreated issued when new execution context is created.
type EventExecutionContextCreated struct {
Context *ExecutionContextDescription `json:"context,omitempty"` // A newly created execution contex.
}
// EventExecutionContextDestroyed issued when execution context is destroyed.
type EventExecutionContextDestroyed struct {
ExecutionContextID ExecutionContextID `json:"executionContextId,omitempty"` // Id of the destroyed context
}
// EventExecutionContextsCleared issued when all executionContexts were
// cleared in browser.
type EventExecutionContextsCleared struct{}
// EventExceptionThrown issued when exception was thrown and unhandled.
type EventExceptionThrown struct {
Timestamp Timestamp `json:"timestamp,omitempty"` // Timestamp of the exception.
ExceptionDetails *ExceptionDetails `json:"exceptionDetails,omitempty"`
}
// EventExceptionRevoked issued when unhandled exception was revoked.
type EventExceptionRevoked struct {
Reason string `json:"reason,omitempty"` // Reason describing why exception was revoked.
ExceptionID int64 `json:"exceptionId,omitempty"` // The id of revoked exception, as reported in exceptionUnhandled.
}
// EventConsoleAPICalled issued when console API was called.
type EventConsoleAPICalled struct {
Type APIType `json:"type,omitempty"` // Type of the call.
Args []*RemoteObject `json:"args,omitempty"` // Call arguments.
ExecutionContextID ExecutionContextID `json:"executionContextId,omitempty"` // Identifier of the context where the call was made.
Timestamp Timestamp `json:"timestamp,omitempty"` // Call timestamp.
StackTrace *StackTrace `json:"stackTrace,omitempty"` // Stack trace captured when the call was made.
}
// EventInspectRequested issued when object should be inspected (for example,
// as a result of inspect() command line API call).
type EventInspectRequested struct {
Object *RemoteObject `json:"object,omitempty"`
Hints easyjson.RawMessage `json:"hints,omitempty"`
}
// EventTypes is all event types in the domain.
var EventTypes = []MethodType{
EventRuntimeExecutionContextCreated,
EventRuntimeExecutionContextDestroyed,
EventRuntimeExecutionContextsCleared,
EventRuntimeExceptionThrown,
EventRuntimeExceptionRevoked,
EventRuntimeConsoleAPICalled,
EventRuntimeInspectRequested,
}

1002
cdp/runtime/runtime.go Normal file

File diff suppressed because it is too large Load Diff

435
cdp/runtime/types.go Normal file
View File

@ -0,0 +1,435 @@
package runtime
// AUTOGENERATED. DO NOT EDIT.
import (
"errors"
. "github.com/knq/chromedp/cdp"
"github.com/mailru/easyjson"
"github.com/mailru/easyjson/jlexer"
"github.com/mailru/easyjson/jwriter"
)
var (
_ BackendNode
_ BackendNodeID
_ ComputedProperty
_ ErrorType
_ Frame
_ FrameID
_ LoaderID
_ Message
_ MessageError
_ MethodType
_ Node
_ NodeID
_ NodeType
_ PseudoType
_ RGBA
_ ShadowRootType
_ Timestamp
)
// ScriptID unique script identifier.
type ScriptID string
// String returns the ScriptID as string value.
func (t ScriptID) String() string {
return string(t)
}
// RemoteObjectID unique object identifier.
type RemoteObjectID string
// String returns the RemoteObjectID as string value.
func (t RemoteObjectID) String() string {
return string(t)
}
// UnserializableValue primitive value which cannot be JSON-stringified.
type UnserializableValue string
// String returns the UnserializableValue as string value.
func (t UnserializableValue) String() string {
return string(t)
}
// UnserializableValue values.
const (
UnserializableValueInfinity UnserializableValue = "Infinity"
UnserializableValueNaN UnserializableValue = "NaN"
UnserializableValueNegativeInfinity UnserializableValue = "-Infinity"
UnserializableValueNegative UnserializableValue = "-0"
)
// MarshalEasyJSON satisfies easyjson.Marshaler.
func (t UnserializableValue) MarshalEasyJSON(out *jwriter.Writer) {
out.String(string(t))
}
// MarshalJSON satisfies json.Marshaler.
func (t UnserializableValue) MarshalJSON() ([]byte, error) {
return easyjson.Marshal(t)
}
// UnmarshalEasyJSON satisfies easyjson.Unmarshaler.
func (t *UnserializableValue) UnmarshalEasyJSON(in *jlexer.Lexer) {
switch UnserializableValue(in.String()) {
case UnserializableValueInfinity:
*t = UnserializableValueInfinity
case UnserializableValueNaN:
*t = UnserializableValueNaN
case UnserializableValueNegativeInfinity:
*t = UnserializableValueNegativeInfinity
case UnserializableValueNegative:
*t = UnserializableValueNegative
default:
in.AddError(errors.New("unknown UnserializableValue value"))
}
}
// UnmarshalJSON satisfies json.Unmarshaler.
func (t *UnserializableValue) UnmarshalJSON(buf []byte) error {
return easyjson.Unmarshal(buf, t)
}
// RemoteObject mirror object referencing original JavaScript object.
type RemoteObject struct {
Type Type `json:"type,omitempty"` // Object type.
Subtype Subtype `json:"subtype,omitempty"` // Object subtype hint. Specified for object type values only.
ClassName string `json:"className,omitempty"` // Object class (constructor) name. Specified for object type values only.
Value easyjson.RawMessage `json:"value,omitempty"` // Remote object value in case of primitive values or JSON values (if it was requested).
UnserializableValue UnserializableValue `json:"unserializableValue,omitempty"` // Primitive value which can not be JSON-stringified does not have value, but gets this property.
Description string `json:"description,omitempty"` // String representation of the object.
ObjectID RemoteObjectID `json:"objectId,omitempty"` // Unique object identifier (for non-primitive values).
Preview *ObjectPreview `json:"preview,omitempty"` // Preview containing abbreviated property values. Specified for object type values only.
CustomPreview *CustomPreview `json:"customPreview,omitempty"`
}
type CustomPreview struct {
Header string `json:"header,omitempty"`
HasBody bool `json:"hasBody,omitempty"`
FormatterObjectID RemoteObjectID `json:"formatterObjectId,omitempty"`
BindRemoteObjectFunctionID RemoteObjectID `json:"bindRemoteObjectFunctionId,omitempty"`
ConfigObjectID RemoteObjectID `json:"configObjectId,omitempty"`
}
// ObjectPreview object containing abbreviated remote object value.
type ObjectPreview struct {
Type Type `json:"type,omitempty"` // Object type.
Subtype Subtype `json:"subtype,omitempty"` // Object subtype hint. Specified for object type values only.
Description string `json:"description,omitempty"` // String representation of the object.
Overflow bool `json:"overflow,omitempty"` // True iff some of the properties or entries of the original object did not fit.
Properties []*PropertyPreview `json:"properties,omitempty"` // List of the properties.
Entries []*EntryPreview `json:"entries,omitempty"` // List of the entries. Specified for map and set subtype values only.
}
type PropertyPreview struct {
Name string `json:"name,omitempty"` // Property name.
Type Type `json:"type,omitempty"` // Object type. Accessor means that the property itself is an accessor property.
Value string `json:"value,omitempty"` // User-friendly property value string.
ValuePreview *ObjectPreview `json:"valuePreview,omitempty"` // Nested value preview.
Subtype Subtype `json:"subtype,omitempty"` // Object subtype hint. Specified for object type values only.
}
type EntryPreview struct {
Key *ObjectPreview `json:"key,omitempty"` // Preview of the key. Specified for map-like collection entries.
Value *ObjectPreview `json:"value,omitempty"` // Preview of the value.
}
// PropertyDescriptor object property descriptor.
type PropertyDescriptor struct {
Name string `json:"name,omitempty"` // Property name or symbol description.
Value *RemoteObject `json:"value,omitempty"` // The value associated with the property.
Writable bool `json:"writable,omitempty"` // True if the value associated with the property may be changed (data descriptors only).
Get *RemoteObject `json:"get,omitempty"` // A function which serves as a getter for the property, or undefined if there is no getter (accessor descriptors only).
Set *RemoteObject `json:"set,omitempty"` // A function which serves as a setter for the property, or undefined if there is no setter (accessor descriptors only).
Configurable bool `json:"configurable,omitempty"` // True if the type of this property descriptor may be changed and if the property may be deleted from the corresponding object.
Enumerable bool `json:"enumerable,omitempty"` // True if this property shows up during enumeration of the properties on the corresponding object.
WasThrown bool `json:"wasThrown,omitempty"` // True if the result was thrown during the evaluation.
IsOwn bool `json:"isOwn,omitempty"` // True if the property is owned for the object.
Symbol *RemoteObject `json:"symbol,omitempty"` // Property symbol object, if the property is of the symbol type.
}
// InternalPropertyDescriptor object internal property descriptor. This
// property isn't normally visible in JavaScript code.
type InternalPropertyDescriptor struct {
Name string `json:"name,omitempty"` // Conventional property name.
Value *RemoteObject `json:"value,omitempty"` // The value associated with the property.
}
// CallArgument represents function call argument. Either remote object id
// objectId, primitive value, unserializable primitive value or neither of (for
// undefined) them should be specified.
type CallArgument struct {
Value easyjson.RawMessage `json:"value,omitempty"` // Primitive value.
UnserializableValue UnserializableValue `json:"unserializableValue,omitempty"` // Primitive value which can not be JSON-stringified.
ObjectID RemoteObjectID `json:"objectId,omitempty"` // Remote object handle.
}
// ExecutionContextID id of an execution context.
type ExecutionContextID int64
// Int64 returns the ExecutionContextID as int64 value.
func (t ExecutionContextID) Int64() int64 {
return int64(t)
}
// ExecutionContextDescription description of an isolated world.
type ExecutionContextDescription struct {
ID ExecutionContextID `json:"id,omitempty"` // Unique id of the execution context. It can be used to specify in which execution context script evaluation should be performed.
Origin string `json:"origin,omitempty"` // Execution context origin.
Name string `json:"name,omitempty"` // Human readable name describing given context.
AuxData easyjson.RawMessage `json:"auxData,omitempty"`
}
// ExceptionDetails detailed information about exception (or error) that was
// thrown during script compilation or execution.
type ExceptionDetails struct {
ExceptionID int64 `json:"exceptionId,omitempty"` // Exception id.
Text string `json:"text,omitempty"` // Exception text, which should be used together with exception object when available.
LineNumber int64 `json:"lineNumber,omitempty"` // Line number of the exception location (0-based).
ColumnNumber int64 `json:"columnNumber,omitempty"` // Column number of the exception location (0-based).
ScriptID ScriptID `json:"scriptId,omitempty"` // Script ID of the exception location.
URL string `json:"url,omitempty"` // URL of the exception location, to be used when the script was not reported.
StackTrace *StackTrace `json:"stackTrace,omitempty"` // JavaScript stack trace if available.
Exception *RemoteObject `json:"exception,omitempty"` // Exception object if available.
ExecutionContextID ExecutionContextID `json:"executionContextId,omitempty"` // Identifier of the context where exception happened.
}
// CallFrame stack entry for runtime errors and assertions.
type CallFrame struct {
FunctionName string `json:"functionName,omitempty"` // JavaScript function name.
ScriptID ScriptID `json:"scriptId,omitempty"` // JavaScript script id.
URL string `json:"url,omitempty"` // JavaScript script name or url.
LineNumber int64 `json:"lineNumber,omitempty"` // JavaScript script line number (0-based).
ColumnNumber int64 `json:"columnNumber,omitempty"` // JavaScript script column number (0-based).
}
// StackTrace call frames for assertions or error messages.
type StackTrace struct {
Description string `json:"description,omitempty"` // String label of this stack trace. For async traces this may be a name of the function that initiated the async call.
CallFrames []*CallFrame `json:"callFrames,omitempty"` // JavaScript function name.
Parent *StackTrace `json:"parent,omitempty"` // Asynchronous JavaScript stack trace that preceded this stack, if available.
}
// Type object type.
type Type string
// String returns the Type as string value.
func (t Type) String() string {
return string(t)
}
// Type values.
const (
TypeObject Type = "object"
TypeFunction Type = "function"
TypeUndefined Type = "undefined"
TypeString Type = "string"
TypeNumber Type = "number"
TypeBoolean Type = "boolean"
TypeSymbol Type = "symbol"
TypeAccessor Type = "accessor"
)
// MarshalEasyJSON satisfies easyjson.Marshaler.
func (t Type) MarshalEasyJSON(out *jwriter.Writer) {
out.String(string(t))
}
// MarshalJSON satisfies json.Marshaler.
func (t Type) MarshalJSON() ([]byte, error) {
return easyjson.Marshal(t)
}
// UnmarshalEasyJSON satisfies easyjson.Unmarshaler.
func (t *Type) UnmarshalEasyJSON(in *jlexer.Lexer) {
switch Type(in.String()) {
case TypeObject:
*t = TypeObject
case TypeFunction:
*t = TypeFunction
case TypeUndefined:
*t = TypeUndefined
case TypeString:
*t = TypeString
case TypeNumber:
*t = TypeNumber
case TypeBoolean:
*t = TypeBoolean
case TypeSymbol:
*t = TypeSymbol
case TypeAccessor:
*t = TypeAccessor
default:
in.AddError(errors.New("unknown Type value"))
}
}
// UnmarshalJSON satisfies json.Unmarshaler.
func (t *Type) UnmarshalJSON(buf []byte) error {
return easyjson.Unmarshal(buf, t)
}
// Subtype object subtype hint. Specified for object type values only.
type Subtype string
// String returns the Subtype as string value.
func (t Subtype) String() string {
return string(t)
}
// Subtype values.
const (
SubtypeArray Subtype = "array"
SubtypeNull Subtype = "null"
SubtypeNode Subtype = "node"
SubtypeRegexp Subtype = "regexp"
SubtypeDate Subtype = "date"
SubtypeMap Subtype = "map"
SubtypeSet Subtype = "set"
SubtypeIterator Subtype = "iterator"
SubtypeGenerator Subtype = "generator"
SubtypeError Subtype = "error"
SubtypeProxy Subtype = "proxy"
SubtypePromise Subtype = "promise"
SubtypeTypedarray Subtype = "typedarray"
)
// MarshalEasyJSON satisfies easyjson.Marshaler.
func (t Subtype) MarshalEasyJSON(out *jwriter.Writer) {
out.String(string(t))
}
// MarshalJSON satisfies json.Marshaler.
func (t Subtype) MarshalJSON() ([]byte, error) {
return easyjson.Marshal(t)
}
// UnmarshalEasyJSON satisfies easyjson.Unmarshaler.
func (t *Subtype) UnmarshalEasyJSON(in *jlexer.Lexer) {
switch Subtype(in.String()) {
case SubtypeArray:
*t = SubtypeArray
case SubtypeNull:
*t = SubtypeNull
case SubtypeNode:
*t = SubtypeNode
case SubtypeRegexp:
*t = SubtypeRegexp
case SubtypeDate:
*t = SubtypeDate
case SubtypeMap:
*t = SubtypeMap
case SubtypeSet:
*t = SubtypeSet
case SubtypeIterator:
*t = SubtypeIterator
case SubtypeGenerator:
*t = SubtypeGenerator
case SubtypeError:
*t = SubtypeError
case SubtypeProxy:
*t = SubtypeProxy
case SubtypePromise:
*t = SubtypePromise
case SubtypeTypedarray:
*t = SubtypeTypedarray
default:
in.AddError(errors.New("unknown Subtype value"))
}
}
// UnmarshalJSON satisfies json.Unmarshaler.
func (t *Subtype) UnmarshalJSON(buf []byte) error {
return easyjson.Unmarshal(buf, t)
}
// APIType type of the call.
type APIType string
// String returns the APIType as string value.
func (t APIType) String() string {
return string(t)
}
// APIType values.
const (
APITypeLog APIType = "log"
APITypeDebug APIType = "debug"
APITypeInfo APIType = "info"
APITypeError APIType = "error"
APITypeWarning APIType = "warning"
APITypeDir APIType = "dir"
APITypeDirxml APIType = "dirxml"
APITypeTable APIType = "table"
APITypeTrace APIType = "trace"
APITypeClear APIType = "clear"
APITypeStartGroup APIType = "startGroup"
APITypeStartGroupCollapsed APIType = "startGroupCollapsed"
APITypeEndGroup APIType = "endGroup"
APITypeAssert APIType = "assert"
APITypeProfile APIType = "profile"
APITypeProfileEnd APIType = "profileEnd"
)
// MarshalEasyJSON satisfies easyjson.Marshaler.
func (t APIType) MarshalEasyJSON(out *jwriter.Writer) {
out.String(string(t))
}
// MarshalJSON satisfies json.Marshaler.
func (t APIType) MarshalJSON() ([]byte, error) {
return easyjson.Marshal(t)
}
// UnmarshalEasyJSON satisfies easyjson.Unmarshaler.
func (t *APIType) UnmarshalEasyJSON(in *jlexer.Lexer) {
switch APIType(in.String()) {
case APITypeLog:
*t = APITypeLog
case APITypeDebug:
*t = APITypeDebug
case APITypeInfo:
*t = APITypeInfo
case APITypeError:
*t = APITypeError
case APITypeWarning:
*t = APITypeWarning
case APITypeDir:
*t = APITypeDir
case APITypeDirxml:
*t = APITypeDirxml
case APITypeTable:
*t = APITypeTable
case APITypeTrace:
*t = APITypeTrace
case APITypeClear:
*t = APITypeClear
case APITypeStartGroup:
*t = APITypeStartGroup
case APITypeStartGroupCollapsed:
*t = APITypeStartGroupCollapsed
case APITypeEndGroup:
*t = APITypeEndGroup
case APITypeAssert:
*t = APITypeAssert
case APITypeProfile:
*t = APITypeProfile
case APITypeProfileEnd:
*t = APITypeProfileEnd
default:
in.AddError(errors.New("unknown APIType value"))
}
}
// UnmarshalJSON satisfies json.Unmarshaler.
func (t *APIType) UnmarshalJSON(buf []byte) error {
return easyjson.Unmarshal(buf, t)
}

266
cdp/schema/easyjson.go Normal file
View File

@ -0,0 +1,266 @@
// AUTOGENERATED FILE: easyjson marshaler/unmarshalers.
package schema
import (
json "encoding/json"
easyjson "github.com/mailru/easyjson"
jlexer "github.com/mailru/easyjson/jlexer"
jwriter "github.com/mailru/easyjson/jwriter"
)
// suppress unused package warning
var (
_ *json.RawMessage
_ *jlexer.Lexer
_ *jwriter.Writer
_ easyjson.Marshaler
)
func easyjsonC5a4559bDecodeGithubComKnqChromedpCdpSchema(in *jlexer.Lexer, out *GetDomainsReturns) {
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 "domains":
if in.IsNull() {
in.Skip()
out.Domains = nil
} else {
in.Delim('[')
if !in.IsDelim(']') {
out.Domains = make([]*Domain, 0, 8)
} else {
out.Domains = []*Domain{}
}
for !in.IsDelim(']') {
var v1 *Domain
if in.IsNull() {
in.Skip()
v1 = nil
} else {
if v1 == nil {
v1 = new(Domain)
}
(*v1).UnmarshalEasyJSON(in)
}
out.Domains = append(out.Domains, v1)
in.WantComma()
}
in.Delim(']')
}
default:
in.SkipRecursive()
}
in.WantComma()
}
in.Delim('}')
if isTopLevel {
in.Consumed()
}
}
func easyjsonC5a4559bEncodeGithubComKnqChromedpCdpSchema(out *jwriter.Writer, in GetDomainsReturns) {
out.RawByte('{')
first := true
_ = first
if len(in.Domains) != 0 {
if !first {
out.RawByte(',')
}
first = false
out.RawString("\"domains\":")
if in.Domains == nil && (out.Flags&jwriter.NilSliceAsEmpty) == 0 {
out.RawString("null")
} else {
out.RawByte('[')
for v2, v3 := range in.Domains {
if v2 > 0 {
out.RawByte(',')
}
if v3 == nil {
out.RawString("null")
} else {
(*v3).MarshalEasyJSON(out)
}
}
out.RawByte(']')
}
}
out.RawByte('}')
}
// MarshalJSON supports json.Marshaler interface
func (v GetDomainsReturns) MarshalJSON() ([]byte, error) {
w := jwriter.Writer{}
easyjsonC5a4559bEncodeGithubComKnqChromedpCdpSchema(&w, v)
return w.Buffer.BuildBytes(), w.Error
}
// MarshalEasyJSON supports easyjson.Marshaler interface
func (v GetDomainsReturns) MarshalEasyJSON(w *jwriter.Writer) {
easyjsonC5a4559bEncodeGithubComKnqChromedpCdpSchema(w, v)
}
// UnmarshalJSON supports json.Unmarshaler interface
func (v *GetDomainsReturns) UnmarshalJSON(data []byte) error {
r := jlexer.Lexer{Data: data}
easyjsonC5a4559bDecodeGithubComKnqChromedpCdpSchema(&r, v)
return r.Error()
}
// UnmarshalEasyJSON supports easyjson.Unmarshaler interface
func (v *GetDomainsReturns) UnmarshalEasyJSON(l *jlexer.Lexer) {
easyjsonC5a4559bDecodeGithubComKnqChromedpCdpSchema(l, v)
}
func easyjsonC5a4559bDecodeGithubComKnqChromedpCdpSchema1(in *jlexer.Lexer, out *GetDomainsParams) {
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 {
default:
in.SkipRecursive()
}
in.WantComma()
}
in.Delim('}')
if isTopLevel {
in.Consumed()
}
}
func easyjsonC5a4559bEncodeGithubComKnqChromedpCdpSchema1(out *jwriter.Writer, in GetDomainsParams) {
out.RawByte('{')
first := true
_ = first
out.RawByte('}')
}
// MarshalJSON supports json.Marshaler interface
func (v GetDomainsParams) MarshalJSON() ([]byte, error) {
w := jwriter.Writer{}
easyjsonC5a4559bEncodeGithubComKnqChromedpCdpSchema1(&w, v)
return w.Buffer.BuildBytes(), w.Error
}
// MarshalEasyJSON supports easyjson.Marshaler interface
func (v GetDomainsParams) MarshalEasyJSON(w *jwriter.Writer) {
easyjsonC5a4559bEncodeGithubComKnqChromedpCdpSchema1(w, v)
}
// UnmarshalJSON supports json.Unmarshaler interface
func (v *GetDomainsParams) UnmarshalJSON(data []byte) error {
r := jlexer.Lexer{Data: data}
easyjsonC5a4559bDecodeGithubComKnqChromedpCdpSchema1(&r, v)
return r.Error()
}
// UnmarshalEasyJSON supports easyjson.Unmarshaler interface
func (v *GetDomainsParams) UnmarshalEasyJSON(l *jlexer.Lexer) {
easyjsonC5a4559bDecodeGithubComKnqChromedpCdpSchema1(l, v)
}
func easyjsonC5a4559bDecodeGithubComKnqChromedpCdpSchema2(in *jlexer.Lexer, out *Domain) {
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 "name":
out.Name = string(in.String())
case "version":
out.Version = string(in.String())
default:
in.SkipRecursive()
}
in.WantComma()
}
in.Delim('}')
if isTopLevel {
in.Consumed()
}
}
func easyjsonC5a4559bEncodeGithubComKnqChromedpCdpSchema2(out *jwriter.Writer, in Domain) {
out.RawByte('{')
first := true
_ = first
if in.Name != "" {
if !first {
out.RawByte(',')
}
first = false
out.RawString("\"name\":")
out.String(string(in.Name))
}
if in.Version != "" {
if !first {
out.RawByte(',')
}
first = false
out.RawString("\"version\":")
out.String(string(in.Version))
}
out.RawByte('}')
}
// MarshalJSON supports json.Marshaler interface
func (v Domain) MarshalJSON() ([]byte, error) {
w := jwriter.Writer{}
easyjsonC5a4559bEncodeGithubComKnqChromedpCdpSchema2(&w, v)
return w.Buffer.BuildBytes(), w.Error
}
// MarshalEasyJSON supports easyjson.Marshaler interface
func (v Domain) MarshalEasyJSON(w *jwriter.Writer) {
easyjsonC5a4559bEncodeGithubComKnqChromedpCdpSchema2(w, v)
}
// UnmarshalJSON supports json.Unmarshaler interface
func (v *Domain) UnmarshalJSON(data []byte) error {
r := jlexer.Lexer{Data: data}
easyjsonC5a4559bDecodeGithubComKnqChromedpCdpSchema2(&r, v)
return r.Error()
}
// UnmarshalEasyJSON supports easyjson.Unmarshaler interface
func (v *Domain) UnmarshalEasyJSON(l *jlexer.Lexer) {
easyjsonC5a4559bDecodeGithubComKnqChromedpCdpSchema2(l, v)
}

90
cdp/schema/schema.go Normal file
View File

@ -0,0 +1,90 @@
// Package schema provides the Chrome Debugging Protocol
// commands, types, and events for the Chrome Schema domain.
//
// Provides information about the protocol schema.
//
// Generated by the chromedp-gen command.
package schema
// AUTOGENERATED. DO NOT EDIT.
import (
"context"
. "github.com/knq/chromedp/cdp"
"github.com/mailru/easyjson"
)
var (
_ BackendNode
_ BackendNodeID
_ ComputedProperty
_ ErrorType
_ Frame
_ FrameID
_ LoaderID
_ Message
_ MessageError
_ MethodType
_ Node
_ NodeID
_ NodeType
_ PseudoType
_ RGBA
_ ShadowRootType
_ Timestamp
)
// GetDomainsParams returns supported domains.
type GetDomainsParams struct{}
// GetDomains returns supported domains.
func GetDomains() *GetDomainsParams {
return &GetDomainsParams{}
}
// GetDomainsReturns return values.
type GetDomainsReturns struct {
Domains []*Domain `json:"domains,omitempty"` // List of supported domains.
}
// Do executes Schema.getDomains.
//
// returns:
// domains - List of supported domains.
func (p *GetDomainsParams) Do(ctxt context.Context, h FrameHandler) (domains []*Domain, err error) {
if ctxt == nil {
ctxt = context.Background()
}
// execute
ch := h.Execute(ctxt, CommandSchemaGetDomains, Empty)
// read response
select {
case res := <-ch:
if res == nil {
return nil, ErrChannelClosed
}
switch v := res.(type) {
case easyjson.RawMessage:
// unmarshal
var r GetDomainsReturns
err = easyjson.Unmarshal(v, &r)
if err != nil {
return nil, ErrInvalidResult
}
return r.Domains, nil
case error:
return nil, v
}
case <-ctxt.Done():
return nil, ErrContextDone
}
return nil, ErrUnknownResult
}

33
cdp/schema/types.go Normal file
View File

@ -0,0 +1,33 @@
package schema
// AUTOGENERATED. DO NOT EDIT.
import (
. "github.com/knq/chromedp/cdp"
)
var (
_ BackendNode
_ BackendNodeID
_ ComputedProperty
_ ErrorType
_ Frame
_ FrameID
_ LoaderID
_ Message
_ MessageError
_ MethodType
_ Node
_ NodeID
_ NodeType
_ PseudoType
_ RGBA
_ ShadowRootType
_ Timestamp
)
// Domain description of the protocol domain.
type Domain struct {
Name string `json:"name,omitempty"` // Domain name.
Version string `json:"version,omitempty"` // Domain version.
}

575
cdp/security/easyjson.go Normal file
View File

@ -0,0 +1,575 @@
// AUTOGENERATED FILE: easyjson marshaler/unmarshalers.
package security
import (
json "encoding/json"
easyjson "github.com/mailru/easyjson"
jlexer "github.com/mailru/easyjson/jlexer"
jwriter "github.com/mailru/easyjson/jwriter"
)
// suppress unused package warning
var (
_ *json.RawMessage
_ *jlexer.Lexer
_ *jwriter.Writer
_ easyjson.Marshaler
)
func easyjsonC5a4559bDecodeGithubComKnqChromedpCdpSecurity(in *jlexer.Lexer, out *ShowCertificateViewerParams) {
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 {
default:
in.SkipRecursive()
}
in.WantComma()
}
in.Delim('}')
if isTopLevel {
in.Consumed()
}
}
func easyjsonC5a4559bEncodeGithubComKnqChromedpCdpSecurity(out *jwriter.Writer, in ShowCertificateViewerParams) {
out.RawByte('{')
first := true
_ = first
out.RawByte('}')
}
// MarshalJSON supports json.Marshaler interface
func (v ShowCertificateViewerParams) MarshalJSON() ([]byte, error) {
w := jwriter.Writer{}
easyjsonC5a4559bEncodeGithubComKnqChromedpCdpSecurity(&w, v)
return w.Buffer.BuildBytes(), w.Error
}
// MarshalEasyJSON supports easyjson.Marshaler interface
func (v ShowCertificateViewerParams) MarshalEasyJSON(w *jwriter.Writer) {
easyjsonC5a4559bEncodeGithubComKnqChromedpCdpSecurity(w, v)
}
// UnmarshalJSON supports json.Unmarshaler interface
func (v *ShowCertificateViewerParams) UnmarshalJSON(data []byte) error {
r := jlexer.Lexer{Data: data}
easyjsonC5a4559bDecodeGithubComKnqChromedpCdpSecurity(&r, v)
return r.Error()
}
// UnmarshalEasyJSON supports easyjson.Unmarshaler interface
func (v *ShowCertificateViewerParams) UnmarshalEasyJSON(l *jlexer.Lexer) {
easyjsonC5a4559bDecodeGithubComKnqChromedpCdpSecurity(l, v)
}
func easyjsonC5a4559bDecodeGithubComKnqChromedpCdpSecurity1(in *jlexer.Lexer, out *SecurityStateExplanation) {
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 "securityState":
(out.SecurityState).UnmarshalEasyJSON(in)
case "summary":
out.Summary = string(in.String())
case "description":
out.Description = string(in.String())
case "hasCertificate":
out.HasCertificate = bool(in.Bool())
default:
in.SkipRecursive()
}
in.WantComma()
}
in.Delim('}')
if isTopLevel {
in.Consumed()
}
}
func easyjsonC5a4559bEncodeGithubComKnqChromedpCdpSecurity1(out *jwriter.Writer, in SecurityStateExplanation) {
out.RawByte('{')
first := true
_ = first
if in.SecurityState != "" {
if !first {
out.RawByte(',')
}
first = false
out.RawString("\"securityState\":")
(in.SecurityState).MarshalEasyJSON(out)
}
if in.Summary != "" {
if !first {
out.RawByte(',')
}
first = false
out.RawString("\"summary\":")
out.String(string(in.Summary))
}
if in.Description != "" {
if !first {
out.RawByte(',')
}
first = false
out.RawString("\"description\":")
out.String(string(in.Description))
}
if in.HasCertificate {
if !first {
out.RawByte(',')
}
first = false
out.RawString("\"hasCertificate\":")
out.Bool(bool(in.HasCertificate))
}
out.RawByte('}')
}
// MarshalJSON supports json.Marshaler interface
func (v SecurityStateExplanation) MarshalJSON() ([]byte, error) {
w := jwriter.Writer{}
easyjsonC5a4559bEncodeGithubComKnqChromedpCdpSecurity1(&w, v)
return w.Buffer.BuildBytes(), w.Error
}
// MarshalEasyJSON supports easyjson.Marshaler interface
func (v SecurityStateExplanation) MarshalEasyJSON(w *jwriter.Writer) {
easyjsonC5a4559bEncodeGithubComKnqChromedpCdpSecurity1(w, v)
}
// UnmarshalJSON supports json.Unmarshaler interface
func (v *SecurityStateExplanation) UnmarshalJSON(data []byte) error {
r := jlexer.Lexer{Data: data}
easyjsonC5a4559bDecodeGithubComKnqChromedpCdpSecurity1(&r, v)
return r.Error()
}
// UnmarshalEasyJSON supports easyjson.Unmarshaler interface
func (v *SecurityStateExplanation) UnmarshalEasyJSON(l *jlexer.Lexer) {
easyjsonC5a4559bDecodeGithubComKnqChromedpCdpSecurity1(l, v)
}
func easyjsonC5a4559bDecodeGithubComKnqChromedpCdpSecurity2(in *jlexer.Lexer, out *InsecureContentStatus) {
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 "ranMixedContent":
out.RanMixedContent = bool(in.Bool())
case "displayedMixedContent":
out.DisplayedMixedContent = bool(in.Bool())
case "ranContentWithCertErrors":
out.RanContentWithCertErrors = bool(in.Bool())
case "displayedContentWithCertErrors":
out.DisplayedContentWithCertErrors = bool(in.Bool())
case "ranInsecureContentStyle":
(out.RanInsecureContentStyle).UnmarshalEasyJSON(in)
case "displayedInsecureContentStyle":
(out.DisplayedInsecureContentStyle).UnmarshalEasyJSON(in)
default:
in.SkipRecursive()
}
in.WantComma()
}
in.Delim('}')
if isTopLevel {
in.Consumed()
}
}
func easyjsonC5a4559bEncodeGithubComKnqChromedpCdpSecurity2(out *jwriter.Writer, in InsecureContentStatus) {
out.RawByte('{')
first := true
_ = first
if in.RanMixedContent {
if !first {
out.RawByte(',')
}
first = false
out.RawString("\"ranMixedContent\":")
out.Bool(bool(in.RanMixedContent))
}
if in.DisplayedMixedContent {
if !first {
out.RawByte(',')
}
first = false
out.RawString("\"displayedMixedContent\":")
out.Bool(bool(in.DisplayedMixedContent))
}
if in.RanContentWithCertErrors {
if !first {
out.RawByte(',')
}
first = false
out.RawString("\"ranContentWithCertErrors\":")
out.Bool(bool(in.RanContentWithCertErrors))
}
if in.DisplayedContentWithCertErrors {
if !first {
out.RawByte(',')
}
first = false
out.RawString("\"displayedContentWithCertErrors\":")
out.Bool(bool(in.DisplayedContentWithCertErrors))
}
if in.RanInsecureContentStyle != "" {
if !first {
out.RawByte(',')
}
first = false
out.RawString("\"ranInsecureContentStyle\":")
(in.RanInsecureContentStyle).MarshalEasyJSON(out)
}
if in.DisplayedInsecureContentStyle != "" {
if !first {
out.RawByte(',')
}
first = false
out.RawString("\"displayedInsecureContentStyle\":")
(in.DisplayedInsecureContentStyle).MarshalEasyJSON(out)
}
out.RawByte('}')
}
// MarshalJSON supports json.Marshaler interface
func (v InsecureContentStatus) MarshalJSON() ([]byte, error) {
w := jwriter.Writer{}
easyjsonC5a4559bEncodeGithubComKnqChromedpCdpSecurity2(&w, v)
return w.Buffer.BuildBytes(), w.Error
}
// MarshalEasyJSON supports easyjson.Marshaler interface
func (v InsecureContentStatus) MarshalEasyJSON(w *jwriter.Writer) {
easyjsonC5a4559bEncodeGithubComKnqChromedpCdpSecurity2(w, v)
}
// UnmarshalJSON supports json.Unmarshaler interface
func (v *InsecureContentStatus) UnmarshalJSON(data []byte) error {
r := jlexer.Lexer{Data: data}
easyjsonC5a4559bDecodeGithubComKnqChromedpCdpSecurity2(&r, v)
return r.Error()
}
// UnmarshalEasyJSON supports easyjson.Unmarshaler interface
func (v *InsecureContentStatus) UnmarshalEasyJSON(l *jlexer.Lexer) {
easyjsonC5a4559bDecodeGithubComKnqChromedpCdpSecurity2(l, v)
}
func easyjsonC5a4559bDecodeGithubComKnqChromedpCdpSecurity3(in *jlexer.Lexer, out *EventSecurityStateChanged) {
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 "securityState":
(out.SecurityState).UnmarshalEasyJSON(in)
case "schemeIsCryptographic":
out.SchemeIsCryptographic = bool(in.Bool())
case "explanations":
if in.IsNull() {
in.Skip()
out.Explanations = nil
} else {
in.Delim('[')
if !in.IsDelim(']') {
out.Explanations = make([]*SecurityStateExplanation, 0, 8)
} else {
out.Explanations = []*SecurityStateExplanation{}
}
for !in.IsDelim(']') {
var v1 *SecurityStateExplanation
if in.IsNull() {
in.Skip()
v1 = nil
} else {
if v1 == nil {
v1 = new(SecurityStateExplanation)
}
(*v1).UnmarshalEasyJSON(in)
}
out.Explanations = append(out.Explanations, v1)
in.WantComma()
}
in.Delim(']')
}
case "insecureContentStatus":
if in.IsNull() {
in.Skip()
out.InsecureContentStatus = nil
} else {
if out.InsecureContentStatus == nil {
out.InsecureContentStatus = new(InsecureContentStatus)
}
(*out.InsecureContentStatus).UnmarshalEasyJSON(in)
}
case "summary":
out.Summary = string(in.String())
default:
in.SkipRecursive()
}
in.WantComma()
}
in.Delim('}')
if isTopLevel {
in.Consumed()
}
}
func easyjsonC5a4559bEncodeGithubComKnqChromedpCdpSecurity3(out *jwriter.Writer, in EventSecurityStateChanged) {
out.RawByte('{')
first := true
_ = first
if in.SecurityState != "" {
if !first {
out.RawByte(',')
}
first = false
out.RawString("\"securityState\":")
(in.SecurityState).MarshalEasyJSON(out)
}
if in.SchemeIsCryptographic {
if !first {
out.RawByte(',')
}
first = false
out.RawString("\"schemeIsCryptographic\":")
out.Bool(bool(in.SchemeIsCryptographic))
}
if len(in.Explanations) != 0 {
if !first {
out.RawByte(',')
}
first = false
out.RawString("\"explanations\":")
if in.Explanations == nil && (out.Flags&jwriter.NilSliceAsEmpty) == 0 {
out.RawString("null")
} else {
out.RawByte('[')
for v2, v3 := range in.Explanations {
if v2 > 0 {
out.RawByte(',')
}
if v3 == nil {
out.RawString("null")
} else {
(*v3).MarshalEasyJSON(out)
}
}
out.RawByte(']')
}
}
if in.InsecureContentStatus != nil {
if !first {
out.RawByte(',')
}
first = false
out.RawString("\"insecureContentStatus\":")
if in.InsecureContentStatus == nil {
out.RawString("null")
} else {
(*in.InsecureContentStatus).MarshalEasyJSON(out)
}
}
if in.Summary != "" {
if !first {
out.RawByte(',')
}
first = false
out.RawString("\"summary\":")
out.String(string(in.Summary))
}
out.RawByte('}')
}
// MarshalJSON supports json.Marshaler interface
func (v EventSecurityStateChanged) MarshalJSON() ([]byte, error) {
w := jwriter.Writer{}
easyjsonC5a4559bEncodeGithubComKnqChromedpCdpSecurity3(&w, v)
return w.Buffer.BuildBytes(), w.Error
}
// MarshalEasyJSON supports easyjson.Marshaler interface
func (v EventSecurityStateChanged) MarshalEasyJSON(w *jwriter.Writer) {
easyjsonC5a4559bEncodeGithubComKnqChromedpCdpSecurity3(w, v)
}
// UnmarshalJSON supports json.Unmarshaler interface
func (v *EventSecurityStateChanged) UnmarshalJSON(data []byte) error {
r := jlexer.Lexer{Data: data}
easyjsonC5a4559bDecodeGithubComKnqChromedpCdpSecurity3(&r, v)
return r.Error()
}
// UnmarshalEasyJSON supports easyjson.Unmarshaler interface
func (v *EventSecurityStateChanged) UnmarshalEasyJSON(l *jlexer.Lexer) {
easyjsonC5a4559bDecodeGithubComKnqChromedpCdpSecurity3(l, v)
}
func easyjsonC5a4559bDecodeGithubComKnqChromedpCdpSecurity4(in *jlexer.Lexer, out *EnableParams) {
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 {
default:
in.SkipRecursive()
}
in.WantComma()
}
in.Delim('}')
if isTopLevel {
in.Consumed()
}
}
func easyjsonC5a4559bEncodeGithubComKnqChromedpCdpSecurity4(out *jwriter.Writer, in EnableParams) {
out.RawByte('{')
first := true
_ = first
out.RawByte('}')
}
// MarshalJSON supports json.Marshaler interface
func (v EnableParams) MarshalJSON() ([]byte, error) {
w := jwriter.Writer{}
easyjsonC5a4559bEncodeGithubComKnqChromedpCdpSecurity4(&w, v)
return w.Buffer.BuildBytes(), w.Error
}
// MarshalEasyJSON supports easyjson.Marshaler interface
func (v EnableParams) MarshalEasyJSON(w *jwriter.Writer) {
easyjsonC5a4559bEncodeGithubComKnqChromedpCdpSecurity4(w, v)
}
// UnmarshalJSON supports json.Unmarshaler interface
func (v *EnableParams) UnmarshalJSON(data []byte) error {
r := jlexer.Lexer{Data: data}
easyjsonC5a4559bDecodeGithubComKnqChromedpCdpSecurity4(&r, v)
return r.Error()
}
// UnmarshalEasyJSON supports easyjson.Unmarshaler interface
func (v *EnableParams) UnmarshalEasyJSON(l *jlexer.Lexer) {
easyjsonC5a4559bDecodeGithubComKnqChromedpCdpSecurity4(l, v)
}
func easyjsonC5a4559bDecodeGithubComKnqChromedpCdpSecurity5(in *jlexer.Lexer, out *DisableParams) {
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 {
default:
in.SkipRecursive()
}
in.WantComma()
}
in.Delim('}')
if isTopLevel {
in.Consumed()
}
}
func easyjsonC5a4559bEncodeGithubComKnqChromedpCdpSecurity5(out *jwriter.Writer, in DisableParams) {
out.RawByte('{')
first := true
_ = first
out.RawByte('}')
}
// MarshalJSON supports json.Marshaler interface
func (v DisableParams) MarshalJSON() ([]byte, error) {
w := jwriter.Writer{}
easyjsonC5a4559bEncodeGithubComKnqChromedpCdpSecurity5(&w, v)
return w.Buffer.BuildBytes(), w.Error
}
// MarshalEasyJSON supports easyjson.Marshaler interface
func (v DisableParams) MarshalEasyJSON(w *jwriter.Writer) {
easyjsonC5a4559bEncodeGithubComKnqChromedpCdpSecurity5(w, v)
}
// UnmarshalJSON supports json.Unmarshaler interface
func (v *DisableParams) UnmarshalJSON(data []byte) error {
r := jlexer.Lexer{Data: data}
easyjsonC5a4559bDecodeGithubComKnqChromedpCdpSecurity5(&r, v)
return r.Error()
}
// UnmarshalEasyJSON supports easyjson.Unmarshaler interface
func (v *DisableParams) UnmarshalEasyJSON(l *jlexer.Lexer) {
easyjsonC5a4559bDecodeGithubComKnqChromedpCdpSecurity5(l, v)
}

41
cdp/security/events.go Normal file
View File

@ -0,0 +1,41 @@
package security
// AUTOGENERATED. DO NOT EDIT.
import (
. "github.com/knq/chromedp/cdp"
)
var (
_ BackendNode
_ BackendNodeID
_ ComputedProperty
_ ErrorType
_ Frame
_ FrameID
_ LoaderID
_ Message
_ MessageError
_ MethodType
_ Node
_ NodeID
_ NodeType
_ PseudoType
_ RGBA
_ ShadowRootType
_ Timestamp
)
// EventSecurityStateChanged the security state of the page changed.
type EventSecurityStateChanged struct {
SecurityState SecurityState `json:"securityState,omitempty"` // Security state.
SchemeIsCryptographic bool `json:"schemeIsCryptographic,omitempty"` // True if the page was loaded over cryptographic transport such as HTTPS.
Explanations []*SecurityStateExplanation `json:"explanations,omitempty"` // 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,omitempty"` // Information about insecure content on the page.
Summary string `json:"summary,omitempty"` // Overrides user-visible description of the state.
}
// EventTypes is all event types in the domain.
var EventTypes = []MethodType{
EventSecuritySecurityStateChanged,
}

Some files were not shown because too many files have changed in this diff Show More