-
Notifications
You must be signed in to change notification settings - Fork 48
/
domain.go
248 lines (221 loc) · 9.99 KB
/
domain.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
241
242
243
244
245
246
247
248
// Code generated by cdpgen. DO NOT EDIT.
// Package emulation implements the Emulation domain. This domain emulates different environments for the page.
package emulation
import (
"context"
"github.com/mafredri/cdp/protocol/internal"
"github.com/mafredri/cdp/rpcc"
)
// domainClient is a client for the Emulation domain. This domain emulates different environments for the page.
type domainClient struct{ conn *rpcc.Conn }
// NewClient returns a client for the Emulation domain with the connection set to conn.
func NewClient(conn *rpcc.Conn) *domainClient {
return &domainClient{conn: conn}
}
// SetDeviceMetricsOverride invokes the Emulation method. 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).
func (d *domainClient) SetDeviceMetricsOverride(ctx context.Context, args *SetDeviceMetricsOverrideArgs) (err error) {
if args != nil {
err = rpcc.Invoke(ctx, "Emulation.setDeviceMetricsOverride", args, nil, d.conn)
} else {
err = rpcc.Invoke(ctx, "Emulation.setDeviceMetricsOverride", nil, nil, d.conn)
}
if err != nil {
err = &internal.OpError{Domain: "Emulation", Op: "SetDeviceMetricsOverride", Err: err}
}
return
}
// ClearDeviceMetricsOverride invokes the Emulation method. Clears the overridden device metrics.
func (d *domainClient) ClearDeviceMetricsOverride(ctx context.Context) (err error) {
err = rpcc.Invoke(ctx, "Emulation.clearDeviceMetricsOverride", nil, nil, d.conn)
if err != nil {
err = &internal.OpError{Domain: "Emulation", Op: "ClearDeviceMetricsOverride", Err: err}
}
return
}
// ResetPageScaleFactor invokes the Emulation method. Requests that page scale factor is reset to initial values.
func (d *domainClient) ResetPageScaleFactor(ctx context.Context) (err error) {
err = rpcc.Invoke(ctx, "Emulation.resetPageScaleFactor", nil, nil, d.conn)
if err != nil {
err = &internal.OpError{Domain: "Emulation", Op: "ResetPageScaleFactor", Err: err}
}
return
}
// SetPageScaleFactor invokes the Emulation method. Sets a specified page scale factor.
func (d *domainClient) SetPageScaleFactor(ctx context.Context, args *SetPageScaleFactorArgs) (err error) {
if args != nil {
err = rpcc.Invoke(ctx, "Emulation.setPageScaleFactor", args, nil, d.conn)
} else {
err = rpcc.Invoke(ctx, "Emulation.setPageScaleFactor", nil, nil, d.conn)
}
if err != nil {
err = &internal.OpError{Domain: "Emulation", Op: "SetPageScaleFactor", Err: err}
}
return
}
// SetVisibleSize invokes the Emulation method. 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.
func (d *domainClient) SetVisibleSize(ctx context.Context, args *SetVisibleSizeArgs) (err error) {
if args != nil {
err = rpcc.Invoke(ctx, "Emulation.setVisibleSize", args, nil, d.conn)
} else {
err = rpcc.Invoke(ctx, "Emulation.setVisibleSize", nil, nil, d.conn)
}
if err != nil {
err = &internal.OpError{Domain: "Emulation", Op: "SetVisibleSize", Err: err}
}
return
}
// SetScriptExecutionDisabled invokes the Emulation method. Switches script execution in the page.
func (d *domainClient) SetScriptExecutionDisabled(ctx context.Context, args *SetScriptExecutionDisabledArgs) (err error) {
if args != nil {
err = rpcc.Invoke(ctx, "Emulation.setScriptExecutionDisabled", args, nil, d.conn)
} else {
err = rpcc.Invoke(ctx, "Emulation.setScriptExecutionDisabled", nil, nil, d.conn)
}
if err != nil {
err = &internal.OpError{Domain: "Emulation", Op: "SetScriptExecutionDisabled", Err: err}
}
return
}
// SetGeolocationOverride invokes the Emulation method. Overrides the Geolocation Position or Error. Omitting any of the parameters emulates position unavailable.
func (d *domainClient) SetGeolocationOverride(ctx context.Context, args *SetGeolocationOverrideArgs) (err error) {
if args != nil {
err = rpcc.Invoke(ctx, "Emulation.setGeolocationOverride", args, nil, d.conn)
} else {
err = rpcc.Invoke(ctx, "Emulation.setGeolocationOverride", nil, nil, d.conn)
}
if err != nil {
err = &internal.OpError{Domain: "Emulation", Op: "SetGeolocationOverride", Err: err}
}
return
}
// ClearGeolocationOverride invokes the Emulation method. Clears the overridden Geolocation Position and Error.
func (d *domainClient) ClearGeolocationOverride(ctx context.Context) (err error) {
err = rpcc.Invoke(ctx, "Emulation.clearGeolocationOverride", nil, nil, d.conn)
if err != nil {
err = &internal.OpError{Domain: "Emulation", Op: "ClearGeolocationOverride", Err: err}
}
return
}
// SetTouchEmulationEnabled invokes the Emulation method. Enables touch on platforms which do not support them.
func (d *domainClient) SetTouchEmulationEnabled(ctx context.Context, args *SetTouchEmulationEnabledArgs) (err error) {
if args != nil {
err = rpcc.Invoke(ctx, "Emulation.setTouchEmulationEnabled", args, nil, d.conn)
} else {
err = rpcc.Invoke(ctx, "Emulation.setTouchEmulationEnabled", nil, nil, d.conn)
}
if err != nil {
err = &internal.OpError{Domain: "Emulation", Op: "SetTouchEmulationEnabled", Err: err}
}
return
}
// SetEmitTouchEventsForMouse invokes the Emulation method.
func (d *domainClient) SetEmitTouchEventsForMouse(ctx context.Context, args *SetEmitTouchEventsForMouseArgs) (err error) {
if args != nil {
err = rpcc.Invoke(ctx, "Emulation.setEmitTouchEventsForMouse", args, nil, d.conn)
} else {
err = rpcc.Invoke(ctx, "Emulation.setEmitTouchEventsForMouse", nil, nil, d.conn)
}
if err != nil {
err = &internal.OpError{Domain: "Emulation", Op: "SetEmitTouchEventsForMouse", Err: err}
}
return
}
// SetEmulatedMedia invokes the Emulation method. Emulates the given media for CSS media queries.
func (d *domainClient) SetEmulatedMedia(ctx context.Context, args *SetEmulatedMediaArgs) (err error) {
if args != nil {
err = rpcc.Invoke(ctx, "Emulation.setEmulatedMedia", args, nil, d.conn)
} else {
err = rpcc.Invoke(ctx, "Emulation.setEmulatedMedia", nil, nil, d.conn)
}
if err != nil {
err = &internal.OpError{Domain: "Emulation", Op: "SetEmulatedMedia", Err: err}
}
return
}
// SetCPUThrottlingRate invokes the Emulation method. Enables CPU throttling to emulate slow CPUs.
func (d *domainClient) SetCPUThrottlingRate(ctx context.Context, args *SetCPUThrottlingRateArgs) (err error) {
if args != nil {
err = rpcc.Invoke(ctx, "Emulation.setCPUThrottlingRate", args, nil, d.conn)
} else {
err = rpcc.Invoke(ctx, "Emulation.setCPUThrottlingRate", nil, nil, d.conn)
}
if err != nil {
err = &internal.OpError{Domain: "Emulation", Op: "SetCPUThrottlingRate", Err: err}
}
return
}
// CanEmulate invokes the Emulation method. Tells whether emulation is supported.
func (d *domainClient) CanEmulate(ctx context.Context) (reply *CanEmulateReply, err error) {
reply = new(CanEmulateReply)
err = rpcc.Invoke(ctx, "Emulation.canEmulate", nil, reply, d.conn)
if err != nil {
err = &internal.OpError{Domain: "Emulation", Op: "CanEmulate", Err: err}
}
return
}
// SetVirtualTimePolicy invokes the Emulation method. 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.
func (d *domainClient) SetVirtualTimePolicy(ctx context.Context, args *SetVirtualTimePolicyArgs) (err error) {
if args != nil {
err = rpcc.Invoke(ctx, "Emulation.setVirtualTimePolicy", args, nil, d.conn)
} else {
err = rpcc.Invoke(ctx, "Emulation.setVirtualTimePolicy", nil, nil, d.conn)
}
if err != nil {
err = &internal.OpError{Domain: "Emulation", Op: "SetVirtualTimePolicy", Err: err}
}
return
}
// SetNavigatorOverrides invokes the Emulation method. Overrides value returned by the javascript navigator object.
func (d *domainClient) SetNavigatorOverrides(ctx context.Context, args *SetNavigatorOverridesArgs) (err error) {
if args != nil {
err = rpcc.Invoke(ctx, "Emulation.setNavigatorOverrides", args, nil, d.conn)
} else {
err = rpcc.Invoke(ctx, "Emulation.setNavigatorOverrides", nil, nil, d.conn)
}
if err != nil {
err = &internal.OpError{Domain: "Emulation", Op: "SetNavigatorOverrides", Err: err}
}
return
}
// SetDefaultBackgroundColorOverride invokes the Emulation method. Sets or clears an override of the default background color of the frame. This override is used if the content does not specify one.
func (d *domainClient) SetDefaultBackgroundColorOverride(ctx context.Context, args *SetDefaultBackgroundColorOverrideArgs) (err error) {
if args != nil {
err = rpcc.Invoke(ctx, "Emulation.setDefaultBackgroundColorOverride", args, nil, d.conn)
} else {
err = rpcc.Invoke(ctx, "Emulation.setDefaultBackgroundColorOverride", nil, nil, d.conn)
}
if err != nil {
err = &internal.OpError{Domain: "Emulation", Op: "SetDefaultBackgroundColorOverride", Err: err}
}
return
}
func (d *domainClient) VirtualTimeBudgetExpired(ctx context.Context) (VirtualTimeBudgetExpiredClient, error) {
s, err := rpcc.NewStream(ctx, "Emulation.virtualTimeBudgetExpired", d.conn)
if err != nil {
return nil, err
}
return &virtualTimeBudgetExpiredClient{Stream: s}, nil
}
type virtualTimeBudgetExpiredClient struct{ rpcc.Stream }
func (c *virtualTimeBudgetExpiredClient) Recv() (*VirtualTimeBudgetExpiredReply, error) {
event := new(VirtualTimeBudgetExpiredReply)
if err := c.RecvMsg(event); err != nil {
return nil, &internal.OpError{Domain: "Emulation", Op: "VirtualTimeBudgetExpired Recv", Err: err}
}
return event, nil
}
func (d *domainClient) VirtualTimePaused(ctx context.Context) (VirtualTimePausedClient, error) {
s, err := rpcc.NewStream(ctx, "Emulation.virtualTimePaused", d.conn)
if err != nil {
return nil, err
}
return &virtualTimePausedClient{Stream: s}, nil
}
type virtualTimePausedClient struct{ rpcc.Stream }
func (c *virtualTimePausedClient) Recv() (*VirtualTimePausedReply, error) {
event := new(VirtualTimePausedReply)
if err := c.RecvMsg(event); err != nil {
return nil, &internal.OpError{Domain: "Emulation", Op: "VirtualTimePaused Recv", Err: err}
}
return event, nil
}