Skip to content

[BUG] The clientX/Y values in drag events are always 0 in firefox #17761

Closed

Description

@kevin940726

Context:

  • Playwright Version: 1.26.1
  • Operating System: Mac
  • Node.js version: 16.14.0
  • Browser: Firefox

Code Snippet

const { expect, firefox } = require( '@playwright/test' );

( async function main() {
	const browser = await firefox.launch( {
		headless: false,
	} );
	const context = await browser.newContext();
	const page = await context.newPage();

	await page.setContent( `
		<button draggable="true">Drag me</button>
	` );

	const logs = await page.evaluateHandle( () => {
		const _logs = [];
		document.addEventListener( 'dragover', ( event ) => {
			_logs.push( {
				clientX: event.clientX,
				clientY: event.clientY,
				pageX: event.pageX,
				pageY: event.pageY,
				screenX: event.screenX,
				screenY: event.screenY,
			} );
		} );
		return _logs;
	} );
	const [ screenLeft, screenTop ] = await page.evaluate( () => [
		window.mozInnerScreenX,
		window.mozInnerScreenY,
	] );

	await page.hover( 'button' );

	await page.mouse.down();
	await page.mouse.move( 100, 100 );
	await page.mouse.up();

	expect( await logs.jsonValue() ).toEqual( [
		{
			clientX: 100,
			clientY: 100,
			pageX: 100,
			pageY: 100,
			screenX: screenLeft + 100,
			screenY: screenTop + 100,
		},
	] );
} )();

Describe the bug

The clientX, clientY, pageX, and pageY values returned in the drag events (dragover, drop, etc) are always 0 in Firefox. I'm not sure what happens here because they are showing correctly in the mouse events. Interestingly though, screenX and screenY are showing the correct values.

When I test the above code manually in a real browser (Firefox), it shows the correct values.

We're using those values in the dragover event to calculate some stuff in our app, and this bug is preventing us from testing them in Firefox. It's working fine in other browsers though (chromium, safari).

It might be worth noting that there's a long-standing bug in Firefox that might be related in some way?

Dmitry Gozman (@dgozman) I hope it's okay to tag you here as you had helped on similar issues before 😉 .

Activity

  1. dgozman commented on Nov 4, 2022

    @dgozman
    Collaborator

    This should be fixed in v1.28 with the latest Firefox roll #18559.

  2. eonhkao commented on May 10, 2024

    @eonhkao

    Are you sure this is fixed, still getting this error

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions