WebDriver:ElementClick unable to click 1x1 px element

RESOLVED FIXED in Firefox 65

Status

enhancement
P1
normal
RESOLVED FIXED
7 months ago
11 days ago

People

(Reporter: ato, Assigned: ato)

Tracking

(Blocks 2 bugs, Regressed 1 bug)

Trunk
mozilla65
Points:
---
Dependency tree / graph

Firefox Tracking Flags

(firefox65 fixed)

Details

(URL)

Attachments

(3 attachments)

(Assignee)

Description

7 months ago
See description and reproducible test case in
https://github.com/mozilla/geckodriver/issues/1402

This could also be a specification problem.
(Assignee)

Updated

7 months ago
(Assignee)

Comment 1

7 months ago
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).
(Assignee)

Comment 3

7 months ago
(In reply to Henrik Skupin (:whimboo) from comment #2)

> That reminds me at
> https://stackoverflow.com/questions/10825926/python-3-x-rounding-behavior
> 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)

Updated

7 months ago
Assignee: nobody → ato
Status: NEW → ASSIGNED
Priority: P2 → P1
(Assignee)

Comment 4

7 months ago
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.
(Assignee)

Comment 5

7 months ago
These tests are not exhaustive, but covers some of the main use
cases and known edge cases.

Depends on D8880

Comment 7

7 months ago
Pushed by atolfsen@mozilla.com:
https://hg.mozilla.org/integration/autoland/rev/ae99f2ef9464
marionette: convert in-view centre point to css pixels; r=whimboo
https://hg.mozilla.org/integration/autoland/rev/d51f52d435da
webdriver: write in-view centre point tests; r=whimboo
https://hg.mozilla.org/integration/autoland/rev/6afa28099f1e
webdriver: add interactability test for zero-sized element; r=whimboo
Created web-platform-tests PR https://github.com/web-platform-tests/wpt/pull/13655 for changes under testing/web-platform/tests
Upstream PR merged
You need to log in before you can comment on or make changes to this bug.