From 18ed92bd08a4c14e7d17f96af6802bc75d29b7fb Mon Sep 17 00:00:00 2001 From: Jan Scheffler Date: Fri, 30 Jul 2021 10:41:42 +0200 Subject: [PATCH] chore: update documentation (#7446) Reference `page.setOfflineMode` and `page.emulateNetworkConditions` from each other. --- docs/api.md | 7 +++++-- src/common/Page.ts | 7 ++++++- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/docs/api.md b/docs/api.md index fb9678fa346..fd756446674 100644 --- a/docs/api.md +++ b/docs/api.md @@ -1706,7 +1706,8 @@ await page.evaluate(() => matchMedia('print').matches); - `latency` <[number]> Latency (ms), `0` to disable - returns: <[Promise]> -> **NOTE** This does not affect WebSockets and WebRTC PeerConnections (see https://crbug.com/563644) +> **NOTE** This does not affect WebSockets and WebRTC PeerConnections (see https://crbug.com/563644). To set the page offline, you can use [page.setOfflineMode(enabled)](#pagesetofflinemodeenabled). + ```js const puppeteer = require('puppeteer'); @@ -2323,9 +2324,11 @@ await page.setGeolocation({ latitude: 59.95, longitude: 30.31667 }); #### page.setOfflineMode(enabled) -- `enabled` <[boolean]> When `true`, enables offline mode for the page. +- `enabled` <[boolean]> When `true`, enables offline mode for the page. - returns: <[Promise]> +> **NOTE** while this method sets the network connection to offline, it does not change the parameters used in [page.emulateNetworkConditions(networkConditions)](#pageemulatenetworkconditionsnetworkconditions). + #### page.setRequestInterception(value) - `value` <[boolean]> Whether to enable request interception. diff --git a/src/common/Page.ts b/src/common/Page.ts index f75a7ffa77c..d8ad85b30e1 100644 --- a/src/common/Page.ts +++ b/src/common/Page.ts @@ -854,6 +854,10 @@ export class Page extends EventEmitter { /** * @param enabled - When `true`, enables offline mode for the page. + * @remarks + * NOTE: while this method sets the network connection to offline, it does + * not change the parameters used in [page.emulateNetworkConditions(networkConditions)] + * (#pageemulatenetworkconditionsnetworkconditions) */ setOfflineMode(enabled: boolean): Promise { return this._frameManager.networkManager().setOfflineMode(enabled); @@ -877,7 +881,8 @@ export class Page extends EventEmitter { * ``` * @remarks * NOTE: This does not affect WebSockets and WebRTC PeerConnections (see - * https://crbug.com/563644) + * https://crbug.com/563644). To set the page offline, you can use + * [page.setOfflineMode(enabled)](#pagesetofflinemodeenabled). */ emulateNetworkConditions( networkConditions: NetworkConditions | null