### Preflight Checklist

- [X] I have read the [Contributing Guidelines](https://github.com/electron/electron/blob/main/CONTRIBUTING.md) for this project.
- [X] I agree to follow the [Code of Conduct](https://github.com/electron/electron/blob/main/CODE_OF_CONDUCT.md) that this project adheres to.
- [X] I have searched the [issue tracker](https://www.github.com/electron/electron/issues) for a bug report that matches the one I want to file, without success.

### Electron Version

18.0.1

### What operating system are you using?

Windows

### Operating System Version

Windows 10 Pro Version	21H2 OS build 19044.1706

### What arch are you using?

x64

### Last Known Working Electron version

18.0.0

### Expected Behavior

Escape should work as a default hotkey for exiting html fullscreen even if callback in setPermissionRequestHandler was not called synchronously.

### Actual Behavior

When html element requests fullscreen with active permissions handler (session.setPermissionRequestHandler) which calls callback asynchronously (allowing fullscreen permission) Escape hotkey does not trigger exit from fullscreen.
Eventually if the page does not provide other ways for exiting element fullscreen the window gets stuck in fullscreen mode.
Versions starting from 18.0.1 to the current latest stable 18.2.4 and even latest stable beta are affected.

Reproduction in Fiddle:
1. Click on "Fullscreen me" button, element with blue background should enter fullscreen
2. Try to exit fullscreen by pressing Esc

Changing electron version to 18.0.0 or  removing setTimeout from handler fixes the problem

### Testcase Gist URL

https://gist.github.com/a889329948e3fa9dbbaddc5012d98a53

### Additional Information

_No response_
shell/browser/api/electron_api_web_contents.cc
content::RenderFrameHost* render_frame_host) {
  
  
  
  
  
  
  
  if (!granted_devices_.empty()) {
    granted_devices_.erase(render_frame_host->GetFrameTreeNodeId());
  }
  
  
  
  
  
  auto* web_frame = WebFrameMain::FromRenderFrameHost(render_frame_host);
  if (web_frame && web_frame->render_frame_host() == render_frame_host)
    web_frame->MarkRenderFrameDisposed();
}
void WebContents::RenderFrameHostChanged(content::RenderFrameHost* old_host,