Closed Bug 1499360 Opened 6 years ago Closed 6 years ago

WebDriver:ElementClick unable to click 1x1 px element


(Remote Protocol :: Marionette, enhancement, P1)



(firefox65 fixed)

Tracking Status
firefox65 --- fixed


(Reporter: ato, Assigned: ato)


(Blocks 1 open bug, )



(3 files)

See description and reproducible test case in

This could also be a specification problem.
I did some investigation into this and it looks like a rounding
error in the specification.  When the element has an odd shape that
can’t be divided in two without a precision point, it fails to ceil
the centre point to the nearest integer.

For example, given a 1x1 rectangle the centre point would be at
(0.5,0.5).  The click synthesise code will accept this input and
pass it on to the event queue without question, but since it is not
a valid pixel it ceils the coordinates and instead clicks (0,0).
Conversely, if the rectangle is 9x9 where the centre point is
(4.5,4.5) it will click (5,5).
(In reply to Henrik Skupin (:whimboo) from comment #2)

> That reminds me at
> whereby this is Javascript.

I’m glad you told me about that because I was just writing a
(Python) WPT test case that ran into this problem.  Using the math
to call out which way to round seems to work fine though.
Assignee: nobody → ato
Priority: P2 → P1
When the in-view centre point contains a floating point, we need to
ensure to convert it to CSS pixels before passing it on to Gecko internals
such as DOMElement.elementsFromPoint and DOMWindowUtils.sendMouseEvent.

For example, with a click target that is a 1x1 square, the in-view
centre point prior to this patch was calculated to (0.5,0.5).
elementsFromPoint will (correctly?) round this coordinate down and
return the paint tree for the DOM element at (0,0) coordinates.

By contrast, sendMouseEvent will click coordinates (1,1) because it
rounds up.  To make sure we all speak the same language internally,
we round the centre point down.
These tests are not exhaustive, but covers some of the main use
cases and known edge cases.

Depends on D8880
Pushed by
marionette: convert in-view centre point to css pixels; r=whimboo
webdriver: write in-view centre point tests; r=whimboo
webdriver: add interactability test for zero-sized element; r=whimboo
Created web-platform-tests PR for changes under testing/web-platform/tests
Product: Testing → Remote Protocol
You need to log in before you can comment on or make changes to this bug.