← Back to Network domain

Network.emulateNetworkConditionsByRule

Activates emulation of network conditions for individual requests using URL match patterns. Unlike the deprecated Network.emulateNetworkConditions this method does not affect `navigator` state. Use Network.overrideNetworkState to explicitly modify `navigator` behavior.

Domain: Network experimental

Parameters

NameTypeDescription
offline (optional)booleanTrue to emulate internet disconnection. Deprecated, use the offline property in matchedNetworkConditions or emulateOfflineServiceWorker instead.
emulateOfflineServiceWorker (optional)booleanTrue to emulate offline service worker.
matchedNetworkConditionsarrayConfigure conditions for matching requests. If multiple entries match a request, the first entry wins. Global conditions can be configured by leaving the urlPattern for the conditions empty. These global conditions are also applied for throttling of p2p connections.

Returns

NameTypeDescription
ruleIdsarrayAn id for each entry in matchedNetworkConditions. The id will be included in the requestWillBeSentExtraInfo for requests affected by a rule.

Example Request

{
  "id": 1,
  "method": "Network.emulateNetworkConditionsByRule",
  "params": {
    "matchedNetworkConditions": []
  }
}

Example Response

{
  "id": 1,
  "result": {
    "ruleIds": []
  }
}

Usage in Node.js

const result = await send('Network.emulateNetworkConditionsByRule', {"matchedNetworkConditions": []});
console.log(result);
// {"ruleIds": []}