8000 fix: process.exit crash in nativeWindowOpen by codebytere · Pull Request #30218 · electron/electron · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

fix: process.exit crash in nativeWindowOpen #30218

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Jul 22, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
8000
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 @@ -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
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
<body>
MAIN PAGE
</body>
40 changes: 40 additions & 0 deletions spec-main/fixtures/crash-cases/native-window-open-exit/index.js
Original file line number Diff line number Diff line change
@@ -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);
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
const { ipcRenderer } = require('electron');

window.addEventListener('DOMContentLoaded', () => {
window.open('127.0.0.1:7001', '_blank');
setTimeout(() => ipcRenderer.send('test-done'));
});
0