Open Bug 1322876 Opened 8 years ago Updated 9 months ago

"contextmenu" event has mozInputSource == MOZ_SOURCE_MOUSE even when hitting the context menu key on the keyboard

Categories

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

defect

Tracking

()

Tracking Status
firefox53 --- affected

People

(Reporter: squib, Unassigned)

Details

(Keywords: good-first-bug, Whiteboard: [domcore-bugbash-triaged])

Attachments

(3 files)

Per the bug title, the "contextmenu" event always claims to be from the mouse even when it's actually from the keyboard. That's because when the WidgetMouseEvent is created, the input source is never overridden: <https://dxr.mozilla.org/mozilla-central/rev/8103c612b79c2587ea4ca1b0a9f9f82db4b185b8/widget/MouseEvents.h#252>. I have a test case and a patch that I'll upload shortly. This is my first (or maybe my second?) m-c bug, so I might get some of the review protocol wrong; if I do anything silly, just let me know!
Attached file A simple test case
Here's a simple test case that logs the input source in the error console. Currently, it always outputs 1 (mouse), even when the event comes from the keyboard.
Comment on attachment 8819081 [details] [diff] [review] "contextmenu" event has mozInputSource == MOZ_SOURCE_MOUSE even when hitting the context menu key on the keyboard Hopefully I flagged the right person for review and managed to upload this patch correctly. Where should I put tests for this? I'm not super-familiar with how m-c organizes its tests.
Attachment #8819081 - Flags: feedback?(bugs)
Comment on attachment 8819081 [details] [diff] [review] "contextmenu" event has mozInputSource == MOZ_SOURCE_MOUSE even when hitting the context menu key on the keyboard It is not super important where to put tests. Possibly dom/events/test/* You aren't setting button to any value when mContextMenuTrigger == eContextMenuKey.
Attachment #8819081 - Flags: feedback?(bugs) → feedback+
(In reply to Olli Pettay [:smaug] from comment #4) > It is not super important where to put tests. Possibly dom/events/test/* Thanks! I'll look there and see if I can cargo-cult an existing test into something that checks this. > You aren't setting button to any value when mContextMenuTrigger == > eContextMenuKey. I was debating what to do here; It's automatically set to 0 in the WidgetMouseEventBase constructor (as is inputSource)[1], but it's theoretically possible that that would change in the future and then we'd have an uninitialized member. I suppose I'd want to either a) do what I'm doing now and rely on the base class to initialize its members, or b) set `button` *and* `inputSource` in both branches. I'm open to either; is there a general guideline I should follow here for Mozilla code? [1] https://dxr.mozilla.org/mozilla-central/rev/8103c612b79c2587ea4ca1b0a9f9f82db4b185b8/widget/MouseEvents.h#94
The general guideline is something along the lines "whatever makes the code easiest to read and maintain, unless there are some performance or security related reasons to do otherwise". So, in this case explicit initialization would be nice.
Priority: -- → P3
Severity: normal → S3

The bug assignee is inactive on Bugzilla, so the assignee is being reset.

Assignee: jporterbugs → nobody
Status: ASSIGNED → NEW

Still valid, and the WIP in the attachment 8819081 [details] [diff] [review] is still pointing out the right direction.

Keywords: good-first-bug
Whiteboard: [domcore-bugbash-triaged]

Hi could I work on this bug?

If its available, I'd like to clarify if I am understanding the desired behavior. Right now as it stands, anyone clicking on the keyboard "context key" results in Firefox considering it a primary mouse click. As it was not a mouse click, we should assign eNotPressed to mButton when the "context key" is pressed (regarding WidgetPointerEvent's constructor specifically)?

Also in considering the two constructors listed here: https://searchfox.org/mozilla-central/source/widget/MouseEvents.h line 813-827, we can only account for this behavior in the 818-827 constructor through aContextMenuTrigger right? Meaning we have to leave the 813 constructor as it is?

Thank you very much!

Flags: needinfo?(htsai)

(In reply to Swarup Ukil from comment #9)

Hi could I work on this bug?

Sure thing! Thank you for being interested in working on this.

If its available, I'd like to clarify if I am understanding the desired behavior. Right now as it stands, anyone clicking on the keyboard "context key" results in Firefox considering it a primary mouse click. As it was not a mouse click, we should assign eNotPressed to mButton when the "context key" is pressed (regarding WidgetPointerEvent's constructor specifically)?

Also in considering the two constructors listed here: https://searchfox.org/mozilla-central/source/widget/MouseEvents.h line 813-827, we can only account for this behavior in the 818-827 constructor through aContextMenuTrigger right? Meaning we have to leave the 813 constructor as it is?

Forwarding the needinfo request to :smaug, who can clarify and explain better than I. :)

Thank you very much!

Flags: needinfo?(htsai) → needinfo?(smaug)

For the mButton handling, worth to check what other browsers do.

And both constructors should be tweaked, I think. For consistency.

Flags: needinfo?(smaug)
Assignee: nobody → swarup.ukil
Status: NEW → ASSIGNED

The bug assignee is inactive on Bugzilla, so the assignee is being reset.

Assignee: swarup.ukil → nobody
Status: ASSIGNED → NEW
Assignee: nobody → swarup.ukil
Status: NEW → ASSIGNED
Attachment #9442321 - Attachment description: Bug 1322876 - Assign mInputSource to keyboard for "contextmenu" event when context key is pressed. r?smaug → Bug 1322876 - Assign mInputSource to keyboard for "contextmenu" event when context key is pressed. r=smaug,masayuki

This good-first-bug hasn't had any activity for 2 months, it is automatically unassigned.
For more information, please visit BugBot documentation.

Assignee: swarup.ukil → nobody
Status: ASSIGNED → NEW
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: