Open Bug 1248300 Opened 8 years ago Updated 2 years ago

Mousemove event returning incorrect mouse coordinates

Categories

(Core :: DOM: Events, defect, P5)

defect

Tracking

()

People

(Reporter: particlecore, Unassigned)

References

Details

Attachments

(1 file)

User Agent: Mozilla/5.0 (Windows NT 6.1; Win64; x64; rv:44.0) Gecko/20100101 Firefox/44.0
Build ID: 20160210153822

Steps to reproduce:

Open a window via javascript:

window.open("about:blank", "window", "width=300,height=300,scrollbars=0");

In the new window console enter the following:

function windowDrag(e) {
    if (e.which === 1) {
        if (e.type === "mousedown") {
            document.addEventListener("mousemove", windowDrag);
            document.addEventListener("click", windowDrag, true);
        } else if (e.type === "mousemove") {
            e.preventDefault();
            e.stopPropagation();
            window.moveBy(e.movementX, e.movementY);
            window.hasMoved = true;
        } else if (window.hasMoved) {
            delete window.hasMoved;
            e.preventDefault();
            e.stopImmediatePropagation();
        }
    }
    if (e.which === 0 || e.type === "click") {
        document.removeEventListener("mousemove", windowDrag);
        document.removeEventListener("click", windowDrag, true);
    }
}
document.addEventListener("mousedown", windowDrag);


Inside the window's page click and move around.

This has been tested with newclientX - oldclientX and newscreenX - oldscreenX as well with exactly the same results.


Actual results:

The following is a recording showing what should happen if the coordinates returned were correct vs the current behavior (left is in a Chrome window, right is in a Firefox window), both windows use the exact same code mentioned above:

https://streamable.com/ff1b

The movement is diminished (moves one pixel for each 2 or 3 pixels of mouse movement) and very jerky.

In Nightly the behavior is even worse, at the slightest movement the window is shot to the sides of the monitor.


Expected results:

It should move the window in sync with the mouse position as if the window as being moved via the titlebar, it is making use of the global mouse coordinates through moveBy so these should be accurate, which they are not, especially in current Nightly version 47.0a1 (2016-02-14) which is returning extremelly innacurate coordinates.
Component: Untriaged → DOM: Events
Product: Firefox → Core
Attached file reporter's testcase
I can reproduce on latest Nightly47.0a1 on Windows7

https://hg.mozilla.org/mozilla-central/rev/e355cacefc881ba360d412853b57e8e060e966f4
Mozilla/5.0 (Windows NT 6.1; WOW64; rv:47.0) Gecko/20100101 Firefox/47.0 ID:20160214030236
Blocks: 1164981
Status: UNCONFIRMED → NEW
Ever confirmed: true
Version: 44 Branch → Trunk
Flags: needinfo?(bugs)
Flags: needinfo?(bugs)
Priority: -- → P5

I know this bug is old, but I encountered the same problem while working on a CodePen. I've created a CodePen that illustrates the problem with as little code as possible.

For me, I keep seeing the coordinates jump to the upper left corner of the bounding box (this seems to happen regardless of the event target being the window, document, or a DOM node). I've tested both in version 83 and Nightly (Windows 10 and Manjaro) and gotten the exact same results. As particlecore mentioned, this doesn't happen in Chromium based browsers on the same device.

Severity: normal → S3
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: