Diff
Modified: trunk/LayoutTests/ChangeLog (214412 => 214413)
--- trunk/LayoutTests/ChangeLog 2017-03-27 13:38:34 UTC (rev 214412)
+++ trunk/LayoutTests/ChangeLog 2017-03-27 15:43:34 UTC (rev 214413)
@@ -1,3 +1,19 @@
+2017-03-27 Alex Christensen <[email protected]>
+
+ Make WebSockets work in network process
+ https://bugs.webkit.org/show_bug.cgi?id=169930
+
+ Reviewed by Youenn Fablet.
+
+ * http/tests/websocket/tests/hybi/network-process-crash-error-expected.txt: Added.
+ * http/tests/websocket/tests/hybi/network-process-crash-error.html: Added.
+ * http/tests/websocket/tests/hybi/slow-reply_wsh.py: Added.
+ (web_socket_do_extra_handshake):
+ (web_socket_transfer_data):
+ * platform/ios-simulator-wk1/TestExpectations:
+ * platform/mac-wk1/TestExpectations:
+ * platform/win/TestExpectations:
+
2017-03-27 Antoine Quint <[email protected]>
[Modern Media Controls] Improve media documents across macOS, iPhone and iPad
Added: trunk/LayoutTests/http/tests/websocket/tests/hybi/network-process-crash-error-expected.txt (0 => 214413)
--- trunk/LayoutTests/http/tests/websocket/tests/hybi/network-process-crash-error-expected.txt (rev 0)
+++ trunk/LayoutTests/http/tests/websocket/tests/hybi/network-process-crash-error-expected.txt 2017-03-27 15:43:34 UTC (rev 214413)
@@ -0,0 +1,5 @@
+ALERT: Created a socket to 'ws://127.0.0.1:8880/websocket/tests/hybi/slow-reply'; readyState 0.
+ALERT: Terminating network process.
+CONSOLE MESSAGE: WebSocket network error: Network process crashed.
+ALERT: Received error:[object Event]
+
Added: trunk/LayoutTests/http/tests/websocket/tests/hybi/network-process-crash-error.html (0 => 214413)
--- trunk/LayoutTests/http/tests/websocket/tests/hybi/network-process-crash-error.html (rev 0)
+++ trunk/LayoutTests/http/tests/websocket/tests/hybi/network-process-crash-error.html 2017-03-27 15:43:34 UTC (rev 214413)
@@ -0,0 +1,34 @@
+<script>
+function endTest() {
+ if (window.testRunner)
+ testRunner.notifyDone();
+}
+
+if (window.testRunner) {
+ testRunner.dumpAsText();
+ testRunner.waitUntilDone();
+}
+
+var ws = new WebSocket("ws://127.0.0.1:8880/websocket/tests/hybi/slow-reply");
+alert("Created a socket to '" + ws.URL + "'; readyState " + ws.readyState + ".");
+
+ws._onopen_ = function()
+{
+ if (window.testRunner && window.testRunner.terminateNetworkProcess) {
+ alert("Terminating network process.");
+ testRunner.terminateNetworkProcess();
+ }
+};
+
+ws._onerror_ = function(e)
+{
+ alert("Received error:" + e);
+ endTest();
+};
+
+ws._onclose_ = function(e)
+{
+ alert("Closed; readyState " + ws.readyState + "." + e);
+ endTest();
+};
+</script>
Added: trunk/LayoutTests/http/tests/websocket/tests/hybi/slow-reply_wsh.py (0 => 214413)
--- trunk/LayoutTests/http/tests/websocket/tests/hybi/slow-reply_wsh.py (rev 0)
+++ trunk/LayoutTests/http/tests/websocket/tests/hybi/slow-reply_wsh.py 2017-03-27 15:43:34 UTC (rev 214413)
@@ -0,0 +1,9 @@
+from mod_pywebsocket import msgutil
+import time
+
+def web_socket_do_extra_handshake(request):
+ pass
+
+def web_socket_transfer_data(request):
+ time.sleep(5)
+ msgutil.send_message(request, 'Hello from Simple WSH.')
\ No newline at end of file
Modified: trunk/LayoutTests/platform/ios-simulator-wk1/TestExpectations (214412 => 214413)
--- trunk/LayoutTests/platform/ios-simulator-wk1/TestExpectations 2017-03-27 13:38:34 UTC (rev 214412)
+++ trunk/LayoutTests/platform/ios-simulator-wk1/TestExpectations 2017-03-27 15:43:34 UTC (rev 214413)
@@ -1885,3 +1885,5 @@
# Hover test does not apply
fast/css/deferred-parsing/hover-test.html [ Skip ]
+# There is not NetworkProcess in WK1, so it can't crash.
+http/tests/websocket/tests/hybi/network-process-crash-error.html [ Skip ]
Modified: trunk/LayoutTests/platform/mac-wk1/TestExpectations (214412 => 214413)
--- trunk/LayoutTests/platform/mac-wk1/TestExpectations 2017-03-27 13:38:34 UTC (rev 214412)
+++ trunk/LayoutTests/platform/mac-wk1/TestExpectations 2017-03-27 15:43:34 UTC (rev 214413)
@@ -166,7 +166,7 @@
### END OF (2) Failures without bug reports
########################################
-# This test is WebKit2-only
+# These tests are WebKit2-only
http/tests/contentfiltering/load-substitute-data-from-appcache.html
fast/dom/Window/child-window-focus.html
@@ -334,3 +334,6 @@
webkit.org/b/169117 media/modern-media-controls/macos-inline-media-controls/macos-inline-media-controls-audio-background.html [ Pass Timeout ]
webkit.org/b/167752 media/modern-media-controls/icon-button/icon-button-active-state.html [ Pass Timeout ]
webkit.org/b/167477 [ Debug ] media/modern-media-controls/play-pause-button/play-pause-button.html [ Pass Timeout ]
+
+# There is not NetworkProcess in WK1, so it can't crash.
+http/tests/websocket/tests/hybi/network-process-crash-error.html [ Skip ]
Modified: trunk/LayoutTests/platform/win/TestExpectations (214412 => 214413)
--- trunk/LayoutTests/platform/win/TestExpectations 2017-03-27 13:38:34 UTC (rev 214412)
+++ trunk/LayoutTests/platform/win/TestExpectations 2017-03-27 15:43:34 UTC (rev 214413)
@@ -3802,3 +3802,6 @@
# webglcontextchanged event not supported
fast/canvas/webgl/webglcontextchangedevent.html [ Skip ]
+
+# There is not NetworkProcess in WK1, so it can't crash.
+http/tests/websocket/tests/hybi/network-process-crash-error.html [ Skip ]
Modified: trunk/Source/WebCore/ChangeLog (214412 => 214413)
--- trunk/Source/WebCore/ChangeLog 2017-03-27 13:38:34 UTC (rev 214412)
+++ trunk/Source/WebCore/ChangeLog 2017-03-27 15:43:34 UTC (rev 214413)
@@ -1,3 +1,25 @@
+2017-03-27 Alex Christensen <[email protected]>
+
+ Make WebSockets work in network process
+ https://bugs.webkit.org/show_bug.cgi?id=169930
+
+ Reviewed by Youenn Fablet.
+
+ Covered by 136 existing tests in http/tests/websocket/tests/hybi
+ This also does fine with the 544 websocket tests in the web-platform-tests which we have not yet imported.
+ Also added http/tests/websocket/tests/hybi/network-process-crash-error.html
+ to test a new condition that couldn't happen before this move: the NetworkProcess crashing.
+
+ * Modules/websockets/WebSocketChannel.cpp:
+ (WebCore::WebSocketChannel::fail):
+ We were asserting that didCloseSocketStream was called. It is still called,
+ but not synchronously like it used to. This assertion is now invalid, but tests
+ that would hit it still pass.
+ * platform/network/cf/SocketStreamHandleImplCFNet.cpp:
+ (WebCore::SocketStreamHandleImpl::platformSendInternal):
+ CFWriteStreamCanAcceptBytes crashes if you give it a null parameter, and that can happen now.
+ If we have no write stream, then we cannot write. Tests that hit this pass still.
+
2017-03-27 Antoine Quint <[email protected]>
[Modern Media Controls] Improve media documents across macOS, iPhone and iPad
Modified: trunk/Source/WebCore/Modules/websockets/WebSocketChannel.cpp (214412 => 214413)
--- trunk/Source/WebCore/Modules/websockets/WebSocketChannel.cpp 2017-03-27 13:38:34 UTC (rev 214412)
+++ trunk/Source/WebCore/Modules/websockets/WebSocketChannel.cpp 2017-03-27 15:43:34 UTC (rev 214413)
@@ -238,10 +238,7 @@
m_client->didReceiveMessageError();
if (m_handle && !m_closed)
- m_handle->disconnect(); // Will call didClose().
-
- // We should be closed by now, but if we never got a handshake then we never even opened.
- ASSERT(m_closed || !m_handshake);
+ m_handle->disconnect(); // Will call didCloseSocketStream() but maybe not synchronously.
}
void WebSocketChannel::disconnect()
@@ -366,6 +363,8 @@
m_document->addConsoleMessage(MessageSource::Network, MessageLevel::Error, message);
}
m_shouldDiscardReceivedData = true;
+ if (m_client)
+ m_client->didReceiveMessageError();
handle.disconnect();
}
Modified: trunk/Source/WebCore/platform/network/cf/SocketStreamHandleImplCFNet.cpp (214412 => 214413)
--- trunk/Source/WebCore/platform/network/cf/SocketStreamHandleImplCFNet.cpp 2017-03-27 13:38:34 UTC (rev 214412)
+++ trunk/Source/WebCore/platform/network/cf/SocketStreamHandleImplCFNet.cpp 2017-03-27 15:43:34 UTC (rev 214413)
@@ -655,6 +655,9 @@
std::optional<size_t> SocketStreamHandleImpl::platformSendInternal(const char* data, size_t length)
{
+ if (!m_writeStream)
+ return std::nullopt;
+
if (!CFWriteStreamCanAcceptBytes(m_writeStream.get()))
return std::nullopt;
Modified: trunk/Source/WebKit2/CMakeLists.txt (214412 => 214413)
--- trunk/Source/WebKit2/CMakeLists.txt 2017-03-27 13:38:34 UTC (rev 214412)
+++ trunk/Source/WebKit2/CMakeLists.txt 2017-03-27 15:43:34 UTC (rev 214413)
@@ -119,6 +119,7 @@
NetworkProcess/NetworkResourceLoadParameters.cpp
NetworkProcess/NetworkResourceLoader.cpp
NetworkProcess/NetworkSession.cpp
+ NetworkProcess/NetworkSocketStream.cpp
NetworkProcess/cache/NetworkCache.cpp
NetworkProcess/cache/NetworkCacheBlobStorage.cpp
@@ -513,6 +514,7 @@
WebProcess/Network/WebLoaderStrategy.cpp
WebProcess/Network/WebResourceLoader.cpp
WebProcess/Network/WebSocketProvider.cpp
+ WebProcess/Network/WebSocketStream.cpp
WebProcess/Notifications/NotificationPermissionRequestManager.cpp
WebProcess/Notifications/WebNotificationManager.cpp
@@ -596,6 +598,7 @@
NetworkProcess/NetworkConnectionToWebProcess.messages.in
NetworkProcess/NetworkProcess.messages.in
NetworkProcess/NetworkResourceLoader.messages.in
+ NetworkProcess/NetworkSocketStream.messages.in
NetworkProcess/webrtc/NetworkRTCMonitor.messages.in
NetworkProcess/webrtc/NetworkRTCProvider.messages.in
@@ -663,6 +666,7 @@
WebProcess/Network/NetworkProcessConnection.messages.in
WebProcess/Network/WebResourceLoader.messages.in
+ WebProcess/Network/WebSocketStream.messages.in
WebProcess/Notifications/WebNotificationManager.messages.in
Modified: trunk/Source/WebKit2/ChangeLog (214412 => 214413)
--- trunk/Source/WebKit2/ChangeLog 2017-03-27 13:38:34 UTC (rev 214412)
+++ trunk/Source/WebKit2/ChangeLog 2017-03-27 15:43:34 UTC (rev 214413)
@@ -1,3 +1,84 @@
+2017-03-27 Alex Christensen <[email protected]>
+
+ Make WebSockets work in network process
+ https://bugs.webkit.org/show_bug.cgi?id=169930
+
+ Reviewed by Youenn Fablet.
+
+ This adds WebSocketStream, which is a SocketStreamHandle that sends asynchronous
+ messages to a NetworkSocketStream in the NetworkProcess. WebKit1 uses a SocketStreamHandleImpl
+ still, but WebKit2 now has a SocketStreamHandleImpl in the NetworkProcess owned by the
+ NetworkSocketStream, which is a SocketStreamHandleClient that sends asynchronous messages back
+ to the WebProcess. WebSocketStream's implementation of SocketStreamHandle::platformSend is special
+ because it stores the completion handler in a map and asynchronously reports to the caller whether
+ it succeeded or not. If the network processes crashes before the completion handlers are called,
+ then they are called indicating failure and an error is reported, but that never happens, right?
+
+ * CMakeLists.txt:
+ * DerivedSources.make:
+ * NetworkProcess/NetworkConnectionToWebProcess.cpp:
+ (WebKit::NetworkConnectionToWebProcess::didReceiveMessage):
+ (WebKit::NetworkConnectionToWebProcess::createSocketStream):
+ (WebKit::NetworkConnectionToWebProcess::destroySocketStream):
+ * NetworkProcess/NetworkConnectionToWebProcess.h:
+ * NetworkProcess/NetworkConnectionToWebProcess.messages.in:
+ * NetworkProcess/NetworkProcess.cpp:
+ (WebKit::NetworkProcess::setAllowsAnySSLCertificateForWebSocket):
+ * NetworkProcess/NetworkProcess.h:
+ * NetworkProcess/NetworkProcess.messages.in:
+ * NetworkProcess/NetworkSocketStream.cpp: Added.
+ (WebKit::NetworkSocketStream::create):
+ (WebKit::NetworkSocketStream::NetworkSocketStream):
+ (WebKit::NetworkSocketStream::sendData):
+ (WebKit::NetworkSocketStream::close):
+ (WebKit::NetworkSocketStream::didOpenSocketStream):
+ (WebKit::NetworkSocketStream::didCloseSocketStream):
+ (WebKit::NetworkSocketStream::didReceiveSocketStreamData):
+ (WebKit::NetworkSocketStream::didFailToReceiveSocketStreamData):
+ (WebKit::NetworkSocketStream::didUpdateBufferedAmount):
+ (WebKit::NetworkSocketStream::didFailSocketStream):
+ (WebKit::NetworkSocketStream::messageSenderConnection):
+ (WebKit::NetworkSocketStream::messageSenderDestinationID):
+ * NetworkProcess/NetworkSocketStream.h: Added.
+ * NetworkProcess/NetworkSocketStream.messages.in: Added.
+ * UIProcess/API/C/WKContext.cpp:
+ (WKContextSetAllowsAnySSLCertificateForWebSocketTesting):
+ (WKContextTerminateNetworkProcess):
+ * UIProcess/API/C/WKContextPrivate.h:
+ * UIProcess/WebProcessPool.cpp:
+ (WebKit::WebProcessPool::sendSyncToNetworkingProcess):
+ (WebKit::WebProcessPool::setAllowsAnySSLCertificateForWebSocket):
+ (WebKit::WebProcessPool::terminateNetworkProcess):
+ * UIProcess/WebProcessPool.h:
+ * WebKit2.xcodeproj/project.pbxproj:
+ * WebProcess/Network/NetworkProcessConnection.cpp:
+ (WebKit::NetworkProcessConnection::didReceiveMessage):
+ * WebProcess/Network/WebSocketProvider.cpp:
+ (WebKit::WebSocketProvider::createSocketStreamHandle):
+ * WebProcess/Network/WebSocketStream.cpp: Added.
+ (WebKit::globalWebSocketStreamMap):
+ (WebKit::WebSocketStream::streamWithIdentifier):
+ (WebKit::WebSocketStream::networkProcessCrashed):
+ (WebKit::WebSocketStream::create):
+ (WebKit::WebSocketStream::WebSocketStream):
+ (WebKit::WebSocketStream::~WebSocketStream):
+ (WebKit::WebSocketStream::messageSenderConnection):
+ (WebKit::WebSocketStream::messageSenderDestinationID):
+ (WebKit::WebSocketStream::platformSend):
+ (WebKit::WebSocketStream::didSendData):
+ (WebKit::WebSocketStream::platformClose):
+ (WebKit::WebSocketStream::bufferedAmount):
+ (WebKit::WebSocketStream::didOpenSocketStream):
+ (WebKit::WebSocketStream::didCloseSocketStream):
+ (WebKit::WebSocketStream::didReceiveSocketStreamData):
+ (WebKit::WebSocketStream::didFailToReceiveSocketStreamData):
+ (WebKit::WebSocketStream::didUpdateBufferedAmount):
+ (WebKit::WebSocketStream::didFailSocketStream):
+ * WebProcess/Network/WebSocketStream.h: Added.
+ * WebProcess/Network/WebSocketStream.messages.in: Added.
+ * WebProcess/WebProcess.cpp:
+ (WebKit::WebProcess::networkProcessConnectionClosed):
+
2017-03-27 Adrian Perez de Castro <[email protected]>
[GTK] NetscapePluginX11::m_windowID is unused/unneeded
Modified: trunk/Source/WebKit2/DerivedSources.make (214412 => 214413)
--- trunk/Source/WebKit2/DerivedSources.make 2017-03-27 13:38:34 UTC (rev 214412)
+++ trunk/Source/WebKit2/DerivedSources.make 2017-03-27 15:43:34 UTC (rev 214413)
@@ -108,6 +108,7 @@
NetworkRTCProvider \
NetworkRTCSocket \
NetworkResourceLoader \
+ NetworkSocketStream \
PluginControllerProxy \
PluginProcess \
PluginProcessConnection \
@@ -164,6 +165,7 @@
WebRTCSocket \
WebResourceLoader \
WebResourceLoadStatisticsStore \
+ WebSocketStream \
WebUserContentController \
WebUserContentControllerProxy \
WebVideoFullscreenManager \
Modified: trunk/Source/WebKit2/NetworkProcess/NetworkConnectionToWebProcess.cpp (214412 => 214413)
--- trunk/Source/WebKit2/NetworkProcess/NetworkConnectionToWebProcess.cpp 2017-03-27 13:38:34 UTC (rev 214412)
+++ trunk/Source/WebKit2/NetworkProcess/NetworkConnectionToWebProcess.cpp 2017-03-27 15:43:34 UTC (rev 214413)
@@ -40,6 +40,8 @@
#include "NetworkResourceLoadParameters.h"
#include "NetworkResourceLoader.h"
#include "NetworkResourceLoaderMessages.h"
+#include "NetworkSocketStream.h"
+#include "NetworkSocketStreamMessages.h"
#include "RemoteNetworkingContext.h"
#include "SessionTracker.h"
#include "WebCoreArgumentCoders.h"
@@ -98,6 +100,16 @@
return;
}
+ if (decoder.messageReceiverName() == Messages::NetworkSocketStream::messageReceiverName()) {
+ auto socketIterator = m_networkSocketStreams.find(decoder.destinationID());
+ if (socketIterator != m_networkSocketStreams.end()) {
+ socketIterator->value->didReceiveMessage(connection, decoder);
+ if (decoder.messageName() == Messages::NetworkSocketStream::Close::name())
+ m_networkSocketStreams.remove(socketIterator);
+ }
+ return;
+ }
+
#if USE(LIBWEBRTC)
if (decoder.messageReceiverName() == Messages::NetworkRTCSocket::messageReceiverName()) {
rtcProvider().didReceiveNetworkRTCSocketMessage(connection, decoder);
@@ -160,6 +172,18 @@
{
}
+void NetworkConnectionToWebProcess::createSocketStream(URL&& url, SessionID sessionID, String cachePartition, uint64_t identifier)
+{
+ ASSERT(!m_networkSocketStreams.contains(identifier));
+ m_networkSocketStreams.set(identifier, NetworkSocketStream::create(WTFMove(url), sessionID, cachePartition, identifier, m_connection));
+}
+
+void NetworkConnectionToWebProcess::destroySocketStream(uint64_t identifier)
+{
+ ASSERT(m_networkSocketStreams.get(identifier));
+ m_networkSocketStreams.remove(identifier);
+}
+
void NetworkConnectionToWebProcess::scheduleResourceLoad(const NetworkResourceLoadParameters& loadParameters)
{
auto loader = NetworkResourceLoader::create(loadParameters, *this);
Modified: trunk/Source/WebKit2/NetworkProcess/NetworkConnectionToWebProcess.h (214412 => 214413)
--- trunk/Source/WebKit2/NetworkProcess/NetworkConnectionToWebProcess.h 2017-03-27 13:38:34 UTC (rev 214412)
+++ trunk/Source/WebKit2/NetworkProcess/NetworkConnectionToWebProcess.h 2017-03-27 15:43:34 UTC (rev 214413)
@@ -43,6 +43,7 @@
class NetworkConnectionToWebProcess;
class NetworkResourceLoader;
+class NetworkSocketStream;
class SyncNetworkResourceLoader;
typedef uint64_t ResourceLoadIdentifier;
@@ -104,6 +105,9 @@
void storeDerivedDataToCache(const WebKit::NetworkCache::DataKey&, const IPC::DataReference&);
+ void createSocketStream(WebCore::URL&&, WebCore::SessionID, String cachePartition, uint64_t);
+ void destroySocketStream(uint64_t);
+
void ensureLegacyPrivateBrowsingSession();
#if USE(LIBWEBRTC)
@@ -112,6 +116,7 @@
Ref<IPC::Connection> m_connection;
+ HashMap<uint64_t, RefPtr<NetworkSocketStream>> m_networkSocketStreams;
HashMap<ResourceLoadIdentifier, RefPtr<NetworkResourceLoader>> m_networkResourceLoaders;
HashMap<String, RefPtr<WebCore::BlobDataFileReference>> m_blobDataFileReferences;
Modified: trunk/Source/WebKit2/NetworkProcess/NetworkConnectionToWebProcess.messages.in (214412 => 214413)
--- trunk/Source/WebKit2/NetworkProcess/NetworkConnectionToWebProcess.messages.in 2017-03-27 13:38:34 UTC (rev 214412)
+++ trunk/Source/WebKit2/NetworkProcess/NetworkConnectionToWebProcess.messages.in 2017-03-27 15:43:34 UTC (rev 214413)
@@ -51,5 +51,7 @@
StoreDerivedDataToCache(WebKit::NetworkCache::DataKey key, IPC::DataReference data)
+ CreateSocketStream(WebCore::URL url, WebCore::SessionID sessionID, String cachePartition, uint64_t identifier)
+
EnsureLegacyPrivateBrowsingSession()
}
Modified: trunk/Source/WebKit2/NetworkProcess/NetworkProcess.cpp (214412 => 214413)
--- trunk/Source/WebKit2/NetworkProcess/NetworkProcess.cpp 2017-03-27 13:38:34 UTC (rev 214412)
+++ trunk/Source/WebKit2/NetworkProcess/NetworkProcess.cpp 2017-03-27 15:43:34 UTC (rev 214413)
@@ -61,6 +61,7 @@
#include <WebCore/SecurityOriginData.h>
#include <WebCore/SecurityOriginHash.h>
#include <WebCore/SessionID.h>
+#include <WebCore/Settings.h>
#include <WebCore/URLParser.h>
#include <wtf/OptionSet.h>
#include <wtf/RunLoop.h>
@@ -581,6 +582,11 @@
parentProcessConnection()->send(Messages::WebProcessPool::DidGetStatistics(data, callbackID), 0);
}
+void NetworkProcess::setAllowsAnySSLCertificateForWebSocket(bool allows)
+{
+ Settings::setAllowsAnySSLCertificate(allows);
+}
+
void NetworkProcess::logDiagnosticMessage(uint64_t webPageID, const String& message, const String& description, ShouldSample shouldSample)
{
if (!DiagnosticLoggingClient::shouldLogAfterSampling(shouldSample))
Modified: trunk/Source/WebKit2/NetworkProcess/NetworkProcess.h (214412 => 214413)
--- trunk/Source/WebKit2/NetworkProcess/NetworkProcess.h 2017-03-27 13:38:34 UTC (rev 214412)
+++ trunk/Source/WebKit2/NetworkProcess/NetworkProcess.h 2017-03-27 15:43:34 UTC (rev 214413)
@@ -189,6 +189,7 @@
void setCanHandleHTTPSServerTrustEvaluation(bool);
void getNetworkProcessStatistics(uint64_t callbackID);
void clearCacheForAllOrigins(uint32_t cachesToClear);
+ void setAllowsAnySSLCertificateForWebSocket(bool);
void didGrantSandboxExtensionsToDatabaseProcessForBlobs(uint64_t requestID);
Modified: trunk/Source/WebKit2/NetworkProcess/NetworkProcess.messages.in (214412 => 214413)
--- trunk/Source/WebKit2/NetworkProcess/NetworkProcess.messages.in 2017-03-27 13:38:34 UTC (rev 214412)
+++ trunk/Source/WebKit2/NetworkProcess/NetworkProcess.messages.in 2017-03-27 15:43:34 UTC (rev 214413)
@@ -62,6 +62,7 @@
SetQOS(int latencyQOS, int throughputQOS)
SetCookieStoragePartitioningEnabled(bool enabled)
#endif
+ SetAllowsAnySSLCertificateForWebSocket(bool enabled) -> ()
AllowSpecificHTTPSCertificateForHost(WebCore::CertificateInfo certificate, String host)
SetCanHandleHTTPSServerTrustEvaluation(bool value)
Added: trunk/Source/WebKit2/NetworkProcess/NetworkSocketStream.cpp (0 => 214413)
--- trunk/Source/WebKit2/NetworkProcess/NetworkSocketStream.cpp (rev 0)
+++ trunk/Source/WebKit2/NetworkProcess/NetworkSocketStream.cpp 2017-03-27 15:43:34 UTC (rev 214413)
@@ -0,0 +1,108 @@
+/*
+ * Copyright (C) 2017 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "config.h"
+#include "NetworkSocketStream.h"
+
+#include "DataReference.h"
+#include "WebSocketStreamMessages.h"
+#include <WebCore/SocketStreamError.h>
+#include <WebCore/SocketStreamHandleImpl.h>
+
+using namespace WebCore;
+
+namespace WebKit {
+
+Ref<NetworkSocketStream> NetworkSocketStream::create(WebCore::URL&& url, WebCore::SessionID sessionID, const String& credentialPartition, uint64_t identifier, IPC::Connection& connection)
+{
+ return adoptRef(*new NetworkSocketStream(WTFMove(url), sessionID, credentialPartition, identifier, connection));
+}
+
+NetworkSocketStream::NetworkSocketStream(URL&& url, SessionID sessionID, const String& credentialPartition, uint64_t identifier, IPC::Connection& connection)
+ : m_impl(SocketStreamHandleImpl::create(url, *this, sessionID, credentialPartition))
+ , m_identifier(identifier)
+ , m_connection(connection)
+{
+}
+
+void NetworkSocketStream::sendData(const IPC::DataReference& data, uint64_t identifier)
+{
+ m_impl->platformSend(reinterpret_cast<const char *>(data.data()), data.size(), [this, protectedThis = makeRef(*this), identifier] (bool success) {
+ send(Messages::WebSocketStream::DidSendData(identifier, success));
+ });
+}
+
+void NetworkSocketStream::close()
+{
+ m_impl->platformClose();
+}
+
+void NetworkSocketStream::didOpenSocketStream(SocketStreamHandle& handle)
+{
+ ASSERT_UNUSED(handle, &handle == m_impl.ptr());
+ send(Messages::WebSocketStream::DidOpenSocketStream());
+}
+
+void NetworkSocketStream::didCloseSocketStream(SocketStreamHandle& handle)
+{
+ ASSERT_UNUSED(handle, &handle == m_impl.ptr());
+ send(Messages::WebSocketStream::DidCloseSocketStream());
+}
+
+void NetworkSocketStream::didReceiveSocketStreamData(SocketStreamHandle& handle, const char* data, size_t length)
+{
+ ASSERT_UNUSED(handle, &handle == m_impl.ptr());
+ send(Messages::WebSocketStream::DidReceiveSocketStreamData(IPC::DataReference(reinterpret_cast<const uint8_t*>(data), length)));
+}
+
+void NetworkSocketStream::didFailToReceiveSocketStreamData(WebCore::SocketStreamHandle& handle)
+{
+ ASSERT_UNUSED(handle, &handle == m_impl.ptr());
+ send(Messages::WebSocketStream::DidFailToReceiveSocketStreamData());
+}
+
+void NetworkSocketStream::didUpdateBufferedAmount(SocketStreamHandle& handle, size_t amount)
+{
+ ASSERT_UNUSED(handle, &handle == m_impl.ptr());
+ send(Messages::WebSocketStream::DidUpdateBufferedAmount(amount));
+}
+
+void NetworkSocketStream::didFailSocketStream(SocketStreamHandle& handle, const SocketStreamError& error)
+{
+ ASSERT_UNUSED(handle, &handle == m_impl.ptr());
+ send(Messages::WebSocketStream::DidFailSocketStream(error));
+}
+
+IPC::Connection* NetworkSocketStream::messageSenderConnection()
+{
+ return &m_connection;
+}
+
+uint64_t NetworkSocketStream::messageSenderDestinationID()
+{
+ return m_identifier;
+}
+
+} // namespace WebKit
Added: trunk/Source/WebKit2/NetworkProcess/NetworkSocketStream.h (0 => 214413)
--- trunk/Source/WebKit2/NetworkProcess/NetworkSocketStream.h (rev 0)
+++ trunk/Source/WebKit2/NetworkProcess/NetworkSocketStream.h 2017-03-27 15:43:34 UTC (rev 214413)
@@ -0,0 +1,74 @@
+/*
+ * Copyright (C) 2017 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#pragma once
+
+#include "MessageReceiver.h"
+#include "MessageSender.h"
+#include <WebCore/SessionID.h>
+#include <WebCore/SocketStreamHandleClient.h>
+#include <WebCore/SocketStreamHandleImpl.h>
+
+namespace IPC {
+class Connection;
+class Decoder;
+class DataReference;
+}
+
+namespace WebCore {
+class SocketStreamHandleImpl;
+class URL;
+}
+
+namespace WebKit {
+
+class NetworkSocketStream : public RefCounted<NetworkSocketStream>, public IPC::MessageSender, public IPC::MessageReceiver, public WebCore::SocketStreamHandleClient {
+public:
+ static Ref<NetworkSocketStream> create(WebCore::URL&&, WebCore::SessionID, const String& credentialPartition, uint64_t, IPC::Connection&);
+
+ void didReceiveMessage(IPC::Connection&, IPC::Decoder&);
+
+ void sendData(const IPC::DataReference&, uint64_t);
+ void close();
+
+ // SocketStreamHandleClient
+ void didOpenSocketStream(WebCore::SocketStreamHandle&) final;
+ void didCloseSocketStream(WebCore::SocketStreamHandle&) final;
+ void didReceiveSocketStreamData(WebCore::SocketStreamHandle&, const char*, size_t) final;
+ void didFailToReceiveSocketStreamData(WebCore::SocketStreamHandle&) final;
+ void didUpdateBufferedAmount(WebCore::SocketStreamHandle&, size_t) final;
+ void didFailSocketStream(WebCore::SocketStreamHandle&, const WebCore::SocketStreamError&) final;
+
+private:
+ IPC::Connection* messageSenderConnection() final;
+ uint64_t messageSenderDestinationID() final;
+
+ NetworkSocketStream(WebCore::URL&&, WebCore::SessionID, const String& credentialPartition, uint64_t, IPC::Connection&);
+ Ref<WebCore::SocketStreamHandleImpl> m_impl;
+ uint64_t m_identifier;
+ IPC::Connection& m_connection;
+};
+
+} // namespace WebKit
Added: trunk/Source/WebKit2/NetworkProcess/NetworkSocketStream.messages.in (0 => 214413)
--- trunk/Source/WebKit2/NetworkProcess/NetworkSocketStream.messages.in (rev 0)
+++ trunk/Source/WebKit2/NetworkProcess/NetworkSocketStream.messages.in 2017-03-27 15:43:34 UTC (rev 214413)
@@ -0,0 +1,26 @@
+# Copyright (C) 2017 Apple Inc. All rights reserved.
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions
+# are met:
+# 1. Redistributions of source code must retain the above copyright
+# notice, this list of conditions and the following disclaimer.
+# 2. Redistributions in binary form must reproduce the above copyright
+# notice, this list of conditions and the following disclaimer in the
+# documentation and/or other materials provided with the distribution.
+#
+# THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' AND
+# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+# DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS BE LIABLE FOR
+# ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+# SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
+# CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+# OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+messages -> NetworkSocketStream {
+ SendData(IPC::DataReference data, uint64_t identifier)
+ Close()
+}
Modified: trunk/Source/WebKit2/UIProcess/API/C/WKContext.cpp (214412 => 214413)
--- trunk/Source/WebKit2/UIProcess/API/C/WKContext.cpp 2017-03-27 13:38:34 UTC (rev 214412)
+++ trunk/Source/WebKit2/UIProcess/API/C/WKContext.cpp 2017-03-27 15:43:34 UTC (rev 214413)
@@ -527,6 +527,11 @@
toImpl(context)->useTestingNetworkSession();
}
+void WKContextSetAllowsAnySSLCertificateForWebSocketTesting(WKContextRef context, bool allows)
+{
+ toImpl(context)->setAllowsAnySSLCertificateForWebSocket(allows);
+}
+
void WKContextClearCachedCredentials(WKContextRef context)
{
toImpl(context)->clearCachedCredentials();
@@ -573,6 +578,11 @@
toImpl(contextRef)->setFontWhitelist(toImpl(arrayRef));
}
+void WKContextTerminateNetworkProcess(WKContextRef context)
+{
+ toImpl(context)->terminateNetworkProcess();
+}
+
pid_t WKContextGetNetworkProcessIdentifier(WKContextRef contextRef)
{
return toImpl(contextRef)->networkProcessIdentifier();
Modified: trunk/Source/WebKit2/UIProcess/API/C/WKContextPrivate.h (214412 => 214413)
--- trunk/Source/WebKit2/UIProcess/API/C/WKContextPrivate.h 2017-03-27 13:38:34 UTC (rev 214412)
+++ trunk/Source/WebKit2/UIProcess/API/C/WKContextPrivate.h 2017-03-27 15:43:34 UTC (rev 214413)
@@ -81,6 +81,10 @@
// At some point it should be removed.
WK_EXPORT void WKContextSetUsesNetworkProcess(WKContextRef, bool);
+WK_EXPORT void WKContextTerminateNetworkProcess(WKContextRef);
+
+WK_EXPORT void WKContextSetAllowsAnySSLCertificateForWebSocketTesting(WKContextRef, bool);
+
// Test only. Should be called before any secondary processes are started.
WK_EXPORT void WKContextUseTestingNetworkSession(WKContextRef context);
Modified: trunk/Source/WebKit2/UIProcess/WebProcessPool.cpp (214412 => 214413)
--- trunk/Source/WebKit2/UIProcess/WebProcessPool.cpp 2017-03-27 13:38:34 UTC (rev 214412)
+++ trunk/Source/WebKit2/UIProcess/WebProcessPool.cpp 2017-03-27 15:43:34 UTC (rev 214413)
@@ -1226,6 +1226,18 @@
m_shouldUseTestingNetworkSession = true;
}
+template<typename T, typename U>
+void WebProcessPool::sendSyncToNetworkingProcess(T&& message, U&& reply)
+{
+ if (m_networkProcess && m_networkProcess->canSendMessage())
+ m_networkProcess->sendSync(std::forward<T>(message), std::forward<U>(reply), 0);
+}
+
+void WebProcessPool::setAllowsAnySSLCertificateForWebSocket(bool allows)
+{
+ sendSyncToNetworkingProcess(Messages::NetworkProcess::SetAllowsAnySSLCertificateForWebSocket(allows), Messages::NetworkProcess::SetAllowsAnySSLCertificateForWebSocket::Reply());
+}
+
void WebProcessPool::clearCachedCredentials()
{
sendToAllProcesses(Messages::WebProcess::ClearCachedCredentials());
@@ -1244,6 +1256,15 @@
#endif
}
+void WebProcessPool::terminateNetworkProcess()
+{
+ if (!m_networkProcess)
+ return;
+
+ m_networkProcess->terminate();
+ m_networkProcess = nullptr;
+}
+
void WebProcessPool::allowSpecificHTTPSCertificateForHost(const WebCertificateInfo* certificate, const String& host)
{
ensureNetworkProcess();
Modified: trunk/Source/WebKit2/UIProcess/WebProcessPool.h (214412 => 214413)
--- trunk/Source/WebKit2/UIProcess/WebProcessPool.h 2017-03-27 13:38:34 UTC (rev 214412)
+++ trunk/Source/WebKit2/UIProcess/WebProcessPool.h 2017-03-27 15:43:34 UTC (rev 214413)
@@ -161,6 +161,7 @@
// Sends the message to WebProcess or NetworkProcess as approporiate for current process model.
template<typename T> void sendToNetworkingProcess(T&& message);
+ template<typename T, typename U> void sendSyncToNetworkingProcess(T&& message, U&& reply);
template<typename T> void sendToNetworkingProcessRelaunchingIfNecessary(T&& message);
// Sends the message to WebProcess or DatabaseProcess as approporiate for current process model.
@@ -254,8 +255,11 @@
void useTestingNetworkSession();
bool isUsingTestingNetworkSession() const { return m_shouldUseTestingNetworkSession; }
+ void setAllowsAnySSLCertificateForWebSocket(bool);
+
void clearCachedCredentials();
void terminateDatabaseProcess();
+ void terminateNetworkProcess();
void reportWebContentCPUTime(int64_t cpuTime, uint64_t activityState);
Modified: trunk/Source/WebKit2/WebKit2.xcodeproj/project.pbxproj (214412 => 214413)
--- trunk/Source/WebKit2/WebKit2.xcodeproj/project.pbxproj 2017-03-27 13:38:34 UTC (rev 214412)
+++ trunk/Source/WebKit2/WebKit2.xcodeproj/project.pbxproj 2017-03-27 15:43:34 UTC (rev 214413)
@@ -1129,6 +1129,10 @@
53BA47D11DC2EF5E004DF4AD /* NetworkDataTaskBlob.h in Headers */ = {isa = PBXBuildFile; fileRef = 539EB5471DC2EE40009D48CF /* NetworkDataTaskBlob.h */; };
53DEA3661DDE423100E82648 /* json.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 53DEA3651DDE422E00E82648 /* json.hpp */; };
5C052F261C6D3BD30076E919 /* AuthenticationManagerCocoa.mm in Sources */ = {isa = PBXBuildFile; fileRef = 5C052F241C6D3AB60076E919 /* AuthenticationManagerCocoa.mm */; };
+ 5C0B17781E7C880E00E9123C /* NetworkSocketStreamMessageReceiver.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 5C0B17741E7C879C00E9123C /* NetworkSocketStreamMessageReceiver.cpp */; };
+ 5C0B17791E7C882100E9123C /* WebSocketStreamMessageReceiver.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 5C0B17761E7C879C00E9123C /* WebSocketStreamMessageReceiver.cpp */; };
+ 5C0B177C1E7C885400E9123C /* WebSocketStream.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 5C0B177A1E7C884F00E9123C /* WebSocketStream.cpp */; };
+ 5C0B17811E7C8C2600E9123C /* NetworkSocketStream.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 5C0B177D1E7C886700E9123C /* NetworkSocketStream.cpp */; };
5C1426EC1C23F80900D41183 /* NetworkProcessCreationParameters.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 5C1426E21C23F80500D41183 /* NetworkProcessCreationParameters.cpp */; };
5C1426ED1C23F80900D41183 /* NetworkProcessCreationParameters.h in Headers */ = {isa = PBXBuildFile; fileRef = 5C1426E31C23F80500D41183 /* NetworkProcessCreationParameters.h */; };
5C1426EE1C23F80900D41183 /* NetworkProcessSupplement.h in Headers */ = {isa = PBXBuildFile; fileRef = 5C1426E41C23F80500D41183 /* NetworkProcessSupplement.h */; };
@@ -3373,6 +3377,16 @@
53DEA3651DDE422E00E82648 /* json.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; name = json.hpp; path = NetworkProcess/capture/json.hpp; sourceTree = "<group>"; };
579D18B71CCFE34B00B1974C /* PhotosSPI.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = PhotosSPI.h; sourceTree = "<group>"; };
5C052F241C6D3AB60076E919 /* AuthenticationManagerCocoa.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; name = AuthenticationManagerCocoa.mm; path = Authentication/cocoa/AuthenticationManagerCocoa.mm; sourceTree = "<group>"; };
+ 5C0B17741E7C879C00E9123C /* NetworkSocketStreamMessageReceiver.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = NetworkSocketStreamMessageReceiver.cpp; sourceTree = "<group>"; };
+ 5C0B17751E7C879C00E9123C /* NetworkSocketStreamMessages.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = NetworkSocketStreamMessages.h; sourceTree = "<group>"; };
+ 5C0B17761E7C879C00E9123C /* WebSocketStreamMessageReceiver.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = WebSocketStreamMessageReceiver.cpp; sourceTree = "<group>"; };
+ 5C0B17771E7C879C00E9123C /* WebSocketStreamMessages.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WebSocketStreamMessages.h; sourceTree = "<group>"; };
+ 5C0B177A1E7C884F00E9123C /* WebSocketStream.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = WebSocketStream.cpp; path = Network/WebSocketStream.cpp; sourceTree = "<group>"; };
+ 5C0B177B1E7C884F00E9123C /* WebSocketStream.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = WebSocketStream.h; path = Network/WebSocketStream.h; sourceTree = "<group>"; };
+ 5C0B177D1E7C886700E9123C /* NetworkSocketStream.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = NetworkSocketStream.cpp; path = NetworkProcess/NetworkSocketStream.cpp; sourceTree = "<group>"; };
+ 5C0B177E1E7C886700E9123C /* NetworkSocketStream.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = NetworkSocketStream.h; path = NetworkProcess/NetworkSocketStream.h; sourceTree = "<group>"; };
+ 5C0B177F1E7C886700E9123C /* NetworkSocketStream.messages.in */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; name = NetworkSocketStream.messages.in; path = NetworkProcess/NetworkSocketStream.messages.in; sourceTree = "<group>"; };
+ 5C0B17801E7C888000E9123C /* WebSocketStream.messages.in */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; name = WebSocketStream.messages.in; path = Network/WebSocketStream.messages.in; sourceTree = "<group>"; };
5C1426E21C23F80500D41183 /* NetworkProcessCreationParameters.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = NetworkProcessCreationParameters.cpp; path = NetworkProcess/NetworkProcessCreationParameters.cpp; sourceTree = "<group>"; };
5C1426E31C23F80500D41183 /* NetworkProcessCreationParameters.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = NetworkProcessCreationParameters.h; path = NetworkProcess/NetworkProcessCreationParameters.h; sourceTree = "<group>"; };
5C1426E41C23F80500D41183 /* NetworkProcessSupplement.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = NetworkProcessSupplement.h; path = NetworkProcess/NetworkProcessSupplement.h; sourceTree = "<group>"; };
@@ -5822,6 +5836,9 @@
5105B0D2162F7A5E00E27709 /* Network */ = {
isa = PBXGroup;
children = (
+ 5C0B17801E7C888000E9123C /* WebSocketStream.messages.in */,
+ 5C0B177A1E7C884F00E9123C /* WebSocketStream.cpp */,
+ 5C0B177B1E7C884F00E9123C /* WebSocketStream.h */,
4130759E1DE85E650039EC69 /* webrtc */,
5105B0D4162F7A7A00E27709 /* NetworkProcessConnection.cpp */,
5105B0D5162F7A7A00E27709 /* NetworkProcessConnection.h */,
@@ -5840,6 +5857,9 @@
510CC7DA16138E0100D03ED3 /* NetworkProcess */ = {
isa = PBXGroup;
children = (
+ 5C0B177D1E7C886700E9123C /* NetworkSocketStream.cpp */,
+ 5C0B177E1E7C886700E9123C /* NetworkSocketStream.h */,
+ 5C0B177F1E7C886700E9123C /* NetworkSocketStream.messages.in */,
E489D2821A0A2BE80078C06A /* cache */,
539BD5B21DADB0BA00F2E4E1 /* capture */,
7EC4F0F818E4A922008056AF /* cocoa */,
@@ -7651,6 +7671,10 @@
C0CE729D1247E71D00BC0EC4 /* Derived Sources */ = {
isa = PBXGroup;
children = (
+ 5C0B17741E7C879C00E9123C /* NetworkSocketStreamMessageReceiver.cpp */,
+ 5C0B17751E7C879C00E9123C /* NetworkSocketStreamMessages.h */,
+ 5C0B17761E7C879C00E9123C /* WebSocketStreamMessageReceiver.cpp */,
+ 5C0B17771E7C879C00E9123C /* WebSocketStreamMessages.h */,
512F58A012A883AD00629530 /* AuthenticationManagerMessageReceiver.cpp */,
512F58A112A883AD00629530 /* AuthenticationManagerMessages.h */,
9955A6F01C79866400EB6A93 /* AutomationBackendDispatchers.cpp */,
@@ -10292,6 +10316,7 @@
5C7706741D1138380012700F /* WebSocketProvider.cpp in Sources */,
8360349F1ACB34D600626549 /* WebSQLiteDatabaseTracker.cpp in Sources */,
1A52C0F71A38CDC70016160A /* WebStorageNamespaceProvider.cpp in Sources */,
+ 5C0B177C1E7C885400E9123C /* WebSocketStream.cpp in Sources */,
BCC5715C115ADAEF001CCAF9 /* WebSystemInterface.mm in Sources */,
51032F18180F73BB00961BB7 /* WebToDatabaseProcessConnection.cpp in Sources */,
C0337DD8127A51B6008FF4F4 /* WebTouchEvent.cpp in Sources */,
@@ -10306,6 +10331,7 @@
7C065F2B1C8CD95F00C2D950 /* WebUserContentControllerDataTypes.cpp in Sources */,
1AAF08B719269E6D00B6390C /* WebUserContentControllerMessageReceiver.cpp in Sources */,
1AAF08A1192681D100B6390C /* WebUserContentControllerProxy.cpp in Sources */,
+ 5C0B17811E7C8C2600E9123C /* NetworkSocketStream.cpp in Sources */,
7C361D78192803BD0036A59D /* WebUserContentControllerProxyMessageReceiver.cpp in Sources */,
15739BBE1B42046600D258C1 /* WebUserMediaClient.cpp in Sources */,
83EE575B1DB7D61100C74C50 /* WebValidationMessageClient.cpp in Sources */,
@@ -10442,6 +10468,7 @@
7CD5EBB81746A15B000C1C45 /* WKObjCTypeWrapperRef.mm in Sources */,
374436881820E7240049579F /* WKObject.mm in Sources */,
1ACC50F11CBC381D003C7D03 /* WKOpenPanelParameters.mm in Sources */,
+ 5C0B17791E7C882100E9123C /* WebSocketStreamMessageReceiver.cpp in Sources */,
BC85806312B8505700EDEB2E /* WKOpenPanelParametersRef.cpp in Sources */,
BC85806212B8505700EDEB2E /* WKOpenPanelResultListener.cpp in Sources */,
BCD597D6112B56DC00EC8C23 /* WKPage.cpp in Sources */,
@@ -10498,6 +10525,7 @@
F6113E28126CE19B0057D0A7 /* WKUserContentURLPattern.cpp in Sources */,
07297FA21C186ADB003F0735 /* WKUserMediaPermissionCheck.cpp in Sources */,
4A3CC18E19B07B8500D14AEF /* WKUserMediaPermissionRequest.cpp in Sources */,
+ 5C0B17781E7C880E00E9123C /* NetworkSocketStreamMessageReceiver.cpp in Sources */,
1AAF089A19267EE500B6390C /* WKUserScript.mm in Sources */,
7C89D2A31A678875003A5FDE /* WKUserScriptRef.cpp in Sources */,
BC8699B6116AADAA002A925B /* WKView.mm in Sources */,
Modified: trunk/Source/WebKit2/WebProcess/Network/NetworkProcessConnection.cpp (214412 => 214413)
--- trunk/Source/WebKit2/WebProcess/Network/NetworkProcessConnection.cpp 2017-03-27 13:38:34 UTC (rev 214412)
+++ trunk/Source/WebKit2/WebProcess/Network/NetworkProcessConnection.cpp 2017-03-27 15:43:34 UTC (rev 214413)
@@ -36,6 +36,8 @@
#include "WebRTCResolverMessages.h"
#include "WebRTCSocketMessages.h"
#include "WebResourceLoaderMessages.h"
+#include "WebSocketStream.h"
+#include "WebSocketStreamMessages.h"
#include <WebCore/CachedResource.h>
#include <WebCore/MemoryCache.h>
#include <WebCore/SessionID.h>
@@ -62,6 +64,11 @@
webResourceLoader->didReceiveWebResourceLoaderMessage(connection, decoder);
return;
}
+ if (decoder.messageReceiverName() == Messages::WebSocketStream::messageReceiverName()) {
+ if (auto* stream = WebSocketStream::streamWithIdentifier(decoder.destinationID()))
+ stream->didReceiveMessage(connection, decoder);
+ return;
+ }
#if USE(LIBWEBRTC)
if (decoder.messageReceiverName() == Messages::WebRTCSocket::messageReceiverName()) {
Modified: trunk/Source/WebKit2/WebProcess/Network/WebSocketProvider.cpp (214412 => 214413)
--- trunk/Source/WebKit2/WebProcess/Network/WebSocketProvider.cpp 2017-03-27 13:38:34 UTC (rev 214412)
+++ trunk/Source/WebKit2/WebProcess/Network/WebSocketProvider.cpp 2017-03-27 15:43:34 UTC (rev 214413)
@@ -33,7 +33,7 @@
#if ENABLE(WEB_SOCKETS)
-#include <WebCore/SocketStreamHandleImpl.h>
+#include "WebSocketStream.h"
using namespace WebCore;
@@ -41,8 +41,7 @@
Ref<SocketStreamHandle> WebSocketProvider::createSocketStreamHandle(const URL& url, SocketStreamHandleClient& client, SessionID sessionID, const String& credentialPartition)
{
- // FIXME: This should return a proxy so we can do the actual network interactions in the NetworkProcess.
- return SocketStreamHandleImpl::create(url, client, sessionID, credentialPartition);
+ return WebSocketStream::create(url, client, sessionID, credentialPartition);
}
} // namespace WebKit
Added: trunk/Source/WebKit2/WebProcess/Network/WebSocketStream.cpp (0 => 214413)
--- trunk/Source/WebKit2/WebProcess/Network/WebSocketStream.cpp (rev 0)
+++ trunk/Source/WebKit2/WebProcess/Network/WebSocketStream.cpp 2017-03-27 15:43:34 UTC (rev 214413)
@@ -0,0 +1,158 @@
+/*
+ * Copyright (C) 2017 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "config.h"
+#include "WebSocketStream.h"
+
+#include "DataReference.h"
+#include "NetworkConnectionToWebProcessMessages.h"
+#include "NetworkProcessConnection.h"
+#include "NetworkSocketStreamMessages.h"
+#include "WebCoreArgumentCoders.h"
+#include "WebProcess.h"
+#include <WebCore/SessionID.h>
+#include <WebCore/SocketStreamError.h>
+#include <WebCore/SocketStreamHandleClient.h>
+#include <wtf/NeverDestroyed.h>
+
+using namespace WebCore;
+
+namespace WebKit {
+
+static uint64_t nextAvailableIdentifier = 1;
+
+static HashMap<uint64_t, WebSocketStream*>& globalWebSocketStreamMap()
+{
+ static NeverDestroyed<HashMap<uint64_t, WebSocketStream*>> globalMap;
+ return globalMap;
+}
+
+WebSocketStream* WebSocketStream::streamWithIdentifier(uint64_t identifier)
+{
+ return globalWebSocketStreamMap().get(identifier);
+}
+
+void WebSocketStream::networkProcessCrashed()
+{
+ for (auto& stream : globalWebSocketStreamMap().values()) {
+ for (auto& callback : stream->m_sendDataCallbacks.values())
+ callback(false);
+ stream->m_client.didFailSocketStream(*stream, SocketStreamError(0, { }, "Network process crashed."));
+ }
+
+ globalWebSocketStreamMap().clear();
+}
+
+Ref<WebSocketStream> WebSocketStream::create(const URL& url, SocketStreamHandleClient& client, SessionID sessionID, const String& credentialPartition)
+{
+ return adoptRef(*new WebSocketStream(url, client, sessionID, credentialPartition));
+}
+
+WebSocketStream::WebSocketStream(const WebCore::URL& url, WebCore::SocketStreamHandleClient& client, WebCore::SessionID sessionID, const String& cachePartition)
+ : SocketStreamHandle(url, client)
+ , m_identifier(nextAvailableIdentifier++)
+ , m_client(client)
+{
+ WebProcess::singleton().networkConnection().connection().send(Messages::NetworkConnectionToWebProcess::CreateSocketStream(url, sessionID, cachePartition, m_identifier), 0);
+
+ ASSERT(!globalWebSocketStreamMap().contains(m_identifier));
+ globalWebSocketStreamMap().set(m_identifier, this);
+}
+
+WebSocketStream::~WebSocketStream()
+{
+ ASSERT(globalWebSocketStreamMap().contains(m_identifier));
+ globalWebSocketStreamMap().remove(m_identifier);
+}
+
+IPC::Connection* WebSocketStream::messageSenderConnection()
+{
+ return &WebProcess::singleton().networkConnection().connection();
+}
+
+uint64_t WebSocketStream::messageSenderDestinationID()
+{
+ return m_identifier;
+}
+
+void WebSocketStream::platformSend(const char* data, size_t length, Function<void(bool)>&& completionHandler)
+{
+ static uint64_t nextDataIdentifier = 1;
+ uint64_t dataIdentifier = nextDataIdentifier++;
+ send(Messages::NetworkSocketStream::SendData(IPC::DataReference(reinterpret_cast<const uint8_t *>(data), length), dataIdentifier));
+ ASSERT(!m_sendDataCallbacks.contains(dataIdentifier));
+ m_sendDataCallbacks.set(dataIdentifier, WTFMove(completionHandler));
+}
+
+void WebSocketStream::didSendData(uint64_t identifier, bool success)
+{
+ ASSERT(m_sendDataCallbacks.contains(identifier));
+ m_sendDataCallbacks.take(identifier)(success);
+}
+
+void WebSocketStream::platformClose()
+{
+ send(Messages::NetworkSocketStream::Close());
+}
+
+size_t WebSocketStream::bufferedAmount()
+{
+ return m_bufferedAmount;
+}
+
+void WebSocketStream::didOpenSocketStream()
+{
+ m_state = Open;
+ m_client.didOpenSocketStream(*this);
+}
+
+void WebSocketStream::didCloseSocketStream()
+{
+ m_state = Closed;
+ m_client.didCloseSocketStream(*this);
+}
+
+void WebSocketStream::didReceiveSocketStreamData(const IPC::DataReference& data)
+{
+ m_client.didReceiveSocketStreamData(*this, reinterpret_cast<const char*>(data.data()), data.size());
+}
+
+void WebSocketStream::didFailToReceiveSocketStreamData()
+{
+ m_client.didFailToReceiveSocketStreamData(*this);
+}
+
+void WebSocketStream::didUpdateBufferedAmount(uint64_t newAmount)
+{
+ m_bufferedAmount = newAmount;
+ m_client.didUpdateBufferedAmount(*this, newAmount);
+}
+
+void WebSocketStream::didFailSocketStream(WebCore::SocketStreamError&& error)
+{
+ m_client.didFailSocketStream(*this, WTFMove(error));
+}
+
+} // namespace WebKit
Added: trunk/Source/WebKit2/WebProcess/Network/WebSocketStream.h (0 => 214413)
--- trunk/Source/WebKit2/WebProcess/Network/WebSocketStream.h (rev 0)
+++ trunk/Source/WebKit2/WebProcess/Network/WebSocketStream.h 2017-03-27 15:43:34 UTC (rev 214413)
@@ -0,0 +1,82 @@
+/*
+ * Copyright (C) 2017 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#pragma once
+
+#include "MessageReceiver.h"
+#include "MessageSender.h"
+#include <WebCore/SessionID.h>
+#include <WebCore/SocketStreamHandle.h>
+
+namespace IPC {
+class Connection;
+class Decoder;
+class DataReference;
+}
+
+namespace WebCore {
+class SocketStreamError;
+}
+
+namespace WebKit {
+
+class WebSocketStream : public IPC::MessageSender, public IPC::MessageReceiver, public WebCore::SocketStreamHandle {
+public:
+ static Ref<WebSocketStream> create(const WebCore::URL&, WebCore::SocketStreamHandleClient&, WebCore::SessionID, const String& credentialPartition);
+ static void networkProcessCrashed();
+ static WebSocketStream* streamWithIdentifier(uint64_t);
+
+ void didReceiveMessage(IPC::Connection&, IPC::Decoder&);
+
+ // SocketStreamHandle
+ void platformSend(const char*, size_t, Function<void(bool)>&&) final;
+ void platformClose() final;
+ size_t bufferedAmount() final;
+
+ // Message receivers
+ void didOpenSocketStream();
+ void didCloseSocketStream();
+ void didReceiveSocketStreamData(const IPC::DataReference&);
+ void didFailToReceiveSocketStreamData();
+ void didUpdateBufferedAmount(uint64_t);
+ void didFailSocketStream(WebCore::SocketStreamError&&);
+
+ void didSendData(uint64_t, bool);
+
+private:
+ // MessageSender
+ IPC::Connection* messageSenderConnection() final;
+ uint64_t messageSenderDestinationID() final;
+
+ WebSocketStream(const WebCore::URL&, WebCore::SocketStreamHandleClient&, WebCore::SessionID, const String& credentialPartition);
+ ~WebSocketStream();
+
+ size_t m_bufferedAmount { 0 };
+ uint64_t m_identifier { 0 };
+ WebCore::SocketStreamHandleClient& m_client;
+ HashMap<uint64_t, Function<void(bool)>> m_sendDataCallbacks;
+};
+
+} // namespace WebKit
Added: trunk/Source/WebKit2/WebProcess/Network/WebSocketStream.messages.in (0 => 214413)
--- trunk/Source/WebKit2/WebProcess/Network/WebSocketStream.messages.in (rev 0)
+++ trunk/Source/WebKit2/WebProcess/Network/WebSocketStream.messages.in 2017-03-27 15:43:34 UTC (rev 214413)
@@ -0,0 +1,32 @@
+# Copyright (C) 2017 Apple Inc. All rights reserved.
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions
+# are met:
+# 1. Redistributions of source code must retain the above copyright
+# notice, this list of conditions and the following disclaimer.
+# 2. Redistributions in binary form must reproduce the above copyright
+# notice, this list of conditions and the following disclaimer in the
+# documentation and/or other materials provided with the distribution.
+#
+# THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' AND
+# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+# DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS BE LIABLE FOR
+# ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+# SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
+# CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+# OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+messages -> WebSocketStream {
+ DidOpenSocketStream()
+ DidCloseSocketStream()
+ DidReceiveSocketStreamData(IPC::DataReference data)
+ DidFailToReceiveSocketStreamData()
+ DidUpdateBufferedAmount(uint64_t bufferedAmount)
+ DidFailSocketStream(WebCore::SocketStreamError error)
+
+ DidSendData(uint64_t identifier, bool success)
+}
Modified: trunk/Source/WebKit2/WebProcess/WebProcess.cpp (214412 => 214413)
--- trunk/Source/WebKit2/WebProcess/WebProcess.cpp 2017-03-27 13:38:34 UTC (rev 214412)
+++ trunk/Source/WebKit2/WebProcess/WebProcess.cpp 2017-03-27 15:43:34 UTC (rev 214413)
@@ -63,6 +63,7 @@
#include "WebProcessPoolMessages.h"
#include "WebProcessProxyMessages.h"
#include "WebResourceLoadStatisticsStoreMessages.h"
+#include "WebSocketStream.h"
#include "WebsiteData.h"
#include "WebsiteDataType.h"
#include <_javascript_Core/JSLock.h>
@@ -1125,6 +1126,7 @@
logDiagnosticMessageForNetworkProcessCrash();
m_webLoaderStrategy.networkProcessCrashed();
+ WebSocketStream::networkProcessCrashed();
}
WebLoaderStrategy& WebProcess::webLoaderStrategy()
Modified: trunk/Tools/ChangeLog (214412 => 214413)
--- trunk/Tools/ChangeLog 2017-03-27 13:38:34 UTC (rev 214412)
+++ trunk/Tools/ChangeLog 2017-03-27 15:43:34 UTC (rev 214413)
@@ -1,3 +1,37 @@
+2017-03-27 Alex Christensen <[email protected]>
+
+ Make WebSockets work in network process
+ https://bugs.webkit.org/show_bug.cgi?id=169930
+
+ Reviewed by Youenn Fablet.
+
+ * WebKitTestRunner/InjectedBundle/Bindings/TestRunner.idl:
+ Add terminateNetworkProcess for the new test
+ http/tests/websocket/tests/hybi/network-process-crash-error.html
+ * WebKitTestRunner/InjectedBundle/TestRunner.cpp:
+ (WTR::TestRunner::setAllowsAnySSLCertificate):
+ (WTR::TestRunner::terminateNetworkProcess):
+ * WebKitTestRunner/InjectedBundle/TestRunner.h:
+ * WebKitTestRunner/TestController.cpp:
+ (WTR::TestController::setAllowsAnySSLCertificate):
+ (WTR::TestController::terminateNetworkProcess):
+ * WebKitTestRunner/TestController.h:
+ * WebKitTestRunner/TestInvocation.cpp:
+ (WTR::TestInvocation::didReceiveMessageFromInjectedBundle):
+ (WTR::TestInvocation::didReceiveSynchronousMessageFromInjectedBundle):
+ * WebKitTestRunner/cocoa/TestControllerCocoa.mm:
+ (WTR::TestController::platformContext):
+ * WebKitTestRunner/gtk/TestControllerGtk.cpp:
+ (WTR::TestController::platformContext):
+ (WTR::TestController::platformLibraryPathForTesting):
+ Add some infrastructure for http/tests/websocket/tests/hybi/simple-wss.html
+ which calls testRunner.setAllowsAnySSLCertificate. It used to only be effective
+ for the WebProcess, but SocketStreamHandleImpl::createStreams is now in the NetworkProcess,
+ and we need its call to Settings::allowsAnySSLCertificate to be loosened for this test,
+ which tests that wss works, but our test certificate has an invalid certificate chain.
+ We want production software to not have the ability to have its security weakened, so this
+ is a test code path that is only implemented in WebKitTestRunner.
+
2017-03-25 Jonathan Bedard <[email protected]>
webkitpy: Use generalized device instead of platform specific one
Modified: trunk/Tools/WebKitTestRunner/InjectedBundle/Bindings/TestRunner.idl (214412 => 214413)
--- trunk/Tools/WebKitTestRunner/InjectedBundle/Bindings/TestRunner.idl 2017-03-27 13:38:34 UTC (rev 214412)
+++ trunk/Tools/WebKitTestRunner/InjectedBundle/Bindings/TestRunner.idl 2017-03-27 15:43:34 UTC (rev 214413)
@@ -270,4 +270,6 @@
void setOpenPanelFiles(object filesArray);
void setWebRTCLegacyAPIEnabled(boolean value);
+
+ void terminateNetworkProcess();
};
Modified: trunk/Tools/WebKitTestRunner/InjectedBundle/TestRunner.cpp (214412 => 214413)
--- trunk/Tools/WebKitTestRunner/InjectedBundle/TestRunner.cpp 2017-03-27 13:38:34 UTC (rev 214412)
+++ trunk/Tools/WebKitTestRunner/InjectedBundle/TestRunner.cpp 2017-03-27 15:43:34 UTC (rev 214413)
@@ -432,7 +432,12 @@
void TestRunner::setAllowsAnySSLCertificate(bool enabled)
{
- InjectedBundle::singleton().setAllowsAnySSLCertificate(enabled);
+ auto& injectedBundle = InjectedBundle::singleton();
+ injectedBundle.setAllowsAnySSLCertificate(enabled);
+
+ WKRetainPtr<WKStringRef> messageName(AdoptWK, WKStringCreateWithUTF8CString("SetAllowsAnySSLCertificate"));
+ WKRetainPtr<WKBooleanRef> messageBody(AdoptWK, WKBooleanCreate(enabled));
+ WKBundlePagePostSynchronousMessageForTesting(injectedBundle.page()->page(), messageName.get(), messageBody.get(), nullptr);
}
void TestRunner::setAllowUniversalAccessFromFileURLs(bool enabled)
@@ -1101,6 +1106,12 @@
WKBundlePagePostMessage(InjectedBundle::singleton().page()->page(), messageName.get(), messageBody.get());
}
+void TestRunner::terminateNetworkProcess()
+{
+ WKRetainPtr<WKStringRef> messageName(AdoptWK, WKStringCreateWithUTF8CString("TerminateNetworkProcess"));
+ WKBundlePagePostMessage(InjectedBundle::singleton().page()->page(), messageName.get(), nullptr);
+}
+
static unsigned nextUIScriptCallbackID()
{
static unsigned callbackID = FirstUIScriptCallbackID;
Modified: trunk/Tools/WebKitTestRunner/InjectedBundle/TestRunner.h (214412 => 214413)
--- trunk/Tools/WebKitTestRunner/InjectedBundle/TestRunner.h 2017-03-27 13:38:34 UTC (rev 214412)
+++ trunk/Tools/WebKitTestRunner/InjectedBundle/TestRunner.h 2017-03-27 15:43:34 UTC (rev 214413)
@@ -371,6 +371,8 @@
// Open panel
void setOpenPanelFiles(JSValueRef);
+ void terminateNetworkProcess();
+
private:
TestRunner();
Modified: trunk/Tools/WebKitTestRunner/TestController.cpp (214412 => 214413)
--- trunk/Tools/WebKitTestRunner/TestController.cpp 2017-03-27 13:38:34 UTC (rev 214412)
+++ trunk/Tools/WebKitTestRunner/TestController.cpp 2017-03-27 15:43:34 UTC (rev 214413)
@@ -888,6 +888,11 @@
#endif
}
+void TestController::setAllowsAnySSLCertificate(bool allows)
+{
+ WKContextSetAllowsAnySSLCertificateForWebSocketTesting(platformContext(), allows);
+}
+
static std::string testPath(WKURLRef url)
{
auto scheme = adoptWK(WKURLCopyScheme(url));
@@ -2302,7 +2307,12 @@
{
WKResourceLoadStatisticsManagerResetToConsistentState();
}
-
+
+void TestController::terminateNetworkProcess()
+{
+ WKContextTerminateNetworkProcess(platformContext());
+}
+
#if !PLATFORM(COCOA)
void TestController::platformWillRunTest(const TestInvocation&)
{
Modified: trunk/Tools/WebKitTestRunner/TestController.h (214412 => 214413)
--- trunk/Tools/WebKitTestRunner/TestController.h 2017-03-27 13:38:34 UTC (rev 214412)
+++ trunk/Tools/WebKitTestRunner/TestController.h 2017-03-27 15:43:34 UTC (rev 214413)
@@ -133,6 +133,7 @@
void setHandlesAuthenticationChallenges(bool value) { m_handlesAuthenticationChallenges = value; }
void setAuthenticationUsername(String username) { m_authenticationUsername = username; }
void setAuthenticationPassword(String password) { m_authenticationPassword = password; }
+ void setAllowsAnySSLCertificate(bool);
void setBlockAllPlugins(bool shouldBlock) { m_shouldBlockAllPlugins = shouldBlock; }
@@ -167,6 +168,8 @@
WKArrayRef openPanelFileURLs() const { return m_openPanelFileURLs.get(); }
void setOpenPanelFileURLs(WKArrayRef fileURLs) { m_openPanelFileURLs = fileURLs; }
+ void terminateNetworkProcess();
+
private:
WKRetainPtr<WKPageConfigurationRef> generatePageConfiguration(WKContextConfigurationRef);
WKRetainPtr<WKContextConfigurationRef> generateContextConfiguration() const;
@@ -192,6 +195,7 @@
void platformWillRunTest(const TestInvocation&);
void platformRunUntil(bool& done, double timeout);
void platformDidCommitLoadForFrame(WKPageRef, WKFrameRef);
+ WKContextRef platformContext();
WKPreferencesRef platformPreferences();
void initializeInjectedBundlePath();
void initializeTestPluginDirectory();
Modified: trunk/Tools/WebKitTestRunner/TestInvocation.cpp (214412 => 214413)
--- trunk/Tools/WebKitTestRunner/TestInvocation.cpp 2017-03-27 13:38:34 UTC (rev 214412)
+++ trunk/Tools/WebKitTestRunner/TestInvocation.cpp 2017-03-27 15:43:34 UTC (rev 214413)
@@ -719,6 +719,12 @@
return;
}
+ if (WKStringIsEqualToUTF8CString(messageName, "TerminateNetworkProcess")) {
+ ASSERT(!messageBody);
+ TestController::singleton().terminateNetworkProcess();
+ return;
+ }
+
if (WKStringIsEqualToUTF8CString(messageName, "RunUIProcessScript")) {
WKDictionaryRef messageBodyDictionary = static_cast<WKDictionaryRef>(messageBody);
WKRetainPtr<WKStringRef> scriptKey(AdoptWK, WKStringCreateWithUTF8CString("Script"));
@@ -798,7 +804,12 @@
WKCookieManagerSetCookieStoragePartitioningEnabled(WKContextGetCookieManager(TestController::singleton().context()), WKBooleanGetValue(accept));
return nullptr;
}
-
+
+ if (WKStringIsEqualToUTF8CString(messageName, "SetAllowsAnySSLCertificate")) {
+ TestController::singleton().setAllowsAnySSLCertificate(WKBooleanGetValue(static_cast<WKBooleanRef>(messageBody)));
+ return nullptr;
+ }
+
if (WKStringIsEqualToUTF8CString(messageName, "ImageCountInGeneralPasteboard")) {
unsigned count = TestController::singleton().imageCountInGeneralPasteboard();
WKRetainPtr<WKUInt64Ref> result(AdoptWK, WKUInt64Create(count));
Modified: trunk/Tools/WebKitTestRunner/cocoa/TestControllerCocoa.mm (214412 => 214413)
--- trunk/Tools/WebKitTestRunner/cocoa/TestControllerCocoa.mm 2017-03-27 13:38:34 UTC (rev 214412)
+++ trunk/Tools/WebKitTestRunner/cocoa/TestControllerCocoa.mm 2017-03-27 15:43:34 UTC (rev 214413)
@@ -74,6 +74,15 @@
#endif
}
+WKContextRef TestController::platformContext()
+{
+#if WK_API_ENABLED
+ return (WKContextRef)globalWebViewConfiguration.processPool;
+#else
+ return nullptr;
+#endif
+}
+
WKPreferencesRef TestController::platformPreferences()
{
#if WK_API_ENABLED
Modified: trunk/Tools/WebKitTestRunner/gtk/TestControllerGtk.cpp (214412 => 214413)
--- trunk/Tools/WebKitTestRunner/gtk/TestControllerGtk.cpp 2017-03-27 13:38:34 UTC (rev 214412)
+++ trunk/Tools/WebKitTestRunner/gtk/TestControllerGtk.cpp 2017-03-27 15:43:34 UTC (rev 214413)
@@ -133,9 +133,14 @@
// FIXME: Need to implement this to test showModalDialog.
}
+WKContextRef TestController::platformContext()
+{
+ return nullptr;
+}
+
const char* TestController::platformLibraryPathForTesting()
{
- return 0;
+ return nullptr;
}
void TestController::platformConfigureViewForTest(const TestInvocation&)