electron/spec/fixtures/api/net-log/main.js
2018-09-14 14:57:01 +10:00

33 lines
591 B
JavaScript

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()
})