From e546820a4a0a1a83ae7c8ff44b7666cb2537fe26 Mon Sep 17 00:00:00 2001 From: Hari Krishna Reddy Juturu Date: Mon, 19 Jun 2017 07:46:14 -0700 Subject: [PATCH] Completing UTs --- spec/api-browser-window-spec.js | 3 +-- .../electron-app-mixed-sandbox-preload.js | 11 ++++++--- spec/fixtures/api/mixed-sandbox-app/main.js | 24 +++++-------------- 3 files changed, 15 insertions(+), 23 deletions(-) diff --git a/spec/api-browser-window-spec.js b/spec/api-browser-window-spec.js index 322f25ca32e0..927363150508 100644 --- a/spec/api-browser-window-spec.js +++ b/spec/api-browser-window-spec.js @@ -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}`) } }) }) diff --git a/spec/fixtures/api/mixed-sandbox-app/electron-app-mixed-sandbox-preload.js b/spec/fixtures/api/mixed-sandbox-app/electron-app-mixed-sandbox-preload.js index 5a781c9b70e4..aee6c9f24bfa 100644 --- a/spec/fixtures/api/mixed-sandbox-app/electron-app-mixed-sandbox-preload.js +++ b/spec/fixtures/api/mixed-sandbox-app/electron-app-mixed-sandbox-preload.js @@ -1,3 +1,8 @@ -process.once('loaded', function () { - window.argv = process.argv -}) \ No newline at end of file +const { ipcRenderer } = require('electron') +if (process) { + process.once('loaded', function () { + ipcRenderer.send('processArgs', process.argv) + }) +} else { + ipcRenderer.send('processArgs', 'unable to get process args') +} \ No newline at end of file diff --git a/spec/fixtures/api/mixed-sandbox-app/main.js b/spec/fixtures/api/mixed-sandbox-app/main.js index 179c0813f327..4caeafb9a77f 100644 --- a/spec/fixtures/api/mixed-sandbox-app/main.js +++ b/spec/fixtures/api/mixed-sandbox-app/main.js @@ -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)) }