WIP: Adding UT
This commit is contained in:
parent
421bf71b98
commit
0b7e7458c9
4 changed files with 112 additions and 0 deletions
52
spec/fixtures/api/mixed-sandbox-app/main.js
vendored
Normal file
52
spec/fixtures/api/mixed-sandbox-app/main.js
vendored
Normal file
|
@ -0,0 +1,52 @@
|
|||
const { app, BrowserWindow, dialog } = 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', () => {
|
||||
app.exit(1)
|
||||
})
|
||||
|
||||
app.once('ready', () => {
|
||||
|
||||
let lastArg = process.argv[process.argv.length - 1]
|
||||
const client = net.connect(socketPath)
|
||||
client.once('connect', () => {
|
||||
if (lastArg === '--enable-mixed-sandbox') {
|
||||
dialog.showErrorBox('connected', app.getAppPath())
|
||||
let window = new BrowserWindow({
|
||||
show: true,
|
||||
webPreferences: {
|
||||
preload: path.join(app.getAppPath(), 'electron-app-mixed-sandbox-preload.js'),
|
||||
sandbox: false
|
||||
}
|
||||
})
|
||||
|
||||
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))
|
||||
}
|
||||
})
|
||||
client.once('end', () => {
|
||||
app.exit(0)
|
||||
})
|
||||
|
||||
if (lastArg !== '--enable-mixed-sandbox') {
|
||||
app.relaunch({ args: process.argv.slice(1).concat('--enable-mixed-sandbox') })
|
||||
}
|
||||
})
|
Loading…
Add table
Add a link
Reference in a new issue