From 1fbff60f64a7483b18ef60796caec67c634d4da9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C4=B0nan=C3=A7=20G=C3=BCm=C3=BC=C5=9F?= Date: Mon, 22 Apr 2024 16:12:02 +0300 Subject: [PATCH] Make Touchscreen.Tap async --- browser/mapping.go | 8 ++++++-- browser/mapping_test.go | 2 +- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/browser/mapping.go b/browser/mapping.go index 0ff22b55e..9697af4ce 100644 --- a/browser/mapping.go +++ b/browser/mapping.go @@ -789,9 +789,13 @@ func mapPage(vu moduleVU, p *common.Page) mapping { } // mapTouchscreen to the JS module. -func mapTouchscreen(_ moduleVU, ts *common.Touchscreen) mapping { +func mapTouchscreen(vu moduleVU, ts *common.Touchscreen) mapping { return mapping{ - "tap": ts.Tap, + "tap": func(x float64, y float64) *goja.Promise { + return k6ext.Promise(vu.Context(), func() (result any, reason error) { + return nil, ts.Tap(x, y) //nolint:wrapcheck + }) + }, } } diff --git a/browser/mapping_test.go b/browser/mapping_test.go index 4e3b2e344..316b825b9 100644 --- a/browser/mapping_test.go +++ b/browser/mapping_test.go @@ -527,7 +527,7 @@ type keyboardAPI interface { //nolint: unused // touchscreenAPI is the interface of a touchscreen. type touchscreenAPI interface { - Tap(x float64, y float64) error + Tap(x float64, y float64) *goja.Promise } // mouseAPI is the interface of a mouse input device.