Hacktoberfest 2026: le issue che i maintainer hanno segnato per ottobre, aperte e adatte ai principianti. Sfoglia le issue Hacktoberfest

[Bug]: Chromium – locale is not applied to Accept-Language / navigator.languages inside dedicated Workers

Chiusa
#43,484 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 1 giorno

Una pull request collegata è già stata integrata.

  • #43488 di @yury-s — integrata

Valutazione

Difficoltà
3/5
Tempo stimato
Mezza giornata
Idoneità per principianti
25/100
Tipo di issue
Bug
Chiarezza
Specificata chiaramente
Stato di attività
Attiva
Stack tecnologico
typescript

Direzione di ricerca

Start with the worker branch of FrameSession._onAttachedToTarget in crPage.ts, where the userAgent override is applied to dedicated Workers but acceptLanguage is not. Run the repro script from the issue to confirm the worker's Accept-Language and navigator.languages still show the default locale. Pull request #43488 already targets this, so review it before starting. Done means the worker's fetch sends de-DE and navigator.languages reads de-DE, with the page's behaviour unchanged.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

Version

1.64.1

Steps to reproduce

(versions reproduced: 1.59.1 and 1.64.1)
Save as repro.js, run npm i playwright && npx playwright install chromium && node repro.js.

const http = require('http');
const { chromium } = require('playwright');

const seen = [];
const server = http.createServer((req, res) => {
  seen.push(`${req.url.padEnd(40)} Accept-Language: ${req.headers['accept-language']}`);
  if (req.url === '/') {
    res.writeHead(200, { 'content-type': 'text/html' });
    return res.end(`<script>
      fetch('/from-page?languages=' + navigator.languages);
      new Worker('/worker.js');
    </script>`);
  }
  if (req.url === '/worker.js') {
    res.writeHead(200, { 'content-type': 'text/javascript' });
    return res.end(`fetch('/from-worker?languages=' + navigator.languages);`);
  }
  res.end('ok');
});

(async () => {
  await new Promise(r => server.listen(0, '127.0.0.1', r));
  const browser = await chromium.launch();
  const context = await browser.newContext({ locale: 'de-DE' });
  const page = await context.newPage();
  await page.goto(`http://127.0.0.1:${server.address().port}/`);
  await page.waitForTimeout(1000);
  console.log(`Chromium ${browser.version()}`);
  console.log(seen.filter(line => !line.startsWith('/favicon')).join('\n'));
  await browser.close();
  server.close();
})();
Expected behavior

Requests made from inside the Worker send Accept-Language: de-DE, and navigator.languages inside the Worker is de-DE, matching the page.

Actual behavior
Chromium 147.0.7727.15
/                                        Accept-Language: de-DE
/from-page?languages=de-DE               Accept-Language: de-DE
/worker.js                               Accept-Language: de-DE
/from-worker?languages=en-US             Accept-Language: en-US,en;q=0.9

The Worker's own fetch uses the browser default Accept-Language, and its navigator.languages ignores locale.

Additional context

userAgent is propagated to dedicated Workers, but locale is not. In crPage.ts (FrameSession._onAttachedToTarget), the worker branch doesn't call setUserAgentOverride with acceptLanguage. Sending Emulation.setUserAgentOverride({ userAgent, acceptLanguage: 'de-DE' }) on the worker's CDP session fixes both the header and navigator.languages, similar to what #41071 did for service workers. Related: #38919 (Firefox, fixed), #13919.

Environment
System:
    OS: macOS 26.7.1
    CPU: (14) arm64 Apple M4 Pro
    Memory: 3.03 GB / 48.00 GB
  Binaries:
    Node: 24.15.0 - ~/.volta/tools/image/node/24.15.0/bin/node
    npm: 11.12.1 - ~/.volta/tools/image/npm/11.12.1/bin/npm
    bun: 1.3.1 - ~/.bun/bin/bun
  IDEs:
    VSCode: 1.142.0 - /usr/local/bin/code
  Languages:
    Bash: 5.3.3 - /opt/homebrew/bin/bash
  npmPackages:
    playwright: 1.59.1 => 1.59.1
Lingua principale
TypeScript
Stelle
98.5k
Fork
6.7k
Merge medio
15h 42m
PR unite (30g)
313

Preparare l'ambiente

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di microsoft/playwright

Tutte le issue di microsoft/playwright

Issue simili

Altre issue su TypeScript

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.