-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathbrowser.go
55 lines (49 loc) · 1.75 KB
/
browser.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
package cdp
import (
"context"
)
func (obj *WebSock) BrowserClose() error {
_, err := obj.send(obj.ctx, commend{
Method: "Browser.close",
})
return err
}
func (obj *WebSock) Cdp(ctx context.Context, sessid string, method string, params ...map[string]any) (RecvData, error) {
comd := commend{
SessionId: sessid,
Method: method,
}
if len(params) > 0 {
comd.Params = params[0]
}
return obj.send(ctx, comd)
}
// Browser.PermissionType
// Allowed Values: ar, audioCapture, automaticFullscreen, backgroundFetch, backgroundSync, cameraPanTiltZoom, capturedSurfaceControl, clipboardReadWrite, clipboardSanitizedWrite, displayCapture, durableStorage, geolocation, handTracking, idleDetection, keyboardLock, localFonts, midi, midiSysex, nfc, notifications, paymentHandler, periodicBackgroundSync, pointerLock, protectedMediaIdentifier, sensors, smartCard, speakerSelection, storageAccess, topLevelStorageAccess, videoCapture, vr, wakeLockScreen, wakeLockSystem, webAppInstallation, webPrinting, windowManagement
func (obj *WebSock) BrowserSetPermission(ctx context.Context, permission string, setting string, origins ...string) error {
params := map[string]any{
"permission": permission,
"setting": setting,
}
if len(origins) > 0 {
params["origin"] = origins[0]
}
_, err := obj.send(ctx, commend{
Method: "Browser.setPermission",
Params: params,
})
return err
}
func (obj *WebSock) BrowserGrantPermissions(ctx context.Context, permissions []string, origins ...string) error {
params := map[string]any{
"permissions": permissions,
}
if len(origins) > 0 {
params["origin"] = origins[0]
}
_, err := obj.send(ctx, commend{
Method: "Browser.grantPermissions",
Params: params,
})
return err
}