Completing UTs

This commit is contained in:
Hari Krishna Reddy Juturu 2017-06-19 07:46:14 -07:00
parent 0b7e7458c9
commit e546820a4a
3 changed files with 15 additions and 23 deletions

View file

@ -1295,13 +1295,12 @@ describe('BrowserWindow module', function () {
})
sandboxServer.on('connection', (client) => {
client.once('data', function (data) {
console.log('jhreddy -' + data)
if (String(data) === 'false' && state === 'none') {
state = 'first-launch'
} else if (String(data) === 'true' && state === 'first-launch') {
done()
} else {
done(`Unexpected state: ${state}`)
done(`Unexpected state: ${data}`)
}
})
})

View file

@ -1,3 +1,8 @@
process.once('loaded', function () {
window.argv = process.argv
})
const { ipcRenderer } = require('electron')
if (process) {
process.once('loaded', function () {
ipcRenderer.send('processArgs', process.argv)
})
} else {
ipcRenderer.send('processArgs', 'unable to get process args')
}

View file

@ -1,10 +1,10 @@
const { app, BrowserWindow, dialog } = require('electron')
const { app, BrowserWindow, ipcMain } = require('electron')
const net = require('net')
const path = require('path')
const socketPath = process.platform === 'win32' ? '\\\\.\\pipe\\electron-app-mixed-sandbox' : '/tmp/electron-app-mixed-sandbox'
process.on('uncaughtException', () => {
process.on('uncaughtException', (error) => {
app.exit(1)
})
@ -14,9 +14,11 @@ app.once('ready', () => {
const client = net.connect(socketPath)
client.once('connect', () => {
if (lastArg === '--enable-mixed-sandbox') {
dialog.showErrorBox('connected', app.getAppPath())
ipcMain.on('processArgs', (event, args) => {
client.end(String(args.indexOf('--no-sandbox') >= 0))
})
let window = new BrowserWindow({
show: true,
show: false,
webPreferences: {
preload: path.join(app.getAppPath(), 'electron-app-mixed-sandbox-preload.js'),
sandbox: false
@ -24,20 +26,6 @@ app.once('ready', () => {
})
window.loadURL('data:,window')
let argv = 'test'
window.webContents.once('did-finish-load', () => {
dialog.showErrorBox('finished-load', 'finished')
window.webContents.executeJavaScript('window.argv', false, (result) => {
dialog.showErrorBox('hello', result)
client.end(String(result))
})
})
// window.webContents.openDevTools()
// window.webContents.executeJavaScript('window.argv', true).then((result) => {
// dialog.showErrorBox('hello', result)
// client.end(String(argv))
// })
} else {
client.end(String(false))
}