electron/spec/fixtures/apps/libuv-hang/main.js

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

38 lines
758 B
JavaScript
Raw Normal View History

2021-03-22 20:11:03 +00:00
const { app, BrowserWindow, ipcMain } = require('electron');
const path = require('node:path');
2021-03-22 20:11:03 +00:00
async function createWindow () {
const mainWindow = new BrowserWindow({
show: false,
webPreferences: {
preload: path.join(__dirname, 'preload.js'),
sandbox: false
2021-03-22 20:11:03 +00:00
}
});
await mainWindow.loadFile('index.html');
}
app.whenReady().then(() => {
createWindow();
app.on('activate', function () {
if (BrowserWindow.getAllWindows().length === 0) {
createWindow();
}
});
});
let count = 0;
ipcMain.handle('reload-successful', () => {
if (count === 2) {
app.quit();
} else {
count++;
return count;
}
});
app.on('window-all-closed', function () {
if (process.platform !== 'darwin') app.quit();
});