2016-03-25 20:03:49 +00:00
|
|
|
const assert = require('assert')
|
2016-06-29 16:37:10 +00:00
|
|
|
const ChildProcess = require('child_process')
|
2018-09-19 10:54:58 +00:00
|
|
|
const { expect } = require('chai')
|
2016-03-25 20:03:49 +00:00
|
|
|
const fs = require('fs')
|
|
|
|
const path = require('path')
|
|
|
|
const os = require('os')
|
2018-09-13 16:10:51 +00:00
|
|
|
const { ipcRenderer, remote } = require('electron')
|
2016-03-25 20:03:49 +00:00
|
|
|
|
2016-06-20 02:16:17 +00:00
|
|
|
const isCI = remote.getGlobal('isCi')
|
|
|
|
|
2017-10-27 20:45:58 +00:00
|
|
|
describe('node feature', () => {
|
|
|
|
const fixtures = path.join(__dirname, 'fixtures')
|
|
|
|
|
|
|
|
describe('child_process', () => {
|
2018-06-18 03:09:51 +00:00
|
|
|
describe('child_process.fork', () => {
|
2017-10-27 20:45:58 +00:00
|
|
|
it('works in current process', (done) => {
|
|
|
|
const child = ChildProcess.fork(path.join(fixtures, 'module', 'ping.js'))
|
|
|
|
child.on('message', (msg) => {
|
2018-09-13 16:10:51 +00:00
|
|
|
assert.strictEqual(msg, 'message')
|
2016-03-25 20:03:49 +00:00
|
|
|
done()
|
|
|
|
})
|
|
|
|
child.send('message')
|
|
|
|
})
|
|
|
|
|
2017-10-27 20:45:58 +00:00
|
|
|
it('preserves args', (done) => {
|
|
|
|
const args = ['--expose_gc', '-test', '1']
|
|
|
|
const child = ChildProcess.fork(path.join(fixtures, 'module', 'process_args.js'), args)
|
|
|
|
child.on('message', (msg) => {
|
2018-09-13 16:10:51 +00:00
|
|
|
assert.deepStrictEqual(args, msg.slice(2))
|
2016-03-25 20:03:49 +00:00
|
|
|
done()
|
|
|
|
})
|
|
|
|
child.send('message')
|
|
|
|
})
|
|
|
|
|
2017-10-27 20:45:58 +00:00
|
|
|
it('works in forked process', (done) => {
|
|
|
|
const child = ChildProcess.fork(path.join(fixtures, 'module', 'fork_ping.js'))
|
|
|
|
child.on('message', (msg) => {
|
2018-09-13 16:10:51 +00:00
|
|
|
assert.strictEqual(msg, 'message')
|
2016-03-25 20:03:49 +00:00
|
|
|
done()
|
|
|
|
})
|
|
|
|
child.send('message')
|
|
|
|
})
|
|
|
|
|
2017-10-27 20:45:58 +00:00
|
|
|
it('works in forked process when options.env is specifed', (done) => {
|
|
|
|
const child = ChildProcess.fork(path.join(fixtures, 'module', 'fork_ping.js'), [], {
|
2016-01-12 02:40:23 +00:00
|
|
|
path: process.env['PATH']
|
2016-03-25 20:03:49 +00:00
|
|
|
})
|
2017-10-27 20:45:58 +00:00
|
|
|
child.on('message', (msg) => {
|
2018-09-13 16:10:51 +00:00
|
|
|
assert.strictEqual(msg, 'message')
|
2016-03-25 20:03:49 +00:00
|
|
|
done()
|
|
|
|
})
|
|
|
|
child.send('message')
|
|
|
|
})
|
|
|
|
|
2017-10-27 20:45:58 +00:00
|
|
|
it('works in browser process', (done) => {
|
|
|
|
const fork = remote.require('child_process').fork
|
|
|
|
const child = fork(path.join(fixtures, 'module', 'ping.js'))
|
|
|
|
child.on('message', (msg) => {
|
2018-09-13 16:10:51 +00:00
|
|
|
assert.strictEqual(msg, 'message')
|
2016-03-25 20:03:49 +00:00
|
|
|
done()
|
|
|
|
})
|
|
|
|
child.send('message')
|
|
|
|
})
|
|
|
|
|
2017-10-27 20:45:58 +00:00
|
|
|
it('has String::localeCompare working in script', (done) => {
|
|
|
|
const child = ChildProcess.fork(path.join(fixtures, 'module', 'locale-compare.js'))
|
|
|
|
child.on('message', (msg) => {
|
2018-09-13 16:10:51 +00:00
|
|
|
assert.deepStrictEqual(msg, [0, -1, 1])
|
2016-03-25 20:03:49 +00:00
|
|
|
done()
|
|
|
|
})
|
|
|
|
child.send('message')
|
|
|
|
})
|
|
|
|
|
2017-10-27 20:45:58 +00:00
|
|
|
it('has setImmediate working in script', (done) => {
|
|
|
|
const child = ChildProcess.fork(path.join(fixtures, 'module', 'set-immediate.js'))
|
|
|
|
child.on('message', (msg) => {
|
2018-09-13 16:10:51 +00:00
|
|
|
assert.strictEqual(msg, 'ok')
|
2016-03-25 20:03:49 +00:00
|
|
|
done()
|
|
|
|
})
|
|
|
|
child.send('message')
|
|
|
|
})
|
2016-05-31 01:26:19 +00:00
|
|
|
|
2017-10-27 20:45:58 +00:00
|
|
|
it('pipes stdio', (done) => {
|
2018-09-13 16:10:51 +00:00
|
|
|
const child = ChildProcess.fork(path.join(fixtures, 'module', 'process-stdout.js'), { silent: true })
|
2016-05-31 01:26:19 +00:00
|
|
|
let data = ''
|
|
|
|
child.stdout.on('data', (chunk) => {
|
|
|
|
data += String(chunk)
|
|
|
|
})
|
2017-04-20 18:40:04 +00:00
|
|
|
child.on('close', (code) => {
|
2018-09-13 16:10:51 +00:00
|
|
|
assert.strictEqual(code, 0)
|
|
|
|
assert.strictEqual(data, 'pipes stdio')
|
2016-05-31 01:26:19 +00:00
|
|
|
done()
|
|
|
|
})
|
|
|
|
})
|
2017-04-06 16:47:33 +00:00
|
|
|
|
2017-10-27 20:45:58 +00:00
|
|
|
it('works when sending a message to a process forked with the --eval argument', (done) => {
|
2017-04-06 16:52:52 +00:00
|
|
|
const source = "process.on('message', (message) => { process.send(message) })"
|
2017-04-06 16:47:33 +00:00
|
|
|
const forked = ChildProcess.fork('--eval', [source])
|
2017-04-06 16:52:52 +00:00
|
|
|
forked.once('message', (message) => {
|
2018-09-13 16:10:51 +00:00
|
|
|
assert.strictEqual(message, 'hello')
|
2017-04-06 16:47:33 +00:00
|
|
|
done()
|
|
|
|
})
|
|
|
|
forked.send('hello')
|
|
|
|
})
|
2016-03-25 20:03:49 +00:00
|
|
|
})
|
2016-10-12 20:01:43 +00:00
|
|
|
|
2018-06-18 03:35:49 +00:00
|
|
|
describe('child_process.spawn', () => {
|
2017-06-12 21:04:57 +00:00
|
|
|
let child
|
|
|
|
|
2017-10-27 20:45:58 +00:00
|
|
|
afterEach(() => {
|
|
|
|
if (child != null) child.kill()
|
2017-06-12 21:04:57 +00:00
|
|
|
})
|
|
|
|
|
2017-10-27 20:45:58 +00:00
|
|
|
it('supports spawning Electron as a node process via the ELECTRON_RUN_AS_NODE env var', (done) => {
|
2017-06-12 21:04:57 +00:00
|
|
|
child = ChildProcess.spawn(process.execPath, [path.join(__dirname, 'fixtures', 'module', 'run-as-node.js')], {
|
2016-10-12 20:01:43 +00:00
|
|
|
env: {
|
|
|
|
ELECTRON_RUN_AS_NODE: true
|
|
|
|
}
|
|
|
|
})
|
|
|
|
|
|
|
|
let output = ''
|
2017-10-27 20:45:58 +00:00
|
|
|
child.stdout.on('data', (data) => {
|
2016-10-12 20:01:43 +00:00
|
|
|
output += data
|
|
|
|
})
|
2017-10-27 20:45:58 +00:00
|
|
|
child.stdout.on('close', () => {
|
2018-09-13 16:10:51 +00:00
|
|
|
assert.deepStrictEqual(JSON.parse(output), {
|
2016-10-12 20:01:43 +00:00
|
|
|
processLog: process.platform === 'win32' ? 'function' : 'undefined',
|
|
|
|
processType: 'undefined',
|
|
|
|
window: 'undefined'
|
|
|
|
})
|
|
|
|
done()
|
|
|
|
})
|
|
|
|
})
|
|
|
|
})
|
2016-03-25 20:03:49 +00:00
|
|
|
})
|
|
|
|
|
2017-10-27 20:45:58 +00:00
|
|
|
describe('contexts', () => {
|
|
|
|
describe('setTimeout in fs callback', () => {
|
|
|
|
it('does not crash', (done) => {
|
|
|
|
fs.readFile(__filename, () => {
|
2016-03-25 20:03:49 +00:00
|
|
|
setTimeout(done, 0)
|
|
|
|
})
|
|
|
|
})
|
|
|
|
})
|
|
|
|
|
2017-10-27 20:45:58 +00:00
|
|
|
describe('error thrown in renderer process node context', () => {
|
|
|
|
it('gets emitted as a process uncaughtException event', (done) => {
|
2017-01-25 16:55:38 +00:00
|
|
|
const error = new Error('boo!')
|
|
|
|
const listeners = process.listeners('uncaughtException')
|
2016-03-25 20:03:49 +00:00
|
|
|
process.removeAllListeners('uncaughtException')
|
2017-01-25 16:55:38 +00:00
|
|
|
process.on('uncaughtException', (thrown) => {
|
|
|
|
assert.strictEqual(thrown, error)
|
2016-03-25 20:03:49 +00:00
|
|
|
process.removeAllListeners('uncaughtException')
|
2017-01-25 16:55:38 +00:00
|
|
|
listeners.forEach((listener) => {
|
|
|
|
process.on('uncaughtException', listener)
|
|
|
|
})
|
2016-03-25 20:03:49 +00:00
|
|
|
done()
|
|
|
|
})
|
2017-01-25 16:55:38 +00:00
|
|
|
fs.readFile(__filename, () => {
|
2016-03-25 20:03:49 +00:00
|
|
|
throw error
|
|
|
|
})
|
|
|
|
})
|
|
|
|
})
|
|
|
|
|
2017-10-27 20:45:58 +00:00
|
|
|
describe('error thrown in main process node context', () => {
|
|
|
|
it('gets emitted as a process uncaughtException event', () => {
|
2017-01-25 16:55:38 +00:00
|
|
|
const error = ipcRenderer.sendSync('handle-uncaught-exception', 'hello')
|
2018-09-13 16:10:51 +00:00
|
|
|
assert.strictEqual(error, 'hello')
|
2017-01-25 16:55:38 +00:00
|
|
|
})
|
|
|
|
})
|
|
|
|
|
2017-10-27 20:45:58 +00:00
|
|
|
describe('promise rejection in main process node context', () => {
|
|
|
|
it('gets emitted as a process unhandledRejection event', () => {
|
2017-01-25 17:04:25 +00:00
|
|
|
const error = ipcRenderer.sendSync('handle-unhandled-rejection', 'hello')
|
2018-09-13 16:10:51 +00:00
|
|
|
assert.strictEqual(error, 'hello')
|
2017-01-25 17:04:25 +00:00
|
|
|
})
|
|
|
|
})
|
|
|
|
|
2017-10-27 20:45:58 +00:00
|
|
|
describe('setTimeout called under Chromium event loop in browser process', () => {
|
|
|
|
it('can be scheduled in time', (done) => {
|
2016-03-25 20:03:49 +00:00
|
|
|
remote.getGlobal('setTimeout')(done, 0)
|
|
|
|
})
|
2018-07-30 01:14:04 +00:00
|
|
|
|
|
|
|
it('can be promisified', (done) => {
|
|
|
|
remote.getGlobal('setTimeoutPromisified')(0).then(done)
|
|
|
|
})
|
2016-03-25 20:03:49 +00:00
|
|
|
})
|
|
|
|
|
2017-10-27 20:45:58 +00:00
|
|
|
describe('setInterval called under Chromium event loop in browser process', () => {
|
|
|
|
it('can be scheduled in time', (done) => {
|
2018-03-07 05:40:27 +00:00
|
|
|
let interval = null
|
2018-03-14 05:51:47 +00:00
|
|
|
let clearing = false
|
2018-03-07 05:40:27 +00:00
|
|
|
const clear = () => {
|
2018-03-14 05:51:47 +00:00
|
|
|
if (interval === null || clearing) {
|
2018-03-07 05:40:27 +00:00
|
|
|
return
|
|
|
|
}
|
2018-03-14 05:51:47 +00:00
|
|
|
// interval might trigger while clearing (remote is slow sometimes)
|
|
|
|
clearing = true
|
2016-03-25 20:03:49 +00:00
|
|
|
remote.getGlobal('clearInterval')(interval)
|
2018-03-14 05:51:47 +00:00
|
|
|
clearing = false
|
2018-03-07 05:40:27 +00:00
|
|
|
interval = null
|
2016-03-25 20:03:49 +00:00
|
|
|
done()
|
|
|
|
}
|
|
|
|
interval = remote.getGlobal('setInterval')(clear, 10)
|
|
|
|
})
|
|
|
|
})
|
|
|
|
})
|
|
|
|
|
2018-06-18 03:29:46 +00:00
|
|
|
describe('inspector', () => {
|
2018-09-19 10:54:58 +00:00
|
|
|
let child = null
|
2017-11-06 14:25:48 +00:00
|
|
|
|
|
|
|
afterEach(() => {
|
2018-09-19 10:54:58 +00:00
|
|
|
if (child !== null) child.kill()
|
2017-11-06 14:25:48 +00:00
|
|
|
})
|
|
|
|
|
|
|
|
it('supports starting the v8 inspector with --inspect/--inspect-brk', (done) => {
|
|
|
|
child = ChildProcess.spawn(process.execPath, ['--inspect-brk', path.join(__dirname, 'fixtures', 'module', 'run-as-node.js')], {
|
|
|
|
env: {
|
|
|
|
ELECTRON_RUN_AS_NODE: true
|
|
|
|
}
|
|
|
|
})
|
|
|
|
|
|
|
|
let output = ''
|
2018-10-02 06:36:22 +00:00
|
|
|
function cleanup () {
|
|
|
|
child.stderr.removeListener('data', errorDataListener)
|
|
|
|
child.stdout.removeListener('data', outDataHandler)
|
|
|
|
}
|
|
|
|
function errorDataListener (data) {
|
2017-11-06 14:25:48 +00:00
|
|
|
output += data
|
2018-10-02 06:36:22 +00:00
|
|
|
if (output.trim().startsWith('Debugger listening on ws://')) {
|
|
|
|
cleanup()
|
|
|
|
done()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
function outDataHandler (data) {
|
|
|
|
cleanup()
|
2017-11-06 14:25:48 +00:00
|
|
|
done(new Error(`Unexpected output: ${data.toString()}`))
|
2018-10-02 06:36:22 +00:00
|
|
|
}
|
|
|
|
child.stderr.on('data', errorDataListener)
|
|
|
|
child.stdout.on('data', outDataHandler)
|
2017-11-06 14:25:48 +00:00
|
|
|
})
|
|
|
|
|
|
|
|
it('supports js binding', (done) => {
|
|
|
|
child = ChildProcess.spawn(process.execPath, ['--inspect', path.join(__dirname, 'fixtures', 'module', 'inspector-binding.js')], {
|
|
|
|
env: {
|
|
|
|
ELECTRON_RUN_AS_NODE: true
|
|
|
|
},
|
|
|
|
stdio: ['ipc']
|
|
|
|
})
|
|
|
|
|
2018-09-13 16:10:51 +00:00
|
|
|
child.on('message', ({ cmd, debuggerEnabled, secondSessionOpened, success }) => {
|
2017-11-06 14:25:48 +00:00
|
|
|
if (cmd === 'assert') {
|
2018-09-13 16:10:51 +00:00
|
|
|
assert.strictEqual(debuggerEnabled, true)
|
|
|
|
assert.strictEqual(secondSessionOpened, true)
|
|
|
|
assert.strictEqual(success, true)
|
2017-11-06 14:25:48 +00:00
|
|
|
done()
|
|
|
|
}
|
|
|
|
})
|
|
|
|
})
|
|
|
|
})
|
|
|
|
|
2017-10-27 20:45:58 +00:00
|
|
|
describe('message loop', () => {
|
|
|
|
describe('process.nextTick', () => {
|
|
|
|
it('emits the callback', (done) => {
|
2016-03-25 20:03:49 +00:00
|
|
|
process.nextTick(done)
|
|
|
|
})
|
|
|
|
|
2017-10-27 20:45:58 +00:00
|
|
|
it('works in nested calls', (done) => {
|
|
|
|
process.nextTick(() => {
|
|
|
|
process.nextTick(() => {
|
2016-03-25 20:03:49 +00:00
|
|
|
process.nextTick(done)
|
|
|
|
})
|
|
|
|
})
|
|
|
|
})
|
|
|
|
})
|
|
|
|
|
2017-10-27 20:45:58 +00:00
|
|
|
describe('setImmediate', () => {
|
|
|
|
it('emits the callback', (done) => {
|
2016-03-25 20:03:49 +00:00
|
|
|
setImmediate(done)
|
|
|
|
})
|
|
|
|
|
2017-10-27 20:45:58 +00:00
|
|
|
it('works in nested calls', (done) => {
|
|
|
|
setImmediate(() => {
|
|
|
|
setImmediate(() => {
|
2016-03-25 20:03:49 +00:00
|
|
|
setImmediate(done)
|
|
|
|
})
|
|
|
|
})
|
|
|
|
})
|
|
|
|
})
|
|
|
|
})
|
|
|
|
|
2017-10-27 20:45:58 +00:00
|
|
|
describe('net.connect', () => {
|
2017-11-15 21:05:46 +00:00
|
|
|
before(function () {
|
|
|
|
if (process.platform !== 'darwin') {
|
|
|
|
this.skip()
|
|
|
|
}
|
|
|
|
})
|
2016-02-17 01:09:41 +00:00
|
|
|
|
2018-06-18 14:24:26 +00:00
|
|
|
it('emit error when connect to a socket path without listeners', (done) => {
|
2017-10-27 20:45:58 +00:00
|
|
|
const socketPath = path.join(os.tmpdir(), 'atom-shell-test.sock')
|
|
|
|
const script = path.join(fixtures, 'module', 'create_socket.js')
|
|
|
|
const child = ChildProcess.fork(script, [socketPath])
|
|
|
|
child.on('exit', (code) => {
|
2018-09-13 16:10:51 +00:00
|
|
|
assert.strictEqual(code, 0)
|
2017-10-27 20:45:58 +00:00
|
|
|
const client = require('net').connect(socketPath)
|
|
|
|
client.on('error', (error) => {
|
2018-09-13 16:10:51 +00:00
|
|
|
assert.strictEqual(error.code, 'ECONNREFUSED')
|
2016-03-25 20:03:49 +00:00
|
|
|
done()
|
|
|
|
})
|
|
|
|
})
|
|
|
|
})
|
|
|
|
})
|
|
|
|
|
2017-10-27 20:45:58 +00:00
|
|
|
describe('Buffer', () => {
|
|
|
|
it('can be created from WebKit external string', () => {
|
|
|
|
const p = document.createElement('p')
|
2016-03-25 20:03:49 +00:00
|
|
|
p.innerText = '闲云潭影日悠悠,物换星移几度秋'
|
2017-11-23 22:22:31 +00:00
|
|
|
const b = Buffer.from(p.innerText)
|
2018-09-13 16:10:51 +00:00
|
|
|
assert.strictEqual(b.toString(), '闲云潭影日悠悠,物换星移几度秋')
|
|
|
|
assert.strictEqual(Buffer.byteLength(p.innerText), 45)
|
2016-03-25 20:03:49 +00:00
|
|
|
})
|
|
|
|
|
2017-10-27 20:45:58 +00:00
|
|
|
it('correctly parses external one-byte UTF8 string', () => {
|
|
|
|
const p = document.createElement('p')
|
2016-03-25 20:03:49 +00:00
|
|
|
p.innerText = 'Jøhänñéß'
|
2017-11-23 22:22:31 +00:00
|
|
|
const b = Buffer.from(p.innerText)
|
2018-09-13 16:10:51 +00:00
|
|
|
assert.strictEqual(b.toString(), 'Jøhänñéß')
|
|
|
|
assert.strictEqual(Buffer.byteLength(p.innerText), 13)
|
2016-03-25 20:03:49 +00:00
|
|
|
})
|
2016-04-05 08:08:27 +00:00
|
|
|
|
2017-10-27 20:45:58 +00:00
|
|
|
it('does not crash when creating large Buffers', () => {
|
2017-11-23 22:22:31 +00:00
|
|
|
let buffer = Buffer.from(new Array(4096).join(' '))
|
2018-09-13 16:10:51 +00:00
|
|
|
assert.strictEqual(buffer.length, 4095)
|
2017-11-23 22:22:31 +00:00
|
|
|
buffer = Buffer.from(new Array(4097).join(' '))
|
2018-09-13 16:10:51 +00:00
|
|
|
assert.strictEqual(buffer.length, 4096)
|
2016-04-05 08:08:27 +00:00
|
|
|
})
|
2017-12-27 11:14:41 +00:00
|
|
|
|
|
|
|
it('does not crash for crypto operations', () => {
|
|
|
|
const crypto = require('crypto')
|
|
|
|
const data = 'lG9E+/g4JmRmedDAnihtBD4Dfaha/GFOjd+xUOQI05UtfVX3DjUXvrS98p7kZQwY3LNhdiFo7MY5rGft8yBuDhKuNNag9vRx/44IuClDhdQ='
|
|
|
|
const key = 'q90K9yBqhWZnAMCMTOJfPQ=='
|
|
|
|
const cipherText = '{"error_code":114,"error_message":"Tham số không hợp lệ","data":null}'
|
|
|
|
for (let i = 0; i < 10000; ++i) {
|
2018-10-02 01:56:31 +00:00
|
|
|
const iv = Buffer.from('0'.repeat(32), 'hex')
|
|
|
|
const input = Buffer.from(data, 'base64')
|
|
|
|
const decipher = crypto.createDecipheriv('aes-128-cbc', Buffer.from(key, 'base64'), iv)
|
|
|
|
const result = Buffer.concat([decipher.update(input), decipher.final()]).toString('utf8')
|
2018-09-13 16:10:51 +00:00
|
|
|
assert.strictEqual(cipherText, result)
|
2017-12-27 11:14:41 +00:00
|
|
|
}
|
|
|
|
})
|
2016-03-25 20:03:49 +00:00
|
|
|
})
|
|
|
|
|
2017-10-27 20:45:58 +00:00
|
|
|
describe('process.stdout', () => {
|
|
|
|
it('does not throw an exception when accessed', () => {
|
|
|
|
assert.doesNotThrow(() => {
|
2017-11-23 22:22:43 +00:00
|
|
|
// eslint-disable-next-line
|
2016-09-07 21:40:18 +00:00
|
|
|
process.stdout
|
|
|
|
})
|
2016-03-25 20:03:49 +00:00
|
|
|
})
|
|
|
|
|
2017-10-27 20:45:58 +00:00
|
|
|
it('does not throw an exception when calling write()', () => {
|
|
|
|
assert.doesNotThrow(() => {
|
2016-09-07 21:40:18 +00:00
|
|
|
process.stdout.write('test')
|
|
|
|
})
|
2016-03-25 20:03:49 +00:00
|
|
|
})
|
|
|
|
|
2017-11-15 21:05:46 +00:00
|
|
|
it('should have isTTY defined on Mac and Linux', function () {
|
|
|
|
if (isCI || process.platform === 'win32') {
|
2018-09-19 10:54:58 +00:00
|
|
|
this.skip()
|
2017-11-15 21:05:46 +00:00
|
|
|
return
|
|
|
|
}
|
|
|
|
|
2018-09-13 16:10:51 +00:00
|
|
|
assert.strictEqual(typeof process.stdout.isTTY, 'boolean')
|
2017-11-15 21:05:46 +00:00
|
|
|
})
|
2016-06-20 02:16:17 +00:00
|
|
|
|
2017-11-15 21:05:46 +00:00
|
|
|
it('should have isTTY undefined on Windows', function () {
|
|
|
|
if (isCI || process.platform !== 'win32') {
|
2018-09-19 10:54:58 +00:00
|
|
|
this.skip()
|
2017-11-15 21:05:46 +00:00
|
|
|
return
|
2016-09-08 20:12:00 +00:00
|
|
|
}
|
2017-11-15 21:05:46 +00:00
|
|
|
|
2018-09-13 16:10:51 +00:00
|
|
|
assert.strictEqual(process.stdout.isTTY, undefined)
|
2016-03-25 20:03:49 +00:00
|
|
|
})
|
|
|
|
})
|
|
|
|
|
2017-10-27 20:45:58 +00:00
|
|
|
describe('process.stdin', () => {
|
|
|
|
it('does not throw an exception when accessed', () => {
|
|
|
|
assert.doesNotThrow(() => {
|
2017-11-23 22:22:43 +00:00
|
|
|
process.stdin // eslint-disable-line
|
2016-09-07 21:40:18 +00:00
|
|
|
})
|
|
|
|
})
|
|
|
|
|
2017-10-27 20:45:58 +00:00
|
|
|
it('returns null when read from', () => {
|
2018-09-13 16:10:51 +00:00
|
|
|
assert.strictEqual(process.stdin.read(), null)
|
2016-09-07 21:40:18 +00:00
|
|
|
})
|
|
|
|
})
|
|
|
|
|
2017-10-27 20:45:58 +00:00
|
|
|
describe('process.version', () => {
|
|
|
|
it('should not have -pre', () => {
|
2016-04-05 10:53:07 +00:00
|
|
|
assert(!process.version.endsWith('-pre'))
|
|
|
|
})
|
|
|
|
})
|
|
|
|
|
2018-09-19 10:54:58 +00:00
|
|
|
describe('vm.runInNewContext', () => {
|
2017-10-27 20:45:58 +00:00
|
|
|
it('should not crash', () => {
|
2016-03-25 20:03:49 +00:00
|
|
|
require('vm').runInNewContext('')
|
|
|
|
})
|
|
|
|
})
|
2017-01-12 01:51:46 +00:00
|
|
|
|
|
|
|
it('includes the electron version in process.versions', () => {
|
2018-09-19 10:54:58 +00:00
|
|
|
expect(process.versions)
|
|
|
|
.to.have.own.property('electron')
|
|
|
|
.that.is.a('string')
|
|
|
|
.and.matches(/^\d+\.\d+\.\d+(\S*)?$/)
|
2017-01-12 01:51:46 +00:00
|
|
|
})
|
|
|
|
|
|
|
|
it('includes the chrome version in process.versions', () => {
|
2018-09-19 10:54:58 +00:00
|
|
|
expect(process.versions)
|
|
|
|
.to.have.own.property('chrome')
|
|
|
|
.that.is.a('string')
|
|
|
|
.and.matches(/^\d+\.\d+\.\d+\.\d+$/)
|
2017-01-12 01:51:46 +00:00
|
|
|
})
|
2016-03-25 20:03:49 +00:00
|
|
|
})
|