fix: process.exit crash in nativeWindowOpen (#30218)
This commit is contained in:
parent
eca1098b55
commit
b24cfe17bc
4 changed files with 50 additions and 1 deletions
|
@ -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
|
||||
|
|
|
@ -0,0 +1,3 @@
|
|||
<body>
|
||||
MAIN PAGE
|
||||
</body>
|
|
@ -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('<title>hello</title>');
|
||||
}).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);
|
||||
});
|
|
@ -0,0 +1,6 @@
|
|||
const { ipcRenderer } = require('electron');
|
||||
|
||||
window.addEventListener('DOMContentLoaded', () => {
|
||||
window.open('127.0.0.1:7001', '_blank');
|
||||
setTimeout(() => ipcRenderer.send('test-done'));
|
||||
});
|
Loading…
Reference in a new issue