Skip to content

[Bug]: ERR_INVALID_ARGUMENT on cross-origin redirect with routes enabled in Chromium #41690

Description

@gofr

Version

1.61.1

Steps to reproduce

Run this test on Chromium:

import http from 'node:http';

import { expect, test } from '@playwright/test';

test('route.continue should pass on 307 cross-origin redirect', async ({ page }) => {
  const originPort = 3401;
  const redirectPort = 3402;
  const finalPort = 3403;

  const finalServer = http.createServer((_req, res) => {
    res.writeHead(200, { 'content-type': 'text/html' });
    res.end('<!doctype html><title>final</title><p>ok</p>');
  });

  const redirectServer = http.createServer((_req, res) => {
    res.writeHead(307, { location: `http://127.0.0.1:${finalPort}/` });
    res.end();
  });

  const originServer = http.createServer((_req, res) => {
    res.writeHead(200, { 'content-type': 'text/html' });
    res.end(`<!doctype html><title>origin</title>
      <form id="f" method="POST" action="http://127.0.0.1:${redirectPort}/">
        <input type="submit">
      </form>`);
  });

  finalServer.listen(finalPort, '127.0.0.1');
  redirectServer.listen(redirectPort, '127.0.0.1');
  originServer.listen(originPort, '127.0.0.1');

  try {
    await page.route('**/*', async (route) => { await route.continue(); });
    await page.goto(`http://127.0.0.1:${originPort}/`);
    await Promise.all([
      page.waitForURL(`http://127.0.0.1:${finalPort}/`, { timeout: 2_000 }),
      page.locator('input').click(),
    ]);
    await expect(page.locator('p')).toHaveText('ok');
  } finally {
    originServer.close();
    redirectServer.close();
    finalServer.close();
  }
});

Expected behavior

Test passes.

Actual behavior

Final page fails to load with ERR_INVALID_ARGUMENT.

Additional context

The reason for the failure is this Chromium change: https://chromium.googlesource.com/chromium/src.git/+/fd71efb820447671572c62544e3a93a78e8a6d7f, introduced in 149.0.7798.0.

The test passes if:

Environment

Not relevant

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions