google-chromeiframechromiummouseup

Mouseup lost when leaving iframe: leads to reversed input


TL;DR question:

How can some javascript tell the window that the mouse button has been released? The mouseup event is being lost because of a cross-domain iframe. I can detect that the problem has happened but I don't know what to do to cure it. If I could force the mouse pointer position, the problem would go away; but no javascript is allowed to change the mouse pointer position. If I could "fire a mouseup" then the problem would go away, because it would replace the lost mouseup event; but using dispatchEvent on a new mouseup event does nothing.

Situation:

Important restrictions:

Triggering the problem:

Another way of making reverse inserted text happen:

Perceived symptom:

Related symptoms:

Again, I emphasize that ONLY CHROME has this behavior. Doing the exact same thing in Firefox, Edge, or IE, the mouse button release is detected immediately no matter where the mouse pointer is.

Workarounds tried:

Catching the lost mouseup event:

By attaching an event handler to the <body> in the outer document, I can catch the mouseup. I can then use standard postMessage technique to tell the inner iframe window that the mouseup happened. The inner iframe knows what element was active during the drag, so that's good. However, I'm having no luck whatsoever at actually simulating the mouseup event. I've tried the triggerMouseEvent technique here. It runs without error, but it does not apparently do anything. Demonstration here has the minimal example from above, plus the plumbing to capture the mouseup in the outer document, post a message to the inner one, and call triggerMouseEvent: Demo2 LINK NO LONGER VALID

Another weird possibility

While trying to create the minimal examples, I discovered that maybe the box model is involved somehow. Demo1a LINK NO LONGER VALID is identical to demo1 above, except that the iframe element has a height of 710px instead of 700px. On my test machines this eliminates the bug. On my colleague's test machine, the bug remains.

Possible related tracked Chromium issue:

EDIT 2018-09-25

I have submitted Chromium issue #882491. It has not yet seen any real activity.

EDIT 2020-08-31

Since I have left the company I was working at, the demo links are no longer valid.


Solution

  • This bug is already fixed in Chrome 70, which has been announced to release October 16, 2018. I have already tested with Chrome 70 in the beta channel and I confirm that it was indeed fixed.