context menu issue, shift + rmb

RESOLVED INVALID

Status

()

Core
DOM: Events
RESOLVED INVALID
10 months ago
10 months ago

People

(Reporter: misik.dmitriy, Unassigned)

Tracking

53 Branch
Points:
---

Firefox Tracking Flags

(Not tracked)

Details

Attachments

(1 attachment)

(Reporter)

Description

10 months ago
Created attachment 8867170 [details]
index.html

User Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/57.0.2987.133 Safari/537.36

Steps to reproduce:

1. have next HTML
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
</head>
<body>
    
    <script>
        function keydown() {
            console.log("keydown");
        }

        function keyup() {
            console.log("keyup");
        }

        function contextmenu(event) {
            event.preventDefault();
            console.log("contextmenu");
        }

        document.addEventListener("keydown", keydown, false);
        document.addEventListener("keyup", keyup, false);
        document.addEventListener("contextmenu", contextmenu, false);
    </script>
</body>
</html>
2. press shift
3. press right mouse button on page
4. release shift


Actual results:

keyup listener doesn't work


Expected results:

keyup listener works

Updated

10 months ago
Component: Untriaged → DOM: Events
Product: Firefox → Core
Could not reproduce on MacOS or in Windows 10 (virtual box) using Nighty. 

The test case:
https://jsfiddle.net/tqfys21L/
(Reporter)

Comment 2

10 months ago
(In reply to Marcos Caceres [:marcosc] from comment #1)
> Could not reproduce on MacOS or in Windows 10 (virtual box) using Nighty. 
> 
> The test case:
> https://jsfiddle.net/tqfys21L/

after releasing right mouse button, event keyup doesn't raise when shift released (maybe because of context menu). but then event keyup works as previously

Comment 3

10 months ago
If I followed the steps:
1. press shift
2. press right mouse button on page (keep pressing the right button)
3. release shift

I got only "keydown" event printed.

According to the spec [1], it says "... ... For example, the user agent could handle right-clicks that have the Shift key depressed in such a way that it does not fire the contextmenu event and instead always shows the default context menu." 

Does that imply our behaviour satisfy the spec? Ideas, Ben or Stone?

[1]https://html.spec.whatwg.org/multipage/forms.html#context-menus
Flags: needinfo?(sshih)
Flags: needinfo?(btian)

Comment 4

10 months ago
(In reply to Hsin-Yi Tsai [:hsinyi] from comment #3)
> If I followed the steps:
> 1. press shift
> 2. press right mouse button on page (keep pressing the right button)
                                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ this should be corrected

This step was - "click" right mouse button, i.e. pressed then released

> 3. release shift
> 
> I got only "keydown" event printed.
> 
> According to the spec [1], it says "... ... For example, the user agent
> could handle right-clicks that have the Shift key depressed in such a way
> that it does not fire the contextmenu event and instead always shows the
> default context menu." 
> 
> Does that imply our behaviour satisfy the spec? Ideas, Ben or Stone?
> 
> [1]https://html.spec.whatwg.org/multipage/forms.html#context-menus

Comment 5

10 months ago
(In reply to Hsin-Yi Tsai [:hsinyi] from comment #3)
> According to the spec [1], it says "... ... For example, the user agent
> could handle right-clicks that have the Shift key depressed in such a way
> that it does not fire the contextmenu event and instead always shows the
> default context menu." 
> 
> Does that imply our behaviour satisfy the spec? Ideas, Ben or Stone?
> 
> [1]https://html.spec.whatwg.org/multipage/forms.html#context-menus

My understanding is our behavior satisfies the spec about context menu, as long as UA always shows the default context menu and doesn't fire 'contextmenu' event. But [1] doesn't specify keyup behavior and I need to check other related spec.

Keep ni? me to comment later.

Comment 6

10 months ago
Document's keyup listener doesn't work because focus is on popped context menu instead of document. This is a UA-dependent behavior complying to spec in comment 3.

Firefox doesn't fire 'contextmenu' event and pops context menu as spec suggests, so focus is switched to popped context menu. On the contrary Chrome and Safari still fires 'contextmenu' event, whose listener calls |preventDefault| to stop further propagation and thus context menu doesn't pop and focus remains on document.

If you switch focus back to document (i.e., additional step 3 below), keyup listener would work as you expect.
1. press shift
2. press right mouse button on page and context menu pops
3. click on page and context menu disappears
4. release shift

--
Tend to resolve this bug as invalid for UA-dependent behavior complying to spec.

Misik, how do you think?
Flags: needinfo?(sshih)
Flags: needinfo?(misik.dmitriy)
Flags: needinfo?(btian)
(Reporter)

Comment 7

10 months ago
(In reply to Ben Tian [:btian] from comment #6)
> Document's keyup listener doesn't work because focus is on popped context
> menu instead of document. This is a UA-dependent behavior complying to spec
> in comment 3.
> 
> Firefox doesn't fire 'contextmenu' event and pops context menu as spec
> suggests, so focus is switched to popped context menu. On the contrary
> Chrome and Safari still fires 'contextmenu' event, whose listener calls
> |preventDefault| to stop further propagation and thus context menu doesn't
> pop and focus remains on document.
> 
> If you switch focus back to document (i.e., additional step 3 below), keyup
> listener would work as you expect.
> 1. press shift
> 2. press right mouse button on page and context menu pops
> 3. click on page and context menu disappears
> 4. release shift
> 
> --
> Tend to resolve this bug as invalid for UA-dependent behavior complying to
> spec.
> 
> Misik, how do you think?

Resolve this bug as invalid for UA
Flags: needinfo?(misik.dmitriy)

Comment 8

10 months ago
Resolve INVALID per comment 6.
Status: UNCONFIRMED → RESOLVED
Last Resolved: 10 months ago
Resolution: --- → INVALID
You need to log in before you can comment on or make changes to this bug.