-
Notifications
You must be signed in to change notification settings - Fork 42
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Cloud Insights Browser Audits PoC #1400
base: main
Are you sure you want to change the base?
Conversation
@@ -3,7 +3,7 @@ module github.com/grafana/xk6-browser | |||
go 1.20 | |||
|
|||
require ( | |||
github.com/chromedp/cdproto v0.0.0-20221023212508-67ada9507fb2 | |||
github.com/chromedp/cdproto v0.0.0-20240709201219-e202069cc16b |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I had to update the chromedp
package as it didn't have the newest CDP protocol's type definitions and Audits.issueAdded
events failed to unmarshal in session.go
:
Lines 85 to 101 in cd451af
ev, err := cdproto.UnmarshalMessage(msg) | |
if errors.Is(err, cdp.ErrUnknownCommandOrEvent("")) && msg.Method == "" { | |
// Results from commands may not always have methods in them. | |
// This is the reason of this error. So it's harmless. | |
// | |
// Also: | |
// This is most likely an event received from an older | |
// Chrome which a newer cdproto doesn't have, as it is | |
// deprecated. Ignore that error, and emit raw cdproto.Message. | |
s.emit("", msg) | |
continue | |
} | |
if err != nil { | |
s.logger.Debugf("Session:readLoop:<-s.readCh", "sid:%v tid:%v cannot unmarshal: %v", s.id, s.targetID, err) | |
continue | |
} | |
s.emit(string(msg.Method), ev) |
I simply updated to the newest version:
go get -u github.com/chromedp/chromedp
postData: func(ents []*network.PostDataEntry) string { | ||
var b bytes.Buffer | ||
for _, e := range ents { | ||
b.WriteString(e.Bytes) | ||
} | ||
return b.String() | ||
}(ev.Request.PostDataEntries), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The new cdproto
version removed the already deprecated PostData
field on network.Request
. Actually supporting the new protocol format could take some time. Not sure what this is used for and how hard it'd be upgrade at this point 🤔
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, updating cdproto
is fine for this PoC. However, updating cdproto
has some issues (as seen here) in general. We can do the update in a separate PR before this one so that we can ensure that the browser module is still stable after the update.
What?
This is a little PoC showcasing the possibility of enabling CDP's
Audits
domain and listening to associated issues for every page.To see it work:
Why?
N/A
Checklist
Related PR(s)/Issue(s)