<!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>[189669] 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/189669">189669</a></dd>
<dt>Author</dt> <dd>mmaxfield@apple.com</dd>
<dt>Date</dt> <dd>2015-09-12 20:47:56 -0700 (Sat, 12 Sep 2015)</dd>
</dl>

<h3>Log Message</h3>
<pre>[Cocoa] Allow testing with the system language
https://bugs.webkit.org/show_bug.cgi?id=148671

Reviewed by Anders Carlsson and Alexey Proskuryakov.

Source/WebKit2:

This patch adds two new SPI functions for setting and retrieving a vector of
override languages to/from the WKContextConfiguration. The implementation of
these functions holds state inside WebProcessPoolConfiguration. Then, when
we launch a process, the WebProcessProxy will inject these override languages
into the ProcessLauncher::LaunchOptions so that the ProcessLauncher can
inject these languages into the XPC Bootstrap message. Then, in the Web
Process's main(), the XPC Boostrap message is read, and the platform
languages are set via NSUserDefaults setting a volatile domain.

* Shared/EntryPointUtilities/mac/XPCService/XPCServiceMain.Development.mm:
(main): Set the volatile domain with NSUserDefaults.
* UIProcess/API/APIProcessPoolConfiguration.cpp:
(API::ProcessPoolConfiguration::copy):
* UIProcess/API/APIProcessPoolConfiguration.h: Hold state for the override
languages.
* UIProcess/API/C/WKContextConfigurationRef.cpp:
(WKContextConfigurationCopyOverrideLanguages): SPI.
(WKContextConfigurationSetOverrideLanguages): Ditto.
* UIProcess/API/C/WKContextConfigurationRef.h:
* UIProcess/Launcher/mac/ProcessLauncherMac.mm:
(WebKit::connectToService): Inject the languages into the XPC Bootstrap
message.
* UIProcess/WebProcessProxy.cpp:
(WebKit::WebProcessProxy::getLaunchOptions): Inject the override languages
into the ProcessLauncher::LaunchOptions.

Tools:

React to tests marked with language=lang1,lang2,etc in their header.
Once this information is parsed, pass it to
WKContextConfigurationSetOverrideLanguages().

* WebKitTestRunner/InjectedBundle/mac/InjectedBundleMac.mm:
(WTR::InjectedBundle::platformInitialize): Don't clobber the language
list.
* WebKitTestRunner/TestController.cpp:
(WTR::TestController::createWebViewWithOptions): Call
WKContextConfigurationSetOverrideLanguages().
(WTR::updateTestOptionsFromTestHeader): Inspect the language option.
* WebKitTestRunner/TestOptions.h:
* WebKitTestRunner/ios/PlatformWebViewIOS.mm:
(WTR::PlatformWebView::viewSupportsOptions): Cause a differing language
option to restart the web process.
* WebKitTestRunner/mac/PlatformWebViewMac.mm:
(WTR::PlatformWebView::viewSupportsOptions): Ditto.

LayoutTests:

Add a test for the declarative form of setting the system language.

* fast/text/international/system-language/declarative-language-expected.txt: Added.
* fast/text/international/system-language/declarative-language.html: Added.
* platform/efl/TestExpectations:
* platform/gtk/TestExpectations:
* platform/mac-wk1/TestExpectations:
* platform/mac/TestExpectations:</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkLayoutTestsChangeLog">trunk/LayoutTests/ChangeLog</a></li>
<li><a href="#trunkLayoutTestsplatformeflTestExpectations">trunk/LayoutTests/platform/efl/TestExpectations</a></li>
<li><a href="#trunkLayoutTestsplatformgtkTestExpectations">trunk/LayoutTests/platform/gtk/TestExpectations</a></li>
<li><a href="#trunkLayoutTestsplatformmacTestExpectations">trunk/LayoutTests/platform/mac/TestExpectations</a></li>
<li><a href="#trunkLayoutTestsplatformmacwk1TestExpectations">trunk/LayoutTests/platform/mac-wk1/TestExpectations</a></li>
<li><a href="#trunkSourceWebKit2ChangeLog">trunk/Source/WebKit2/ChangeLog</a></li>
<li><a href="#trunkSourceWebKit2SharedEntryPointUtilitiesmacXPCServiceXPCServiceMainDevelopmentmm">trunk/Source/WebKit2/Shared/EntryPointUtilities/mac/XPCService/XPCServiceMain.Development.mm</a></li>
<li><a href="#trunkSourceWebKit2UIProcessAPIAPIProcessPoolConfigurationcpp">trunk/Source/WebKit2/UIProcess/API/APIProcessPoolConfiguration.cpp</a></li>
<li><a href="#trunkSourceWebKit2UIProcessAPIAPIProcessPoolConfigurationh">trunk/Source/WebKit2/UIProcess/API/APIProcessPoolConfiguration.h</a></li>
<li><a href="#trunkSourceWebKit2UIProcessAPICWKContextConfigurationRefcpp">trunk/Source/WebKit2/UIProcess/API/C/WKContextConfigurationRef.cpp</a></li>
<li><a href="#trunkSourceWebKit2UIProcessAPICWKContextConfigurationRefh">trunk/Source/WebKit2/UIProcess/API/C/WKContextConfigurationRef.h</a></li>
<li><a href="#trunkSourceWebKit2UIProcessLaunchermacProcessLauncherMacmm">trunk/Source/WebKit2/UIProcess/Launcher/mac/ProcessLauncherMac.mm</a></li>
<li><a href="#trunkSourceWebKit2UIProcessWebProcessProxycpp">trunk/Source/WebKit2/UIProcess/WebProcessProxy.cpp</a></li>
<li><a href="#trunkToolsChangeLog">trunk/Tools/ChangeLog</a></li>
<li><a href="#trunkToolsWebKitTestRunnerInjectedBundlemacInjectedBundleMacmm">trunk/Tools/WebKitTestRunner/InjectedBundle/mac/InjectedBundleMac.mm</a></li>
<li><a href="#trunkToolsWebKitTestRunnerTestControllercpp">trunk/Tools/WebKitTestRunner/TestController.cpp</a></li>
<li><a href="#trunkToolsWebKitTestRunnerTestOptionsh">trunk/Tools/WebKitTestRunner/TestOptions.h</a></li>
<li><a href="#trunkToolsWebKitTestRunneriosPlatformWebViewIOSmm">trunk/Tools/WebKitTestRunner/ios/PlatformWebViewIOS.mm</a></li>
<li><a href="#trunkToolsWebKitTestRunnermacPlatformWebViewMacmm">trunk/Tools/WebKitTestRunner/mac/PlatformWebViewMac.mm</a></li>
</ul>

