refactor: netLog directly uses network service (#18289)
This commit is contained in:
parent
d57df5a4a1
commit
646f572b77
10 changed files with 220 additions and 141 deletions
31
spec-main/fixtures/api/net-log/main.js
Normal file
31
spec-main/fixtures/api/net-log/main.js
Normal file
|
@ -0,0 +1,31 @@
|
|||
const { app, net, session } = require('electron')
|
||||
|
||||
if (process.env.TEST_DUMP_FILE) {
|
||||
app.commandLine.appendSwitch('log-net-log', process.env.TEST_DUMP_FILE)
|
||||
}
|
||||
|
||||
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 () => {
|
||||
const netLog = session.defaultSession.netLog
|
||||
|
||||
if (process.env.TEST_DUMP_FILE_DYNAMIC) {
|
||||
await netLog.startLogging(process.env.TEST_DUMP_FILE_DYNAMIC)
|
||||
}
|
||||
|
||||
await request()
|
||||
|
||||
if (process.env.TEST_MANUAL_STOP) {
|
||||
await netLog.stopLogging()
|
||||
}
|
||||
|
||||
app.quit()
|
||||
})
|
Loading…
Add table
Add a link
Reference in a new issue