window.navigator.language incorrectly returns all lowercase string
authorcdumez@apple.com <cdumez@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sat, 8 Oct 2016 03:31:15 +0000 (03:31 +0000)
committercdumez@apple.com <cdumez@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sat, 8 Oct 2016 03:31:15 +0000 (03:31 +0000)
commit1e246d42f08f499d9252944077dd1c2dc6a20733
tree71762db9d199b240b0f0513a2d0dbe1b5e838d16
parent20c99f2869495e85765e855ad34a6fd3388039fa
window.navigator.language incorrectly returns all lowercase string
https://bugs.webkit.org/show_bug.cgi?id=163096

Reviewed by Darin Adler.

Source/WebCore:

Update navigator.language so that it no longer returns an all lowercase
string (e.g. 'en-us' -> 'en-US'). This matches the behavior of other
browsers and the specification which indicate we should return a
BCP 47 language tag:
- https://html.spec.whatwg.org/#dom-navigator-language
- https://tools.ietf.org/html/bcp47

The other call sites relying on userPreferredLanguages() use case
insensitive comparison so they will not break.

No new tests, updated existing test.

* platform/Language.h:

Source/WTF:

Update platformUserPreferredLanguages() so that it no longer lowercases
the string it returns. On Mac, we rely on CFLocale which returns
BCP-47 language tags as per:
- https://developer.apple.com/reference/corefoundation/1666963-cflocale?language=objc

* wtf/PlatformUserPreferredLanguagesMac.mm:
(WTF::httpStyleLanguageCode):
* wtf/PlatformUserPreferredLanguagesUnix.cpp:
(WTF::platformLanguage):

LayoutTests:

Update existing test so that it does not lowercase navigator.language
before checking it. This way, we can make sure it returns en-US and
not en-us.

* js/dom/navigator-language-expected.txt:
* js/dom/navigator-language.html:

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@206949 268f45cc-cd09-0410-ab3c-d52691b4dbfc
LayoutTests/ChangeLog
LayoutTests/js/dom/navigator-language-expected.txt
LayoutTests/js/dom/navigator-language.html
Source/WTF/ChangeLog
Source/WTF/wtf/PlatformUserPreferredLanguagesMac.mm
Source/WTF/wtf/PlatformUserPreferredLanguagesUnix.cpp
Source/WebCore/ChangeLog
Source/WebCore/platform/Language.h