2018-10-04 18:08:56 +00:00
|
|
|
const { app, net, session } = require('electron')
|
|
|
|
|
|
|
|
if (process.env.TEST_DUMP_FILE) {
|
|
|
|
app.commandLine.appendSwitch('log-net-log', process.env.TEST_DUMP_FILE)
|
|
|
|
}
|
2018-06-19 01:45:58 +00:00
|
|
|
|
|
|
|
function request () {
|
|
|
|
return new Promise((resolve) => {
|
|
|
|
const req = net.request(process.env.TEST_REQUEST_URL)
|
|
|
|
req.on('response', () => {
|
|
|
|
resolve()
|
|
|
|
})
|
|
|
|
req.end()
|
|
|
|
})
|
|
|
|
}
|
|
|
|
|
|
|
|
app.on('ready', async () => {
|
2018-10-04 18:08:56 +00:00
|
|
|
const netLog = session.defaultSession.netLog
|
2018-06-19 01:45:58 +00:00
|
|
|
|
2018-10-04 18:08:56 +00:00
|
|
|
// The net log exporter becomes ready only after
|
|
|
|
// default path is setup, which is posted as task
|
|
|
|
// to a sequenced task runner due to sync IO operations,
|
|
|
|
// the task are blocked for some reason,
|
|
|
|
// revisit task scheduling after 69 upgrade and fix this workaround.
|
|
|
|
setImmediate(async () => {
|
|
|
|
if (process.env.TEST_DUMP_FILE_DYNAMIC) {
|
|
|
|
netLog.startLogging(process.env.TEST_DUMP_FILE_DYNAMIC)
|
|
|
|
}
|
2018-06-19 01:45:58 +00:00
|
|
|
|
2018-10-04 18:08:56 +00:00
|
|
|
await request()
|
2018-06-19 01:45:58 +00:00
|
|
|
|
2018-10-04 18:08:56 +00:00
|
|
|
if (process.env.TEST_MANUAL_STOP) {
|
2019-02-19 10:48:27 +00:00
|
|
|
await netLog.stopLogging()
|
2018-10-04 18:08:56 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
app.quit()
|
|
|
|
})
|
2018-06-19 01:45:58 +00:00
|
|
|
})
|