forked from chromedp/chromedp
/
events.go
128 lines (108 loc) · 5.07 KB
/
events.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
package page
// Code generated by chromedp-gen. DO NOT EDIT.
import (
cdp "github.com/knq/chromedp/cdp"
"github.com/knq/chromedp/cdp/runtime"
)
// EventDomContentEventFired [no description].
type EventDomContentEventFired struct {
Timestamp *cdp.MonotonicTime `json:"timestamp"`
}
// EventLoadEventFired [no description].
type EventLoadEventFired struct {
Timestamp *cdp.MonotonicTime `json:"timestamp"`
}
// EventFrameAttached fired when frame has been attached to its parent.
type EventFrameAttached struct {
FrameID cdp.FrameID `json:"frameId"` // Id of the frame that has been attached.
ParentFrameID cdp.FrameID `json:"parentFrameId"` // Parent frame identifier.
Stack *runtime.StackTrace `json:"stack,omitempty"` // JavaScript stack trace of when frame was attached, only set if frame initiated from script.
}
// EventFrameNavigated fired once navigation of the frame has completed.
// Frame is now associated with the new loader.
type EventFrameNavigated struct {
Frame *cdp.Frame `json:"frame"` // Frame object.
}
// EventFrameDetached fired when frame has been detached from its parent.
type EventFrameDetached struct {
FrameID cdp.FrameID `json:"frameId"` // Id of the frame that has been detached.
}
// EventFrameStartedLoading fired when frame has started loading.
type EventFrameStartedLoading struct {
FrameID cdp.FrameID `json:"frameId"` // Id of the frame that has started loading.
}
// EventFrameStoppedLoading fired when frame has stopped loading.
type EventFrameStoppedLoading struct {
FrameID cdp.FrameID `json:"frameId"` // Id of the frame that has stopped loading.
}
// EventFrameScheduledNavigation fired when frame schedules a potential
// navigation.
type EventFrameScheduledNavigation struct {
FrameID cdp.FrameID `json:"frameId"` // Id of the frame that has scheduled a navigation.
Delay float64 `json:"delay"` // Delay (in seconds) until the navigation is scheduled to begin. The navigation is not guaranteed to start.
Reason FrameScheduledNavigationReason `json:"reason"` // The reason for the navigation.
URL string `json:"url"` // The destination URL for the scheduled navigation.
}
// EventFrameClearedScheduledNavigation fired when frame no longer has a
// scheduled navigation.
type EventFrameClearedScheduledNavigation struct {
FrameID cdp.FrameID `json:"frameId"` // Id of the frame that has cleared its scheduled navigation.
}
// EventFrameResized [no description].
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"` // Message that will be displayed by the dialog.
Type DialogType `json:"type"` // Dialog type.
}
// EventJavascriptDialogClosed fired when a JavaScript initiated dialog
// (alert, confirm, prompt, or onbeforeunload) has been closed.
type EventJavascriptDialogClosed struct {
Result bool `json:"result"` // Whether dialog was confirmed.
}
// EventScreencastFrame compressed image data requested by the
// startScreencast.
type EventScreencastFrame struct {
Data string `json:"data"` // Base64-encoded compressed image.
Metadata *ScreencastFrameMetadata `json:"metadata"` // Screencast frame metadata.
SessionID int64 `json:"sessionId"` // Frame number.
}
// EventScreencastVisibilityChanged fired when the page with currently
// enabled screencast was shown or hidden .
type EventScreencastVisibilityChanged struct {
Visible bool `json:"visible"` // True if the page is visible.
}
// 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"` // Whether the navigation is taking place in the main frame or in a subframe.
IsRedirect bool `json:"isRedirect"` // Whether the navigation has encountered a server redirect or not.
NavigationID int64 `json:"navigationId"`
URL string `json:"url"` // URL of requested navigation.
}
// EventTypes all event types in the domain.
var EventTypes = []cdp.MethodType{
cdp.EventPageDomContentEventFired,
cdp.EventPageLoadEventFired,
cdp.EventPageFrameAttached,
cdp.EventPageFrameNavigated,
cdp.EventPageFrameDetached,
cdp.EventPageFrameStartedLoading,
cdp.EventPageFrameStoppedLoading,
cdp.EventPageFrameScheduledNavigation,
cdp.EventPageFrameClearedScheduledNavigation,
cdp.EventPageFrameResized,
cdp.EventPageJavascriptDialogOpening,
cdp.EventPageJavascriptDialogClosed,
cdp.EventPageScreencastFrame,
cdp.EventPageScreencastVisibilityChanged,
cdp.EventPageInterstitialShown,
cdp.EventPageInterstitialHidden,
cdp.EventPageNavigationRequested,
}