<h3>Added Paths</h3>
<ul>
<li>trunk/LayoutTests/fast/text/international/system-language/</li>
<li><a href="#trunkLayoutTestsfasttextinternationalsystemlanguagedeclarativelanguageexpectedtxt">trunk/LayoutTests/fast/text/international/system-language/declarative-language-expected.txt</a></li>
<li><a href="#trunkLayoutTestsfasttextinternationalsystemlanguagedeclarativelanguagehtml">trunk/LayoutTests/fast/text/international/system-language/declarative-language.html</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkLayoutTestsChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/ChangeLog (189668 => 189669)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/ChangeLog        2015-09-13 02:31:34 UTC (rev 189668)
+++ trunk/LayoutTests/ChangeLog        2015-09-13 03:47:56 UTC (rev 189669)
</span><span class="lines">@@ -1,3 +1,19 @@
</span><ins>+2015-09-12  Myles C. Maxfield  &lt;mmaxfield@apple.com&gt;
+
+        [Cocoa] Allow testing with the system language
+        https://bugs.webkit.org/show_bug.cgi?id=148671
+
+        Reviewed by Anders Carlsson and Alexey Proskuryakov.
+
+        Add a test for the declarative form of setting the system language.
+
+        * fast/text/international/system-language/declarative-language-expected.txt: Added.
+        * fast/text/international/system-language/declarative-language.html: Added.
+        * platform/efl/TestExpectations:
+        * platform/gtk/TestExpectations:
+        * platform/mac-wk1/TestExpectations:
+        * platform/mac/TestExpectations:
+
</ins><span class="cx"> 2015-09-12  Chris Dumez  &lt;cdumez@apple.com&gt;
</span><span class="cx"> 
</span><span class="cx">         window.EventTarget should exist
</span></span></pre></div>
<a id="trunkLayoutTestsfasttextinternationalsystemlanguagedeclarativelanguageexpectedtxt"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/fast/text/international/system-language/declarative-language-expected.txt (0 => 189669)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/fast/text/international/system-language/declarative-language-expected.txt                                (rev 0)
+++ trunk/LayoutTests/fast/text/international/system-language/declarative-language-expected.txt        2015-09-13 03:47:56 UTC (rev 189669)
</span><span class="lines">@@ -0,0 +1,8 @@
</span><ins>+PASS internals.userPreferredLanguages().length is 2
+PASS internals.userPreferredLanguages()[0].startsWith('ko') is true
+PASS internals.userPreferredLanguages()[1].startsWith('zh') is true
+PASS internals.userPreferredLanguages().length is 3
+PASS internals.userPreferredLanguages()[0] is &quot;hi&quot;
+PASS internals.userPreferredLanguages()[1] is &quot;jp&quot;
+PASS internals.userPreferredLanguages()[2] is &quot;in&quot;
+
</ins><span class="cx">Property changes on: trunk/LayoutTests/fast/text/international/system-language/declarative-language-expected.txt
</span><span class="cx">___________________________________________________________________
</span></span></pre></div>
<a id="svnkeywords"></a>
<div class="addfile"><h4>Added: svn:keywords</h4></div>
<a id="svneolstyle"></a>
<div class="addfile"><h4>Added: svn:eol-style</h4></div>
<a id="trunkLayoutTestsfasttextinternationalsystemlanguagedeclarativelanguagehtml"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/fast/text/international/system-language/declarative-language.html (0 => 189669)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/fast/text/international/system-language/declarative-language.html                                (rev 0)
+++ trunk/LayoutTests/fast/text/international/system-language/declarative-language.html        2015-09-13 03:47:56 UTC (rev 189669)
</span><span class="lines">@@ -0,0 +1,21 @@
</span><ins>+&lt;!DOCTYPE html&gt;&lt;!-- webkit-test-runner [ language=ko,zh ] --&gt;
+&lt;html&gt;
+&lt;head&gt;
+&lt;script src=&quot;../../../../resources/js-test-pre.js&quot;&gt;&lt;/script&gt;
+&lt;/head&gt;
+&lt;body&gt;
+&lt;script&gt;
+if (window.internals) {
+    shouldBe(&quot;internals.userPreferredLanguages().length&quot;, &quot;2&quot;);
+    shouldBeTrue(&quot;internals.userPreferredLanguages()[0].startsWith('ko')&quot;);
+    shouldBeTrue(&quot;internals.userPreferredLanguages()[1].startsWith('zh')&quot;);
+    internals.setUserPreferredLanguages([&quot;hi&quot;, &quot;jp&quot;, &quot;in&quot;]);
+    shouldBe(&quot;internals.userPreferredLanguages().length&quot;, &quot;3&quot;);
+    shouldBeEqualToString(&quot;internals.userPreferredLanguages()[0]&quot;, &quot;hi&quot;);
+    shouldBeEqualToString(&quot;internals.userPreferredLanguages()[1]&quot;, &quot;jp&quot;);
+    shouldBeEqualToString(&quot;internals.userPreferredLanguages()[2]&quot;, &quot;in&quot;);
+}
+&lt;/script&gt;
+&lt;script src=&quot;../../../resources/js-test-post.js&quot;&gt;&lt;/script&gt;
+&lt;/body&gt;
+&lt;/html&gt;
</ins></span></pre></div>
<a id="trunkLayoutTestsplatformeflTestExpectations"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/platform/efl/TestExpectations (189668 => 189669)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/platform/efl/TestExpectations        2015-09-13 02:31:34 UTC (rev 189668)
+++ trunk/LayoutTests/platform/efl/TestExpectations        2015-09-13 03:47:56 UTC (rev 189669)
</span><span class="lines">@@ -2548,3 +2548,6 @@
</span><span class="cx"> webkit.org/b/148470 svg/text/select-x-list-with-tspans-3.svg [ Failure ]
</span><span class="cx"> webkit.org/b/148470 svg/text/select-x-list-with-tspans-4.svg [ Failure ]
</span><span class="cx"> webkit.org/b/148470 svg/text/selection-doubleclick.svg [ Failure ]
</span><ins>+
+# Mocking the system language is not implemented in EFL.
+fast/text/international/system-language [ Failure ]
</ins></span></pre></div>
<a id="trunkLayoutTestsplatformgtkTestExpectations"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/platform/gtk/TestExpectations (189668 => 189669)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/platform/gtk/TestExpectations        2015-09-13 02:31:34 UTC (rev 189668)
+++ trunk/LayoutTests/platform/gtk/TestExpectations        2015-09-13 03:47:56 UTC (rev 189669)
</span><span class="lines">@@ -2612,3 +2612,6 @@
</span><span class="cx"> 
</span><span class="cx"> # Media controls tests are OS X only
</span><span class="cx"> media/controls [ Skip ]
</span><ins>+
+# Mocking the system language is not implemented in GTK.
+fast/text/international/system-language [ Failure ]
</ins></span></pre></div>
<a id="trunkLayoutTestsplatformmacTestExpectations"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/platform/mac/TestExpectations (189668 => 189669)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/platform/mac/TestExpectations        2015-09-13 02:31:34 UTC (rev 189668)
+++ trunk/LayoutTests/platform/mac/TestExpectations        2015-09-13 03:47:56 UTC (rev 189669)
</span><span class="lines">@@ -1284,3 +1284,6 @@
</span><span class="cx"> 
</span><span class="cx"> # Colorspaces on CA OpenGL layers not available in Mavericks and Yosemite
</span><span class="cx"> [ Mavericks Yosemite ] fast/canvas/webgl/match-page-color-space.html [ Skip ]
</span><ins>+
+# Mocking the system language relies on Bootstrap XPC messages, which are not supported in Mavericks.
+[ Mavericks ] fast/text/international/system-language [ Failure ]
</ins></span></pre></div>
<a id="trunkLayoutTestsplatformmacwk1TestExpectations"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/platform/mac-wk1/TestExpectations (189668 => 189669)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/platform/mac-wk1/TestExpectations        2015-09-13 02:31:34 UTC (rev 189668)
+++ trunk/LayoutTests/platform/mac-wk1/TestExpectations        2015-09-13 03:47:56 UTC (rev 189669)
</span><span class="lines">@@ -141,3 +141,6 @@
</span><span class="cx"> 
</span><span class="cx"> # This test is WebKit2-only
</span><span class="cx"> http/tests/contentfiltering/load-substitute-data-from-appcache.html
</span><ins>+
+# Testing the system language declaratively only makes sense in WK2, because it's implemented in WebKitTestRunner by launching a new WebContent process.
+fast/text/international/system-language [ Failure ]
</ins></span></pre></div>
<a id="trunkSourceWebKit2ChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/ChangeLog (189668 => 189669)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/ChangeLog        2015-09-13 02:31:34 UTC (rev 189668)
+++ trunk/Source/WebKit2/ChangeLog        2015-09-13 03:47:56 UTC (rev 189669)
</span><span class="lines">@@ -1,3 +1,36 @@
</span><ins>+2015-09-12  Myles C. Maxfield  &lt;mmaxfield@apple.com&gt;
+
+        [Cocoa] Allow testing with the system language
+        https://bugs.webkit.org/show_bug.cgi?id=148671
+
+        Reviewed by Anders Carlsson and Alexey Proskuryakov.
+
+        This patch adds two new SPI functions for setting and retrieving a vector of
+        override languages to/from the WKContextConfiguration. The implementation of
+        these functions holds state inside WebProcessPoolConfiguration. Then, when
+        we launch a process, the WebProcessProxy will inject these override languages
+        into the ProcessLauncher::LaunchOptions so that the ProcessLauncher can
+        inject these languages into the XPC Bootstrap message. Then, in the Web
+        Process's main(), the XPC Boostrap message is read, and the platform
+        languages are set via NSUserDefaults setting a volatile domain.
+
+        * Shared/EntryPointUtilities/mac/XPCService/XPCServiceMain.Development.mm:
+        (main): Set the volatile domain with NSUserDefaults.
+        * UIProcess/API/APIProcessPoolConfiguration.cpp:
+        (API::ProcessPoolConfiguration::copy):
+        * UIProcess/API/APIProcessPoolConfiguration.h: Hold state for the override
+        languages.
+        * UIProcess/API/C/WKContextConfigurationRef.cpp:
+        (WKContextConfigurationCopyOverrideLanguages): SPI.
+        (WKContextConfigurationSetOverrideLanguages): Ditto.
+        * UIProcess/API/C/WKContextConfigurationRef.h:
+        * UIProcess/Launcher/mac/ProcessLauncherMac.mm:
+        (WebKit::connectToService): Inject the languages into the XPC Bootstrap
+        message.
+        * UIProcess/WebProcessProxy.cpp:
+        (WebKit::WebProcessProxy::getLaunchOptions): Inject the override languages
+        into the ProcessLauncher::LaunchOptions.
+
</ins><span class="cx"> 2015-09-12  Alexey Proskuryakov  &lt;ap@apple.com&gt;
</span><span class="cx"> 
</span><span class="cx">         [iOS] Allow UDP networking
</span></span></pre></div>
<a id="trunkSourceWebKit2SharedEntryPointUtilitiesmacXPCServiceXPCServiceMainDevelopmentmm"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/Shared/EntryPointUtilities/mac/XPCService/XPCServiceMain.Development.mm (189668 => 189669)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/Shared/EntryPointUtilities/mac/XPCService/XPCServiceMain.Development.mm        2015-09-13 02:31:34 UTC (rev 189668)
+++ trunk/Source/WebKit2/Shared/EntryPointUtilities/mac/XPCService/XPCServiceMain.Development.mm        2015-09-13 03:47:56 UTC (rev 189669)
</span><span class="lines">@@ -32,6 +32,7 @@
</span><span class="cx"> #import &lt;stdio.h&gt;
</span><span class="cx"> #import &lt;stdlib.h&gt;
</span><span class="cx"> #import &lt;wtf/OSObjectPtr.h&gt;
</span><ins>+#import &lt;wtf/RetainPtr.h&gt;
</ins><span class="cx"> #import &lt;wtf/spi/darwin/XPCSPI.h&gt;
</span><span class="cx"> 
</span><span class="cx"> namespace WebKit {
</span><span class="lines">@@ -159,6 +160,22 @@
</span><span class="cx"> 
</span><span class="cx"> int main(int argc, char** argv)
</span><span class="cx"> {
</span><ins>+#if PLATFORM(IOS) || __MAC_OS_X_VERSION_MIN_REQUIRED &gt;= 101000
+    if (auto bootstrap = adoptOSObject(xpc_copy_bootstrap())) {
+        if (xpc_object_t languages = xpc_dictionary_get_value(bootstrap.get(), &quot;OverrideLanguages&quot;)) {
+            NSDictionary *existingArguments = [[NSUserDefaults standardUserDefaults] volatileDomainForName:NSArgumentDomain];
+            NSMutableDictionary *newArguments = [existingArguments mutableCopy];
+            RetainPtr&lt;NSMutableArray *&gt; newLanguages = adoptNS([[NSMutableArray alloc] init]);
+            xpc_array_apply(languages, ^(size_t index, xpc_object_t value) {
+                [newLanguages addObject:[NSString stringWithCString:xpc_string_get_string_ptr(value) encoding:NSUTF8StringEncoding]];
+                return true;
+            });
+            [newArguments setValue:newLanguages.get() forKey:@&quot;AppleLanguages&quot;];
+            [[NSUserDefaults standardUserDefaults] setVolatileDomain:newArguments forName:NSArgumentDomain];
+        }
+    }
+#endif
+
</ins><span class="cx"> #if PLATFORM(MAC) &amp;&amp; __MAC_OS_X_VERSION_MIN_REQUIRED &gt;= 101000
</span><span class="cx"> #pragma clang diagnostic push
</span><span class="cx"> #pragma clang diagnostic ignored &quot;-Wdeprecated-declarations&quot;
</span></span></pre></div>
<a id="trunkSourceWebKit2UIProcessAPIAPIProcessPoolConfigurationcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/UIProcess/API/APIProcessPoolConfiguration.cpp (189668 => 189669)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/UIProcess/API/APIProcessPoolConfiguration.cpp        2015-09-13 02:31:34 UTC (rev 189668)
+++ trunk/Source/WebKit2/UIProcess/API/APIProcessPoolConfiguration.cpp        2015-09-13 03:47:56 UTC (rev 189669)
</span><span class="lines">@@ -88,6 +88,7 @@
</span><span class="cx">     copy-&gt;m_webSQLDatabaseDirectory = this-&gt;m_webSQLDatabaseDirectory;
</span><span class="cx">     copy-&gt;m_cachePartitionedURLSchemes = this-&gt;m_cachePartitionedURLSchemes;
</span><span class="cx">     copy-&gt;m_fullySynchronousModeIsAllowedForTesting = this-&gt;m_fullySynchronousModeIsAllowedForTesting;
</span><ins>+    copy-&gt;m_overrideLanguages = this-&gt;m_overrideLanguages;
</ins><span class="cx">     
</span><span class="cx">     return copy;
</span><span class="cx"> }
</span></span></pre></div>
<a id="trunkSourceWebKit2UIProcessAPIAPIProcessPoolConfigurationh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/UIProcess/API/APIProcessPoolConfiguration.h (189668 => 189669)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/UIProcess/API/APIProcessPoolConfiguration.h        2015-09-13 02:31:34 UTC (rev 189668)
+++ trunk/Source/WebKit2/UIProcess/API/APIProcessPoolConfiguration.h        2015-09-13 03:47:56 UTC (rev 189669)
</span><span class="lines">@@ -90,6 +90,9 @@
</span><span class="cx">     bool fullySynchronousModeIsAllowedForTesting() const { return m_fullySynchronousModeIsAllowedForTesting; }
</span><span class="cx">     void setFullySynchronousModeIsAllowedForTesting(bool allowed) { m_fullySynchronousModeIsAllowedForTesting = allowed; }
</span><span class="cx"> 
</span><ins>+    const Vector&lt;WTF::String&gt;&amp; overrideLanguages() const { return m_overrideLanguages; }
+    void setOverrideLanguages(Vector&lt;WTF::String&gt;&amp;&amp; languages) { m_overrideLanguages = WTF::move(languages); }
+
</ins><span class="cx"> private:
</span><span class="cx">     bool m_shouldHaveLegacyDataStore { false };
</span><span class="cx"> 
</span><span class="lines">@@ -108,6 +111,7 @@
</span><span class="cx">     WTF::String m_mediaKeysStorageDirectory;
</span><span class="cx">     Vector&lt;WTF::String&gt; m_cachePartitionedURLSchemes;
</span><span class="cx">     bool m_fullySynchronousModeIsAllowedForTesting { false };
</span><ins>+    Vector&lt;WTF::String&gt; m_overrideLanguages;
</ins><span class="cx"> };
</span><span class="cx"> 
</span><span class="cx"> } // namespace API
</span></span></pre></div>
<a id="trunkSourceWebKit2UIProcessAPICWKContextConfigurationRefcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/UIProcess/API/C/WKContextConfigurationRef.cpp (189668 => 189669)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/UIProcess/API/C/WKContextConfigurationRef.cpp        2015-09-13 02:31:34 UTC (rev 189668)
+++ trunk/Source/WebKit2/UIProcess/API/C/WKContextConfigurationRef.cpp        2015-09-13 03:47:56 UTC (rev 189669)
</span><span class="lines">@@ -121,3 +121,13 @@
</span><span class="cx"> {
</span><span class="cx">     toImpl(configuration)-&gt;setFullySynchronousModeIsAllowedForTesting(allowed);
</span><span class="cx"> }
</span><ins>+
+WKArrayRef WKContextConfigurationCopyOverrideLanguages(WKContextConfigurationRef configuration)
+{
+    return toAPI(&amp;API::Array::createStringArray(toImpl(configuration)-&gt;overrideLanguages()).leakRef());
+}
+
+void WKContextConfigurationSetOverrideLanguages(WKContextConfigurationRef configuration, WKArrayRef overrideLanguages)
+{
+    toImpl(configuration)-&gt;setOverrideLanguages(toImpl(overrideLanguages)-&gt;toStringVector());
+}
</ins></span></pre></div>
<a id="trunkSourceWebKit2UIProcessAPICWKContextConfigurationRefh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/UIProcess/API/C/WKContextConfigurationRef.h (189668 => 189669)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/UIProcess/API/C/WKContextConfigurationRef.h        2015-09-13 02:31:34 UTC (rev 189668)
+++ trunk/Source/WebKit2/UIProcess/API/C/WKContextConfigurationRef.h        2015-09-13 03:47:56 UTC (rev 189669)
</span><span class="lines">@@ -58,6 +58,9 @@
</span><span class="cx"> WK_EXPORT bool WKContextConfigurationFullySynchronousModeIsAllowedForTesting(WKContextConfigurationRef configuration);
</span><span class="cx"> WK_EXPORT void WKContextConfigurationSetFullySynchronousModeIsAllowedForTesting(WKContextConfigurationRef configuration, bool allowed);
</span><span class="cx"> 
</span><ins>+WK_EXPORT WKArrayRef WKContextConfigurationCopyOverrideLanguages(WKContextConfigurationRef configuration);
+WK_EXPORT void WKContextConfigurationSetOverrideLanguages(WKContextConfigurationRef configuration, WKArrayRef overrideLanguages);
+
</ins><span class="cx"> #ifdef __cplusplus
</span><span class="cx"> }
</span><span class="cx"> #endif
</span></span></pre></div>
<a id="trunkSourceWebKit2UIProcessLaunchermacProcessLauncherMacmm"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/UIProcess/Launcher/mac/ProcessLauncherMac.mm (189668 => 189669)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/UIProcess/Launcher/mac/ProcessLauncherMac.mm        2015-09-13 02:31:34 UTC (rev 189668)
+++ trunk/Source/WebKit2/UIProcess/Launcher/mac/ProcessLauncherMac.mm        2015-09-13 03:47:56 UTC (rev 189669)
</span><span class="lines">@@ -243,6 +243,17 @@
</span><span class="cx">         xpc_dictionary_set_string(containerEnvironmentVariables.get(), &quot;TMPDIR&quot;, environmentTMPDIR);
</span><span class="cx">     xpc_dictionary_set_value(initializationMessage.get(), &quot;ContainerEnvironmentVariables&quot;, containerEnvironmentVariables.get());
</span><span class="cx"> #endif
</span><ins>+
+    auto languagesIterator = launchOptions.extraInitializationData.find(&quot;OverrideLanguages&quot;);
+    if (languagesIterator != launchOptions.extraInitializationData.end()) {
+        auto languages = adoptOSObject(xpc_array_create(nullptr, 0));
+        Vector&lt;String&gt; languageVector;
+        languagesIterator-&gt;value.split(&quot;,&quot;, false, languageVector);
+        for (auto&amp; language : languageVector)
+            xpc_array_set_string(languages.get(), XPC_ARRAY_APPEND, language.utf8().data());
+        xpc_dictionary_set_value(initializationMessage.get(), &quot;OverrideLanguages&quot;, languages.get());
+    }
+
</ins><span class="cx">     xpc_connection_set_bootstrap(connection.get(), initializationMessage.get());
</span><span class="cx"> #endif
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkSourceWebKit2UIProcessWebProcessProxycpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/UIProcess/WebProcessProxy.cpp (189668 => 189669)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/UIProcess/WebProcessProxy.cpp        2015-09-13 02:31:34 UTC (rev 189668)
+++ trunk/Source/WebKit2/UIProcess/WebProcessProxy.cpp        2015-09-13 03:47:56 UTC (rev 189669)
</span><span class="lines">@@ -129,8 +129,21 @@
</span><span class="cx"> void WebProcessProxy::getLaunchOptions(ProcessLauncher::LaunchOptions&amp; launchOptions)
</span><span class="cx"> {
</span><span class="cx">     launchOptions.processType = ProcessLauncher::WebProcess;
</span><ins>+
</ins><span class="cx">     if (WebInspectorProxy::isInspectorProcessPool(m_processPool))
</span><span class="cx">         launchOptions.extraInitializationData.add(ASCIILiteral(&quot;inspector-process&quot;), ASCIILiteral(&quot;1&quot;));
</span><ins>+
+    auto overrideLanguages = m_processPool-&gt;configuration().overrideLanguages();
+    if (overrideLanguages.size()) {
+        StringBuilder languageString;
+        for (size_t i = 0; i &lt; overrideLanguages.size(); ++i) {
+            if (i)
+                languageString.append(',');
+            languageString.append(overrideLanguages[i]);
+        }
+        launchOptions.extraInitializationData.add(ASCIILiteral(&quot;OverrideLanguages&quot;), languageString.toString());
+    }
+
</ins><span class="cx">     platformGetLaunchOptions(launchOptions);
</span><span class="cx"> }
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkToolsChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Tools/ChangeLog (189668 => 189669)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Tools/ChangeLog        2015-09-13 02:31:34 UTC (rev 189668)
+++ trunk/Tools/ChangeLog        2015-09-13 03:47:56 UTC (rev 189669)
</span><span class="lines">@@ -1,5 +1,30 @@
</span><span class="cx"> 2015-09-12  Myles C. Maxfield  &lt;mmaxfield@apple.com&gt;
</span><span class="cx"> 
</span><ins>+        [Cocoa] Allow testing with the system language
+        https://bugs.webkit.org/show_bug.cgi?id=148671
+
+        Reviewed by Anders Carlsson and Alexey Proskuryakov.
+
+        React to tests marked with language=lang1,lang2,etc in their header.
+        Once this information is parsed, pass it to
+        WKContextConfigurationSetOverrideLanguages().
+
+        * WebKitTestRunner/InjectedBundle/mac/InjectedBundleMac.mm:
+        (WTR::InjectedBundle::platformInitialize): Don't clobber the language
+        list.
+        * WebKitTestRunner/TestController.cpp:
+        (WTR::TestController::createWebViewWithOptions): Call
+        WKContextConfigurationSetOverrideLanguages().
+        (WTR::updateTestOptionsFromTestHeader): Inspect the language option.
+        * WebKitTestRunner/TestOptions.h:
+        * WebKitTestRunner/ios/PlatformWebViewIOS.mm:
+        (WTR::PlatformWebView::viewSupportsOptions): Cause a differing language
+        option to restart the web process.
+        * WebKitTestRunner/mac/PlatformWebViewMac.mm:
+        (WTR::PlatformWebView::viewSupportsOptions): Ditto.
+
+2015-09-12  Myles C. Maxfield  &lt;mmaxfield@apple.com&gt;
+
</ins><span class="cx">         [WKTR] Allow changing the WKContextConfiguration between successive tests
</span><span class="cx">         https://bugs.webkit.org/show_bug.cgi?id=148833
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkToolsWebKitTestRunnerInjectedBundlemacInjectedBundleMacmm"></a>
<div class="modfile"><h4>Modified: trunk/Tools/WebKitTestRunner/InjectedBundle/mac/InjectedBundleMac.mm (189668 => 189669)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Tools/WebKitTestRunner/InjectedBundle/mac/InjectedBundleMac.mm        2015-09-13 02:31:34 UTC (rev 189668)
+++ trunk/Tools/WebKitTestRunner/InjectedBundle/mac/InjectedBundleMac.mm        2015-09-13 03:47:56 UTC (rev 189669)
</span><span class="lines">@@ -42,6 +42,11 @@
</span><span class="cx">     static const int NoFontSmoothing = 0;
</span><span class="cx">     static const int BlueTintedAppearance = 1;
</span><span class="cx"> 
</span><ins>+    // Language was set up earlier in main(). Don't clobber it.
+    NSArray *languages = [[[NSUserDefaults standardUserDefaults] volatileDomainForName:NSArgumentDomain] valueForKey:@&quot;AppleLanguages&quot;];
+    if (!languages)
+        languages = @[ @&quot;en&quot; ];
+
</ins><span class="cx">     NSDictionary *dict = @{
</span><span class="cx">         @&quot;AppleAntiAliasingThreshold&quot;: @4,
</span><span class="cx">         // FIXME: Setting AppleFontSmoothing is likely unnecessary and ineffective. WebKit2 has its own preference for font smoothing, which is
</span><span class="lines">@@ -56,7 +61,7 @@
</span><span class="cx">         @&quot;NSButtonAnimationsEnabled&quot;: @NO, // Ideally, we should find a way to test animations, but for now, make sure that the dumped snapshot matches actual state.
</span><span class="cx">         // FIXME (&lt;rdar://problem/13396515&gt;): It is too late to set AppleLanguages here, as loaded frameworks localizations cannot be changed.
</span><span class="cx">         // This breaks some accessibility tests on machines with non-English user language.
</span><del>-        @&quot;AppleLanguages&quot;: @[ @&quot;en&quot; ],
</del><ins>+        @&quot;AppleLanguages&quot;: languages,
</ins><span class="cx">         @&quot;NSPreferredSpellServerLanguage&quot;: @&quot;en_US&quot;,
</span><span class="cx">         @&quot;NSUserDictionaryReplacementItems&quot;: @[],
</span><span class="cx">         @&quot;NSTestCorrectionDictionary&quot;: @{
</span></span></pre></div>
<a id="trunkToolsWebKitTestRunnerTestControllercpp"></a>
<div class="modfile"><h4>Modified: trunk/Tools/WebKitTestRunner/TestController.cpp (189668 => 189669)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Tools/WebKitTestRunner/TestController.cpp        2015-09-13 02:31:34 UTC (rev 189668)
+++ trunk/Tools/WebKitTestRunner/TestController.cpp        2015-09-13 03:47:56 UTC (rev 189669)
</span><span class="lines">@@ -463,7 +463,12 @@
</span><span class="cx"> void TestController::createWebViewWithOptions(const TestOptions&amp; options)
</span><span class="cx"> {
</span><span class="cx">     auto contextConfiguration = generateContextConfiguration();
</span><del>-    // Modify contextConfiguration here.
</del><ins>+
+    WKRetainPtr&lt;WKMutableArrayRef&gt; overrideLanguages = adoptWK(WKMutableArrayCreate());
+    for (auto&amp; language : options.overrideLanguages)
+        WKArrayAppendItem(overrideLanguages.get(), adoptWK(WKStringCreateWithUTF8CString(language.utf8().data())).get());
+    WKContextConfigurationSetOverrideLanguages(contextConfiguration.get(), overrideLanguages.get());
+
</ins><span class="cx">     auto configuration = generatePageConfiguration(contextConfiguration.get());
</span><span class="cx"> 
</span><span class="cx">     // Some preferences (notably mock scroll bars setting) currently cannot be re-applied to an existing view, so we need to set them now.
</span><span class="lines">@@ -856,7 +861,8 @@
</span><span class="cx">         }
</span><span class="cx">         auto key = pairString.substr(pairStart, equalsLocation - pairStart);
</span><span class="cx">         auto value = pairString.substr(equalsLocation + 1, pairEnd - (equalsLocation + 1));
</span><del>-        // Options processing to modify testOptions goes here.
</del><ins>+        if (key == &quot;language&quot;)
+            String(value.c_str()).split(&quot;,&quot;, false, testOptions.overrideLanguages);
</ins><span class="cx">         pairStart = pairEnd + 1;
</span><span class="cx">     }
</span><span class="cx"> }
</span></span></pre></div>
<a id="trunkToolsWebKitTestRunnerTestOptionsh"></a>
<div class="modfile"><h4>Modified: trunk/Tools/WebKitTestRunner/TestOptions.h (189668 => 189669)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Tools/WebKitTestRunner/TestOptions.h        2015-09-13 02:31:34 UTC (rev 189668)
+++ trunk/Tools/WebKitTestRunner/TestOptions.h        2015-09-13 03:47:56 UTC (rev 189669)
</span><span class="lines">@@ -26,6 +26,9 @@
</span><span class="cx"> #ifndef TestOptions_h
</span><span class="cx"> #define TestOptions_h
</span><span class="cx"> 
</span><ins>+#include &lt;wtf/Vector.h&gt;
+#include &lt;wtf/text/WTFString.h&gt;
+
</ins><span class="cx"> namespace WTR {
</span><span class="cx"> 
</span><span class="cx"> struct TestOptions {
</span><span class="lines">@@ -34,6 +37,7 @@
</span><span class="cx">     bool shouldShowWebView { false };
</span><span class="cx"> 
</span><span class="cx">     bool useFixedLayout { false };
</span><ins>+    Vector&lt;String&gt; overrideLanguages;
</ins><span class="cx"> };
</span><span class="cx"> 
</span><span class="cx"> }
</span></span></pre></div>
<a id="trunkToolsWebKitTestRunneriosPlatformWebViewIOSmm"></a>
<div class="modfile"><h4>Modified: trunk/Tools/WebKitTestRunner/ios/PlatformWebViewIOS.mm (189668 => 189669)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Tools/WebKitTestRunner/ios/PlatformWebViewIOS.mm        2015-09-13 02:31:34 UTC (rev 189668)
+++ trunk/Tools/WebKitTestRunner/ios/PlatformWebViewIOS.mm        2015-09-13 03:47:56 UTC (rev 189669)
</span><span class="lines">@@ -204,6 +204,9 @@
</span><span class="cx"> 
</span><span class="cx"> bool PlatformWebView::viewSupportsOptions(const TestOptions&amp; options) const
</span><span class="cx"> {
</span><ins>+    if (m_options.overrideLanguages != options.overrideLanguages)
+        return false;
+
</ins><span class="cx">     return true;
</span><span class="cx"> }
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkToolsWebKitTestRunnermacPlatformWebViewMacmm"></a>
<div class="modfile"><h4>Modified: trunk/Tools/WebKitTestRunner/mac/PlatformWebViewMac.mm (189668 => 189669)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Tools/WebKitTestRunner/mac/PlatformWebViewMac.mm        2015-09-13 02:31:34 UTC (rev 189668)
+++ trunk/Tools/WebKitTestRunner/mac/PlatformWebViewMac.mm        2015-09-13 03:47:56 UTC (rev 189669)
</span><span class="lines">@@ -242,7 +242,7 @@
</span><span class="cx"> 
</span><span class="cx"> bool PlatformWebView::viewSupportsOptions(const TestOptions&amp; options) const
</span><span class="cx"> {
</span><del>-    if (m_options.useThreadedScrolling != options.useThreadedScrolling)
</del><ins>+    if (m_options.useThreadedScrolling != options.useThreadedScrolling || m_options.overrideLanguages != options.overrideLanguages)
</ins><span class="cx">         return false;
</span><span class="cx"> 
</span><span class="cx">     return true;
</span></span></pre>
</div>
</div>

</body>
</html>