-
Notifications
You must be signed in to change notification settings - Fork 33
/
Copy pathdebugger.go
69 lines (56 loc) · 1.84 KB
/
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
package chrome
import "github.com/gopherjs/gopherjs/js"
type Debugger struct {
o *js.Object
}
/*
* Types
*/
type Debugee struct {
*js.Object
TabId int `js:"tabId"`
ExtensionId string `js:"extensionId"`
TargetId string `js:"targetId"`
}
type TargetInfo struct {
*js.Object
Type string `js:"type"`
Id string `js:"id"`
TabId int `js:"tabId"`
ExtensionId string `js:"extensionId"`
Attached bool `js:"attached"`
Title string `js:"title"`
Url string `js:"url"`
FaviconUrl string `js:"faviconUrl"`
}
/*
* Methods:
*/
// Attach attaches debugger to the given target.
func (d *Debugger) Attach(target Debugee, requiredVersion string, callback func()) {
d.o.Call("attach", target, requiredVersion, callback)
}
// Detach detaches debugger from the given target.
func (d *Debugger) Detach(target Debugee, callback func()) {
d.o.Call("detach", target, callback)
}
// SendCommand sends given command to the debugging target.
func (d *Debugger) SendCommand(target Debugee, method string, commandParams Object, callback func(result Object)) {
d.o.Call("sendCommand", target, method, commandParams, callback)
}
// GetTargets returns the list of available debug targets.
func (d *Debugger) GetTargets(callback func(result []TargetInfo)) {
d.o.Call("getTargets", callback)
}
/*
* Events
*/
// OnEvent fired whenever debugging target issues instrumentation event.
func (d *Debugger) OnEvent(callback func(source Debugee, method string, params Object)) {
d.o.Get("onEvent").Call("addListener", callback)
}
// OnDetach fired when browser terminates debugging session for the tab. This happens when
// either the tab is being closed or Chrome DevTools is being invoked for the attached tab.
func (d *Debugger) OnDetach(callback func(source Debugee, reason string)) {
d.o.Get("onDetach").Call("addListener", callback)
}