/
domain.go
92 lines (79 loc) · 3.09 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
// Code generated by cdpgen. DO NOT EDIT.
// Package audits implements the Audits domain. Audits domain allows
// investigation of page violations and possible improvements.
package audits
import (
"context"
"github.com/mafredri/cdp/protocol/internal"
"github.com/mafredri/cdp/rpcc"
)
// domainClient is a client for the Audits domain. Audits domain allows
// investigation of page violations and possible improvements.
type domainClient struct{ conn *rpcc.Conn }
// NewClient returns a client for the Audits domain with the connection set to conn.
func NewClient(conn *rpcc.Conn) *domainClient {
return &domainClient{conn: conn}
}
// GetEncodedResponse invokes the Audits method. Returns the response body and
// size if it were re-encoded with the specified settings. Only applies to
// images.
func (d *domainClient) GetEncodedResponse(ctx context.Context, args *GetEncodedResponseArgs) (reply *GetEncodedResponseReply, err error) {
reply = new(GetEncodedResponseReply)
if args != nil {
err = rpcc.Invoke(ctx, "Audits.getEncodedResponse", args, reply, d.conn)
} else {
err = rpcc.Invoke(ctx, "Audits.getEncodedResponse", nil, reply, d.conn)
}
if err != nil {
err = &internal.OpError{Domain: "Audits", Op: "GetEncodedResponse", Err: err}
}
return
}
// Disable invokes the Audits method. Disables issues domain, prevents further
// issues from being reported to the client.
func (d *domainClient) Disable(ctx context.Context) (err error) {
err = rpcc.Invoke(ctx, "Audits.disable", nil, nil, d.conn)
if err != nil {
err = &internal.OpError{Domain: "Audits", Op: "Disable", Err: err}
}
return
}
// Enable invokes the Audits method. Enables issues domain, sends the issues
// collected so far to the client by means of the `issueAdded` event.
func (d *domainClient) Enable(ctx context.Context) (err error) {
err = rpcc.Invoke(ctx, "Audits.enable", nil, nil, d.conn)
if err != nil {
err = &internal.OpError{Domain: "Audits", Op: "Enable", Err: err}
}
return
}
// CheckContrast invokes the Audits method. Runs the contrast check for the
// target page. Found issues are reported using Audits.issueAdded event.
func (d *domainClient) CheckContrast(ctx context.Context, args *CheckContrastArgs) (err error) {
if args != nil {
err = rpcc.Invoke(ctx, "Audits.checkContrast", args, nil, d.conn)
} else {
err = rpcc.Invoke(ctx, "Audits.checkContrast", nil, nil, d.conn)
}
if err != nil {
err = &internal.OpError{Domain: "Audits", Op: "CheckContrast", Err: err}
}
return
}
func (d *domainClient) IssueAdded(ctx context.Context) (IssueAddedClient, error) {
s, err := rpcc.NewStream(ctx, "Audits.issueAdded", d.conn)
if err != nil {
return nil, err
}
return &issueAddedClient{Stream: s}, nil
}
type issueAddedClient struct{ rpcc.Stream }
// GetStream returns the original Stream for use with cdp.Sync.
func (c *issueAddedClient) GetStream() rpcc.Stream { return c.Stream }
func (c *issueAddedClient) Recv() (*IssueAddedReply, error) {
event := new(IssueAddedReply)
if err := c.RecvMsg(event); err != nil {
return nil, &internal.OpError{Domain: "Audits", Op: "IssueAdded Recv", Err: err}
}
return event, nil
}