forked from mkenney/go-chrome
/
cdtp.dom.debugger.go
240 lines (200 loc) · 7.34 KB
/
cdtp.dom.debugger.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
package socket
import (
"encoding/json"
"github.com/mkenney/go-chrome/tot/dom/debugger"
)
/*
DOMDebuggerProtocol provides a namespace for the Chrome DOMDebugger protocol
methods. The DOMDebugger protocol allows setting breakpoints on particular DOM
operations and events. JavaScript execution will stop on these operations as if
there was a regular breakpoint set.
https://chromedevtools.github.io/devtools-protocol/tot/DOMDebugger/
*/
type DOMDebuggerProtocol struct {
Socket Socketer
}
/*
GetEventListeners returns event listeners of the given object.
https://chromedevtools.github.io/devtools-protocol/tot/DOMDebugger/#method-getEventListeners
*/
func (protocol *DOMDebuggerProtocol) GetEventListeners(
params *debugger.GetEventListenersParams,
) <-chan *debugger.GetEventListenersResult {
resultChan := make(chan *debugger.GetEventListenersResult)
command := NewCommand(protocol.Socket, "DOMDebugger.getEventListeners", params)
result := &debugger.GetEventListenersResult{}
go func() {
response := <-protocol.Socket.SendCommand(command)
if nil != response.Error && 0 != response.Error.Code {
result.Err = response.Error
} else {
result.Err = json.Unmarshal(response.Result, &result)
}
resultChan <- result
close(resultChan)
}()
return resultChan
}
/*
RemoveDOMBreakpoint removes the DOM breakpoint that was set using
setDOMBreakpoint.
https://chromedevtools.github.io/devtools-protocol/tot/DOMDebugger/#method-removeDOMBreakpoint
*/
func (protocol *DOMDebuggerProtocol) RemoveDOMBreakpoint(
params *debugger.RemoveDOMBreakpointParams,
) <-chan *debugger.RemoveDOMBreakpointResult {
resultChan := make(chan *debugger.RemoveDOMBreakpointResult)
command := NewCommand(protocol.Socket, "DOMDebugger.removeDOMBreakpoint", params)
result := &debugger.RemoveDOMBreakpointResult{}
go func() {
response := <-protocol.Socket.SendCommand(command)
if nil != response.Error && 0 != response.Error.Code {
result.Err = response.Error
}
resultChan <- result
close(resultChan)
}()
return resultChan
}
/*
RemoveEventListenerBreakpoint removes breakpoint on particular DOM event.
https://chromedevtools.github.io/devtools-protocol/tot/DOMDebugger/#method-removeEventListenerBreakpoint
*/
func (protocol *DOMDebuggerProtocol) RemoveEventListenerBreakpoint(
params *debugger.RemoveEventListenerBreakpointParams,
) <-chan *debugger.RemoveEventListenerBreakpointResult {
resultChan := make(chan *debugger.RemoveEventListenerBreakpointResult)
command := NewCommand(protocol.Socket, "DOMDebugger.removeEventListenerBreakpoint", params)
result := &debugger.RemoveEventListenerBreakpointResult{}
go func() {
response := <-protocol.Socket.SendCommand(command)
if nil != response.Error && 0 != response.Error.Code {
result.Err = response.Error
}
resultChan <- result
close(resultChan)
}()
return resultChan
}
/*
RemoveInstrumentationBreakpoint removes breakpoint on particular native event.
https://chromedevtools.github.io/devtools-protocol/tot/DOMDebugger/#method-removeInstrumentationBreakpoint
EXPERIMENTAL.
*/
func (protocol *DOMDebuggerProtocol) RemoveInstrumentationBreakpoint(
params *debugger.RemoveInstrumentationBreakpointParams,
) <-chan *debugger.RemoveInstrumentationBreakpointResult {
resultChan := make(chan *debugger.RemoveInstrumentationBreakpointResult)
command := NewCommand(protocol.Socket, "DOMDebugger.removeInstrumentationBreakpoint", params)
result := &debugger.RemoveInstrumentationBreakpointResult{}
go func() {
response := <-protocol.Socket.SendCommand(command)
if nil != response.Error && 0 != response.Error.Code {
result.Err = response.Error
}
resultChan <- result
close(resultChan)
}()
return resultChan
}
/*
RemoveXHRBreakpoint removes breakpoint from XMLHttpRequest.
https://chromedevtools.github.io/devtools-protocol/tot/DOMDebugger/#method-removeXHRBreakpoint
*/
func (protocol *DOMDebuggerProtocol) RemoveXHRBreakpoint(
params *debugger.RemoveXHRBreakpointParams,
) <-chan *debugger.RemoveXHRBreakpointResult {
resultChan := make(chan *debugger.RemoveXHRBreakpointResult)
command := NewCommand(protocol.Socket, "DOMDebugger.removeXHRBreakpoint", params)
result := &debugger.RemoveXHRBreakpointResult{}
go func() {
response := <-protocol.Socket.SendCommand(command)
if nil != response.Error && 0 != response.Error.Code {
result.Err = response.Error
}
resultChan <- result
close(resultChan)
}()
return resultChan
}
/*
SetDOMBreakpoint sets a breakpoint on a particular operation with DOM.
https://chromedevtools.github.io/devtools-protocol/tot/DOMDebugger/#method-setDOMBreakpoint
*/
func (protocol *DOMDebuggerProtocol) SetDOMBreakpoint(
params *debugger.SetDOMBreakpointParams,
) <-chan *debugger.SetDOMBreakpointResult {
resultChan := make(chan *debugger.SetDOMBreakpointResult)
command := NewCommand(protocol.Socket, "DOMDebugger.setDOMBreakpoint", params)
result := &debugger.SetDOMBreakpointResult{}
go func() {
response := <-protocol.Socket.SendCommand(command)
if nil != response.Error && 0 != response.Error.Code {
result.Err = response.Error
}
resultChan <- result
close(resultChan)
}()
return resultChan
}
/*
SetEventListenerBreakpoint sets the breakpoint on a particular DOM event.
https://chromedevtools.github.io/devtools-protocol/tot/DOMDebugger/#method-setEventListenerBreakpoint
*/
func (protocol *DOMDebuggerProtocol) SetEventListenerBreakpoint(
params *debugger.SetEventListenerBreakpointParams,
) <-chan *debugger.SetEventListenerBreakpointResult {
resultChan := make(chan *debugger.SetEventListenerBreakpointResult)
command := NewCommand(protocol.Socket, "DOMDebugger.setEventListenerBreakpoint", params)
result := &debugger.SetEventListenerBreakpointResult{}
go func() {
response := <-protocol.Socket.SendCommand(command)
if nil != response.Error && 0 != response.Error.Code {
result.Err = response.Error
}
resultChan <- result
close(resultChan)
}()
return resultChan
}
/*
SetInstrumentationBreakpoint sets breakpoint on particular native event.
https://chromedevtools.github.io/devtools-protocol/tot/DOMDebugger/#method-setInstrumentationBreakpoint
EXPERIMENTAL.
*/
func (protocol *DOMDebuggerProtocol) SetInstrumentationBreakpoint(
params *debugger.SetInstrumentationBreakpointParams,
) <-chan *debugger.SetInstrumentationBreakpointResult {
resultChan := make(chan *debugger.SetInstrumentationBreakpointResult)
command := NewCommand(protocol.Socket, "DOMDebugger.setInstrumentationBreakpoint", params)
result := &debugger.SetInstrumentationBreakpointResult{}
go func() {
response := <-protocol.Socket.SendCommand(command)
if nil != response.Error && 0 != response.Error.Code {
result.Err = response.Error
}
resultChan <- result
close(resultChan)
}()
return resultChan
}
/*
SetXHRBreakpoint sets breakpoint on XMLHttpRequest.
https://chromedevtools.github.io/devtools-protocol/tot/DOMDebugger/#method-setXHRBreakpoint
*/
func (protocol *DOMDebuggerProtocol) SetXHRBreakpoint(
params *debugger.SetXHRBreakpointParams,
) <-chan *debugger.SetXHRBreakpointResult {
resultChan := make(chan *debugger.SetXHRBreakpointResult)
command := NewCommand(protocol.Socket, "DOMDebugger.setXHRBreakpoint", params)
result := &debugger.SetXHRBreakpointResult{}
go func() {
response := <-protocol.Socket.SendCommand(command)
if nil != response.Error && 0 != response.Error.Code {
result.Err = response.Error
}
resultChan <- result
close(resultChan)
}()
return resultChan
}