Only on Pale Moon, releasing right-click fires click event on https://jsfiddle.net/wkcr5p4e/

For support with specific websites

Moderator: trava90

Forum rules
Please always mention the name/domain of the website in question in your topic title.
Please one website per topic thread (to help keep things organized). While behavior on different sites might at first glance seem similar, they are not necessarily caused by the same.

Please try to include any relevant output from the Toolkit Error Console or the Developer Tools Web Console using the following procedure:
  1. Clear any current output
  2. Navigate or refresh the page in question
  3. Copy and paste Errors or seemingly relevant Warnings into a single [ code ] block.
User avatar
craniumcadoo
Apollo supporter
Apollo supporter
Posts: 41
Joined: 2023-08-02, 19:42

Only on Pale Moon, releasing right-click fires click event on https://jsfiddle.net/wkcr5p4e/

Unread post by craniumcadoo » 2023-10-26, 14:20

If you right-click the result area on this JSFiddle, when you release right-click "a" is displayed. This is not the case on other browsers, where only a left click triggers the click event. https://w3c.github.io/uievents/#event-type-click specifies that the click event is only meant to be fired by clicking the primary pointer button or simulating such an action.

User avatar
craniumcadoo
Apollo supporter
Apollo supporter
Posts: 41
Joined: 2023-08-02, 19:42

Re: Only on Pale Moon, releasing right-click fires click event on https://jsfiddle.net/wkcr5p4e/

Unread post by craniumcadoo » 2023-10-26, 14:56

Also occurs with the middle mouse button


User avatar
craniumcadoo
Apollo supporter
Apollo supporter
Posts: 41
Joined: 2023-08-02, 19:42

Re: Only on Pale Moon, releasing right-click fires click event on https://jsfiddle.net/wkcr5p4e/

Unread post by craniumcadoo » 2023-10-26, 15:48

It applies for window, not a button element. Did you try https://jsfiddle.net/wkcr5p4e/?

User avatar
craniumcadoo
Apollo supporter
Apollo supporter
Posts: 41
Joined: 2023-08-02, 19:42

Re: Only on Pale Moon, releasing right-click fires click event on https://jsfiddle.net/wkcr5p4e/

Unread post by craniumcadoo » 2023-10-26, 15:49

If you switch the code in the second link you sent to document.addEventListener("click", myFunction); or window.addEventListener("click", myFunction); instead of element.addEventListener("click", myFunction); it occurs.

User avatar
Kris_88
Keeps coming back
Keeps coming back
Posts: 940
Joined: 2021-01-26, 11:18

Re: Only on Pale Moon, releasing right-click fires click event on https://jsfiddle.net/wkcr5p4e/

Unread post by Kris_88 » 2023-10-26, 16:01


User avatar
craniumcadoo
Apollo supporter
Apollo supporter
Posts: 41
Joined: 2023-08-02, 19:42

Re: Only on Pale Moon, releasing right-click fires click event on https://jsfiddle.net/wkcr5p4e/

Unread post by craniumcadoo » 2023-10-26, 17:57

That link is slightly different. The latest Firefox version clicks the hovered over option when releasing right-click on the browser's context menu, yes. However, that Firefox version does not actually fire a click event to the document or window at that time. Only Pale Moon does that. And firing the click event when using the middle or right mouse button definitely contradicts the part of the w3c spec that says "The click event should only be fired for the primary pointer button (i.e., when button value is 0, buttons value is 1). Secondary buttons (like the middle or right button on a standard mouse) MUST NOT fire click events."

User avatar
Moonchild
Pale Moon guru
Pale Moon guru
Posts: 35652
Joined: 2011-08-28, 17:27
Location: Motala, SE

Re: Only on Pale Moon, releasing right-click fires click event on https://jsfiddle.net/wkcr5p4e/

Unread post by Moonchild » 2023-10-26, 18:34

I confirm that we're doing this differently than Google Chrome or the latest Firefox. That said this is not a regression as far as I can tell.
The issue is that you're attaching the click event to the window, way up the hierarchy and not on a trusted target for receiving these events (which are meant to be Elements, not the document or window, see also the table in the W3C spec you're referring to). You should never do that.

It doesn't seem like even Mozilla themselves have a clear record of when this changed, it may need a mozregression to find out.
"Sometimes, the best way to get what you want is to be a good person." -- Louis Rossmann
"Seek wisdom, not knowledge. Knowledge is of the past; wisdom is of the future." -- Native American proverb
"Linux makes everything difficult." -- Lyceus Anubite

User avatar
craniumcadoo
Apollo supporter
Apollo supporter
Posts: 41
Joined: 2023-08-02, 19:42

Re: Only on Pale Moon, releasing right-click fires click event on https://jsfiddle.net/wkcr5p4e/

Unread post by craniumcadoo » 2023-10-26, 18:48

Hmm, interesting, you're right that those are not Trusted Targets, but I've seen so many people all over the web do document.addEventListener("click") or window.addEventListener("click") that I never would have thought as much.

I suppose the simplest workaround, which would also match the spec, would be to use document.documentElement.

User avatar
craniumcadoo
Apollo supporter
Apollo supporter
Posts: 41
Joined: 2023-08-02, 19:42

Re: Only on Pale Moon, releasing right-click fires click event on https://jsfiddle.net/wkcr5p4e/

Unread post by craniumcadoo » 2023-10-26, 19:07

It's so prevalent it even appears on https://www.w3schools.com/jsref/met_doc ... stener.asp

User avatar
craniumcadoo
Apollo supporter
Apollo supporter
Posts: 41
Joined: 2023-08-02, 19:42

Re: Only on Pale Moon, releasing right-click fires click event on https://jsfiddle.net/wkcr5p4e/

Unread post by craniumcadoo » 2023-10-26, 19:14


User avatar
Moonchild
Pale Moon guru
Pale Moon guru
Posts: 35652
Joined: 2011-08-28, 17:27
Location: Motala, SE

Re: Only on Pale Moon, releasing right-click fires click event on https://jsfiddle.net/wkcr5p4e/

Unread post by Moonchild » 2023-10-26, 19:22

Thank you for finding the BZ bug! We can work with that.

Filed Issue #2362 (UXP)
"Sometimes, the best way to get what you want is to be a good person." -- Louis Rossmann
"Seek wisdom, not knowledge. Knowledge is of the past; wisdom is of the future." -- Native American proverb
"Linux makes everything difficult." -- Lyceus Anubite