fix: simpleFullScreen exits when web content calls requestFullscreen (#50987)

fix: simpleFullScreen exits when web content calls requestFullscreen

SetHtmlApiFullscreen only checked IsFullscreen() to detect that the
window was already fullscreen, missing the simple-fullscreen case on
macOS. When web content triggered requestFullscreen the code fell
through to SetFullScreen(true) which toggled simple fullscreen off.

Include IsSimpleFullScreen() in the guard so the HTML-API fullscreen
state is updated without touching the window's fullscreen mode.

Co-authored-by: trop[bot] <37223003+trop[bot]@users.noreply.github.com>
Co-authored-by: Shelley Vohr <shelley.vohr@gmail.com>
This commit is contained in:
trop[bot]
2026-04-12 20:48:08 -07:00
committed by GitHub
parent 043377523a
commit 1a67d03b0b
2 changed files with 22 additions and 1 deletions

View File

@@ -4505,7 +4505,8 @@ void WebContents::OnDevToolsSearchCompleted(
void WebContents::SetHtmlApiFullscreen(bool enter_fullscreen) {
// Window is already in fullscreen mode, save the state.
if (enter_fullscreen && owner_window()->IsFullscreen()) {
if (enter_fullscreen && (owner_window()->IsFullscreen() ||
owner_window()->IsSimpleFullScreen())) {
native_fullscreen_ = true;
UpdateHtmlApiFullscreen(true);
return;

View File

@@ -6583,6 +6583,26 @@ describe('BrowserWindow module', () => {
w.setFullScreen(!w.isFullScreen());
});
ifit(process.platform === 'darwin')('does not exit simpleFullScreen when requestFullscreen is called', async () => {
const w = new BrowserWindow();
await w.loadFile(path.join(fixtures, 'pages', 'a.html'));
w.setSimpleFullScreen(true);
expect(w.isSimpleFullScreen()).to.be.true('isSimpleFullScreen');
const enterHtmlFS = once(w.webContents, 'enter-html-full-screen');
await w.webContents.executeJavaScript('document.getElementById("div").requestFullscreen()', true);
await enterHtmlFS;
expect(w.isSimpleFullScreen()).to.be.true('isSimpleFullScreen after requestFullscreen');
const leaveHtmlFS = once(w.webContents, 'leave-html-full-screen');
await w.webContents.executeJavaScript('document.exitFullscreen()');
await leaveHtmlFS;
expect(w.isSimpleFullScreen()).to.be.true('isSimpleFullScreen after exitFullscreen');
});
it('should not be changed by setKiosk method', async () => {
const w = new BrowserWindow();