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

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.
This commit is contained in:
Shelley Vohr authored and GitHub committed 2026-04-12 19:06:07 -05:00
1 parent ea757689b3
commit a007bafaf1
2 files changed
+22 -1

No files matched your search

@@ -4509,7 +4509,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;
+20
View File
@@ -6681,6 +6681,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();