Skip to content

Stop the browser on a redirect when followRedirects(false) - #54

Draft
kbond wants to merge 3 commits into
playwright-php:mainfrom
kbond:redirect-interception
Draft

Stop the browser on a redirect when followRedirects(false)#54
kbond wants to merge 3 commits into
playwright-php:mainfrom
kbond:redirect-interception

Conversation

@kbond

@kbond kbond commented Aug 14, 2026

Copy link
Copy Markdown
Collaborator

Draft: this branch is based on #53, so the diff includes it. I will rebase once that lands.

followRedirects(false) currently does nothing. The flag is inherited from AbstractBrowser and isFollowingRedirects() reports it correctly, but the route handler follows every 3xx regardless.

This makes it stop instead: the 3xx is fulfilled as a 200 with no Location and an empty body, so the browser parks on the url that redirected while getLastSymfonyResponse() keeps the real status and Location for the caller to inspect. The body has to be dropped because a RedirectResponse carries a <meta http-equiv="refresh"> that navigates whatever the status says.

followRedirect() then steps a stopped redirect one hop at a time. fetch redirects keep their client-side replay: followRedirects() is about where the test client navigates, not what application JS asked fetch() to do.

This is what zenstruck/browser needs for interceptRedirects(), followRedirect(), assertRedirected(), assertRedirectedTo() and clickAndIntercept(), whose existing KernelBrowser implementations already call exactly followRedirects(false).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant