<!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>[207096] releases/WebKitGTK/webkit-2.14</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/207096">207096</a></dd>
<dt>Author</dt> <dd>carlosgc@webkit.org</dd>
<dt>Date</dt> <dd>2016-10-11 04:58:38 -0700 (Tue, 11 Oct 2016)</dd>
</dl>
<h3>Log Message</h3>
<pre>Merge <a href="http://trac.webkit.org/projects/webkit/changeset/206295">r206295</a> - REGRESSION(<a href="http://trac.webkit.org/projects/webkit/changeset/194387">r194387</a>): Crash on github.com in IntlDateTimeFormat::resolvedOptions in C locale
https://bugs.webkit.org/show_bug.cgi?id=162139
Reviewed by Michael Catanzaro.
Source/JavaScriptCore:
The crash happens in unix ports because the resolved locale is empty when system locale is "C". IntlObject
considers any language tag with a size < 2 to be an invalid language, so "C" is not a valid language to resolve
the locale. We should ensure that WTF::platformUserPreferredLanguages() never returns invalid languages, but
that's not enough, because languages can be overriden from the public API, so we need to handle those cases and
throw exceptions instead of crashing.
* runtime/IntlCollator.cpp:
(JSC::IntlCollator::initializeCollator): Throw a exception when we fail to resolve the locale.
* runtime/IntlDateTimeFormat.cpp:
(JSC::IntlDateTimeFormat::initializeDateTimeFormat): Ditto.
* runtime/IntlNumberFormat.cpp:
(JSC::IntlNumberFormat::initializeNumberFormat): Ditto.
Source/WebKit2:
Handle the case of "C" locale passed by the user using "en-US" as default to match what
WTF::platformUserPreferredLanguages() does.
* UIProcess/API/gtk/WebKitWebContext.cpp:
(webkit_web_context_set_preferred_languages): Remove the call to languageDidChange() because
overrideUserPreferredLanguages() already calls it, so we were actually notifying the observers twice.
Source/WTF:
Handle the case of "C" or "POSIX" locale and use "en-US" as default. That matches what ICU and other ports do,
as well as what layout tests expect (some tests like js/intl-collator.html pass in the bots only because we use
en-US as system locale in those bots).
* wtf/PlatformUserPreferredLanguagesUnix.cpp:
(WTF::platformLanguage):
Tools:
Add test cases to check the behavior when using the C locale and an invalid locale.
* TestWebKitAPI/Tests/WebKit2Gtk/TestWebKitWebContext.cpp:
(testWebContextLanguages):
LayoutTests:
* js/intl-invalid-locale-crash-expected.txt: Added.
* js/intl-invalid-locale-crash.html: Added.</pre>
<h3>Modified Paths</h3>
<ul>
<li><a href="#releasesWebKitGTKwebkit214LayoutTestsChangeLog">releases/WebKitGTK/webkit-2.14/LayoutTests/ChangeLog</a></li>
<li><a href="#releasesWebKitGTKwebkit214SourceJavaScriptCoreChangeLog">releases/WebKitGTK/webkit-2.14/Source/JavaScriptCore/ChangeLog</a></li>
<li><a href="#releasesWebKitGTKwebkit214SourceJavaScriptCoreruntimeIntlCollatorcpp">releases/WebKitGTK/webkit-2.14/Source/JavaScriptCore/runtime/IntlCollator.cpp</a></li>
<li><a href="#releasesWebKitGTKwebkit214SourceJavaScriptCoreruntimeIntlDateTimeFormatcpp">releases/WebKitGTK/webkit-2.14/Source/JavaScriptCore/runtime/IntlDateTimeFormat.cpp</a></li>
<li><a href="#releasesWebKitGTKwebkit214SourceJavaScriptCoreruntimeIntlNumberFormatcpp">releases/WebKitGTK/webkit-2.14/Source/JavaScriptCore/runtime/IntlNumberFormat.cpp</a></li>
<li><a href="#releasesWebKitGTKwebkit214SourceWTFChangeLog">releases/WebKitGTK/webkit-2.14/Source/WTF/ChangeLog</a></li>
<li><a href="#releasesWebKitGTKwebkit214SourceWTFwtfPlatformUserPreferredLanguagesUnixcpp">releases/WebKitGTK/webkit-2.14/Source/WTF/wtf/PlatformUserPreferredLanguagesUnix.cpp</a></li>
<li><a href="#releasesWebKitGTKwebkit214SourceWebKit2ChangeLog">releases/WebKitGTK/webkit-2.14/Source/WebKit2/ChangeLog</a></li>
<li><a href="#releasesWebKitGTKwebkit214SourceWebKit2UIProcessAPIgtkWebKitWebContextcpp">releases/WebKitGTK/webkit-2.14/Source/WebKit2/UIProcess/API/gtk/WebKitWebContext.cpp</a></li>
<li><a href="#releasesWebKitGTKwebkit214ToolsChangeLog">releases/WebKitGTK/webkit-2.14/Tools/ChangeLog</a></li>
<li><a href="#releasesWebKitGTKwebkit214ToolsTestWebKitAPITestsWebKit2GtkTestWebKitWebContextcpp">releases/WebKitGTK/webkit-2.14/Tools/TestWebKitAPI/Tests/WebKit2Gtk/TestWebKitWebContext.cpp</a></li>
</ul>
<h3>Added Paths</h3>
<ul>
<li><a href="#releasesWebKitGTKwebkit214LayoutTestsjsintlinvalidlocalecrashexpectedtxt">releases/WebKitGTK/webkit-2.14/LayoutTests/js/intl-invalid-locale-crash-expected.txt</a></li>
<li><a href="#releasesWebKitGTKwebkit214LayoutTestsjsintlinvalidlocalecrashhtml">releases/WebKitGTK/webkit-2.14/LayoutTests/js/intl-invalid-locale-crash.html</a></li>
</ul>
</div>
<div id="patch">
<h3>Diff</h3>
<a id="releasesWebKitGTKwebkit214LayoutTestsChangeLog"></a>
<div class="modfile"><h4>Modified: releases/WebKitGTK/webkit-2.14/LayoutTests/ChangeLog (207095 => 207096)</h4>
<pre class="diff"><span>
<span class="info">--- releases/WebKitGTK/webkit-2.14/LayoutTests/ChangeLog        2016-10-11 11:52:19 UTC (rev 207095)
+++ releases/WebKitGTK/webkit-2.14/LayoutTests/ChangeLog        2016-10-11 11:58:38 UTC (rev 207096)
</span><span class="lines">@@ -1,3 +1,13 @@
</span><ins>+2016-09-23 Carlos Garcia Campos <cgarcia@igalia.com>
+
+ REGRESSION(r194387): Crash on github.com in IntlDateTimeFormat::resolvedOptions in C locale
+ https://bugs.webkit.org/show_bug.cgi?id=162139
+
+ Reviewed by Michael Catanzaro.
+
+ * js/intl-invalid-locale-crash-expected.txt: Added.
+ * js/intl-invalid-locale-crash.html: Added.
+
</ins><span class="cx"> 2016-09-22 Brady Eidson <beidson@apple.com>
</span><span class="cx">
</span><span class="cx"> IDBIndex.openCursor() matches indices on multiple object stores.
</span></span></pre></div>
<a id="releasesWebKitGTKwebkit214LayoutTestsjsintlinvalidlocalecrashexpectedtxt"></a>
<div class="addfile"><h4>Added: releases/WebKitGTK/webkit-2.14/LayoutTests/js/intl-invalid-locale-crash-expected.txt (0 => 207096)</h4>
<pre class="diff"><span>
<span class="info">--- releases/WebKitGTK/webkit-2.14/LayoutTests/js/intl-invalid-locale-crash-expected.txt         (rev 0)
+++ releases/WebKitGTK/webkit-2.14/LayoutTests/js/intl-invalid-locale-crash-expected.txt        2016-10-11 11:58:38 UTC (rev 207096)
</span><span class="lines">@@ -0,0 +1,7 @@
</span><ins>+PASS new Intl.DateTimeFormat().resolvedOptions() threw exception TypeError: failed to initialize DateTimeFormat due to invalid locale.
+PASS new Intl.NumberFormat().resolvedOptions() threw exception TypeError: failed to initialize NumberFormat due to invalid locale.
+PASS new Intl.Collator().resolvedOptions() threw exception TypeError: failed to initialize Collator due to invalid locale.
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
</ins></span></pre></div>
<a id="releasesWebKitGTKwebkit214LayoutTestsjsintlinvalidlocalecrashhtml"></a>
<div class="addfile"><h4>Added: releases/WebKitGTK/webkit-2.14/LayoutTests/js/intl-invalid-locale-crash.html (0 => 207096)</h4>
<pre class="diff"><span>
<span class="info">--- releases/WebKitGTK/webkit-2.14/LayoutTests/js/intl-invalid-locale-crash.html         (rev 0)
+++ releases/WebKitGTK/webkit-2.14/LayoutTests/js/intl-invalid-locale-crash.html        2016-10-11 11:58:38 UTC (rev 207096)
</span><span class="lines">@@ -0,0 +1,19 @@
</span><ins>+<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
+<html>
+<head>
+<meta charset="utf-8">
+<script src="../resources/js-test-pre.js"></script>
+</head>
+<body>
+<script>
+if (window.internals) {
+ // Any language name with less than two characters is considered invalid, so we use "a" here.
+ window.internals.setUserPreferredLanguages(["a"]);
+}
+shouldThrow("new Intl.DateTimeFormat().resolvedOptions()", "'TypeError: failed to initialize DateTimeFormat due to invalid locale'");
+shouldThrow("new Intl.NumberFormat().resolvedOptions()", "'TypeError: failed to initialize NumberFormat due to invalid locale'");
+shouldThrow("new Intl.Collator().resolvedOptions()", "'TypeError: failed to initialize Collator due to invalid locale'");
+</script>
+<script src="../resources/js-test-post.js"></script>
+</body>
+</html>
</ins></span></pre></div>
<a id="releasesWebKitGTKwebkit214SourceJavaScriptCoreChangeLog"></a>
<div class="modfile"><h4>Modified: releases/WebKitGTK/webkit-2.14/Source/JavaScriptCore/ChangeLog (207095 => 207096)</h4>
<pre class="diff"><span>
<span class="info">--- releases/WebKitGTK/webkit-2.14/Source/JavaScriptCore/ChangeLog        2016-10-11 11:52:19 UTC (rev 207095)
+++ releases/WebKitGTK/webkit-2.14/Source/JavaScriptCore/ChangeLog        2016-10-11 11:58:38 UTC (rev 207096)
</span><span class="lines">@@ -1,3 +1,23 @@
</span><ins>+2016-09-23 Carlos Garcia Campos <cgarcia@igalia.com>
+
+ REGRESSION(r194387): Crash on github.com in IntlDateTimeFormat::resolvedOptions in C locale
+ https://bugs.webkit.org/show_bug.cgi?id=162139
+
+ Reviewed by Michael Catanzaro.
+
+ The crash happens in unix ports because the resolved locale is empty when system locale is "C". IntlObject
+ considers any language tag with a size < 2 to be an invalid language, so "C" is not a valid language to resolve
+ the locale. We should ensure that WTF::platformUserPreferredLanguages() never returns invalid languages, but
+ that's not enough, because languages can be overriden from the public API, so we need to handle those cases and
+ throw exceptions instead of crashing.
+
+ * runtime/IntlCollator.cpp:
+ (JSC::IntlCollator::initializeCollator): Throw a exception when we fail to resolve the locale.
+ * runtime/IntlDateTimeFormat.cpp:
+ (JSC::IntlDateTimeFormat::initializeDateTimeFormat): Ditto.
+ * runtime/IntlNumberFormat.cpp:
+ (JSC::IntlNumberFormat::initializeNumberFormat): Ditto.
+
</ins><span class="cx"> 2016-09-20 Jonathan Bedard <jbedard@apple.com>
</span><span class="cx">
</span><span class="cx"> Undefined behavior: Left shift negative number
</span></span></pre></div>
<a id="releasesWebKitGTKwebkit214SourceJavaScriptCoreruntimeIntlCollatorcpp"></a>
<div class="modfile"><h4>Modified: releases/WebKitGTK/webkit-2.14/Source/JavaScriptCore/runtime/IntlCollator.cpp (207095 => 207096)</h4>
<pre class="diff"><span>
<span class="info">--- releases/WebKitGTK/webkit-2.14/Source/JavaScriptCore/runtime/IntlCollator.cpp        2016-10-11 11:52:19 UTC (rev 207095)
+++ releases/WebKitGTK/webkit-2.14/Source/JavaScriptCore/runtime/IntlCollator.cpp        2016-10-11 11:58:38 UTC (rev 207096)
</span><span class="lines">@@ -162,6 +162,9 @@
</span><span class="cx">
</span><span class="cx"> void IntlCollator::initializeCollator(ExecState& state, JSValue locales, JSValue optionsValue)
</span><span class="cx"> {
</span><ins>+ VM& vm = state.vm();
+ auto scope = DECLARE_THROW_SCOPE(vm);
+
</ins><span class="cx"> // 10.1.1 InitializeCollator (collator, locales, options) (ECMA-402 2.0)
</span><span class="cx"> // 1. If collator has an [[initializedIntlObject]] internal slot with value true, throw a TypeError exception.
</span><span class="cx"> // 2. Set collator.[[initializedIntlObject]] to true.
</span><span class="lines">@@ -254,6 +257,10 @@
</span><span class="cx">
</span><span class="cx"> // 19. Set collator.[[locale]] to the value of r.[[locale]].
</span><span class="cx"> m_locale = result.get(ASCIILiteral("locale"));
</span><ins>+ if (m_locale.isEmpty()) {
+ throwTypeError(&state, scope, ASCIILiteral("failed to initialize Collator due to invalid locale"));
+ return;
+ }
</ins><span class="cx">
</span><span class="cx"> // 20. Let k be 0.
</span><span class="cx"> // 21. Let lenValue be Get(relevantExtensionKeys, "length").
</span></span></pre></div>
<a id="releasesWebKitGTKwebkit214SourceJavaScriptCoreruntimeIntlDateTimeFormatcpp"></a>
<div class="modfile"><h4>Modified: releases/WebKitGTK/webkit-2.14/Source/JavaScriptCore/runtime/IntlDateTimeFormat.cpp (207095 => 207096)</h4>
<pre class="diff"><span>
<span class="info">--- releases/WebKitGTK/webkit-2.14/Source/JavaScriptCore/runtime/IntlDateTimeFormat.cpp        2016-10-11 11:52:19 UTC (rev 207095)
+++ releases/WebKitGTK/webkit-2.14/Source/JavaScriptCore/runtime/IntlDateTimeFormat.cpp        2016-10-11 11:58:38 UTC (rev 207096)
</span><span class="lines">@@ -455,6 +455,10 @@
</span><span class="cx">
</span><span class="cx"> // 13. Set dateTimeFormat.[[locale]] to the value of r.[[locale]].
</span><span class="cx"> m_locale = resolved.get(vm.propertyNames->locale.string());
</span><ins>+ if (m_locale.isEmpty()) {
+ throwTypeError(&exec, scope, ASCIILiteral("failed to initialize DateTimeFormat due to invalid locale"));
+ return;
+ }
</ins><span class="cx"> // 14. Set dateTimeFormat.[[calendar]] to the value of r.[[ca]].
</span><span class="cx"> m_calendar = resolved.get(ASCIILiteral("ca"));
</span><span class="cx"> // Switch to preferred aliases.
</span></span></pre></div>
<a id="releasesWebKitGTKwebkit214SourceJavaScriptCoreruntimeIntlNumberFormatcpp"></a>
<div class="modfile"><h4>Modified: releases/WebKitGTK/webkit-2.14/Source/JavaScriptCore/runtime/IntlNumberFormat.cpp (207095 => 207096)</h4>
<pre class="diff"><span>
<span class="info">--- releases/WebKitGTK/webkit-2.14/Source/JavaScriptCore/runtime/IntlNumberFormat.cpp        2016-10-11 11:52:19 UTC (rev 207095)
+++ releases/WebKitGTK/webkit-2.14/Source/JavaScriptCore/runtime/IntlNumberFormat.cpp        2016-10-11 11:58:38 UTC (rev 207096)
</span><span class="lines">@@ -198,6 +198,10 @@
</span><span class="cx">
</span><span class="cx"> // 13. Set numberFormat.[[locale]] to the value of r.[[locale]].
</span><span class="cx"> m_locale = result.get(ASCIILiteral("locale"));
</span><ins>+ if (m_locale.isEmpty()) {
+ throwTypeError(&state, scope, ASCIILiteral("failed to initialize NumberFormat due to invalid locale"));
+ return;
+ }
</ins><span class="cx">
</span><span class="cx"> // 14. Set numberFormat.[[numberingSystem]] to the value of r.[[nu]].
</span><span class="cx"> m_numberingSystem = result.get(ASCIILiteral("nu"));
</span></span></pre></div>
<a id="releasesWebKitGTKwebkit214SourceWTFChangeLog"></a>
<div class="modfile"><h4>Modified: releases/WebKitGTK/webkit-2.14/Source/WTF/ChangeLog (207095 => 207096)</h4>
<pre class="diff"><span>
<span class="info">--- releases/WebKitGTK/webkit-2.14/Source/WTF/ChangeLog        2016-10-11 11:52:19 UTC (rev 207095)
+++ releases/WebKitGTK/webkit-2.14/Source/WTF/ChangeLog        2016-10-11 11:58:38 UTC (rev 207096)
</span><span class="lines">@@ -1,3 +1,17 @@
</span><ins>+2016-09-23 Carlos Garcia Campos <cgarcia@igalia.com>
+
+ REGRESSION(r194387): Crash on github.com in IntlDateTimeFormat::resolvedOptions in C locale
+ https://bugs.webkit.org/show_bug.cgi?id=162139
+
+ Reviewed by Michael Catanzaro.
+
+ Handle the case of "C" or "POSIX" locale and use "en-US" as default. That matches what ICU and other ports do,
+ as well as what layout tests expect (some tests like js/intl-collator.html pass in the bots only because we use
+ en-US as system locale in those bots).
+
+ * wtf/PlatformUserPreferredLanguagesUnix.cpp:
+ (WTF::platformLanguage):
+
</ins><span class="cx"> 2016-09-20 Jonathan Bedard <jbedard@apple.com>
</span><span class="cx">
</span><span class="cx"> Undefined behavior: Left shift negative number
</span></span></pre></div>
<a id="releasesWebKitGTKwebkit214SourceWTFwtfPlatformUserPreferredLanguagesUnixcpp"></a>
<div class="modfile"><h4>Modified: releases/WebKitGTK/webkit-2.14/Source/WTF/wtf/PlatformUserPreferredLanguagesUnix.cpp (207095 => 207096)</h4>
<pre class="diff"><span>
<span class="info">--- releases/WebKitGTK/webkit-2.14/Source/WTF/wtf/PlatformUserPreferredLanguagesUnix.cpp        2016-10-11 11:52:19 UTC (rev 207095)
+++ releases/WebKitGTK/webkit-2.14/Source/WTF/wtf/PlatformUserPreferredLanguagesUnix.cpp        2016-10-11 11:58:38 UTC (rev 207096)
</span><span class="lines">@@ -35,8 +35,8 @@
</span><span class="cx"> static String platformLanguage()
</span><span class="cx"> {
</span><span class="cx"> String localeDefault(setlocale(LC_CTYPE, nullptr));
</span><del>- if (localeDefault.isEmpty())
- return String("c");
</del><ins>+ if (localeDefault.isEmpty() || equalIgnoringASCIICase(localeDefault, "C") || equalIgnoringASCIICase(localeDefault, "POSIX"))
+ return ASCIILiteral("en-us");
</ins><span class="cx">
</span><span class="cx"> String normalizedDefault = localeDefault.convertToASCIILowercase();
</span><span class="cx"> normalizedDefault.replace('_', '-');
</span></span></pre></div>
<a id="releasesWebKitGTKwebkit214SourceWebKit2ChangeLog"></a>
<div class="modfile"><h4>Modified: releases/WebKitGTK/webkit-2.14/Source/WebKit2/ChangeLog (207095 => 207096)</h4>
<pre class="diff"><span>
<span class="info">--- releases/WebKitGTK/webkit-2.14/Source/WebKit2/ChangeLog        2016-10-11 11:52:19 UTC (rev 207095)
+++ releases/WebKitGTK/webkit-2.14/Source/WebKit2/ChangeLog        2016-10-11 11:58:38 UTC (rev 207096)
</span><span class="lines">@@ -1,5 +1,19 @@
</span><span class="cx"> 2016-09-23 Carlos Garcia Campos <cgarcia@igalia.com>
</span><span class="cx">
</span><ins>+ REGRESSION(r194387): Crash on github.com in IntlDateTimeFormat::resolvedOptions in C locale
+ https://bugs.webkit.org/show_bug.cgi?id=162139
+
+ Reviewed by Michael Catanzaro.
+
+ Handle the case of "C" locale passed by the user using "en-US" as default to match what
+ WTF::platformUserPreferredLanguages() does.
+
+ * UIProcess/API/gtk/WebKitWebContext.cpp:
+ (webkit_web_context_set_preferred_languages): Remove the call to languageDidChange() because
+ overrideUserPreferredLanguages() already calls it, so we were actually notifying the observers twice.
+
+2016-09-23 Carlos Garcia Campos <cgarcia@igalia.com>
+
</ins><span class="cx"> [GTK] Improve performance when resizing a window with multiple web views in X11
</span><span class="cx"> https://bugs.webkit.org/show_bug.cgi?id=162413
</span><span class="cx">
</span></span></pre></div>
<a id="releasesWebKitGTKwebkit214SourceWebKit2UIProcessAPIgtkWebKitWebContextcpp"></a>
<div class="modfile"><h4>Modified: releases/WebKitGTK/webkit-2.14/Source/WebKit2/UIProcess/API/gtk/WebKitWebContext.cpp (207095 => 207096)</h4>
<pre class="diff"><span>
<span class="info">--- releases/WebKitGTK/webkit-2.14/Source/WebKit2/UIProcess/API/gtk/WebKitWebContext.cpp        2016-10-11 11:52:19 UTC (rev 207095)
+++ releases/WebKitGTK/webkit-2.14/Source/WebKit2/UIProcess/API/gtk/WebKitWebContext.cpp        2016-10-11 11:58:38 UTC (rev 207096)
</span><span class="lines">@@ -972,11 +972,14 @@
</span><span class="cx"> return;
</span><span class="cx">
</span><span class="cx"> Vector<String> languages;
</span><del>- for (size_t i = 0; languageList[i]; ++i)
- languages.append(String::fromUTF8(languageList[i]).convertToASCIILowercase().replace("_", "-"));
-
</del><ins>+ for (size_t i = 0; languageList[i]; ++i) {
+ // Do not propagate the C locale to WebCore.
+ if (!g_ascii_strcasecmp(languageList[i], "C") || !g_ascii_strcasecmp(languageList[i], "POSIX"))
+ languages.append(ASCIILiteral("en-us"));
+ else
+ languages.append(String::fromUTF8(languageList[i]).convertToASCIILowercase().replace("_", "-"));
+ }
</ins><span class="cx"> WebCore::overrideUserPreferredLanguages(languages);
</span><del>- WebCore::languageDidChange();
</del><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> /**
</span></span></pre></div>
<a id="releasesWebKitGTKwebkit214ToolsChangeLog"></a>
<div class="modfile"><h4>Modified: releases/WebKitGTK/webkit-2.14/Tools/ChangeLog (207095 => 207096)</h4>
<pre class="diff"><span>
<span class="info">--- releases/WebKitGTK/webkit-2.14/Tools/ChangeLog        2016-10-11 11:52:19 UTC (rev 207095)
+++ releases/WebKitGTK/webkit-2.14/Tools/ChangeLog        2016-10-11 11:58:38 UTC (rev 207096)
</span><span class="lines">@@ -1,3 +1,15 @@
</span><ins>+2016-09-23 Carlos Garcia Campos <cgarcia@igalia.com>
+
+ REGRESSION(r194387): Crash on github.com in IntlDateTimeFormat::resolvedOptions in C locale
+ https://bugs.webkit.org/show_bug.cgi?id=162139
+
+ Reviewed by Michael Catanzaro.
+
+ Add test cases to check the behavior when using the C locale and an invalid locale.
+
+ * TestWebKitAPI/Tests/WebKit2Gtk/TestWebKitWebContext.cpp:
+ (testWebContextLanguages):
+
</ins><span class="cx"> 2016-09-08 Yusuke Suzuki <utatane.tea@gmail.com>
</span><span class="cx">
</span><span class="cx"> [WTF] HashTable's rehash is not compatible to Ref<T> and ASan
</span></span></pre></div>
<a id="releasesWebKitGTKwebkit214ToolsTestWebKitAPITestsWebKit2GtkTestWebKitWebContextcpp"></a>
<div class="modfile"><h4>Modified: releases/WebKitGTK/webkit-2.14/Tools/TestWebKitAPI/Tests/WebKit2Gtk/TestWebKitWebContext.cpp (207095 => 207096)</h4>
<pre class="diff"><span>
<span class="info">--- releases/WebKitGTK/webkit-2.14/Tools/TestWebKitAPI/Tests/WebKit2Gtk/TestWebKitWebContext.cpp        2016-10-11 11:52:19 UTC (rev 207095)
+++ releases/WebKitGTK/webkit-2.14/Tools/TestWebKitAPI/Tests/WebKit2Gtk/TestWebKitWebContext.cpp        2016-10-11 11:58:38 UTC (rev 207096)
</span><span class="lines">@@ -465,7 +465,7 @@
</span><span class="cx">
</span><span class="cx"> static void testWebContextLanguages(WebViewTest* test, gconstpointer)
</span><span class="cx"> {
</span><del>- static const char* expectedDefaultLanguage = "en";
</del><ins>+ static const char* expectedDefaultLanguage = "en-us";
</ins><span class="cx"> test->loadURI(kServer->getURIForPath("/").data());
</span><span class="cx"> test->waitUntilLoadFinished();
</span><span class="cx"> size_t mainResourceDataSize = 0;
</span><span class="lines">@@ -487,6 +487,32 @@
</span><span class="cx"> mainResourceData = test->mainResourceData(mainResourceDataSize);
</span><span class="cx"> g_assert_cmpuint(mainResourceDataSize, ==, strlen(expectedLanguages));
</span><span class="cx"> g_assert(!strncmp(mainResourceData, expectedLanguages, mainResourceDataSize));
</span><ins>+
+ // When using the C locale, en-US should be used as default.
+ const char* cLanguage[] = { "C", nullptr };
+ webkit_web_context_set_preferred_languages(test->m_webContext.get(), cLanguage);
+ GUniqueOutPtr<GError> error;
+ WebKitJavascriptResult* javascriptResult = test->runJavaScriptAndWaitUntilFinished("Intl.DateTimeFormat().resolvedOptions().locale", &error.outPtr());
+ g_assert(javascriptResult);
+ g_assert(!error);
+ GUniquePtr<char> locale(WebViewTest::javascriptResultToCString(javascriptResult));
+ g_assert_cmpstr(locale.get(), ==, "en-US");
+
+ // When using the POSIX locale, en-US should be used as default.
+ const char* posixLanguage[] = { "POSIX", nullptr };
+ webkit_web_context_set_preferred_languages(test->m_webContext.get(), posixLanguage);
+ javascriptResult = test->runJavaScriptAndWaitUntilFinished("Intl.DateTimeFormat().resolvedOptions().locale", &error.outPtr());
+ g_assert(javascriptResult);
+ g_assert(!error);
+ locale.reset(WebViewTest::javascriptResultToCString(javascriptResult));
+ g_assert_cmpstr(locale.get(), ==, "en-US");
+
+ // An invalid locale should throw an exception.
+ const char* invalidLanguage[] = { "A", nullptr };
+ webkit_web_context_set_preferred_languages(test->m_webContext.get(), invalidLanguage);
+ javascriptResult = test->runJavaScriptAndWaitUntilFinished("Intl.DateTimeFormat().resolvedOptions().locale", &error.outPtr());
+ g_assert(!javascriptResult);
+ g_assert_error(error.get(), WEBKIT_JAVASCRIPT_ERROR, WEBKIT_JAVASCRIPT_ERROR_SCRIPT_FAILED);
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> static void serverCallback(SoupServer* server, SoupMessage* message, const char* path, GHashTable*, SoupClientContext*, gpointer)
</span></span></pre>
</div>
</div>
</body>
</html>