electron/spec/fixtures/api/net-log/main.js

34 lines
591 B
JavaScript
Raw Normal View History

2018-09-13 16:10:51 +00:00
const { app, net, netLog } = require('electron')
function request () {
return new Promise((resolve) => {
const req = net.request(process.env.TEST_REQUEST_URL)
req.on('response', () => {
resolve()
})
req.end()
})
}
function stopLogging () {
return new Promise((resolve) => {
netLog.stopLogging(() => {
resolve()
})
})
}
app.on('ready', async () => {
if (process.env.TEST_DUMP_FILE) {
netLog.startLogging(process.env.TEST_DUMP_FILE)
}
await request()
if (process.env.TEST_MANUAL_STOP) {
await stopLogging()
}
app.quit()
})