Repository navigation
New Feature: Migrate network emulation to Network.emulateNetworkConditionsByRule (#15508) - #3616
Merged
Merged
Conversation
…#15508) Implements puppeteer/puppeteer#15508 Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This was referenced Oct 15, 2026
lahma
added a commit
to sebastienros/jint
that referenced
this pull request
Oct 17, 2026
…ate and emulateNetworkConditionsByRule (#4292) * Answer PuppeteerSharp 25.14's offline mode: Network.overrideNetworkState and emulateNetworkConditionsByRule PuppeteerSharp 25.14 (hardkoded/puppeteer-sharp#3616, porting puppeteer/puppeteer#15508) moved SetOfflineModeAsync and EmulateNetworkConditionsAsync off the deprecated Network.emulateNetworkConditions onto the pair Chrome replaced it with: Network.overrideNetworkState, then Network.emulateNetworkConditionsByRule. Both answered -32601 here, and the failure was silent because PuppeteerSharp's NetworkManager.CanIgnoreError swallows any error whose message contains "wasn't found" - Chrome's own -32601 wording - so the first command's rejection was dropped and the second was never sent. The page stayed online. Both commands are now implemented and mapped the way Chrome maps them: - emulateNetworkConditionsByRule is the transport. It writes the same offline state emulateNetworkConditions always wrote, replacing it rather than merging, so the last of the two to be sent decides and an empty list goes back online. A global entry (empty urlPattern) is honoured; the first entry wins and the deprecated top-level offline overrides each entry's own, as in Chrome. An entry scoped to a URL is refused with -32000 rather than applied to every request or to none. One rule id is minted per entry. - overrideNetworkState is the navigator. navigator.onLine now reads the page's EmulationState.Offline instead of always answering true, and a change fires HTML's offline/online event at the window. It fails no request. - emulateNetworkConditions keeps working and now writes both halves, which is what Chrome does (one global rule plus the renderer's navigator override), so clearing through either form leaves nothing set through the other. The PuppeteerSharp pin moves to 25.14.0 in the same change, so PuppeteerSetsHeadersCookiesAndTakesThePageOffline proves the fix; it now also turns offline back off and reads navigator.onLine. The two methods move from "none" to "page" in HandshakeReplayTests.Absent. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01YVwU18SgMKKzYrrCh4TMpT * Pin what PuppeteerSharp's BlockList hears from the URL-scoped refusal ConnectOptions.BlockList and Allowlist are the PuppeteerSharp path that sends URL-scoped Network.emulateNetworkConditionsByRule entries, from ChromeTargetManager.MaybeSetupNetworkBlockListAsync on every attached target. That method catches every exception and logs "Failed to setup network block list", so the -32000 refusal reaches the client's log and never ConnectAsync, NewPageAsync or GoToAsync. Before the command was answered, its -32601 took the same catch (it is not NetworkManager's CanIgnoreError path). PuppeteerConnectsWithABlockListAndHearsTheUrlScopedRulesRefused connects with a block list through a recording ILoggerFactory, navigates to an allowed URL, has PuppeteerSharp's own pre-send check refuse the blocked one, and waits for the refusal's reason in the client's log. NetworkDomain's remarks name the path. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01YVwU18SgMKKzYrrCh4TMpT --------- Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
This was referenced Oct 19, 2026
This was referenced Oct 26, 2026
This was referenced Nov 9, 2026
This was referenced Nov 16, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Implements changes from puppeteer/puppeteer#15508
🤖 Generated with Claude Code