diff --git a/browser/mouse_mapping.go b/browser/mouse_mapping.go index 9f485dcd1..87c7abfcc 100644 --- a/browser/mouse_mapping.go +++ b/browser/mouse_mapping.go @@ -1,15 +1,37 @@ package browser import ( + "github.com/dop251/goja" "github.com/grafana/xk6-browser/common" + "github.com/grafana/xk6-browser/k6ext" ) -func mapMouse(_ moduleVU, m *common.Mouse) mapping { +func mapMouse(vu moduleVU, m *common.Mouse) mapping { return mapping{ - "click": m.Click, - "dblClick": m.DblClick, - "down": m.Down, - "up": m.Up, - "move": m.Move, + "click": func(x float64, y float64, opts goja.Value) *goja.Promise { + return k6ext.Promise(vu.Context(), func() (any, error) { + return nil, m.Click(x, y, opts) //nolint:wrapcheck + }) + }, + "dblClick": func(x float64, y float64, opts goja.Value) *goja.Promise { + return k6ext.Promise(vu.Context(), func() (any, error) { + return nil, m.DblClick(x, y, opts) //nolint:wrapcheck + }) + }, + "down": func(opts goja.Value) *goja.Promise { + return k6ext.Promise(vu.Context(), func() (any, error) { + return nil, m.Down(opts) //nolint:wrapcheck + }) + }, + "up": func(opts goja.Value) *goja.Promise { + return k6ext.Promise(vu.Context(), func() (any, error) { + return nil, m.Up(opts) //nolint:wrapcheck + }) + }, + "move": func(x float64, y float64, opts goja.Value) *goja.Promise { + return k6ext.Promise(vu.Context(), func() (any, error) { + return nil, m.Move(x, y, opts) //nolint:wrapcheck + }) + }, } }