chromedp/cdp/domdebugger/domdebugger.go

530 lines
12 KiB
Go
Raw Normal View History

2017-01-24 15:09:23 +00:00
// 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"
2017-01-26 07:28:34 +00:00
cdp "github.com/knq/chromedp/cdp"
2017-01-24 15:09:23 +00:00
"github.com/knq/chromedp/cdp/runtime"
"github.com/mailru/easyjson"
)
// SetDOMBreakpointParams sets breakpoint on particular operation with DOM.
type SetDOMBreakpointParams struct {
2017-01-26 07:28:34 +00:00
NodeID cdp.NodeID `json:"nodeId"` // Identifier of the node to set breakpoint on.
2017-01-24 15:09:23 +00:00
Type DOMBreakpointType `json:"type"` // Type of the operation to stop upon.
}
// SetDOMBreakpoint sets breakpoint on particular operation with DOM.
//
// parameters:
2017-01-26 07:28:34 +00:00
// nodeID - Identifier of the node to set breakpoint on.
2017-01-24 15:09:23 +00:00
// type - Type of the operation to stop upon.
2017-01-26 07:28:34 +00:00
func SetDOMBreakpoint(nodeID cdp.NodeID, typeVal DOMBreakpointType) *SetDOMBreakpointParams {
2017-01-24 15:09:23 +00:00
return &SetDOMBreakpointParams{
2017-01-26 07:28:34 +00:00
NodeID: nodeID,
Type: typeVal,
2017-01-24 15:09:23 +00:00
}
}
// Do executes DOMDebugger.setDOMBreakpoint.
2017-01-26 07:28:34 +00:00
func (p *SetDOMBreakpointParams) Do(ctxt context.Context, h cdp.FrameHandler) (err error) {
2017-01-24 15:09:23 +00:00
if ctxt == nil {
ctxt = context.Background()
}
// marshal
buf, err := easyjson.Marshal(p)
if err != nil {
return err
}
// execute
2017-01-26 07:28:34 +00:00
ch := h.Execute(ctxt, cdp.CommandDOMDebuggerSetDOMBreakpoint, easyjson.RawMessage(buf))
2017-01-24 15:09:23 +00:00
// read response
select {
case res := <-ch:
if res == nil {
2017-01-26 07:28:34 +00:00
return cdp.ErrChannelClosed
2017-01-24 15:09:23 +00:00
}
switch v := res.(type) {
case easyjson.RawMessage:
return nil
case error:
return v
}
case <-ctxt.Done():
2017-01-26 07:28:34 +00:00
return cdp.ErrContextDone
2017-01-24 15:09:23 +00:00
}
2017-01-26 07:28:34 +00:00
return cdp.ErrUnknownResult
2017-01-24 15:09:23 +00:00
}
// RemoveDOMBreakpointParams removes DOM breakpoint that was set using
// setDOMBreakpoint.
type RemoveDOMBreakpointParams struct {
2017-01-26 07:28:34 +00:00
NodeID cdp.NodeID `json:"nodeId"` // Identifier of the node to remove breakpoint from.
2017-01-24 15:09:23 +00:00
Type DOMBreakpointType `json:"type"` // Type of the breakpoint to remove.
}
// RemoveDOMBreakpoint removes DOM breakpoint that was set using
// setDOMBreakpoint.
//
// parameters:
2017-01-26 07:28:34 +00:00
// nodeID - Identifier of the node to remove breakpoint from.
2017-01-24 15:09:23 +00:00
// type - Type of the breakpoint to remove.
2017-01-26 07:28:34 +00:00
func RemoveDOMBreakpoint(nodeID cdp.NodeID, typeVal DOMBreakpointType) *RemoveDOMBreakpointParams {
2017-01-24 15:09:23 +00:00
return &RemoveDOMBreakpointParams{
2017-01-26 07:28:34 +00:00
NodeID: nodeID,
Type: typeVal,
2017-01-24 15:09:23 +00:00
}
}
// Do executes DOMDebugger.removeDOMBreakpoint.
2017-01-26 07:28:34 +00:00
func (p *RemoveDOMBreakpointParams) Do(ctxt context.Context, h cdp.FrameHandler) (err error) {
2017-01-24 15:09:23 +00:00
if ctxt == nil {
ctxt = context.Background()
}
// marshal
buf, err := easyjson.Marshal(p)
if err != nil {
return err
}
// execute
2017-01-26 07:28:34 +00:00
ch := h.Execute(ctxt, cdp.CommandDOMDebuggerRemoveDOMBreakpoint, easyjson.RawMessage(buf))
2017-01-24 15:09:23 +00:00
// read response
select {
case res := <-ch:
if res == nil {
2017-01-26 07:28:34 +00:00
return cdp.ErrChannelClosed
2017-01-24 15:09:23 +00:00
}
switch v := res.(type) {
case easyjson.RawMessage:
return nil
case error:
return v
}
case <-ctxt.Done():
2017-01-26 07:28:34 +00:00
return cdp.ErrContextDone
2017-01-24 15:09:23 +00:00
}
2017-01-26 07:28:34 +00:00
return cdp.ErrUnknownResult
2017-01-24 15:09:23 +00:00
}
// 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.
2017-01-26 07:28:34 +00:00
func (p *SetEventListenerBreakpointParams) Do(ctxt context.Context, h cdp.FrameHandler) (err error) {
2017-01-24 15:09:23 +00:00
if ctxt == nil {
ctxt = context.Background()
}
// marshal
buf, err := easyjson.Marshal(p)
if err != nil {
return err
}
// execute
2017-01-26 07:28:34 +00:00
ch := h.Execute(ctxt, cdp.CommandDOMDebuggerSetEventListenerBreakpoint, easyjson.RawMessage(buf))
2017-01-24 15:09:23 +00:00
// read response
select {
case res := <-ch:
if res == nil {
2017-01-26 07:28:34 +00:00
return cdp.ErrChannelClosed
2017-01-24 15:09:23 +00:00
}
switch v := res.(type) {
case easyjson.RawMessage:
return nil
case error:
return v
}
case <-ctxt.Done():
2017-01-26 07:28:34 +00:00
return cdp.ErrContextDone
2017-01-24 15:09:23 +00:00
}
2017-01-26 07:28:34 +00:00
return cdp.ErrUnknownResult
2017-01-24 15:09:23 +00:00
}
// 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.
2017-01-26 07:28:34 +00:00
func (p *RemoveEventListenerBreakpointParams) Do(ctxt context.Context, h cdp.FrameHandler) (err error) {
2017-01-24 15:09:23 +00:00
if ctxt == nil {
ctxt = context.Background()
}
// marshal
buf, err := easyjson.Marshal(p)
if err != nil {
return err
}
// execute
2017-01-26 07:28:34 +00:00
ch := h.Execute(ctxt, cdp.CommandDOMDebuggerRemoveEventListenerBreakpoint, easyjson.RawMessage(buf))
2017-01-24 15:09:23 +00:00
// read response
select {
case res := <-ch:
if res == nil {
2017-01-26 07:28:34 +00:00
return cdp.ErrChannelClosed
2017-01-24 15:09:23 +00:00
}
switch v := res.(type) {
case easyjson.RawMessage:
return nil
case error:
return v
}
case <-ctxt.Done():
2017-01-26 07:28:34 +00:00
return cdp.ErrContextDone
2017-01-24 15:09:23 +00:00
}
2017-01-26 07:28:34 +00:00
return cdp.ErrUnknownResult
2017-01-24 15:09:23 +00:00
}
// 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.
2017-01-26 07:28:34 +00:00
func (p *SetInstrumentationBreakpointParams) Do(ctxt context.Context, h cdp.FrameHandler) (err error) {
2017-01-24 15:09:23 +00:00
if ctxt == nil {
ctxt = context.Background()
}
// marshal
buf, err := easyjson.Marshal(p)
if err != nil {
return err
}
// execute
2017-01-26 07:28:34 +00:00
ch := h.Execute(ctxt, cdp.CommandDOMDebuggerSetInstrumentationBreakpoint, easyjson.RawMessage(buf))
2017-01-24 15:09:23 +00:00
// read response
select {
case res := <-ch:
if res == nil {
2017-01-26 07:28:34 +00:00
return cdp.ErrChannelClosed
2017-01-24 15:09:23 +00:00
}
switch v := res.(type) {
case easyjson.RawMessage:
return nil
case error:
return v
}
case <-ctxt.Done():
2017-01-26 07:28:34 +00:00
return cdp.ErrContextDone
2017-01-24 15:09:23 +00:00
}
2017-01-26 07:28:34 +00:00
return cdp.ErrUnknownResult
2017-01-24 15:09:23 +00:00
}
// 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.
2017-01-26 07:28:34 +00:00
func (p *RemoveInstrumentationBreakpointParams) Do(ctxt context.Context, h cdp.FrameHandler) (err error) {
2017-01-24 15:09:23 +00:00
if ctxt == nil {
ctxt = context.Background()
}
// marshal
buf, err := easyjson.Marshal(p)
if err != nil {
return err
}
// execute
2017-01-26 07:28:34 +00:00
ch := h.Execute(ctxt, cdp.CommandDOMDebuggerRemoveInstrumentationBreakpoint, easyjson.RawMessage(buf))
2017-01-24 15:09:23 +00:00
// read response
select {
case res := <-ch:
if res == nil {
2017-01-26 07:28:34 +00:00
return cdp.ErrChannelClosed
2017-01-24 15:09:23 +00:00
}
switch v := res.(type) {
case easyjson.RawMessage:
return nil
case error:
return v
}
case <-ctxt.Done():
2017-01-26 07:28:34 +00:00
return cdp.ErrContextDone
2017-01-24 15:09:23 +00:00
}
2017-01-26 07:28:34 +00:00
return cdp.ErrUnknownResult
2017-01-24 15:09:23 +00:00
}
// 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.
2017-01-26 07:28:34 +00:00
func (p *SetXHRBreakpointParams) Do(ctxt context.Context, h cdp.FrameHandler) (err error) {
2017-01-24 15:09:23 +00:00
if ctxt == nil {
ctxt = context.Background()
}
// marshal
buf, err := easyjson.Marshal(p)
if err != nil {
return err
}
// execute
2017-01-26 07:28:34 +00:00
ch := h.Execute(ctxt, cdp.CommandDOMDebuggerSetXHRBreakpoint, easyjson.RawMessage(buf))
2017-01-24 15:09:23 +00:00
// read response
select {
case res := <-ch:
if res == nil {
2017-01-26 07:28:34 +00:00
return cdp.ErrChannelClosed
2017-01-24 15:09:23 +00:00
}
switch v := res.(type) {
case easyjson.RawMessage:
return nil
case error:
return v
}
case <-ctxt.Done():
2017-01-26 07:28:34 +00:00
return cdp.ErrContextDone
2017-01-24 15:09:23 +00:00
}
2017-01-26 07:28:34 +00:00
return cdp.ErrUnknownResult
2017-01-24 15:09:23 +00:00
}
// 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.
2017-01-26 07:28:34 +00:00
func (p *RemoveXHRBreakpointParams) Do(ctxt context.Context, h cdp.FrameHandler) (err error) {
2017-01-24 15:09:23 +00:00
if ctxt == nil {
ctxt = context.Background()
}
// marshal
buf, err := easyjson.Marshal(p)
if err != nil {
return err
}
// execute
2017-01-26 07:28:34 +00:00
ch := h.Execute(ctxt, cdp.CommandDOMDebuggerRemoveXHRBreakpoint, easyjson.RawMessage(buf))
2017-01-24 15:09:23 +00:00
// read response
select {
case res := <-ch:
if res == nil {
2017-01-26 07:28:34 +00:00
return cdp.ErrChannelClosed
2017-01-24 15:09:23 +00:00
}
switch v := res.(type) {
case easyjson.RawMessage:
return nil
case error:
return v
}
case <-ctxt.Done():
2017-01-26 07:28:34 +00:00
return cdp.ErrContextDone
2017-01-24 15:09:23 +00:00
}
2017-01-26 07:28:34 +00:00
return cdp.ErrUnknownResult
2017-01-24 15:09:23 +00:00
}
// 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:
2017-01-26 07:28:34 +00:00
// objectID - Identifier of the object to return listeners for.
func GetEventListeners(objectID runtime.RemoteObjectID) *GetEventListenersParams {
2017-01-24 15:09:23 +00:00
return &GetEventListenersParams{
2017-01-26 07:28:34 +00:00
ObjectID: objectID,
2017-01-24 15:09:23 +00:00
}
}
// 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.
2017-01-26 07:28:34 +00:00
func (p *GetEventListenersParams) Do(ctxt context.Context, h cdp.FrameHandler) (listeners []*EventListener, err error) {
2017-01-24 15:09:23 +00:00
if ctxt == nil {
ctxt = context.Background()
}
// marshal
buf, err := easyjson.Marshal(p)
if err != nil {
return nil, err
}
// execute
2017-01-26 07:28:34 +00:00
ch := h.Execute(ctxt, cdp.CommandDOMDebuggerGetEventListeners, easyjson.RawMessage(buf))
2017-01-24 15:09:23 +00:00
// read response
select {
case res := <-ch:
if res == nil {
2017-01-26 07:28:34 +00:00
return nil, cdp.ErrChannelClosed
2017-01-24 15:09:23 +00:00
}
switch v := res.(type) {
case easyjson.RawMessage:
// unmarshal
var r GetEventListenersReturns
err = easyjson.Unmarshal(v, &r)
if err != nil {
2017-01-26 07:28:34 +00:00
return nil, cdp.ErrInvalidResult
2017-01-24 15:09:23 +00:00
}
return r.Listeners, nil
case error:
return nil, v
}
case <-ctxt.Done():
2017-01-26 07:28:34 +00:00
return nil, cdp.ErrContextDone
2017-01-24 15:09:23 +00:00
}
2017-01-26 07:28:34 +00:00
return nil, cdp.ErrUnknownResult
2017-01-24 15:09:23 +00:00
}