Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: close window when leave fullscreen crash #25524

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion shell/browser/api/electron_api_browser_window.cc
Expand Up @@ -340,11 +340,11 @@ void BrowserWindow::OnWindowResize() {
}

void BrowserWindow::OnWindowLeaveFullScreen() {
BaseWindow::OnWindowLeaveFullScreen();
#if defined(OS_MAC)
if (web_contents()->IsFullscreen())
web_contents()->ExitFullscreen(true);
#endif
BaseWindow::OnWindowLeaveFullScreen();
}

void BrowserWindow::Focus() {
Expand Down
16 changes: 16 additions & 0 deletions spec-main/api-browser-window-spec.ts
Expand Up @@ -3946,6 +3946,22 @@ describe('BrowserWindow module', () => {
});

ifdescribe(process.platform === 'darwin')('fullscreen state', () => {
it('should not cause a crash if called when exiting fullscreen', async () => {
const w = new BrowserWindow();

const enterFullScreen = emittedOnce(w, 'enter-full-screen');
w.setFullScreen(true);
await enterFullScreen;

await delay();

const leaveFullScreen = emittedOnce(w, 'leave-full-screen');
w.setFullScreen(false);
await leaveFullScreen;

w.close();
});

it('can be changed with setFullScreen method', async () => {
const w = new BrowserWindow();
const enterFullScreen = emittedOnce(w, 'enter-full-screen');
Expand Down