Skip to content
This repository was archived by the owner on Jan 30, 2025. It is now read-only.

Commit 56e4c94

Browse files
committed
Do not expose browser.on method
A decision was made to no longer expose browser.on method as it currently only supports 'disconnect' event, and that is non applicable after the changes made to abstract the browser initialization/closing procedures from the JS API in #910.
1 parent 6b21ec7 commit 56e4c94

File tree

2 files changed

+4
-9
lines changed

2 files changed

+4
-9
lines changed

browser/mapping.go

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -697,15 +697,6 @@ func mapBrowser(vu moduleVU, wsURL string, isRemoteBrowser bool) mapping { //nol
697697
}
698698
return b.IsConnected(), nil
699699
},
700-
"on": func(event string) *goja.Promise {
701-
return k6ext.Promise(vu.Context(), func() (result any, reason error) {
702-
b, err := getOrInitBrowser(ctx, bt, vu, wsURL, isRemoteBrowser)
703-
if err != nil {
704-
return nil, err
705-
}
706-
return b.On(event) //nolint:wrapcheck
707-
})
708-
},
709700
"newContext": func(opts goja.Value) (*goja.Object, error) {
710701
b, err := getOrInitBrowser(ctx, bt, vu, wsURL, isRemoteBrowser)
711702
if err != nil {

browser/mapping_test.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,10 @@ func customMappings() map[string]string {
4040
"Frame.loaderID": "",
4141
"JSHandle.objectID": "",
4242
"Browser.close": "",
43+
// TODO: browser.on method is unexposed until more event
44+
// types other than 'disconnect' are supported.
45+
// See: https://github.com/grafana/xk6-browser/issues/913
46+
"Browser.on": "",
4347
}
4448
}
4549

0 commit comments

Comments
 (0)