-
Notifications
You must be signed in to change notification settings - Fork 3.8k
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
base: main
Are you sure you want to change the base?
chore(bidi): pointerMove action needs to floor fractional values for x and y position #34191
Conversation
…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.
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); |
There was a problem hiding this comment.
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()
?
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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?
Test results for "tests 1"4 flaky37501 passed, 650 skipped Merge workflow run. |
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.