Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
1 task done
lazka opened this issue Jun 15, 2023 · 3 comments
Open
1 task done

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

lazka opened this issue Jun 15, 2023 · 3 comments

Comments

@lazka
Copy link

lazka commented Jun 15, 2023

System info

  • Playwright Version: 1.32.3
  • Operating System: Ubuntu 23.04
  • Browser: Firefox
  • Other info:

Source code

  • I provided exact source code that allows reproducing the issue locally.

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

  • Run the test with Chromium
  • Look at the web dev tools network tab and check the request headers
  • See that Accept-Language=de is sent
  • Run the test with Firefox
  • Look at the web dev tools network tab and check the request headers

Expected

  • The request is sent with the Accept-Language=de header, same as with Chromium

Actual

  • The request is sent with the Accept-Language=en-GB header instead
@yury-s
Copy link
Member

yury-s commented Jun 15, 2023

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.

@yury-s yury-s self-assigned this Jun 15, 2023
@aslushnikov aslushnikov changed the title [BUG] Wrong Accept-Language sent with Firefox only [BUG] Wrong Accept-Language sent with Firefox and WebKit Jul 7, 2023
@aslushnikov aslushnikov removed the v1.36 label Jul 7, 2023
@bschelling
Copy link

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
Copy link

avetisk commented Nov 29, 2023

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.

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

No branches or pull requests

5 participants