New issue
Advanced search Search tips

Issue 755338 link

Starred by 4 users

Issue metadata

Status: Available
Owner: ----
Cc:
Components:
EstimatedDays: ----
NextAction: ----
OS: ----
Pri: 3
Type: Bug

Blocking:
issue 705916


Show other hotlists

Hotlists containing this issue:
Hotlist-1


Sign in to add a comment

Headless chrome does not use correct locale for Date.prototype.toLocaleDateString()

Reported by hoe...@hsac.nl, Aug 14 2017

Issue description

Chrome Version       : 60.0.3112.101

I'm using Selenium to drive headless chrome (from Java on macOS), and I see a difference in the locale used as the system default between 'normal' and headless chrome.

(1) Open any URL using 'normal' chrome
(3) execute `return (new Date(2018, 8, 27)).toLocaleDateString()`, I get '27/09/2018'

(1) Open same URL using 'headless' chrome
(2) execute `return (new Date(2018, 8, 27)).toLocaleDateString()`, I get '9/27/2018'

Is this intentional, can I set the locale used by headless chrome in some way?

 
Components: Internals>Headless

Comment 2 by bokan@chromium.org, Aug 15 2017

Components: -Blink Blink>JavaScript
Components: -Blink>JavaScript
Labels: Needs-Triage-M60 TE-NeedsTriageHelp
The issue seems to be related to selenium driving headless chrome and it is out of TE-scope . Hence, adding  labelTE-NeedsTriageHelp for further investigation.

Thanks...!!

Labels: -TE-NeedsTriageHelp -Needs-Triage-M60
Status: Available (was: Unconfirmed)
I'm also seeing this kind of issue with Headless Chrome being driven by Puppeteer: https://github.com/GoogleChrome/puppeteer/issues/1871.
I don't think this is related to Selenium.

On mac, when I set my system lang to `en-GB` and examine `navigator.language`, headless doesn't take the system's lang prefs into account:

Headless chrome:
navigator.languages === 'en-US'
navigator.languages === ['en-US']

Headful chrome:
navigator.languages === 'en-GB'
navigator.languages === ['en-GB', 'en-US', 'en']

A workaround that may work for your use case is passing the --lang=<locale> parameter. This didn't seem to change the local on the 'normal' Chrome but led for locale to be detected properly for 'headless' Chrome.

Sign in to add a comment