electron/spec/fixtures/apps/libuv-hang/main.js
Milan Burda d78f37ec8f
refactor: use node scheme imports in spec (#38487)
Co-authored-by: Milan Burda <miburda@microsoft.com>
2023-06-15 10:42:27 -04:00

37 lines
758 B
JavaScript

const { app, BrowserWindow, ipcMain } = require('electron');
const path = require('node:path');
async function createWindow () {
const mainWindow = new BrowserWindow({
show: false,
webPreferences: {
preload: path.join(__dirname, 'preload.js'),
sandbox: false
}
});
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();
});