The default bug view has changed. See this FAQ.

Incorrect behavior of preventDefault() when used with context menu

VERIFIED FIXED in Firefox 9

Status

Fennec Graveyard
General
VERIFIED FIXED
6 years ago
6 years ago

People

(Reporter: Dan Walkowski, Assigned: wesj)

Tracking

Trunk
Firefox 9

Details

(Whiteboard: [inbound], URL)

Attachments

(2 attachments)

(Reporter)

Description

6 years ago
User Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.6; rv:7.0.1) Gecko/20100101 Firefox/7.0.1
Build ID: 20110928134238

Steps to reproduce:

Please visit this page: mozilla.github.com/icongrid

I am overriding the press-and-hold behavior by preventDefault() on the context menu event, and substituting my own.

I am using the latest nightly of Fennec.


Actual results:

If, and only if, the page is not scrolled at all, then press-and-hold on an icon behaves correctly.  Pressing for 1 second lifts the icon from the page, allowing you to reposition it.  No context menu is shown.  
However, if the page is scrolled up even 1 pixel, this behavior does NOT happen, but instead it appears the the coordinate system is changed out from under me, causing the press and hold to fail.


Expected results:

The correct behavior should happen no matter how the page is scrolled.
Please note that the correct behavior is observed on every other platform tested:
Firefox
Chrome
Safari
Safari Mobile
Android default webkit browser.
A testcase would be nice.
(Reporter)

Comment 2

6 years ago
I gave you a test case.  Visit the page mentioned above: mozilla.github.com/icongrid, and follow the trivial steps mentioned above.

Updated

6 years ago
Created attachment 565031 [details]
testcase

This is probably because e.touches[0].clientY returns something different in Fennec. That value seems in Fennec the vertical offset in the window plus the amount scrolled. In the Android stock browser, it's the vertical offset in the window.

Updated

6 years ago
Blocks: 544614
(Assignee)

Comment 4

6 years ago
The github example page seems to work now? Have you fixed something on your end? Is there still a bug in Fennec that we need to address.

Martjin, your problem seems different. If there's a difference, can you file a separate bug to find out which impelementation is right.
(Reporter)

Comment 5

6 years ago
No, the github page does not work.  Be sure to scroll the page slightly to see the problem. I can demonstrate it for you if you are local to MV, I'm on second floor.
(Assignee)

Comment 6

6 years ago
Created attachment 565109 [details] [diff] [review]
Patch

Not in MV.

Looked into this some more, but I think the description here is wrong and Martijn's right. In every test I can throw at it, contextmenu is fired and preventDefault works. But AFAICT, your page doesn't use the contextmenu event for anything but hiding the context menu, which works. A reduced test case would probably have made this much easier to diagnose.

The page is doing its own "longtap" detection by setting a timer on touchdown. They also register to pick up mouse events. We fire a mousemove event a few hundred ms after touchdown. The page compares the coordinates of touchdown and mousemove events and they don't match.

We fire mouse events using DOMWindowUtils which automatically does the correct pixel conversions for us. We fire touchdown events using our own coordinates. This just makes us correct for client offset. I'm a bit worried about iframes... may need to look at this more.

Note for Dan, if you call preventDefault on the touch events, we won't fire mouse events and you won't have this cross pollination problem. You also won't see our sidebars or the urlbar in us or other browsers pan in. Glad we found the real bug though.
Assignee: nobody → wjohnston
Attachment #565109 - Flags: review?(mbrubeck)
Attachment #565109 - Flags: review?(mbrubeck) → review+
(Reporter)

Comment 7

6 years ago
wesj: and the real bug is that the e.touches[0].clientY is incorrect?
any chance this will make it into a soonish nightly?
(Assignee)

Comment 8

6 years ago
http://hg.mozilla.org/integration/mozilla-inbound/rev/e53f415e6cc7
Whiteboard: [inbound]
Dan, you could adjust your code to circumvent this bug.
https://hg.mozilla.org/mozilla-central/rev/e53f415e6cc7
Status: NEW → RESOLVED
Last Resolved: 6 years ago
Resolution: --- → FIXED
Target Milestone: --- → Firefox 10
(Assignee)

Comment 11

6 years ago
Comment on attachment 565109 [details] [diff] [review]
Patch

nominating this for aurora. this is low risk and fixes bad behavior in our original touch events implementation.
Attachment #565109 - Flags: approval-mozilla-aurora?
Additional comments for Aurora approval:  This is a two-line Fennec-only patch that is a straightforward fix for a miscalculation.  It fixes a web compatibility bug that affects at least one JavaScript library in the wild (and published by Mozilla!); see comment 0 for details.
status-firefox10: --- → fixed
status-firefox7: --- → wontfix
status-firefox8: --- → affected
status-firefox9: --- → affected
OS: Mac OS X → All
Hardware: x86 → All

Updated

6 years ago
Attachment #565109 - Flags: approval-mozilla-aurora? → approval-mozilla-aurora+
https://hg.mozilla.org/releases/mozilla-aurora/rev/fafffd7c801e
status-firefox9: affected → fixed
Target Milestone: Firefox 10 → Firefox 9

Comment 14

6 years ago
Build ID: Mozilla/5.0 (Android; Linux armv7l; rv:9.0a2) Gecko/20111017 Firefox/9.0a2 Fennec/9.0a2
Device: HTC Desire Z
OS: Android 2.3

Verified issue on above environment:
- If page is scrolled then press-and-hold on an icon behaves correctly: pressing for 1 second lifts the icon from the page, allowing you to reposition it. No context menu is shown. - OK

- If page is NOT scrolled then pressing for 1 second lifts the icon from the page, allowing you to reposition it and also the entire page is scrolled up/down or left/right panels are displayed if moving icon left/right. Is this related to this bug or is it a new issue? 
I will reopen the bug for now. If this is a different issue I will close this bug and open a new one.
Status: RESOLVED → REOPENED
Resolution: FIXED → ---
Sounds like a new bug, seems to work for me, btw.
Status: REOPENED → RESOLVED
Last Resolved: 6 years ago6 years ago
Resolution: --- → FIXED

Comment 16

6 years ago
Bug #695317 was logged for issue described in comment #14.

BAsed on previous 2 comments, marking bug as verified fixed.
Status: RESOLVED → VERIFIED
You need to log in before you can comment on or make changes to this bug.