[Cocoa] Allow testing with the system language
authormmaxfield@apple.com <mmaxfield@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sun, 13 Sep 2015 03:47:56 +0000 (03:47 +0000)
committermmaxfield@apple.com <mmaxfield@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sun, 13 Sep 2015 03:47:56 +0000 (03:47 +0000)
commit32ac04b984f75b4c076e742f6b53ef82d42f4dae
treeb2a094af12fa5c78ecd01db1e0607a04a31e324c
parentf214ebf141b4f987ddd5ab32c3f6315c7e039b50
[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:

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@189669 268f45cc-cd09-0410-ab3c-d52691b4dbfc
21 files changed:
LayoutTests/ChangeLog
LayoutTests/fast/text/international/system-language/declarative-language-expected.txt [new file with mode: 0644]
LayoutTests/fast/text/international/system-language/declarative-language.html [new file with mode: 0644]
LayoutTests/platform/efl/TestExpectations
LayoutTests/platform/gtk/TestExpectations
LayoutTests/platform/mac-wk1/TestExpectations
LayoutTests/platform/mac/TestExpectations
Source/WebKit2/ChangeLog
Source/WebKit2/Shared/EntryPointUtilities/mac/XPCService/XPCServiceMain.Development.mm
Source/WebKit2/UIProcess/API/APIProcessPoolConfiguration.cpp
Source/WebKit2/UIProcess/API/APIProcessPoolConfiguration.h
Source/WebKit2/UIProcess/API/C/WKContextConfigurationRef.cpp
Source/WebKit2/UIProcess/API/C/WKContextConfigurationRef.h
Source/WebKit2/UIProcess/Launcher/mac/ProcessLauncherMac.mm
Source/WebKit2/UIProcess/WebProcessProxy.cpp
Tools/ChangeLog
Tools/WebKitTestRunner/InjectedBundle/mac/InjectedBundleMac.mm
Tools/WebKitTestRunner/TestController.cpp
Tools/WebKitTestRunner/TestOptions.h
Tools/WebKitTestRunner/ios/PlatformWebViewIOS.mm
Tools/WebKitTestRunner/mac/PlatformWebViewMac.mm