Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore(bidi): pointerMove action needs to floor fractional values for x and y position #34191

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions packages/playwright-core/src/server/bidi/bidiInput.ts
Original file line number Diff line number Diff line change
Expand Up @@ -77,8 +77,8 @@ export class RawMouseImpl implements input.RawMouse {

async move(x: number, y: number, button: types.MouseButton | 'none', buttons: Set<types.MouseButton>, modifiers: Set<types.KeyboardModifier>, forClick: boolean): Promise<void> {
// Bidi throws when x/y are not integers.
x = Math.round(x);
y = Math.round(y);
x = Math.floor(x);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is already a block that fixes the same problem for Firefox, accounting for all kinds of oddly shaped elements: https://github.com/microsoft/playwright/blob/main/packages/playwright-core/src/server/dom.ts#L269. Perhaps we should generalize that check through PageDelegate.shouldClickAtIntegerCoordinates()?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This referenced command in the DOM module is using Content Quads to calculate the position. This is a feature that is not yet supported in WebDriver BiDi. So I feel it might be inappropriate to be used right now. If you agree I could at least add a comment to my changes to reference that other method for future adaption once quads are supported.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Even though content quads are not supported in BiDi yet, there is a polyfill in BidiPage for it. Otherwise, click won't work in Playwright at all. Therefore, we can still assume there are some content quads available and perform smart integer rounding, wdyt?

y = Math.floor(y);
await this._performActions([{ type: 'pointerMove', x, y }]);
}

Expand Down
2 changes: 1 addition & 1 deletion tests/bidi/expectations/bidi-chromium-page.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down
2 changes: 1 addition & 1 deletion tests/bidi/expectations/bidi-firefox-nightly-page.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down
Loading