Open Bug 1681647 Opened 4 years ago Updated 2 years ago

`mousemove` events for outside `<iframe>` are fired in the subdocument even if preceding `mousedown` in the subdocument is canceled

Categories

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

defect

Tracking

()

Tracking Status
firefox85 --- affected

People

(Reporter: masayuki, Unassigned)

References

(Blocks 1 open bug)

Details

(Keywords: parity-chrome)

STR:

  1. Load data:text/html,<p>here is an iframe</p><iframe width=800 srcdoc="<span onmousedown=event.preventDefault()>Here prevents default of mousedown</span><br><span>Here does nothing</span><p></p><script>window.addEventListener('mousemove', event => {document.querySelector('p').textContent=mousemove on ${event.target.nodeName}: ${event.clientX}, ${event.clientY}}, true);</script>"><iframe>
  2. Mousedown in "Here prevents default of mousedown".
  3. Keep pressing the mouse button and drag outside the <iframe>

AR:
mousemove events are fired on the document node of the subdocument.

ER:
I'm not sure from point of view of standards, but Chrome fires mousemove events under the cursor (i.e., in the outer document).

This is different from this test:
https://searchfox.org/mozilla-central/rev/ffdb6a4d934b3f5294f18cf0e1df618109ccb36b/layout/base/tests/test_bug603550.html#91-99

But I think that the Chrome's behavior makes more sense.

What do you think smaug? (And Edgar?)

Flags: needinfo?(bugs)

I think Chrome's behavior makes sense.
I also tested Safari, Safari behaves the same as Chrome.

How do pointerevents work in other browsers? Thinking about implicit capture.

Flags: needinfo?(bugs)

testcase for mouse events:
https://jsfiddle.net/d_toybox/5j1wpytu/17/
testcase for pointer events:
https://jsfiddle.net/d_toybox/5j1wpytu/19/

Same for both mouse events and pointer events. Both Blink and WebKit captures mouse/pointer events in target document, but if mousedown/pointerdown is canceled, they don't capture the events.

Summary: `mousemove` events for outside `<iframe>` are fined in the subdocument even if preceding `mousedown` in the subdocument is canceled → `mousemove` events for outside `<iframe>` are fired in the subdocument even if preceding `mousedown` in the subdocument is canceled

We have a feature in Canva to support dragging things from an iframe to outside, and it works by cancelling the initial mousedown event within the iframe via preventDefault , then setting the iframe’s pointer-events: none, which allows the parent window to begin listening to mousemove events to facilitate dragging.

This bug means that the feature doesn't work on Firefox. Any chance we can get this fixed? Is there any concern on masayuki's proposed change in comment 1?

Unfortunately, I don't have much time to work on this at least for a couple of weeks...

Assignee: masayuki → nobody
Status: ASSIGNED → NEW

Any updates on this? Wondering what the timeline is in getting this fixed so that we don't need a workaround specifically in Firefox.

Flags: needinfo?(masayuki)

Nothing special. I'm not working on around events due to tons of editor work.

Flags: needinfo?(masayuki)

I don't remember the test results, I had patches:

  1. https://hg.mozilla.org/try/rev/526f12981bdaae7ba2f5893d7a5f4faef684667a
  2. https://hg.mozilla.org/try/rev/2e05dcf01db48fcaa8a8e32fa2c469a5274b0039

but the latter does not contain new test, so need to write it.

You need to log in before you can comment on or make changes to this bug.