fix: close window when leave fs crash (#25468)

This commit is contained in:
Shelley Vohr 2020-09-17 17:40:07 -06:00 committed by GitHub
parent 2cfa41e6e0
commit a65f7f7d42
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 17 additions and 1 deletions

View file

@ -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() {

View file

@ -3970,6 +3970,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');