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

Conversation

whimboo
Copy link
Contributor

@whimboo whimboo commented Jan 2, 2025

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).

This will fix the test page/page-click.spec.ts :: should click the aligned 1x1 div.

@yury-s can you please review? Thanks.

…x and y position.

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).

This comment has been minimized.

@@ -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?

Copy link
Contributor

github-actions bot commented Jan 3, 2025

Test results for "tests 1"

4 flaky ⚠️ [firefox-page] › page/page-evaluate.spec.ts:403:3 › should throw for too deep reference chain @firefox-ubuntu-22.04-node18
⚠️ [webkit-library] › library/browsertype-connect.spec.ts:187:5 › run-server › should be able to visit ipv6 through localhost @webkit-ubuntu-22.04-node18
⚠️ [webkit-library] › library/selector-generator.spec.ts:215:5 › selector generator › should use internal:has-text with regexp with a quote @webkit-ubuntu-22.04-node18
⚠️ [webkit-page] › page/page-set-input-files.spec.ts:245:3 › should upload large file with relative path @webkit-ubuntu-22.04-node18

37501 passed, 650 skipped
✔️✔️✔️

Merge workflow run.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants