Open Bug 1654480 Opened 4 years ago Updated 13 days ago

requestFullScreen from keydown event fails

Categories

(Core :: DOM: Core & HTML, defect, P3)

78 Branch
defect

Tracking

()

UNCONFIRMED

People

(Reporter: kljbonnema, Unassigned)

References

(Blocks 1 open bug, )

Details

Attachments

(1 file)

Attached file test.html

User Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:78.0) Gecko/20100101 Firefox/78.0

Steps to reproduce:

A page toggles fullscreen mode on a keydown event with javascript.
The attached test page triggers on F9 and should enter or leave fullscreen on each F9 keydown.

Actual results:

After an exitFullscreen a new F9 keydown for a requestFullscreen will get an "Uncaught (in promise) TypeError: Fullscreen request denied" and the fullscreen does not happen.
If you mouse click somewhere inside the page then a subsequent F9 will go to fullscreen and the next F9 will again exit fullscreen.
It seems like the exit fullscreen action has somehow lost focus but the F9 keydown event is properly received.

Expected results:

The requestFullscreen call should be honored without needing to "focus" the page first with a mouse click.
This has been successfully tested in Chrome.

Bugbug thinks this bug should belong to this component, but please revert this change in case of error.

Component: Untriaged → DOM: Events
Product: Firefox → Core

It is becuase right now F9 isn't be treated as user activaion in Firefox, the behaviour is inconsisten between browsers and also spec.

Blocks: 1577516
Severity: -- → S3
Component: DOM: Events → DOM: Core & HTML
Priority: -- → P3

F9 has been used in the test script. I have also tried ALT + r which gives the same result.
Is any keypress considered not to be a user activation right now?
If this is so then why does it work after you have clicked the page earlier (at least more then a second earlier).
Also F9 in this script will always work to exit fullscreen.

I have this issue right now.

I have an Angular app running in Firefox 115.9.1esr 64-bit.

We are manually handling full screen for cross browser compatibility and synchronisation with UI elements.
I have an event listener subscribed to key down events. When an F11 key is received I call "prevent default" and then I call requestFullScreen.

I can log the key down listener and see that the F11 is seen and recognised every time.

The issue occurs when entering full screen (not exiting full screen), and only if at least 2 F11s are processed without the user interacting with the page by any other means before the final full screen. For example:

  1. F11 (fullscreen) > F11 (exit) > F11 (fullscreen denied).
  2. F11 (fullscreen) > click somewhere > F11 (exit) > F11 (full screen) > F11 (exit) > F11 (full screen denied).
  3. F11 (fullscreen) > click somewhere > F11 (exit) > click somewhere > F11 (fullscreen) > F11 (exit) > F11 (full screen denied)

The same issue does not occur on Chrome, but interestingly Chrome also does not appear to listen to F11 keypresses while in full screen, so it's never executing my code, it's executing the default Chrome F11 exit.

I've also noticed that Firefox appears to handle "full screen" via the API differently than full screen via the Firefox UI, e.g. if triggered via the UI I don't get the Firefox full screen temporary overlay, but I do if I trigger it via API.

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

Attachment

General

Creator:
Created:
Updated:
Size: