diff --git a/browser/mapping.go b/browser/mapping.go index 7bac135f5..0ff22b55e 100644 --- a/browser/mapping.go +++ b/browser/mapping.go @@ -709,7 +709,7 @@ func mapPage(vu moduleVU, p *common.Page) mapping { "throttleCPU": p.ThrottleCPU, "throttleNetwork": p.ThrottleNetwork, "title": p.Title, - "touchscreen": rt.ToValue(p.GetTouchscreen()).ToObject(rt), + "touchscreen": mapTouchscreen(vu, p.GetTouchscreen()), "type": p.Type, "uncheck": p.Uncheck, "url": p.URL, @@ -788,6 +788,13 @@ func mapPage(vu moduleVU, p *common.Page) mapping { return maps } +// mapTouchscreen to the JS module. +func mapTouchscreen(_ moduleVU, ts *common.Touchscreen) mapping { + return mapping{ + "tap": ts.Tap, + } +} + // mapWorker to the JS module. func mapWorker(vu moduleVU, w *common.Worker) mapping { return mapping{ diff --git a/browser/mapping_test.go b/browser/mapping_test.go index fefc98ccc..4e3b2e344 100644 --- a/browser/mapping_test.go +++ b/browser/mapping_test.go @@ -193,6 +193,12 @@ func TestMappings(t *testing.T) { return mapConsoleMessage(moduleVU{VU: vu}, &common.ConsoleMessage{}) }, }, + "mapTouchscreen": { + apiInterface: (*touchscreenAPI)(nil), + mapp: func() mapping { + return mapTouchscreen(moduleVU{VU: vu}, &common.Touchscreen{}) + }, + }, } { tt := tt t.Run(name, func(t *testing.T) { @@ -520,10 +526,7 @@ type keyboardAPI interface { //nolint: unused } // touchscreenAPI is the interface of a touchscreen. -// TODO: map this to page.GetTouchscreen(). Currently, the common.TouchscreenAPI type -// mapping is not tested using this interface. We use the concrete type -// without testing its exported methods. -type touchscreenAPI interface { //nolint: unused +type touchscreenAPI interface { Tap(x float64, y float64) error }