Skip to content

Commit

Permalink
fix: close window when leave fs crash
Browse files Browse the repository at this point in the history
  • Loading branch information
codebytere committed Sep 29, 2020
1 parent 6c3c9b5 commit 2cc6a98
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
Original file line number Diff line number Diff line change
Expand Up @@ -308,11 +308,11 @@ void BrowserWindow::OnWindowResize() {
}

void BrowserWindow::OnWindowLeaveFullScreen() {
TopLevelWindow::OnWindowLeaveFullScreen();
#if defined(OS_MACOSX)
if (web_contents()->IsFullscreenForCurrentTab())
web_contents()->ExitFullscreen(true);
#endif
TopLevelWindow::OnWindowLeaveFullScreen();
}

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

ifdescribe(process.platform === 'darwin')('fullscreen state', () => {
it('should not cause a crash if called when exiting fullscreen', (done) => {
const w = new BrowserWindow();
w.once('enter-full-screen', async () => {
expect(w.isFullScreen()).to.be.true('isFullScreen');
await tick();
w.setFullScreen(false);
});

w.once('leave-full-screen', () => {
expect(w.isFullScreen()).to.be.false('isFullScreen');
w.close();
done();
});
w.setFullScreen(true);
});

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

0 comments on commit 2cc6a98

Please sign in to comment.