Closed Bug 1499360 Opened 7 years ago Closed 7 years ago

WebDriver:ElementClick unable to click 1x1 px element

Categories

(Remote Protocol :: Marionette, enhancement, P1)

enhancement

Tracking

(firefox65 fixed)

RESOLVED FIXED
mozilla65
Tracking Status
firefox65 --- fixed

People

(Reporter: ato, Assigned: ato)

References

(Blocks 1 open bug, )

Details

Attachments

(3 files)

See description and reproducible test case in https://github.com/mozilla/geckodriver/issues/1402 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 > 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: nobody → ato
Status: NEW → ASSIGNED
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 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
Product: Testing → Remote Protocol
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: