Exposing process.env status (#12166)
This commit is contained in:
parent
134872e9c1
commit
704af29543
4 changed files with 24 additions and 0 deletions
|
@ -44,6 +44,7 @@ preloadProcess.getSystemMemoryInfo = () => binding.getSystemMemoryInfo()
|
||||||
preloadProcess.argv = binding.getArgv()
|
preloadProcess.argv = binding.getArgv()
|
||||||
process.platform = preloadProcess.platform = electron.remote.process.platform
|
process.platform = preloadProcess.platform = electron.remote.process.platform
|
||||||
process.execPath = preloadProcess.execPath = electron.remote.process.execPath
|
process.execPath = preloadProcess.execPath = electron.remote.process.execPath
|
||||||
|
process.env = preloadProcess.env = electron.remote.process.env
|
||||||
process.on('exit', () => preloadProcess.emit('exit'))
|
process.on('exit', () => preloadProcess.emit('exit'))
|
||||||
|
|
||||||
// This is the `require` function that will be visible to the preload script
|
// This is the `require` function that will be visible to the preload script
|
||||||
|
|
|
@ -1539,6 +1539,23 @@ describe('BrowserWindow module', () => {
|
||||||
done()
|
done()
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
|
it('validate process.env access in sandbox renderer', (done) => {
|
||||||
|
ipcMain.once('answer', function (event, test) {
|
||||||
|
assert.equal(test, 'foo')
|
||||||
|
done()
|
||||||
|
})
|
||||||
|
remote.process.env.sandboxmain = 'foo'
|
||||||
|
w.destroy()
|
||||||
|
w = new BrowserWindow({
|
||||||
|
show: false,
|
||||||
|
webPreferences: {
|
||||||
|
sandbox: true,
|
||||||
|
preload: preload
|
||||||
|
}
|
||||||
|
})
|
||||||
|
w.loadURL('file://' + path.join(fixtures, 'api', 'preload.html'))
|
||||||
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
describe('nativeWindowOpen option', () => {
|
describe('nativeWindowOpen option', () => {
|
||||||
|
|
3
spec/fixtures/module/preload-sandbox.js
vendored
3
spec/fixtures/module/preload-sandbox.js
vendored
|
@ -7,6 +7,9 @@
|
||||||
if (location.protocol === 'file:') {
|
if (location.protocol === 'file:') {
|
||||||
window.test = 'preload'
|
window.test = 'preload'
|
||||||
window.process = process
|
window.process = process
|
||||||
|
if (process.env.sandboxmain) {
|
||||||
|
window.test = process.env.sandboxmain
|
||||||
|
}
|
||||||
} else if (location.href !== 'about:blank') {
|
} else if (location.href !== 'about:blank') {
|
||||||
addEventListener('DOMContentLoaded', () => {
|
addEventListener('DOMContentLoaded', () => {
|
||||||
ipcRenderer.send('child-loaded', window.opener == null, document.body.innerHTML)
|
ipcRenderer.send('child-loaded', window.opener == null, document.body.innerHTML)
|
||||||
|
|
|
@ -38,6 +38,9 @@ process.env.ELECTRON_DISABLE_SECURITY_WARNINGS = true
|
||||||
// eslint-disable-next-line
|
// eslint-disable-next-line
|
||||||
process.stdout
|
process.stdout
|
||||||
|
|
||||||
|
// Adding a variable for sandbox process.env test validation
|
||||||
|
process.env.sandboxmain = ''
|
||||||
|
|
||||||
// Access console to reproduce #3482.
|
// Access console to reproduce #3482.
|
||||||
// eslint-disable-next-line
|
// eslint-disable-next-line
|
||||||
console
|
console
|
||||||
|
|
Loading…
Reference in a new issue