Merge pull request #2914 from deepak1556/network_emulation_api_patch

session: api to emulate network conditions
This commit is contained in:
Cheng Zhao 2015-09-28 17:02:23 +08:00
commit a987715222
4 changed files with 72 additions and 1 deletions

View file

@ -191,3 +191,30 @@ proxy-uri = [<proxy-scheme>"://"]<proxy-host>[":"<proxy-port>]
Sets download saving directory. By default, the download directory will be the
`Downloads` under the respective app folder.
### `session.enableNetworkEmulation(options)`
* `options` Object
* `offline` Boolean - Whether to emulate network outage.
* `latency` Double - RTT in ms
* `downloadThroughput` Double - Download rate in Bps
* `uploadThroughput` Double - Upload rate in Bps
Emulates network with the given configuration for the `session`.
```javascript
// To emulate a GPRS connection with 50kbps throughput and 500 ms latency.
window.webContents.session.enableNetworkEmulation({
latency: 500,
downloadThroughput: 6400,
uploadThroughput: 6400
});
// To emulate a network outage.
window.webContents.session.enableNetworkEmulation({offline: true});
```
### `session.disableNetworkEmulation`
Disables any network emulation already active for the `session`. Resets to
the original network configuration.