Skip to content

[1.16] Allow setting a referrer and other options in Page::navigate() - #740

Merged
GrahamCampbell merged 2 commits into
1.16from
navigate-referrer
Jul 6, 2026
Merged

GrahamCampbell merged 2 commits into
1.16from
navigate-referrer

Conversation

@GrahamCampbell

Copy link
Copy Markdown
Member

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.

@GrahamCampbell GrahamCampbell mentioned this pull request Jul 6, 2026
@GrahamCampbell
GrahamCampbell merged commit 294e8f3 into 1.16 Jul 6, 2026
40 checks passed
@GrahamCampbell
GrahamCampbell deleted the navigate-referrer branch July 6, 2026 01:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

2 participants