Repository navigation
[1.16] Allow setting a referrer and other options in Page::navigate() - #740
Merged
Merged
Conversation
Closed
GrahamCampbell
force-pushed
the
navigate-referrer
branch
from
July 6, 2026 01:19
9d06393 to
41fd9e1
Compare
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.
There is currently no way to set the referrer for a navigation. Faking one with setExtraHTTPHeaders is not equivalent, since that stamps the header on every request including subresources, and a referrer policy cannot be expressed that way at all, which is what #530, #596 and #696 asked for. The only correct mechanism is the referrer, referrerPolicy and transitionType parameters of Page.navigate itself. This picks up @waahhhh's change from #701, retargeted at 1.16, with the original commit included as authored.
A follow-up commit replaces the blind passthrough of the options array with a validated allowlist of strict, referrer, referrerPolicy and transitionType, throwing an InvalidArgumentException for anything else, following the precedent of the screenshot options validation. Passing arbitrary protocol parameters through is not safe here: frameId in particular would break PageNavigation, which hard-codes the main frame for its loader tracking, and a typo in an option name should fail loudly rather than being silently dropped by the browser. The follow-up also restores the option documentation on the navigate docblocks rather than deferring to a protocol link, documents the options in the README, and adds tests covering the referrer end to end and the rejection of unsupported options. Since PageNavigation's constructor was internal until 1.16, reshaping its signature is safe here. Supersedes #701. Closes #696.