Skip to content

Commit

Permalink
fix: close window when leave fs crash (#25524)
Browse files Browse the repository at this point in the history
Co-authored-by: Shelley Vohr <shelley.vohr@gmail.com>
  • Loading branch information
trop[bot] and codebytere committed Sep 19, 2020
1 parent e2b90ee commit 7e40dc2
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 1 deletion.
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

0 comments on commit 7e40dc2

Please sign in to comment.