electron/spec/fixtures/api/mixed-sandbox-app/main.js

47 lines
1 KiB
JavaScript
Raw Normal View History

const {app, BrowserWindow, ipcMain} = require('electron')
2017-06-16 22:34:11 +00:00
const path = require('path')
2017-06-19 15:03:02 +00:00
process.on('uncaughtException', () => {
2017-06-16 22:34:11 +00:00
app.exit(1)
})
let sandboxWindow
let noSandboxWindow
2017-06-19 15:03:02 +00:00
app.once('ready', () => {
sandboxWindow = new BrowserWindow({
show: false,
webPreferences: {
preload: path.join(app.getAppPath(), 'electron-app-mixed-sandbox-preload.js'),
sandbox: true
2017-06-16 22:34:11 +00:00
}
})
sandboxWindow.loadURL('about:blank')
noSandboxWindow = new BrowserWindow({
show: false,
webPreferences: {
preload: path.join(app.getAppPath(), 'electron-app-mixed-sandbox-preload.js'),
sandbox: false
}
2017-06-16 22:34:11 +00:00
})
noSandboxWindow.loadURL('about:blank')
2017-06-16 22:34:11 +00:00
const argv = {
sandbox: null,
noSandbox: null
2017-06-16 22:34:11 +00:00
}
ipcMain.on('argv', (event, value) => {
if (event.sender === sandboxWindow.webContents) {
argv.sandbox = value
} else if (event.sender === noSandboxWindow.webContents) {
argv.noSandbox = value
}
if (argv.sandbox != null && argv.noSandbox != null) {
process.send(argv)
}
})
2017-06-16 22:34:11 +00:00
})