Diff
Modified: releases/WebKitGTK/webkit-2.14/LayoutTests/ChangeLog (207095 => 207096)
--- 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)
@@ -1,3 +1,13 @@
+2016-09-23 Carlos Garcia Campos <[email protected]>
+
+ 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.
+
2016-09-22 Brady Eidson <[email protected]>
IDBIndex.openCursor() matches indices on multiple object stores.
Added: releases/WebKitGTK/webkit-2.14/LayoutTests/js/intl-invalid-locale-crash-expected.txt (0 => 207096)
--- 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)
@@ -0,0 +1,7 @@
+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
+
Added: releases/WebKitGTK/webkit-2.14/LayoutTests/js/intl-invalid-locale-crash.html (0 => 207096)
--- 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)
@@ -0,0 +1,19 @@
+<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
+<html>
+<head>
+<meta charset="utf-8">
+<script src=""
+</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=""
+</body>
+</html>
Modified: releases/WebKitGTK/webkit-2.14/Source/_javascript_Core/ChangeLog (207095 => 207096)
--- releases/WebKitGTK/webkit-2.14/Source/_javascript_Core/ChangeLog 2016-10-11 11:52:19 UTC (rev 207095)
+++ releases/WebKitGTK/webkit-2.14/Source/_javascript_Core/ChangeLog 2016-10-11 11:58:38 UTC (rev 207096)
@@ -1,3 +1,23 @@
+2016-09-23 Carlos Garcia Campos <[email protected]>
+
+ 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.
+
2016-09-20 Jonathan Bedard <[email protected]>
Undefined behavior: Left shift negative number
Modified: releases/WebKitGTK/webkit-2.14/Source/_javascript_Core/runtime/IntlCollator.cpp (207095 => 207096)
--- releases/WebKitGTK/webkit-2.14/Source/_javascript_Core/runtime/IntlCollator.cpp 2016-10-11 11:52:19 UTC (rev 207095)
+++ releases/WebKitGTK/webkit-2.14/Source/_javascript_Core/runtime/IntlCollator.cpp 2016-10-11 11:58:38 UTC (rev 207096)
@@ -162,6 +162,9 @@
void IntlCollator::initializeCollator(ExecState& state, JSValue locales, JSValue optionsValue)
{
+ VM& vm = state.vm();
+ auto scope = DECLARE_THROW_SCOPE(vm);
+
// 10.1.1 InitializeCollator (collator, locales, options) (ECMA-402 2.0)
// 1. If collator has an [[initializedIntlObject]] internal slot with value true, throw a TypeError exception.
// 2. Set collator.[[initializedIntlObject]] to true.
@@ -254,6 +257,10 @@
// 19. Set collator.[[locale]] to the value of r.[[locale]].
m_locale = result.get(ASCIILiteral("locale"));
+ if (m_locale.isEmpty()) {
+ throwTypeError(&state, scope, ASCIILiteral("failed to initialize Collator due to invalid locale"));
+ return;
+ }
// 20. Let k be 0.
// 21. Let lenValue be Get(relevantExtensionKeys, "length").
Modified: releases/WebKitGTK/webkit-2.14/Source/_javascript_Core/runtime/IntlDateTimeFormat.cpp (207095 => 207096)
--- releases/WebKitGTK/webkit-2.14/Source/_javascript_Core/runtime/IntlDateTimeFormat.cpp 2016-10-11 11:52:19 UTC (rev 207095)
+++ releases/WebKitGTK/webkit-2.14/Source/_javascript_Core/runtime/IntlDateTimeFormat.cpp 2016-10-11 11:58:38 UTC (rev 207096)
@@ -455,6 +455,10 @@
// 13. Set dateTimeFormat.[[locale]] to the value of r.[[locale]].
m_locale = resolved.get(vm.propertyNames->locale.string());
+ if (m_locale.isEmpty()) {
+ throwTypeError(&exec, scope, ASCIILiteral("failed to initialize DateTimeFormat due to invalid locale"));
+ return;
+ }
// 14. Set dateTimeFormat.[[calendar]] to the value of r.[[ca]].
m_calendar = resolved.get(ASCIILiteral("ca"));
// Switch to preferred aliases.
Modified: releases/WebKitGTK/webkit-2.14/Source/_javascript_Core/runtime/IntlNumberFormat.cpp (207095 => 207096)
--- releases/WebKitGTK/webkit-2.14/Source/_javascript_Core/runtime/IntlNumberFormat.cpp 2016-10-11 11:52:19 UTC (rev 207095)
+++ releases/WebKitGTK/webkit-2.14/Source/_javascript_Core/runtime/IntlNumberFormat.cpp 2016-10-11 11:58:38 UTC (rev 207096)
@@ -198,6 +198,10 @@
// 13. Set numberFormat.[[locale]] to the value of r.[[locale]].
m_locale = result.get(ASCIILiteral("locale"));
+ if (m_locale.isEmpty()) {
+ throwTypeError(&state, scope, ASCIILiteral("failed to initialize NumberFormat due to invalid locale"));
+ return;
+ }
// 14. Set numberFormat.[[numberingSystem]] to the value of r.[[nu]].
m_numberingSystem = result.get(ASCIILiteral("nu"));
Modified: releases/WebKitGTK/webkit-2.14/Source/WTF/ChangeLog (207095 => 207096)
--- 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)
@@ -1,3 +1,17 @@
+2016-09-23 Carlos Garcia Campos <[email protected]>
+
+ 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):
+
2016-09-20 Jonathan Bedard <[email protected]>
Undefined behavior: Left shift negative number
Modified: releases/WebKitGTK/webkit-2.14/Source/WTF/wtf/PlatformUserPreferredLanguagesUnix.cpp (207095 => 207096)
--- 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)
@@ -35,8 +35,8 @@
static String platformLanguage()
{
String localeDefault(setlocale(LC_CTYPE, nullptr));
- if (localeDefault.isEmpty())
- return String("c");
+ if (localeDefault.isEmpty() || equalIgnoringASCIICase(localeDefault, "C") || equalIgnoringASCIICase(localeDefault, "POSIX"))
+ return ASCIILiteral("en-us");
String normalizedDefault = localeDefault.convertToASCIILowercase();
normalizedDefault.replace('_', '-');
Modified: releases/WebKitGTK/webkit-2.14/Source/WebKit2/ChangeLog (207095 => 207096)
--- 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)
@@ -1,5 +1,19 @@
2016-09-23 Carlos Garcia Campos <[email protected]>
+ 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 <[email protected]>
+
[GTK] Improve performance when resizing a window with multiple web views in X11
https://bugs.webkit.org/show_bug.cgi?id=162413
Modified: releases/WebKitGTK/webkit-2.14/Source/WebKit2/UIProcess/API/gtk/WebKitWebContext.cpp (207095 => 207096)
--- 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)
@@ -972,11 +972,14 @@
return;
Vector<String> languages;
- for (size_t i = 0; languageList[i]; ++i)
- languages.append(String::fromUTF8(languageList[i]).convertToASCIILowercase().replace("_", "-"));
-
+ 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("_", "-"));
+ }
WebCore::overrideUserPreferredLanguages(languages);
- WebCore::languageDidChange();
}
/**
Modified: releases/WebKitGTK/webkit-2.14/Tools/ChangeLog (207095 => 207096)
--- 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)
@@ -1,3 +1,15 @@
+2016-09-23 Carlos Garcia Campos <[email protected]>
+
+ 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):
+
2016-09-08 Yusuke Suzuki <[email protected]>
[WTF] HashTable's rehash is not compatible to Ref<T> and ASan
Modified: releases/WebKitGTK/webkit-2.14/Tools/TestWebKitAPI/Tests/WebKit2Gtk/TestWebKitWebContext.cpp (207095 => 207096)
--- 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)
@@ -465,7 +465,7 @@
static void testWebContextLanguages(WebViewTest* test, gconstpointer)
{
- static const char* expectedDefaultLanguage = "en";
+ static const char* expectedDefaultLanguage = "en-us";
test->loadURI(kServer->getURIForPath("/").data());
test->waitUntilLoadFinished();
size_t mainResourceDataSize = 0;
@@ -487,6 +487,32 @@
mainResourceData = test->mainResourceData(mainResourceDataSize);
g_assert_cmpuint(mainResourceDataSize, ==, strlen(expectedLanguages));
g_assert(!strncmp(mainResourceData, expectedLanguages, mainResourceDataSize));
+
+ // 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* _javascript_Result = test->runJavaScriptAndWaitUntilFinished("Intl.DateTimeFormat().resolvedOptions().locale", &error.outPtr());
+ g_assert(_javascript_Result);
+ g_assert(!error);
+ GUniquePtr<char> locale(WebViewTest::_javascript_ResultToCString(_javascript_Result));
+ 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);
+ _javascript_Result = test->runJavaScriptAndWaitUntilFinished("Intl.DateTimeFormat().resolvedOptions().locale", &error.outPtr());
+ g_assert(_javascript_Result);
+ g_assert(!error);
+ locale.reset(WebViewTest::_javascript_ResultToCString(_javascript_Result));
+ 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);
+ _javascript_Result = test->runJavaScriptAndWaitUntilFinished("Intl.DateTimeFormat().resolvedOptions().locale", &error.outPtr());
+ g_assert(!_javascript_Result);
+ g_assert_error(error.get(), WEBKIT_JAVASCRIPT_ERROR, WEBKIT_JAVASCRIPT_ERROR_SCRIPT_FAILED);
}
static void serverCallback(SoupServer* server, SoupMessage* message, const char* path, GHashTable*, SoupClientContext*, gpointer)