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 15, 2020
1 parent 459a95a commit b1d0acf
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
2 changes: 1 addition & 1 deletion shell/browser/api/electron_api_browser_window.cc
Expand Up @@ -320,11 +320,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
15 changes: 15 additions & 0 deletions spec-main/api-browser-window-spec.ts
Expand Up @@ -110,6 +110,21 @@ describe('BrowserWindow module', () => {
await emittedOnce(w.webContents, 'before-unload-fired');
});

it('should not cause a crash if called when exiting fullscreen', (done) => {
w.on('enter-full-screen', async () => {
// Wait a tick for the full-screen state to 'stick'
await delay();
w.setFullScreen(false);
});

w.on('leave-full-screen', () => {
w.close();
done();
});

w.setFullScreen(true);
});

describe('when invoked synchronously inside navigation observer', () => {
let server: http.Server = null as unknown as http.Server;
let url: string = null as unknown as string;
Expand Down

0 comments on commit b1d0acf

Please sign in to comment.