Skip to content

Commit

Permalink
chore: wheel input in bidi (#32499)
Browse files Browse the repository at this point in the history
  • Loading branch information
yury-s committed Sep 7, 2024
1 parent 37bc485 commit f3ada9c
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion packages/playwright-core/src/server/bidi/bidiInput.ts
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ 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> {
// TODO: bidi throws when x/y are not integers.
// Bidi throws when x/y are not integers.
x = Math.round(x);
y = Math.round(y);
await this._performActions([{ type: 'pointerMove', x, y }]);
Expand All @@ -91,6 +91,19 @@ export class RawMouseImpl implements input.RawMouse {
}

async wheel(x: number, y: number, buttons: Set<types.MouseButton>, modifiers: Set<types.KeyboardModifier>, deltaX: number, deltaY: number): Promise<void> {
// Bidi throws when x/y are not integers.
x = Math.round(x);
y = Math.round(y);
await this._session.send('input.performActions', {
context: this._session.sessionId,
actions: [
{
type: 'wheel',
id: 'pw_mouse_wheel',
actions: [{ type: 'scroll', x, y, deltaX, deltaY }],
}
]
});
}

private async _performActions(actions: bidi.Input.PointerSourceAction[]) {
Expand Down

0 comments on commit f3ada9c

Please sign in to comment.