Skip to main content
Version: Next

Browser.restrictNetwork() method

Sets the network conditions (blocklist or allowlist) and re-applies the conditions to all targets. To clear all network conditions, omit the argument or pass null.

Signature​

class Browser {
restrictNetwork(conditions?: NetworkRestrictions | null): Promise<void>;
}

Parameters​

Parameter

Type

Description

conditions

NetworkRestrictions | null

(Optional) The network conditions to apply.

Returns:

Promise<void>

Remarks​

Currently only supported for Chrome and the CDP protocol.

Targets that are already on a blocked URL when restrictNetwork is called will remain attached and stay on the blocked page. This is a behavior difference compared to launching the browser with network restrictions, where such targets are detached immediately upon initial attach.

The restrictions have the same WebTransport and WebRTC limitations as ConnectOptions.blocklist and ConnectOptions.allowlist.