<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>[206949] trunk</title>
</head>
<body>
<style type="text/css"><!--
#msg dl.meta { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dl.meta dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer, #logmsg { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; }
#msg dl a { font-weight: bold}
#msg dl a:link { color:#fc3; }
#msg dl a:active { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: bold; }
#msg pre { overflow: auto; background: #ffc; border: 1px #fa0 solid; padding: 6px; }
#logmsg { background: #ffc; border: 1px #fa0 solid; padding: 1em 1em 0 1em; }
#logmsg p, #logmsg pre, #logmsg blockquote { margin: 0 0 1em 0; }
#logmsg p, #logmsg li, #logmsg dt, #logmsg dd { line-height: 14pt; }
#logmsg h1, #logmsg h2, #logmsg h3, #logmsg h4, #logmsg h5, #logmsg h6 { margin: .5em 0; }
#logmsg h1:first-child, #logmsg h2:first-child, #logmsg h3:first-child, #logmsg h4:first-child, #logmsg h5:first-child, #logmsg h6:first-child { margin-top: 0; }
#logmsg ul, #logmsg ol { padding: 0; list-style-position: inside; margin: 0 0 0 1em; }
#logmsg ul { text-indent: -1em; padding-left: 1em; }#logmsg ol { text-indent: -1.5em; padding-left: 1.5em; }
#logmsg > ul, #logmsg > ol { margin: 0 0 1em 0; }
#logmsg pre { background: #eee; padding: 1em; }
#logmsg blockquote { border: 1px solid #fa0; border-left-width: 10px; padding: 1em 1em 0 1em; background: white;}
#logmsg dl { margin: 0; }
#logmsg dt { font-weight: bold; }
#logmsg dd { margin: 0; padding: 0 0 0.5em 0; }
#logmsg dd:before { content:'\00bb';}
#logmsg table { border-spacing: 0px; border-collapse: collapse; border-top: 4px solid #fa0; border-bottom: 1px solid #fa0; background: #fff; }
#logmsg table th { text-align: left; font-weight: normal; padding: 0.2em 0.5em; border-top: 1px dotted #fa0; }
#logmsg table td { text-align: right; border-top: 1px dotted #fa0; padding: 0.2em 0.5em; }
#logmsg table thead th { text-align: center; border-bottom: 1px solid #fa0; }
#logmsg table th.Corner { text-align: left; }
#logmsg hr { border: none 0; border-top: 2px dashed #fa0; height: 1px; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: 6px; }
#patch { width: 100%; }
#patch h4 {font-family: verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
#patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;}
#patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;}
#patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;}
#patch .lines, .info {color:#888;background:#fff;}
--></style>
<div id="msg">
<dl class="meta">
<dt>Revision</dt> <dd><a href="http://trac.webkit.org/projects/webkit/changeset/206949">206949</a></dd>
<dt>Author</dt> <dd>cdumez@apple.com</dd>
<dt>Date</dt> <dd>2016-10-07 20:31:15 -0700 (Fri, 07 Oct 2016)</dd>
</dl>
<h3>Log Message</h3>
<pre>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:</pre>
<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkLayoutTestsChangeLog">trunk/LayoutTests/ChangeLog</a></li>
<li><a href="#trunkLayoutTestsjsdomnavigatorlanguageexpectedtxt">trunk/LayoutTests/js/dom/navigator-language-expected.txt</a></li>
<li><a href="#trunkLayoutTestsjsdomnavigatorlanguagehtml">trunk/LayoutTests/js/dom/navigator-language.html</a></li>
<li><a href="#trunkSourceWTFChangeLog">trunk/Source/WTF/ChangeLog</a></li>
<li><a href="#trunkSourceWTFwtfPlatformUserPreferredLanguagesMacmm">trunk/Source/WTF/wtf/PlatformUserPreferredLanguagesMac.mm</a></li>
<li><a href="#trunkSourceWTFwtfPlatformUserPreferredLanguagesUnixcpp">trunk/Source/WTF/wtf/PlatformUserPreferredLanguagesUnix.cpp</a></li>
<li><a href="#trunkSourceWebCoreChangeLog">trunk/Source/WebCore/ChangeLog</a></li>
<li><a href="#trunkSourceWebCoreplatformLanguageh">trunk/Source/WebCore/platform/Language.h</a></li>
</ul>
</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkLayoutTestsChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/ChangeLog (206948 => 206949)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/ChangeLog        2016-10-08 03:20:53 UTC (rev 206948)
+++ trunk/LayoutTests/ChangeLog        2016-10-08 03:31:15 UTC (rev 206949)
</span><span class="lines">@@ -1,3 +1,17 @@
</span><ins>+2016-10-07 Chris Dumez <cdumez@apple.com>
+
+ window.navigator.language incorrectly returns all lowercase string
+ https://bugs.webkit.org/show_bug.cgi?id=163096
+
+ Reviewed by Darin Adler.
+
+ 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:
+
</ins><span class="cx"> 2016-10-07 Yusuke Suzuki <utatane.tea@gmail.com>
</span><span class="cx">
</span><span class="cx"> REGRESSION (r206853?): LayoutTest js/regress-141098.html failing
</span></span></pre></div>
<a id="trunkLayoutTestsjsdomnavigatorlanguageexpectedtxt"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/js/dom/navigator-language-expected.txt (206948 => 206949)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/js/dom/navigator-language-expected.txt        2016-10-08 03:20:53 UTC (rev 206948)
+++ trunk/LayoutTests/js/dom/navigator-language-expected.txt        2016-10-08 03:31:15 UTC (rev 206949)
</span><span class="lines">@@ -2,7 +2,7 @@
</span><span class="cx"> On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
</span><span class="cx">
</span><span class="cx">
</span><del>-PASS language is 'en-us'
</del><ins>+PASS language is 'en-US'
</ins><span class="cx"> PASS successfullyParsed is true
</span><span class="cx">
</span><span class="cx"> TEST COMPLETE
</span></span></pre></div>
<a id="trunkLayoutTestsjsdomnavigatorlanguagehtml"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/js/dom/navigator-language.html (206948 => 206949)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/js/dom/navigator-language.html        2016-10-08 03:20:53 UTC (rev 206948)
+++ trunk/LayoutTests/js/dom/navigator-language.html        2016-10-08 03:31:15 UTC (rev 206949)
</span><span class="lines">@@ -14,11 +14,11 @@
</span><span class="cx"> testRunner.setPOSIXLocale("en_US.iso88591");
</span><span class="cx"> }
</span><span class="cx">
</span><del>-var language = navigator.language.toLowerCase();
</del><ins>+var language = navigator.language;
</ins><span class="cx"> if (language.length == 2)
</span><span class="cx"> shouldBe("language", "'en'");
</span><span class="cx"> else
</span><del>- shouldBe("language", "'en-us'");
</del><ins>+ shouldBe("language", "'en-US'");
</ins><span class="cx"> </script>
</span><span class="cx"> <script src="../../resources/js-test-post.js"></script>
</span><span class="cx"> </body>
</span></span></pre></div>
<a id="trunkSourceWTFChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WTF/ChangeLog (206948 => 206949)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WTF/ChangeLog        2016-10-08 03:20:53 UTC (rev 206948)
+++ trunk/Source/WTF/ChangeLog        2016-10-08 03:31:15 UTC (rev 206949)
</span><span class="lines">@@ -1,3 +1,20 @@
</span><ins>+2016-10-07 Chris Dumez <cdumez@apple.com>
+
+ window.navigator.language incorrectly returns all lowercase string
+ https://bugs.webkit.org/show_bug.cgi?id=163096
+
+ Reviewed by Darin Adler.
+
+ 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):
+
</ins><span class="cx"> 2016-10-06 Brent Fulgham <bfulgham@apple.com>
</span><span class="cx">
</span><span class="cx"> [Win][Direct2D] Add Direct2D CMake rules
</span></span></pre></div>
<a id="trunkSourceWTFwtfPlatformUserPreferredLanguagesMacmm"></a>
<div class="modfile"><h4>Modified: trunk/Source/WTF/wtf/PlatformUserPreferredLanguagesMac.mm (206948 => 206949)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WTF/wtf/PlatformUserPreferredLanguagesMac.mm        2016-10-08 03:20:53 UTC (rev 206948)
+++ trunk/Source/WTF/wtf/PlatformUserPreferredLanguagesMac.mm        2016-10-08 03:31:15 UTC (rev 206949)
</span><span class="lines">@@ -80,10 +80,10 @@
</span><span class="cx"> static String httpStyleLanguageCode(NSString *language)
</span><span class="cx"> {
</span><span class="cx"> SInt32 languageCode;
</span><del>- SInt32 regionCode;
- SInt32 scriptCode;
</del><ins>+ SInt32 regionCode;
+ SInt32 scriptCode;
</ins><span class="cx"> CFStringEncoding stringEncoding;
</span><del>-
</del><ins>+
</ins><span class="cx"> // FIXME: This transformation is very wrong:
</span><span class="cx"> // 1. There is no reason why CFBundle localization names would be at all related to language names as used on the Web.
</span><span class="cx"> // 2. Script Manager codes cannot represent all languages that are now supported by the platform, so the conversion is lossy.
</span><span class="lines">@@ -93,17 +93,14 @@
</span><span class="cx"> if (preferredLanguageCode)
</span><span class="cx"> language = (NSString *)preferredLanguageCode.get();
</span><span class="cx">
</span><del>- // Make the string lowercase.
- NSString *lowercaseLanguageCode = [language lowercaseString];
-
</del><span class="cx"> // Turn a '_' into a '-' if it appears after a 2-letter language code
</span><del>- if ([lowercaseLanguageCode length] >= 3 && [lowercaseLanguageCode characterAtIndex:2] == '_') {
- RetainPtr<NSMutableString> mutableLanguageCode = adoptNS([lowercaseLanguageCode mutableCopy]);
</del><ins>+ if ([language length] >= 3 && [language characterAtIndex:2] == '_') {
+ RetainPtr<NSMutableString> mutableLanguageCode = adoptNS([language mutableCopy]);
</ins><span class="cx"> [mutableLanguageCode.get() replaceCharactersInRange:NSMakeRange(2, 1) withString:@"-"];
</span><span class="cx"> return mutableLanguageCode.get();
</span><span class="cx"> }
</span><span class="cx">
</span><del>- return lowercaseLanguageCode;
</del><ins>+ return language;
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> Vector<String> platformUserPreferredLanguages()
</span></span></pre></div>
<a id="trunkSourceWTFwtfPlatformUserPreferredLanguagesUnixcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WTF/wtf/PlatformUserPreferredLanguagesUnix.cpp (206948 => 206949)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WTF/wtf/PlatformUserPreferredLanguagesUnix.cpp        2016-10-08 03:20:53 UTC (rev 206948)
+++ trunk/Source/WTF/wtf/PlatformUserPreferredLanguagesUnix.cpp        2016-10-08 03:31:15 UTC (rev 206949)
</span><span class="lines">@@ -36,9 +36,9 @@
</span><span class="cx"> {
</span><span class="cx"> String localeDefault(setlocale(LC_CTYPE, nullptr));
</span><span class="cx"> if (localeDefault.isEmpty() || equalIgnoringASCIICase(localeDefault, "C") || equalIgnoringASCIICase(localeDefault, "POSIX"))
</span><del>- return ASCIILiteral("en-us");
</del><ins>+ return ASCIILiteral("en-US");
</ins><span class="cx">
</span><del>- String normalizedDefault = localeDefault.convertToASCIILowercase();
</del><ins>+ String normalizedDefault = localeDefault;
</ins><span class="cx"> normalizedDefault.replace('_', '-');
</span><span class="cx"> normalizedDefault.truncate(normalizedDefault.find('.'));
</span><span class="cx"> return normalizedDefault;
</span></span></pre></div>
<a id="trunkSourceWebCoreChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/ChangeLog (206948 => 206949)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/ChangeLog        2016-10-08 03:20:53 UTC (rev 206948)
+++ trunk/Source/WebCore/ChangeLog        2016-10-08 03:31:15 UTC (rev 206949)
</span><span class="lines">@@ -1,3 +1,24 @@
</span><ins>+2016-10-07 Chris Dumez <cdumez@apple.com>
+
+ window.navigator.language incorrectly returns all lowercase string
+ https://bugs.webkit.org/show_bug.cgi?id=163096
+
+ Reviewed by Darin Adler.
+
+ 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:
+
</ins><span class="cx"> 2016-10-07 Wenson Hsieh <wenson_hsieh@apple.com>
</span><span class="cx">
</span><span class="cx"> Support onbeforeinput event handling for the new InputEvent spec
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformLanguageh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/Language.h (206948 => 206949)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/Language.h        2016-10-08 03:20:53 UTC (rev 206948)
+++ trunk/Source/WebCore/platform/Language.h        2016-10-08 03:31:15 UTC (rev 206949)
</span><span class="lines">@@ -32,7 +32,7 @@
</span><span class="cx"> namespace WebCore {
</span><span class="cx">
</span><span class="cx"> WEBCORE_EXPORT String defaultLanguage(); // Thread-safe.
</span><del>-WEBCORE_EXPORT Vector<String> userPreferredLanguages(); // Thread-safe.
</del><ins>+WEBCORE_EXPORT Vector<String> userPreferredLanguages(); // Thread-safe, returns BCP 47 language tags.
</ins><span class="cx"> Vector<String> userPreferredLanguagesOverride();
</span><span class="cx"> WEBCORE_EXPORT void overrideUserPreferredLanguages(const Vector<String>&);
</span><span class="cx"> size_t indexOfBestMatchingLanguageInList(const String& language, const Vector<String>& languageList, bool& exactMatch);
</span></span></pre>
</div>
</div>
</body>
</html>