From 94f7ab39f8f0db5b9e888e6ba56cfb8820d9205a Mon Sep 17 00:00:00 2001 From: Henrik Skupin Date: Thu, 2 Jan 2025 12:27:25 +0100 Subject: [PATCH 1/2] chore(bidi): pointerMove action needs to floor fractional values for x and y position. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit For elements that are only 1 pixel in size, rounding can cause the click to occur outside the element’s rect. For example, a 1px div at (8,8) would not be reached if the click is rounded to (9,9). --- packages/playwright-core/src/server/bidi/bidiInput.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/playwright-core/src/server/bidi/bidiInput.ts b/packages/playwright-core/src/server/bidi/bidiInput.ts index 3550051a6a71f..1273dd1705650 100644 --- a/packages/playwright-core/src/server/bidi/bidiInput.ts +++ b/packages/playwright-core/src/server/bidi/bidiInput.ts @@ -77,8 +77,8 @@ export class RawMouseImpl implements input.RawMouse { async move(x: number, y: number, button: types.MouseButton | 'none', buttons: Set, modifiers: Set, forClick: boolean): Promise { // Bidi throws when x/y are not integers. - x = Math.round(x); - y = Math.round(y); + x = Math.floor(x); + y = Math.floor(y); await this._performActions([{ type: 'pointerMove', x, y }]); } From 8af1764420525d9148b2049d0af23df784f83249 Mon Sep 17 00:00:00 2001 From: Henrik Skupin Date: Fri, 3 Jan 2025 10:23:03 +0100 Subject: [PATCH 2/2] Updated expectations --- tests/bidi/expectations/bidi-chromium-page.txt | 2 +- tests/bidi/expectations/bidi-firefox-nightly-page.txt | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/bidi/expectations/bidi-chromium-page.txt b/tests/bidi/expectations/bidi-chromium-page.txt index da2bee1fefd42..492d86bca8699 100644 --- a/tests/bidi/expectations/bidi-chromium-page.txt +++ b/tests/bidi/expectations/bidi-chromium-page.txt @@ -1170,7 +1170,7 @@ page/page-listeners.spec.ts › should not throw with ignoreErrors [pass] page/page-listeners.spec.ts › should wait [pass] page/page-listeners.spec.ts › wait should throw [pass] page/page-mouse.spec.ts › down and up should generate click [pass] -page/page-mouse.spec.ts › should always round down [fail] +page/page-mouse.spec.ts › should always round down [pass] page/page-mouse.spec.ts › should click the document @smoke [pass] page/page-mouse.spec.ts › should dblclick the div [pass] page/page-mouse.spec.ts › should dispatch mouse move after context menu was opened [pass] diff --git a/tests/bidi/expectations/bidi-firefox-nightly-page.txt b/tests/bidi/expectations/bidi-firefox-nightly-page.txt index f7e42922276b0..a9e9fb7fe83ee 100644 --- a/tests/bidi/expectations/bidi-firefox-nightly-page.txt +++ b/tests/bidi/expectations/bidi-firefox-nightly-page.txt @@ -1178,7 +1178,7 @@ page/page-listeners.spec.ts › should not throw with ignoreErrors [pass] page/page-listeners.spec.ts › should wait [pass] page/page-listeners.spec.ts › wait should throw [pass] page/page-mouse.spec.ts › down and up should generate click [pass] -page/page-mouse.spec.ts › should always round down [fail] +page/page-mouse.spec.ts › should always round down [pass] page/page-mouse.spec.ts › should click the document @smoke [pass] page/page-mouse.spec.ts › should dblclick the div [fail] page/page-mouse.spec.ts › should dispatch mouse move after context menu was opened [pass]