2020-03-20 20:28:31 +00:00
|
|
|
const { app, net, session } = require('electron');
|
2019-05-23 22:31:38 +00:00
|
|
|
|
|
|
|
if (process.env.TEST_DUMP_FILE) {
|
2020-03-20 20:28:31 +00:00
|
|
|
app.commandLine.appendSwitch('log-net-log', process.env.TEST_DUMP_FILE);
|
2019-05-23 22:31:38 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
function request () {
|
|
|
|
return new Promise((resolve) => {
|
2020-03-20 20:28:31 +00:00
|
|
|
const req = net.request(process.env.TEST_REQUEST_URL);
|
2019-05-23 22:31:38 +00:00
|
|
|
req.on('response', () => {
|
2020-03-20 20:28:31 +00:00
|
|
|
resolve();
|
|
|
|
});
|
|
|
|
req.end();
|
|
|
|
});
|
2019-05-23 22:31:38 +00:00
|
|
|
}
|
|
|
|
|
2020-02-03 22:43:22 +00:00
|
|
|
app.whenReady().then(async () => {
|
2020-03-20 20:28:31 +00:00
|
|
|
const netLog = session.defaultSession.netLog;
|
2019-05-23 22:31:38 +00:00
|
|
|
|
|
|
|
if (process.env.TEST_DUMP_FILE_DYNAMIC) {
|
2020-03-20 20:28:31 +00:00
|
|
|
await netLog.startLogging(process.env.TEST_DUMP_FILE_DYNAMIC);
|
2019-05-23 22:31:38 +00:00
|
|
|
}
|
|
|
|
|
2020-03-20 20:28:31 +00:00
|
|
|
await request();
|
2019-05-23 22:31:38 +00:00
|
|
|
|
|
|
|
if (process.env.TEST_MANUAL_STOP) {
|
2020-03-20 20:28:31 +00:00
|
|
|
await netLog.stopLogging();
|
2019-05-23 22:31:38 +00:00
|
|
|
}
|
|
|
|
|
2020-03-20 20:28:31 +00:00
|
|
|
app.quit();
|
|
|
|
});
|