Integration test: offline mode

This commit is contained in:
DC
2016-09-14 22:43:20 -07:00
parent bdb733352a
commit 9dabfc1367
2 changed files with 40 additions and 12 deletions

View File

@@ -151,13 +151,18 @@ function init () {
ipc.on('testOffline', function (e, isOffline) {
log('Testing, network ' + (isOffline ? 'OFFLINE' : 'ONLINE'))
// Get the two Electron BrowserWindows (main UI window, hidden webtorrent window)
const wins = [windows.main.win, windows.webtorrent.win]
wins.forEach(function (win) {
if (isOffline) win.webContents.session.enableNetworkEmulation({ latency: 10e3 })
else win.webContents.session.disableNetworkEmulation()
log('WTF')
})
windows.webtorrent.send('wt-test-offline')
// TODO: this easy way to disable networking doesn't work due to a Chrome bug.
// WebRTC is unaffected by DevTools throttling:
// https://bugs.chromium.org/p/chromium/issues/detail?id=490143
// Also doesn't work due to an Electron bug. Node networking APIs are unaffected, only
// Chrome networking (external resources, XHRs, etc) are affected.
// const wins = [windows.main.win, windows.webtorrent.win]
// wins.forEach(function (win) {
// if (isOffline) win.webContents.session.enableNetworkEmulation({ offline: true })
// else win.webContents.session.disableNetworkEmulation()
// !})
})
/**