microsoft / playwright

Playwright is a framework for Web Testing and Automation. It allows testing Chromium, Firefox and WebKit with a single API.
https://playwright.dev
Apache License 2.0
65.65k stars 3.57k forks source link

[BUG] Wrong Accept-Language sent with Firefox and WebKit #23732

Open lazka opened 1 year ago

lazka commented 1 year ago

System info

Source code

Config file

// playwright.config.js
import { defineConfig, devices } from '@playwright/test';

export default defineConfig({
  projects: [
    {
      name: 'chromium',
      use: {
        ...devices['Desktop Chrome'],
      },
    },
    {
      name: 'firefox',
      use: {
        ...devices['Desktop Firefox'],
      },
    },
  ],
});

Test file (self-contained)

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

test.use({
  locale: 'en-GB',
});

test('test-send-with-Accept-Language', async ({ page }) => {
  await page.evaluate(async () => {
    await fetch(
      "https://api.github.com/rate_limit", {
        headers: {
            'Content-Type': 'application/json',
            'Accept-Language': 'de'
        },
      });
  });
});

Steps

Expected

Actual

yury-s commented 1 year ago

What I see in 1.35.0 is that all three browsers send three different values. Chromium doesn't send accept-language at all unless you add mode: 'no-cors'and in that case the header is equal to de.

bschelling commented 9 months ago

I just ran into something very similar: The accept language set as a customheaders is ignored, using the "locale" setting in the config works. I'd be fine if the "locale" setting would only overwrite the header if a value is present, but simply ignoring the accept-language header setting without any warning is evil.

avetisk commented 9 months ago

Indeed, I have the same issue where the custom accept-language header is overwritten in Firefox and Webkit.

It's annoying as hell as this feature works fine with the other browsers.

I'm going to try @bschelling's suggestion and see if I can temporary solve this using the locale setting.

mratzenb commented 3 weeks ago

Are there any updates on this bug? Version 1.46.1 has still the same behavior for Firefox.