diff --git a/shell/browser/api/electron_api_browser_window.cc b/shell/browser/api/electron_api_browser_window.cc index 5b02132af542..68e772caf3af 100644 --- a/shell/browser/api/electron_api_browser_window.cc +++ b/shell/browser/api/electron_api_browser_window.cc @@ -154,7 +154,7 @@ void BrowserWindow::RenderFrameCreated( } void BrowserWindow::DidFirstVisuallyNonEmptyPaint() { - if (window()->IsVisible()) + if (window()->IsClosed() || window()->IsVisible()) return; // When there is a non-empty first paint, resize the RenderWidget to force diff --git a/spec-main/fixtures/crash-cases/native-window-open-exit/index.html b/spec-main/fixtures/crash-cases/native-window-open-exit/index.html new file mode 100644 index 000000000000..ee82a9694ed5 --- /dev/null +++ b/spec-main/fixtures/crash-cases/native-window-open-exit/index.html @@ -0,0 +1,3 @@ + + MAIN PAGE + \ No newline at end of file diff --git a/spec-main/fixtures/crash-cases/native-window-open-exit/index.js b/spec-main/fixtures/crash-cases/native-window-open-exit/index.js new file mode 100644 index 000000000000..4ef61051800a --- /dev/null +++ b/spec-main/fixtures/crash-cases/native-window-open-exit/index.js @@ -0,0 +1,40 @@ +const { app, ipcMain, BrowserWindow } = require('electron'); +const path = require('path'); +const http = require('http'); + +function createWindow () { + const mainWindow = new BrowserWindow({ + webPreferences: { + webSecurity: false, + preload: path.join(__dirname, 'preload.js') + } + }); + + mainWindow.loadFile('index.html'); + mainWindow.webContents.on('render-process-gone', () => { + process.exit(1); + }); +} + +const server = http.createServer((_req, res) => { + res.end('hello'); +}).listen(7001, '127.0.0.1'); + +app.whenReady().then(() => { + createWindow(); + app.on('activate', () => { + if (BrowserWindow.getAllWindows().length === 0) { + createWindow(); + } + }); +}); + +app.on('window-all-closed', function () { + if (process.platform !== 'darwin') app.quit(); +}); + +ipcMain.on('test-done', () => { + console.log('test passed'); + server.close(); + process.exit(0); +}); diff --git a/spec-main/fixtures/crash-cases/native-window-open-exit/preload.js b/spec-main/fixtures/crash-cases/native-window-open-exit/preload.js new file mode 100644 index 000000000000..aace1d035a0d --- /dev/null +++ b/spec-main/fixtures/crash-cases/native-window-open-exit/preload.js @@ -0,0 +1,6 @@ +const { ipcRenderer } = require('electron'); + +window.addEventListener('DOMContentLoaded', () => { + window.open('127.0.0.1:7001', '_blank'); + setTimeout(() => ipcRenderer.send('test-done')); +});