<!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>[214413] 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/214413">214413</a></dd>
<dt>Author</dt> <dd>achristensen@apple.com</dd>
<dt>Date</dt> <dd>2017-03-27 08:43:34 -0700 (Mon, 27 Mar 2017)</dd>
</dl>

<h3>Log Message</h3>
<pre>Make WebSockets work in network process
https://bugs.webkit.org/show_bug.cgi?id=169930

Reviewed by Youenn Fablet.

Source/WebCore:

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.

Source/WebKit2:

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):

Tools:

* 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.

LayoutTests:

* 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:</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkLayoutTestsChangeLog">trunk/LayoutTests/ChangeLog</a></li>
<li><a href="#trunkLayoutTestsplatformiossimulatorwk1TestExpectations">trunk/LayoutTests/platform/ios-simulator-wk1/TestExpectations</a></li>
<li><a href="#trunkLayoutTestsplatformmacwk1TestExpectations">trunk/LayoutTests/platform/mac-wk1/TestExpectations</a></li>
<li><a href="#trunkLayoutTestsplatformwinTestExpectations">trunk/LayoutTests/platform/win/TestExpectations</a></li>
<li><a href="#trunkSourceWebCoreChangeLog">trunk/Source/WebCore/ChangeLog</a></li>
<li><a href="#trunkSourceWebCoreModuleswebsocketsWebSocketChannelcpp">trunk/Source/WebCore/Modules/websockets/WebSocketChannel.cpp</a></li>
<li><a href="#trunkSourceWebCoreplatformnetworkcfSocketStreamHandleImplCFNetcpp">trunk/Source/WebCore/platform/network/cf/SocketStreamHandleImplCFNet.cpp</a></li>
<li><a href="#trunkSourceWebKit2CMakeListstxt">trunk/Source/WebKit2/CMakeLists.txt</a></li>
<li><a href="#trunkSourceWebKit2ChangeLog">trunk/Source/WebKit2/ChangeLog</a></li>
<li><a href="#trunkSourceWebKit2DerivedSourcesmake">trunk/Source/WebKit2/DerivedSources.make</a></li>
<li><a href="#trunkSourceWebKit2NetworkProcessNetworkConnectionToWebProcesscpp">trunk/Source/WebKit2/NetworkProcess/NetworkConnectionToWebProcess.cpp</a></li>
<li><a href="#trunkSourceWebKit2NetworkProcessNetworkConnectionToWebProcessh">trunk/Source/WebKit2/NetworkProcess/NetworkConnectionToWebProcess.h</a></li>
<li><a href="#trunkSourceWebKit2NetworkProcessNetworkConnectionToWebProcessmessagesin">trunk/Source/WebKit2/NetworkProcess/NetworkConnectionToWebProcess.messages.in</a></li>
<li><a href="#trunkSourceWebKit2NetworkProcessNetworkProcesscpp">trunk/Source/WebKit2/NetworkProcess/NetworkProcess.cpp</a></li>
<li><a href="#trunkSourceWebKit2NetworkProcessNetworkProcessh">trunk/Source/WebKit2/NetworkProcess/NetworkProcess.h</a></li>
<li><a href="#trunkSourceWebKit2NetworkProcessNetworkProcessmessagesin">trunk/Source/WebKit2/NetworkProcess/NetworkProcess.messages.in</a></li>
<li><a href="#trunkSourceWebKit2UIProcessAPICWKContextcpp">trunk/Source/WebKit2/UIProcess/API/C/WKContext.cpp</a></li>
<li><a href="#trunkSourceWebKit2UIProcessAPICWKContextPrivateh">trunk/Source/WebKit2/UIProcess/API/C/WKContextPrivate.h</a></li>
<li><a href="#trunkSourceWebKit2UIProcessWebProcessPoolcpp">trunk/Source/WebKit2/UIProcess/WebProcessPool.cpp</a></li>
<li><a href="#trunkSourceWebKit2UIProcessWebProcessPoolh">trunk/Source/WebKit2/UIProcess/WebProcessPool.h</a></li>
<li><a href="#trunkSourceWebKit2WebKit2xcodeprojprojectpbxproj">trunk/Source/WebKit2/WebKit2.xcodeproj/project.pbxproj</a></li>
<li><a href="#trunkSourceWebKit2WebProcessNetworkNetworkProcessConnectioncpp">trunk/Source/WebKit2/WebProcess/Network/NetworkProcessConnection.cpp</a></li>
<li><a href="#trunkSourceWebKit2WebProcessNetworkWebSocketProvidercpp">trunk/Source/WebKit2/WebProcess/Network/WebSocketProvider.cpp</a></li>
<li><a href="#trunkSourceWebKit2WebProcessWebProcesscpp">trunk/Source/WebKit2/WebProcess/WebProcess.cpp</a></li>
<li><a href="#trunkToolsChangeLog">trunk/Tools/ChangeLog</a></li>
<li><a href="#trunkToolsWebKitTestRunnerInjectedBundleBindingsTestRunneridl">trunk/Tools/WebKitTestRunner/InjectedBundle/Bindings/TestRunner.idl</a></li>
<li><a href="#trunkToolsWebKitTestRunnerInjectedBundleTestRunnercpp">trunk/Tools/WebKitTestRunner/InjectedBundle/TestRunner.cpp</a></li>
<li><a href="#trunkToolsWebKitTestRunnerInjectedBundleTestRunnerh">trunk/Tools/WebKitTestRunner/InjectedBundle/TestRunner.h</a></li>
<li><a href="#trunkToolsWebKitTestRunnerTestControllercpp">trunk/Tools/WebKitTestRunner/TestController.cpp</a></li>
<li><a href="#trunkToolsWebKitTestRunnerTestControllerh">trunk/Tools/WebKitTestRunner/TestController.h</a></li>
<li><a href="#trunkToolsWebKitTestRunnerTestInvocationcpp">trunk/Tools/WebKitTestRunner/TestInvocation.cpp</a></li>
<li><a href="#trunkToolsWebKitTestRunnercocoaTestControllerCocoamm">trunk/Tools/WebKitTestRunner/cocoa/TestControllerCocoa.mm</a></li>
<li><a href="#trunkToolsWebKitTestRunnergtkTestControllerGtkcpp">trunk/Tools/WebKitTestRunner/gtk/TestControllerGtk.cpp</a></li>
</ul>

<h3>Added Paths</h3>
<ul>
<li><a href="#trunkLayoutTestshttptestswebsockettestshybinetworkprocesscrasherrorexpectedtxt">trunk/LayoutTests/http/tests/websocket/tests/hybi/network-process-crash-error-expected.txt</a></li>
<li><a href="#trunkLayoutTestshttptestswebsockettestshybinetworkprocesscrasherrorhtml">trunk/LayoutTests/http/tests/websocket/tests/hybi/network-process-crash-error.html</a></li>
<li><a href="#trunkLayoutTestshttptestswebsockettestshybislowreply_wshpy">trunk/LayoutTests/http/tests/websocket/tests/hybi/slow-reply_wsh.py</a></li>
<li><a href="#trunkSourceWebKit2NetworkProcessNetworkSocketStreamcpp">trunk/Source/WebKit2/NetworkProcess/NetworkSocketStream.cpp</a></li>
<li><a href="#trunkSourceWebKit2NetworkProcessNetworkSocketStreamh">trunk/Source/WebKit2/NetworkProcess/NetworkSocketStream.h</a></li>
<li><a href="#trunkSourceWebKit2NetworkProcessNetworkSocketStreammessagesin">trunk/Source/WebKit2/NetworkProcess/NetworkSocketStream.messages.in</a></li>
<li><a href="#trunkSourceWebKit2WebProcessNetworkWebSocketStreamcpp">trunk/Source/WebKit2/WebProcess/Network/WebSocketStream.cpp</a></li>
<li><a href="#trunkSourceWebKit2WebProcessNetworkWebSocketStreamh">trunk/Source/WebKit2/WebProcess/Network/WebSocketStream.h</a></li>
<li><a href="#trunkSourceWebKit2WebProcessNetworkWebSocketStreammessagesin">trunk/Source/WebKit2/WebProcess/Network/WebSocketStream.messages.in</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkLayoutTestsChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/ChangeLog (214412 => 214413)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/ChangeLog        2017-03-27 13:38:34 UTC (rev 214412)
+++ trunk/LayoutTests/ChangeLog        2017-03-27 15:43:34 UTC (rev 214413)
</span><span class="lines">@@ -1,3 +1,19 @@
</span><ins>+2017-03-27  Alex Christensen  &lt;achristensen@webkit.org&gt;
+
+        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:
+
</ins><span class="cx"> 2017-03-27  Antoine Quint  &lt;graouts@apple.com&gt;
</span><span class="cx"> 
</span><span class="cx">         [Modern Media Controls] Improve media documents across macOS, iPhone and iPad
</span></span></pre></div>
<a id="trunkLayoutTestshttptestswebsockettestshybinetworkprocesscrasherrorexpectedtxt"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/http/tests/websocket/tests/hybi/network-process-crash-error-expected.txt (0 => 214413)</h4>
<pre class="diff"><span>
<span class="info">--- 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)
</span><span class="lines">@@ -0,0 +1,5 @@
</span><ins>+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]
+
</ins></span></pre></div>
<a id="trunkLayoutTestshttptestswebsockettestshybinetworkprocesscrasherrorhtml"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/http/tests/websocket/tests/hybi/network-process-crash-error.html (0 => 214413)</h4>
<pre class="diff"><span>
<span class="info">--- 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)
</span><span class="lines">@@ -0,0 +1,34 @@
</span><ins>+&lt;script&gt;
+function endTest() {
+    if (window.testRunner)
+        testRunner.notifyDone();
+}
+
+if (window.testRunner) {
+    testRunner.dumpAsText();
+    testRunner.waitUntilDone();
+}
+
+var ws = new WebSocket(&quot;ws://127.0.0.1:8880/websocket/tests/hybi/slow-reply&quot;);
+alert(&quot;Created a socket to '&quot; + ws.URL + &quot;'; readyState &quot; + ws.readyState + &quot;.&quot;);
+
+ws.onopen = function()
+{
+    if (window.testRunner &amp;&amp; window.testRunner.terminateNetworkProcess) {
+        alert(&quot;Terminating network process.&quot;);
+        testRunner.terminateNetworkProcess();
+    }
+};
+
+ws.onerror = function(e)
+{
+    alert(&quot;Received error:&quot; + e);
+    endTest();
+};
+
+ws.onclose = function(e)
+{
+    alert(&quot;Closed; readyState &quot; + ws.readyState + &quot;.&quot; + e);
+    endTest();
+};
+&lt;/script&gt;
</ins></span></pre></div>
<a id="trunkLayoutTestshttptestswebsockettestshybislowreply_wshpy"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/http/tests/websocket/tests/hybi/slow-reply_wsh.py (0 => 214413)</h4>
<pre class="diff"><span>
<span class="info">--- 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)
</span><span class="lines">@@ -0,0 +1,9 @@
</span><ins>+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.')
</ins><span class="cx">\ No newline at end of file
</span></span></pre></div>
<a id="trunkLayoutTestsplatformiossimulatorwk1TestExpectations"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/platform/ios-simulator-wk1/TestExpectations (214412 => 214413)</h4>
<pre class="diff"><span>
<span class="info">--- 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)
</span><span class="lines">@@ -1885,3 +1885,5 @@
</span><span class="cx"> # Hover test does not apply
</span><span class="cx"> fast/css/deferred-parsing/hover-test.html [ Skip ]
</span><span class="cx"> 
</span><ins>+# There is not NetworkProcess in WK1, so it can't crash.
+http/tests/websocket/tests/hybi/network-process-crash-error.html [ Skip ]
</ins></span></pre></div>
<a id="trunkLayoutTestsplatformmacwk1TestExpectations"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/platform/mac-wk1/TestExpectations (214412 => 214413)</h4>
<pre class="diff"><span>
<span class="info">--- 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)
</span><span class="lines">@@ -166,7 +166,7 @@
</span><span class="cx"> ### END OF (2) Failures without bug reports
</span><span class="cx"> ########################################
</span><span class="cx"> 
</span><del>-# This test is WebKit2-only
</del><ins>+# These tests are WebKit2-only
</ins><span class="cx"> http/tests/contentfiltering/load-substitute-data-from-appcache.html
</span><span class="cx"> fast/dom/Window/child-window-focus.html
</span><span class="cx"> 
</span><span class="lines">@@ -334,3 +334,6 @@
</span><span class="cx"> webkit.org/b/169117 media/modern-media-controls/macos-inline-media-controls/macos-inline-media-controls-audio-background.html [ Pass Timeout ]
</span><span class="cx"> webkit.org/b/167752 media/modern-media-controls/icon-button/icon-button-active-state.html [ Pass Timeout ]
</span><span class="cx"> webkit.org/b/167477 [ Debug ] media/modern-media-controls/play-pause-button/play-pause-button.html [ Pass Timeout ]
</span><ins>+
+# There is not NetworkProcess in WK1, so it can't crash.
+http/tests/websocket/tests/hybi/network-process-crash-error.html [ Skip ]
</ins></span></pre></div>
<a id="trunkLayoutTestsplatformwinTestExpectations"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/platform/win/TestExpectations (214412 => 214413)</h4>
<pre class="diff"><span>
<span class="info">--- 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)
</span><span class="lines">@@ -3802,3 +3802,6 @@
</span><span class="cx"> 
</span><span class="cx"> # webglcontextchanged event not supported
</span><span class="cx"> fast/canvas/webgl/webglcontextchangedevent.html [ Skip ]
</span><ins>+
+# There is not NetworkProcess in WK1, so it can't crash.
+http/tests/websocket/tests/hybi/network-process-crash-error.html [ Skip ]
</ins></span></pre></div>
<a id="trunkSourceWebCoreChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/ChangeLog (214412 => 214413)</h4>
<pre class="diff"><span>
<span class="info">--- 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)
</span><span class="lines">@@ -1,3 +1,25 @@
</span><ins>+2017-03-27  Alex Christensen  &lt;achristensen@webkit.org&gt;
+
+        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.
+
</ins><span class="cx"> 2017-03-27  Antoine Quint  &lt;graouts@apple.com&gt;
</span><span class="cx"> 
</span><span class="cx">         [Modern Media Controls] Improve media documents across macOS, iPhone and iPad
</span></span></pre></div>
<a id="trunkSourceWebCoreModuleswebsocketsWebSocketChannelcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/Modules/websockets/WebSocketChannel.cpp (214412 => 214413)</h4>
<pre class="diff"><span>
<span class="info">--- 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)
</span><span class="lines">@@ -238,10 +238,7 @@
</span><span class="cx">     m_client-&gt;didReceiveMessageError();
</span><span class="cx"> 
</span><span class="cx">     if (m_handle &amp;&amp; !m_closed)
</span><del>-        m_handle-&gt;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);
</del><ins>+        m_handle-&gt;disconnect(); // Will call didCloseSocketStream() but maybe not synchronously.
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> void WebSocketChannel::disconnect()
</span><span class="lines">@@ -366,6 +363,8 @@
</span><span class="cx">         m_document-&gt;addConsoleMessage(MessageSource::Network, MessageLevel::Error, message);
</span><span class="cx">     }
</span><span class="cx">     m_shouldDiscardReceivedData = true;
</span><ins>+    if (m_client)
+        m_client-&gt;didReceiveMessageError();
</ins><span class="cx">     handle.disconnect();
</span><span class="cx"> }
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformnetworkcfSocketStreamHandleImplCFNetcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/network/cf/SocketStreamHandleImplCFNet.cpp (214412 => 214413)</h4>
<pre class="diff"><span>
<span class="info">--- 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)
</span><span class="lines">@@ -655,6 +655,9 @@
</span><span class="cx"> 
</span><span class="cx"> std::optional&lt;size_t&gt; SocketStreamHandleImpl::platformSendInternal(const char* data, size_t length)
</span><span class="cx"> {
</span><ins>+    if (!m_writeStream)
+        return std::nullopt;
+
</ins><span class="cx">     if (!CFWriteStreamCanAcceptBytes(m_writeStream.get()))
</span><span class="cx">         return std::nullopt;
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkSourceWebKit2CMakeListstxt"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/CMakeLists.txt (214412 => 214413)</h4>
<pre class="diff"><span>
<span class="info">--- 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)
</span><span class="lines">@@ -119,6 +119,7 @@
</span><span class="cx">     NetworkProcess/NetworkResourceLoadParameters.cpp
</span><span class="cx">     NetworkProcess/NetworkResourceLoader.cpp
</span><span class="cx">     NetworkProcess/NetworkSession.cpp
</span><ins>+    NetworkProcess/NetworkSocketStream.cpp
</ins><span class="cx"> 
</span><span class="cx">     NetworkProcess/cache/NetworkCache.cpp
</span><span class="cx">     NetworkProcess/cache/NetworkCacheBlobStorage.cpp
</span><span class="lines">@@ -513,6 +514,7 @@
</span><span class="cx">     WebProcess/Network/WebLoaderStrategy.cpp
</span><span class="cx">     WebProcess/Network/WebResourceLoader.cpp
</span><span class="cx">     WebProcess/Network/WebSocketProvider.cpp
</span><ins>+    WebProcess/Network/WebSocketStream.cpp
</ins><span class="cx"> 
</span><span class="cx">     WebProcess/Notifications/NotificationPermissionRequestManager.cpp
</span><span class="cx">     WebProcess/Notifications/WebNotificationManager.cpp
</span><span class="lines">@@ -596,6 +598,7 @@
</span><span class="cx">     NetworkProcess/NetworkConnectionToWebProcess.messages.in
</span><span class="cx">     NetworkProcess/NetworkProcess.messages.in
</span><span class="cx">     NetworkProcess/NetworkResourceLoader.messages.in
</span><ins>+    NetworkProcess/NetworkSocketStream.messages.in
</ins><span class="cx"> 
</span><span class="cx">     NetworkProcess/webrtc/NetworkRTCMonitor.messages.in
</span><span class="cx">     NetworkProcess/webrtc/NetworkRTCProvider.messages.in
</span><span class="lines">@@ -663,6 +666,7 @@
</span><span class="cx"> 
</span><span class="cx">     WebProcess/Network/NetworkProcessConnection.messages.in
</span><span class="cx">     WebProcess/Network/WebResourceLoader.messages.in
</span><ins>+    WebProcess/Network/WebSocketStream.messages.in
</ins><span class="cx"> 
</span><span class="cx">     WebProcess/Notifications/WebNotificationManager.messages.in
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkSourceWebKit2ChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/ChangeLog (214412 => 214413)</h4>
<pre class="diff"><span>
<span class="info">--- 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)
</span><span class="lines">@@ -1,3 +1,84 @@
</span><ins>+2017-03-27  Alex Christensen  &lt;achristensen@webkit.org&gt;
+
+        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):
+
</ins><span class="cx"> 2017-03-27  Adrian Perez de Castro  &lt;aperez@igalia.com&gt;
</span><span class="cx"> 
</span><span class="cx">         [GTK] NetscapePluginX11::m_windowID is unused/unneeded
</span></span></pre></div>
<a id="trunkSourceWebKit2DerivedSourcesmake"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/DerivedSources.make (214412 => 214413)</h4>
<pre class="diff"><span>
<span class="info">--- 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)
</span><span class="lines">@@ -108,6 +108,7 @@
</span><span class="cx">     NetworkRTCProvider \
</span><span class="cx">     NetworkRTCSocket \
</span><span class="cx">     NetworkResourceLoader \
</span><ins>+    NetworkSocketStream \
</ins><span class="cx">     PluginControllerProxy \
</span><span class="cx">     PluginProcess \
</span><span class="cx">     PluginProcessConnection \
</span><span class="lines">@@ -164,6 +165,7 @@
</span><span class="cx">     WebRTCSocket \
</span><span class="cx">     WebResourceLoader \
</span><span class="cx">     WebResourceLoadStatisticsStore \
</span><ins>+    WebSocketStream \
</ins><span class="cx">     WebUserContentController \
</span><span class="cx">     WebUserContentControllerProxy \
</span><span class="cx">     WebVideoFullscreenManager \
</span></span></pre></div>
<a id="trunkSourceWebKit2NetworkProcessNetworkConnectionToWebProcesscpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/NetworkProcess/NetworkConnectionToWebProcess.cpp (214412 => 214413)</h4>
<pre class="diff"><span>
<span class="info">--- 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)
</span><span class="lines">@@ -40,6 +40,8 @@
</span><span class="cx"> #include &quot;NetworkResourceLoadParameters.h&quot;
</span><span class="cx"> #include &quot;NetworkResourceLoader.h&quot;
</span><span class="cx"> #include &quot;NetworkResourceLoaderMessages.h&quot;
</span><ins>+#include &quot;NetworkSocketStream.h&quot;
+#include &quot;NetworkSocketStreamMessages.h&quot;
</ins><span class="cx"> #include &quot;RemoteNetworkingContext.h&quot;
</span><span class="cx"> #include &quot;SessionTracker.h&quot;
</span><span class="cx"> #include &quot;WebCoreArgumentCoders.h&quot;
</span><span class="lines">@@ -98,6 +100,16 @@
</span><span class="cx">         return;
</span><span class="cx">     }
</span><span class="cx"> 
</span><ins>+    if (decoder.messageReceiverName() == Messages::NetworkSocketStream::messageReceiverName()) {
+        auto socketIterator = m_networkSocketStreams.find(decoder.destinationID());
+        if (socketIterator != m_networkSocketStreams.end()) {
+            socketIterator-&gt;value-&gt;didReceiveMessage(connection, decoder);
+            if (decoder.messageName() == Messages::NetworkSocketStream::Close::name())
+                m_networkSocketStreams.remove(socketIterator);
+        }
+        return;
+    }
+
</ins><span class="cx"> #if USE(LIBWEBRTC)
</span><span class="cx">     if (decoder.messageReceiverName() == Messages::NetworkRTCSocket::messageReceiverName()) {
</span><span class="cx">         rtcProvider().didReceiveNetworkRTCSocketMessage(connection, decoder);
</span><span class="lines">@@ -160,6 +172,18 @@
</span><span class="cx"> {
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+void NetworkConnectionToWebProcess::createSocketStream(URL&amp;&amp; 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);
+}
+
</ins><span class="cx"> void NetworkConnectionToWebProcess::scheduleResourceLoad(const NetworkResourceLoadParameters&amp; loadParameters)
</span><span class="cx"> {
</span><span class="cx">     auto loader = NetworkResourceLoader::create(loadParameters, *this);
</span></span></pre></div>
<a id="trunkSourceWebKit2NetworkProcessNetworkConnectionToWebProcessh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/NetworkProcess/NetworkConnectionToWebProcess.h (214412 => 214413)</h4>
<pre class="diff"><span>
<span class="info">--- 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)
</span><span class="lines">@@ -43,6 +43,7 @@
</span><span class="cx"> 
</span><span class="cx"> class NetworkConnectionToWebProcess;
</span><span class="cx"> class NetworkResourceLoader;
</span><ins>+class NetworkSocketStream;
</ins><span class="cx"> class SyncNetworkResourceLoader;
</span><span class="cx"> typedef uint64_t ResourceLoadIdentifier;
</span><span class="cx"> 
</span><span class="lines">@@ -104,6 +105,9 @@
</span><span class="cx"> 
</span><span class="cx">     void storeDerivedDataToCache(const WebKit::NetworkCache::DataKey&amp;, const IPC::DataReference&amp;);
</span><span class="cx"> 
</span><ins>+    void createSocketStream(WebCore::URL&amp;&amp;, WebCore::SessionID, String cachePartition, uint64_t);
+    void destroySocketStream(uint64_t);
+    
</ins><span class="cx">     void ensureLegacyPrivateBrowsingSession();
</span><span class="cx"> 
</span><span class="cx"> #if USE(LIBWEBRTC)
</span><span class="lines">@@ -112,6 +116,7 @@
</span><span class="cx">     
</span><span class="cx">     Ref&lt;IPC::Connection&gt; m_connection;
</span><span class="cx"> 
</span><ins>+    HashMap&lt;uint64_t, RefPtr&lt;NetworkSocketStream&gt;&gt; m_networkSocketStreams;
</ins><span class="cx">     HashMap&lt;ResourceLoadIdentifier, RefPtr&lt;NetworkResourceLoader&gt;&gt; m_networkResourceLoaders;
</span><span class="cx">     HashMap&lt;String, RefPtr&lt;WebCore::BlobDataFileReference&gt;&gt; m_blobDataFileReferences;
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkSourceWebKit2NetworkProcessNetworkConnectionToWebProcessmessagesin"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/NetworkProcess/NetworkConnectionToWebProcess.messages.in (214412 => 214413)</h4>
<pre class="diff"><span>
<span class="info">--- 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)
</span><span class="lines">@@ -51,5 +51,7 @@
</span><span class="cx"> 
</span><span class="cx">     StoreDerivedDataToCache(WebKit::NetworkCache::DataKey key, IPC::DataReference data)
</span><span class="cx"> 
</span><ins>+    CreateSocketStream(WebCore::URL url, WebCore::SessionID sessionID, String cachePartition, uint64_t identifier)
+
</ins><span class="cx">     EnsureLegacyPrivateBrowsingSession()
</span><span class="cx"> }
</span></span></pre></div>
<a id="trunkSourceWebKit2NetworkProcessNetworkProcesscpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/NetworkProcess/NetworkProcess.cpp (214412 => 214413)</h4>
<pre class="diff"><span>
<span class="info">--- 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)
</span><span class="lines">@@ -61,6 +61,7 @@
</span><span class="cx"> #include &lt;WebCore/SecurityOriginData.h&gt;
</span><span class="cx"> #include &lt;WebCore/SecurityOriginHash.h&gt;
</span><span class="cx"> #include &lt;WebCore/SessionID.h&gt;
</span><ins>+#include &lt;WebCore/Settings.h&gt;
</ins><span class="cx"> #include &lt;WebCore/URLParser.h&gt;
</span><span class="cx"> #include &lt;wtf/OptionSet.h&gt;
</span><span class="cx"> #include &lt;wtf/RunLoop.h&gt;
</span><span class="lines">@@ -581,6 +582,11 @@
</span><span class="cx">     parentProcessConnection()-&gt;send(Messages::WebProcessPool::DidGetStatistics(data, callbackID), 0);
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+void NetworkProcess::setAllowsAnySSLCertificateForWebSocket(bool allows)
+{
+    Settings::setAllowsAnySSLCertificate(allows);
+}
+
</ins><span class="cx"> void NetworkProcess::logDiagnosticMessage(uint64_t webPageID, const String&amp; message, const String&amp; description, ShouldSample shouldSample)
</span><span class="cx"> {
</span><span class="cx">     if (!DiagnosticLoggingClient::shouldLogAfterSampling(shouldSample))
</span></span></pre></div>
<a id="trunkSourceWebKit2NetworkProcessNetworkProcessh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/NetworkProcess/NetworkProcess.h (214412 => 214413)</h4>
<pre class="diff"><span>
<span class="info">--- 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)
</span><span class="lines">@@ -189,6 +189,7 @@
</span><span class="cx">     void setCanHandleHTTPSServerTrustEvaluation(bool);
</span><span class="cx">     void getNetworkProcessStatistics(uint64_t callbackID);
</span><span class="cx">     void clearCacheForAllOrigins(uint32_t cachesToClear);
</span><ins>+    void setAllowsAnySSLCertificateForWebSocket(bool);
</ins><span class="cx"> 
</span><span class="cx">     void didGrantSandboxExtensionsToDatabaseProcessForBlobs(uint64_t requestID);
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkSourceWebKit2NetworkProcessNetworkProcessmessagesin"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/NetworkProcess/NetworkProcess.messages.in (214412 => 214413)</h4>
<pre class="diff"><span>
<span class="info">--- 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)
</span><span class="lines">@@ -62,6 +62,7 @@
</span><span class="cx">     SetQOS(int latencyQOS, int throughputQOS)
</span><span class="cx">     SetCookieStoragePartitioningEnabled(bool enabled)
</span><span class="cx"> #endif
</span><ins>+    SetAllowsAnySSLCertificateForWebSocket(bool enabled) -&gt; ()
</ins><span class="cx"> 
</span><span class="cx">     AllowSpecificHTTPSCertificateForHost(WebCore::CertificateInfo certificate, String host)
</span><span class="cx">     SetCanHandleHTTPSServerTrustEvaluation(bool value)
</span></span></pre></div>
<a id="trunkSourceWebKit2NetworkProcessNetworkSocketStreamcpp"></a>
<div class="addfile"><h4>Added: trunk/Source/WebKit2/NetworkProcess/NetworkSocketStream.cpp (0 => 214413)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/NetworkProcess/NetworkSocketStream.cpp                                (rev 0)
+++ trunk/Source/WebKit2/NetworkProcess/NetworkSocketStream.cpp        2017-03-27 15:43:34 UTC (rev 214413)
</span><span class="lines">@@ -0,0 +1,108 @@
</span><ins>+/*
+ * 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 &quot;config.h&quot;
+#include &quot;NetworkSocketStream.h&quot;
+
+#include &quot;DataReference.h&quot;
+#include &quot;WebSocketStreamMessages.h&quot;
+#include &lt;WebCore/SocketStreamError.h&gt;
+#include &lt;WebCore/SocketStreamHandleImpl.h&gt;
+
+using namespace WebCore;
+
+namespace WebKit {
+
+Ref&lt;NetworkSocketStream&gt; NetworkSocketStream::create(WebCore::URL&amp;&amp; url, WebCore::SessionID sessionID, const String&amp; credentialPartition, uint64_t identifier, IPC::Connection&amp; connection)
+{
+    return adoptRef(*new NetworkSocketStream(WTFMove(url), sessionID, credentialPartition, identifier, connection));
+}
+
+NetworkSocketStream::NetworkSocketStream(URL&amp;&amp; url, SessionID sessionID, const String&amp; credentialPartition, uint64_t identifier, IPC::Connection&amp; connection)
+    : m_impl(SocketStreamHandleImpl::create(url, *this, sessionID, credentialPartition))
+    , m_identifier(identifier)
+    , m_connection(connection)
+{
+}
+
+void NetworkSocketStream::sendData(const IPC::DataReference&amp; data, uint64_t identifier)
+{
+    m_impl-&gt;platformSend(reinterpret_cast&lt;const char *&gt;(data.data()), data.size(), [this, protectedThis = makeRef(*this), identifier] (bool success) {
+        send(Messages::WebSocketStream::DidSendData(identifier, success));
+    });
+}
+
+void NetworkSocketStream::close()
+{
+    m_impl-&gt;platformClose();
+}
+
+void NetworkSocketStream::didOpenSocketStream(SocketStreamHandle&amp; handle)
+{
+    ASSERT_UNUSED(handle, &amp;handle == m_impl.ptr());
+    send(Messages::WebSocketStream::DidOpenSocketStream());
+}
+
+void NetworkSocketStream::didCloseSocketStream(SocketStreamHandle&amp; handle)
+{
+    ASSERT_UNUSED(handle, &amp;handle == m_impl.ptr());
+    send(Messages::WebSocketStream::DidCloseSocketStream());
+}
+
+void NetworkSocketStream::didReceiveSocketStreamData(SocketStreamHandle&amp; handle, const char* data, size_t length)
+{
+    ASSERT_UNUSED(handle, &amp;handle == m_impl.ptr());
+    send(Messages::WebSocketStream::DidReceiveSocketStreamData(IPC::DataReference(reinterpret_cast&lt;const uint8_t*&gt;(data), length)));
+}
+
+void NetworkSocketStream::didFailToReceiveSocketStreamData(WebCore::SocketStreamHandle&amp; handle)
+{
+    ASSERT_UNUSED(handle, &amp;handle == m_impl.ptr());
+    send(Messages::WebSocketStream::DidFailToReceiveSocketStreamData());
+}
+
+void NetworkSocketStream::didUpdateBufferedAmount(SocketStreamHandle&amp; handle, size_t amount)
+{
+    ASSERT_UNUSED(handle, &amp;handle == m_impl.ptr());
+    send(Messages::WebSocketStream::DidUpdateBufferedAmount(amount));
+}
+
+void NetworkSocketStream::didFailSocketStream(SocketStreamHandle&amp; handle, const SocketStreamError&amp; error)
+{
+    ASSERT_UNUSED(handle, &amp;handle == m_impl.ptr());
+    send(Messages::WebSocketStream::DidFailSocketStream(error));
+}
+
+IPC::Connection* NetworkSocketStream::messageSenderConnection()
+{
+    return &amp;m_connection;
+}
+
+uint64_t NetworkSocketStream::messageSenderDestinationID()
+{
+    return m_identifier;
+}
+
+} // namespace WebKit
</ins></span></pre></div>
<a id="trunkSourceWebKit2NetworkProcessNetworkSocketStreamh"></a>
<div class="addfile"><h4>Added: trunk/Source/WebKit2/NetworkProcess/NetworkSocketStream.h (0 => 214413)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/NetworkProcess/NetworkSocketStream.h                                (rev 0)
+++ trunk/Source/WebKit2/NetworkProcess/NetworkSocketStream.h        2017-03-27 15:43:34 UTC (rev 214413)
</span><span class="lines">@@ -0,0 +1,74 @@
</span><ins>+/*
+ * 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 &quot;MessageReceiver.h&quot;
+#include &quot;MessageSender.h&quot;
+#include &lt;WebCore/SessionID.h&gt;
+#include &lt;WebCore/SocketStreamHandleClient.h&gt;
+#include &lt;WebCore/SocketStreamHandleImpl.h&gt;
+
+namespace IPC {
+class Connection;
+class Decoder;
+class DataReference;
+}
+
+namespace WebCore {
+class SocketStreamHandleImpl;
+class URL;
+}
+
+namespace WebKit {
+
+class NetworkSocketStream : public RefCounted&lt;NetworkSocketStream&gt;, public IPC::MessageSender, public IPC::MessageReceiver, public WebCore::SocketStreamHandleClient {
+public:
+    static Ref&lt;NetworkSocketStream&gt; create(WebCore::URL&amp;&amp;, WebCore::SessionID, const String&amp; credentialPartition, uint64_t, IPC::Connection&amp;);
+    
+    void didReceiveMessage(IPC::Connection&amp;, IPC::Decoder&amp;);
+
+    void sendData(const IPC::DataReference&amp;, uint64_t);
+    void close();
+    
+    // SocketStreamHandleClient
+    void didOpenSocketStream(WebCore::SocketStreamHandle&amp;) final;
+    void didCloseSocketStream(WebCore::SocketStreamHandle&amp;) final;
+    void didReceiveSocketStreamData(WebCore::SocketStreamHandle&amp;, const char*, size_t) final;
+    void didFailToReceiveSocketStreamData(WebCore::SocketStreamHandle&amp;) final;
+    void didUpdateBufferedAmount(WebCore::SocketStreamHandle&amp;, size_t) final;
+    void didFailSocketStream(WebCore::SocketStreamHandle&amp;, const WebCore::SocketStreamError&amp;) final;
+
+private:
+    IPC::Connection* messageSenderConnection() final;
+    uint64_t messageSenderDestinationID() final;
+
+    NetworkSocketStream(WebCore::URL&amp;&amp;, WebCore::SessionID, const String&amp; credentialPartition, uint64_t, IPC::Connection&amp;);
+    Ref&lt;WebCore::SocketStreamHandleImpl&gt; m_impl;
+    uint64_t m_identifier;
+    IPC::Connection&amp; m_connection;
+};
+
+} // namespace WebKit
</ins></span></pre></div>
<a id="trunkSourceWebKit2NetworkProcessNetworkSocketStreammessagesin"></a>
<div class="addfile"><h4>Added: trunk/Source/WebKit2/NetworkProcess/NetworkSocketStream.messages.in (0 => 214413)</h4>
<pre class="diff"><span>
<span class="info">--- 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)
</span><span class="lines">@@ -0,0 +1,26 @@
</span><ins>+# 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 -&gt; NetworkSocketStream {
+    SendData(IPC::DataReference data, uint64_t identifier)
+    Close()
+}
</ins></span></pre></div>
<a id="trunkSourceWebKit2UIProcessAPICWKContextcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/UIProcess/API/C/WKContext.cpp (214412 => 214413)</h4>
<pre class="diff"><span>
<span class="info">--- 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)
</span><span class="lines">@@ -527,6 +527,11 @@
</span><span class="cx">     toImpl(context)-&gt;useTestingNetworkSession();
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+void WKContextSetAllowsAnySSLCertificateForWebSocketTesting(WKContextRef context, bool allows)
+{
+    toImpl(context)-&gt;setAllowsAnySSLCertificateForWebSocket(allows);
+}
+
</ins><span class="cx"> void WKContextClearCachedCredentials(WKContextRef context)
</span><span class="cx"> {
</span><span class="cx">     toImpl(context)-&gt;clearCachedCredentials();
</span><span class="lines">@@ -573,6 +578,11 @@
</span><span class="cx">     toImpl(contextRef)-&gt;setFontWhitelist(toImpl(arrayRef));
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+void WKContextTerminateNetworkProcess(WKContextRef context)
+{
+    toImpl(context)-&gt;terminateNetworkProcess();
+}
+
</ins><span class="cx"> pid_t WKContextGetNetworkProcessIdentifier(WKContextRef contextRef)
</span><span class="cx"> {
</span><span class="cx">     return toImpl(contextRef)-&gt;networkProcessIdentifier();
</span></span></pre></div>
<a id="trunkSourceWebKit2UIProcessAPICWKContextPrivateh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/UIProcess/API/C/WKContextPrivate.h (214412 => 214413)</h4>
<pre class="diff"><span>
<span class="info">--- 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)
</span><span class="lines">@@ -81,6 +81,10 @@
</span><span class="cx"> // At some point it should be removed.
</span><span class="cx"> WK_EXPORT void WKContextSetUsesNetworkProcess(WKContextRef, bool);
</span><span class="cx"> 
</span><ins>+WK_EXPORT void WKContextTerminateNetworkProcess(WKContextRef);
+
+WK_EXPORT void WKContextSetAllowsAnySSLCertificateForWebSocketTesting(WKContextRef, bool);
+    
</ins><span class="cx"> // Test only. Should be called before any secondary processes are started.
</span><span class="cx"> WK_EXPORT void WKContextUseTestingNetworkSession(WKContextRef context);
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkSourceWebKit2UIProcessWebProcessPoolcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/UIProcess/WebProcessPool.cpp (214412 => 214413)</h4>
<pre class="diff"><span>
<span class="info">--- 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)
</span><span class="lines">@@ -1226,6 +1226,18 @@
</span><span class="cx">     m_shouldUseTestingNetworkSession = true;
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+template&lt;typename T, typename U&gt;
+void WebProcessPool::sendSyncToNetworkingProcess(T&amp;&amp; message, U&amp;&amp; reply)
+{
+    if (m_networkProcess &amp;&amp; m_networkProcess-&gt;canSendMessage())
+        m_networkProcess-&gt;sendSync(std::forward&lt;T&gt;(message), std::forward&lt;U&gt;(reply), 0);
+}
+
+void WebProcessPool::setAllowsAnySSLCertificateForWebSocket(bool allows)
+{
+    sendSyncToNetworkingProcess(Messages::NetworkProcess::SetAllowsAnySSLCertificateForWebSocket(allows), Messages::NetworkProcess::SetAllowsAnySSLCertificateForWebSocket::Reply());
+}
+
</ins><span class="cx"> void WebProcessPool::clearCachedCredentials()
</span><span class="cx"> {
</span><span class="cx">     sendToAllProcesses(Messages::WebProcess::ClearCachedCredentials());
</span><span class="lines">@@ -1244,6 +1256,15 @@
</span><span class="cx"> #endif
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+void WebProcessPool::terminateNetworkProcess()
+{
+    if (!m_networkProcess)
+        return;
+    
+    m_networkProcess-&gt;terminate();
+    m_networkProcess = nullptr;
+}
+
</ins><span class="cx"> void WebProcessPool::allowSpecificHTTPSCertificateForHost(const WebCertificateInfo* certificate, const String&amp; host)
</span><span class="cx"> {
</span><span class="cx">     ensureNetworkProcess();
</span></span></pre></div>
<a id="trunkSourceWebKit2UIProcessWebProcessPoolh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/UIProcess/WebProcessPool.h (214412 => 214413)</h4>
<pre class="diff"><span>
<span class="info">--- 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)
</span><span class="lines">@@ -161,6 +161,7 @@
</span><span class="cx"> 
</span><span class="cx">     // Sends the message to WebProcess or NetworkProcess as approporiate for current process model.
</span><span class="cx">     template&lt;typename T&gt; void sendToNetworkingProcess(T&amp;&amp; message);
</span><ins>+    template&lt;typename T, typename U&gt; void sendSyncToNetworkingProcess(T&amp;&amp; message, U&amp;&amp; reply);
</ins><span class="cx">     template&lt;typename T&gt; void sendToNetworkingProcessRelaunchingIfNecessary(T&amp;&amp; message);
</span><span class="cx"> 
</span><span class="cx">     // Sends the message to WebProcess or DatabaseProcess as approporiate for current process model.
</span><span class="lines">@@ -254,8 +255,11 @@
</span><span class="cx">     void useTestingNetworkSession();
</span><span class="cx">     bool isUsingTestingNetworkSession() const { return m_shouldUseTestingNetworkSession; }
</span><span class="cx"> 
</span><ins>+    void setAllowsAnySSLCertificateForWebSocket(bool);
+
</ins><span class="cx">     void clearCachedCredentials();
</span><span class="cx">     void terminateDatabaseProcess();
</span><ins>+    void terminateNetworkProcess();
</ins><span class="cx"> 
</span><span class="cx">     void reportWebContentCPUTime(int64_t cpuTime, uint64_t activityState);
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkSourceWebKit2WebKit2xcodeprojprojectpbxproj"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/WebKit2.xcodeproj/project.pbxproj (214412 => 214413)</h4>
<pre class="diff"><span>
<span class="info">--- 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)
</span><span class="lines">@@ -1129,6 +1129,10 @@
</span><span class="cx">                 53BA47D11DC2EF5E004DF4AD /* NetworkDataTaskBlob.h in Headers */ = {isa = PBXBuildFile; fileRef = 539EB5471DC2EE40009D48CF /* NetworkDataTaskBlob.h */; };
</span><span class="cx">                 53DEA3661DDE423100E82648 /* json.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 53DEA3651DDE422E00E82648 /* json.hpp */; };
</span><span class="cx">                 5C052F261C6D3BD30076E919 /* AuthenticationManagerCocoa.mm in Sources */ = {isa = PBXBuildFile; fileRef = 5C052F241C6D3AB60076E919 /* AuthenticationManagerCocoa.mm */; };
</span><ins>+                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 */; };
</ins><span class="cx">                 5C1426EC1C23F80900D41183 /* NetworkProcessCreationParameters.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 5C1426E21C23F80500D41183 /* NetworkProcessCreationParameters.cpp */; };
</span><span class="cx">                 5C1426ED1C23F80900D41183 /* NetworkProcessCreationParameters.h in Headers */ = {isa = PBXBuildFile; fileRef = 5C1426E31C23F80500D41183 /* NetworkProcessCreationParameters.h */; };
</span><span class="cx">                 5C1426EE1C23F80900D41183 /* NetworkProcessSupplement.h in Headers */ = {isa = PBXBuildFile; fileRef = 5C1426E41C23F80500D41183 /* NetworkProcessSupplement.h */; };
</span><span class="lines">@@ -3373,6 +3377,16 @@
</span><span class="cx">                 53DEA3651DDE422E00E82648 /* json.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; name = json.hpp; path = NetworkProcess/capture/json.hpp; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><span class="cx">                 579D18B71CCFE34B00B1974C /* PhotosSPI.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = PhotosSPI.h; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><span class="cx">                 5C052F241C6D3AB60076E919 /* AuthenticationManagerCocoa.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; name = AuthenticationManagerCocoa.mm; path = Authentication/cocoa/AuthenticationManagerCocoa.mm; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><ins>+                5C0B17741E7C879C00E9123C /* NetworkSocketStreamMessageReceiver.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = NetworkSocketStreamMessageReceiver.cpp; sourceTree = &quot;&lt;group&gt;&quot;; };
+                5C0B17751E7C879C00E9123C /* NetworkSocketStreamMessages.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = NetworkSocketStreamMessages.h; sourceTree = &quot;&lt;group&gt;&quot;; };
+                5C0B17761E7C879C00E9123C /* WebSocketStreamMessageReceiver.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = WebSocketStreamMessageReceiver.cpp; sourceTree = &quot;&lt;group&gt;&quot;; };
+                5C0B17771E7C879C00E9123C /* WebSocketStreamMessages.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WebSocketStreamMessages.h; sourceTree = &quot;&lt;group&gt;&quot;; };
+                5C0B177A1E7C884F00E9123C /* WebSocketStream.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = WebSocketStream.cpp; path = Network/WebSocketStream.cpp; sourceTree = &quot;&lt;group&gt;&quot;; };
+                5C0B177B1E7C884F00E9123C /* WebSocketStream.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = WebSocketStream.h; path = Network/WebSocketStream.h; sourceTree = &quot;&lt;group&gt;&quot;; };
+                5C0B177D1E7C886700E9123C /* NetworkSocketStream.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = NetworkSocketStream.cpp; path = NetworkProcess/NetworkSocketStream.cpp; sourceTree = &quot;&lt;group&gt;&quot;; };
+                5C0B177E1E7C886700E9123C /* NetworkSocketStream.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = NetworkSocketStream.h; path = NetworkProcess/NetworkSocketStream.h; sourceTree = &quot;&lt;group&gt;&quot;; };
+                5C0B177F1E7C886700E9123C /* NetworkSocketStream.messages.in */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; name = NetworkSocketStream.messages.in; path = NetworkProcess/NetworkSocketStream.messages.in; sourceTree = &quot;&lt;group&gt;&quot;; };
+                5C0B17801E7C888000E9123C /* WebSocketStream.messages.in */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; name = WebSocketStream.messages.in; path = Network/WebSocketStream.messages.in; sourceTree = &quot;&lt;group&gt;&quot;; };
</ins><span class="cx">                 5C1426E21C23F80500D41183 /* NetworkProcessCreationParameters.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = NetworkProcessCreationParameters.cpp; path = NetworkProcess/NetworkProcessCreationParameters.cpp; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><span class="cx">                 5C1426E31C23F80500D41183 /* NetworkProcessCreationParameters.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = NetworkProcessCreationParameters.h; path = NetworkProcess/NetworkProcessCreationParameters.h; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><span class="cx">                 5C1426E41C23F80500D41183 /* NetworkProcessSupplement.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = NetworkProcessSupplement.h; path = NetworkProcess/NetworkProcessSupplement.h; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><span class="lines">@@ -5822,6 +5836,9 @@
</span><span class="cx">                 5105B0D2162F7A5E00E27709 /* Network */ = {
</span><span class="cx">                         isa = PBXGroup;
</span><span class="cx">                         children = (
</span><ins>+                                5C0B17801E7C888000E9123C /* WebSocketStream.messages.in */,
+                                5C0B177A1E7C884F00E9123C /* WebSocketStream.cpp */,
+                                5C0B177B1E7C884F00E9123C /* WebSocketStream.h */,
</ins><span class="cx">                                 4130759E1DE85E650039EC69 /* webrtc */,
</span><span class="cx">                                 5105B0D4162F7A7A00E27709 /* NetworkProcessConnection.cpp */,
</span><span class="cx">                                 5105B0D5162F7A7A00E27709 /* NetworkProcessConnection.h */,
</span><span class="lines">@@ -5840,6 +5857,9 @@
</span><span class="cx">                 510CC7DA16138E0100D03ED3 /* NetworkProcess */ = {
</span><span class="cx">                         isa = PBXGroup;
</span><span class="cx">                         children = (
</span><ins>+                                5C0B177D1E7C886700E9123C /* NetworkSocketStream.cpp */,
+                                5C0B177E1E7C886700E9123C /* NetworkSocketStream.h */,
+                                5C0B177F1E7C886700E9123C /* NetworkSocketStream.messages.in */,
</ins><span class="cx">                                 E489D2821A0A2BE80078C06A /* cache */,
</span><span class="cx">                                 539BD5B21DADB0BA00F2E4E1 /* capture */,
</span><span class="cx">                                 7EC4F0F818E4A922008056AF /* cocoa */,
</span><span class="lines">@@ -7651,6 +7671,10 @@
</span><span class="cx">                 C0CE729D1247E71D00BC0EC4 /* Derived Sources */ = {
</span><span class="cx">                         isa = PBXGroup;
</span><span class="cx">                         children = (
</span><ins>+                                5C0B17741E7C879C00E9123C /* NetworkSocketStreamMessageReceiver.cpp */,
+                                5C0B17751E7C879C00E9123C /* NetworkSocketStreamMessages.h */,
+                                5C0B17761E7C879C00E9123C /* WebSocketStreamMessageReceiver.cpp */,
+                                5C0B17771E7C879C00E9123C /* WebSocketStreamMessages.h */,
</ins><span class="cx">                                 512F58A012A883AD00629530 /* AuthenticationManagerMessageReceiver.cpp */,
</span><span class="cx">                                 512F58A112A883AD00629530 /* AuthenticationManagerMessages.h */,
</span><span class="cx">                                 9955A6F01C79866400EB6A93 /* AutomationBackendDispatchers.cpp */,
</span><span class="lines">@@ -10292,6 +10316,7 @@
</span><span class="cx">                                 5C7706741D1138380012700F /* WebSocketProvider.cpp in Sources */,
</span><span class="cx">                                 8360349F1ACB34D600626549 /* WebSQLiteDatabaseTracker.cpp in Sources */,
</span><span class="cx">                                 1A52C0F71A38CDC70016160A /* WebStorageNamespaceProvider.cpp in Sources */,
</span><ins>+                                5C0B177C1E7C885400E9123C /* WebSocketStream.cpp in Sources */,
</ins><span class="cx">                                 BCC5715C115ADAEF001CCAF9 /* WebSystemInterface.mm in Sources */,
</span><span class="cx">                                 51032F18180F73BB00961BB7 /* WebToDatabaseProcessConnection.cpp in Sources */,
</span><span class="cx">                                 C0337DD8127A51B6008FF4F4 /* WebTouchEvent.cpp in Sources */,
</span><span class="lines">@@ -10306,6 +10331,7 @@
</span><span class="cx">                                 7C065F2B1C8CD95F00C2D950 /* WebUserContentControllerDataTypes.cpp in Sources */,
</span><span class="cx">                                 1AAF08B719269E6D00B6390C /* WebUserContentControllerMessageReceiver.cpp in Sources */,
</span><span class="cx">                                 1AAF08A1192681D100B6390C /* WebUserContentControllerProxy.cpp in Sources */,
</span><ins>+                                5C0B17811E7C8C2600E9123C /* NetworkSocketStream.cpp in Sources */,
</ins><span class="cx">                                 7C361D78192803BD0036A59D /* WebUserContentControllerProxyMessageReceiver.cpp in Sources */,
</span><span class="cx">                                 15739BBE1B42046600D258C1 /* WebUserMediaClient.cpp in Sources */,
</span><span class="cx">                                 83EE575B1DB7D61100C74C50 /* WebValidationMessageClient.cpp in Sources */,
</span><span class="lines">@@ -10442,6 +10468,7 @@
</span><span class="cx">                                 7CD5EBB81746A15B000C1C45 /* WKObjCTypeWrapperRef.mm in Sources */,
</span><span class="cx">                                 374436881820E7240049579F /* WKObject.mm in Sources */,
</span><span class="cx">                                 1ACC50F11CBC381D003C7D03 /* WKOpenPanelParameters.mm in Sources */,
</span><ins>+                                5C0B17791E7C882100E9123C /* WebSocketStreamMessageReceiver.cpp in Sources */,
</ins><span class="cx">                                 BC85806312B8505700EDEB2E /* WKOpenPanelParametersRef.cpp in Sources */,
</span><span class="cx">                                 BC85806212B8505700EDEB2E /* WKOpenPanelResultListener.cpp in Sources */,
</span><span class="cx">                                 BCD597D6112B56DC00EC8C23 /* WKPage.cpp in Sources */,
</span><span class="lines">@@ -10498,6 +10525,7 @@
</span><span class="cx">                                 F6113E28126CE19B0057D0A7 /* WKUserContentURLPattern.cpp in Sources */,
</span><span class="cx">                                 07297FA21C186ADB003F0735 /* WKUserMediaPermissionCheck.cpp in Sources */,
</span><span class="cx">                                 4A3CC18E19B07B8500D14AEF /* WKUserMediaPermissionRequest.cpp in Sources */,
</span><ins>+                                5C0B17781E7C880E00E9123C /* NetworkSocketStreamMessageReceiver.cpp in Sources */,
</ins><span class="cx">                                 1AAF089A19267EE500B6390C /* WKUserScript.mm in Sources */,
</span><span class="cx">                                 7C89D2A31A678875003A5FDE /* WKUserScriptRef.cpp in Sources */,
</span><span class="cx">                                 BC8699B6116AADAA002A925B /* WKView.mm in Sources */,
</span></span></pre></div>
<a id="trunkSourceWebKit2WebProcessNetworkNetworkProcessConnectioncpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/WebProcess/Network/NetworkProcessConnection.cpp (214412 => 214413)</h4>
<pre class="diff"><span>
<span class="info">--- 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)
</span><span class="lines">@@ -36,6 +36,8 @@
</span><span class="cx"> #include &quot;WebRTCResolverMessages.h&quot;
</span><span class="cx"> #include &quot;WebRTCSocketMessages.h&quot;
</span><span class="cx"> #include &quot;WebResourceLoaderMessages.h&quot;
</span><ins>+#include &quot;WebSocketStream.h&quot;
+#include &quot;WebSocketStreamMessages.h&quot;
</ins><span class="cx"> #include &lt;WebCore/CachedResource.h&gt;
</span><span class="cx"> #include &lt;WebCore/MemoryCache.h&gt;
</span><span class="cx"> #include &lt;WebCore/SessionID.h&gt;
</span><span class="lines">@@ -62,6 +64,11 @@
</span><span class="cx">             webResourceLoader-&gt;didReceiveWebResourceLoaderMessage(connection, decoder);
</span><span class="cx">         return;
</span><span class="cx">     }
</span><ins>+    if (decoder.messageReceiverName() == Messages::WebSocketStream::messageReceiverName()) {
+        if (auto* stream = WebSocketStream::streamWithIdentifier(decoder.destinationID()))
+            stream-&gt;didReceiveMessage(connection, decoder);
+        return;
+    }
</ins><span class="cx"> 
</span><span class="cx"> #if USE(LIBWEBRTC)
</span><span class="cx">     if (decoder.messageReceiverName() == Messages::WebRTCSocket::messageReceiverName()) {
</span></span></pre></div>
<a id="trunkSourceWebKit2WebProcessNetworkWebSocketProvidercpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/WebProcess/Network/WebSocketProvider.cpp (214412 => 214413)</h4>
<pre class="diff"><span>
<span class="info">--- 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)
</span><span class="lines">@@ -33,7 +33,7 @@
</span><span class="cx"> 
</span><span class="cx"> #if ENABLE(WEB_SOCKETS)
</span><span class="cx"> 
</span><del>-#include &lt;WebCore/SocketStreamHandleImpl.h&gt;
</del><ins>+#include &quot;WebSocketStream.h&quot;
</ins><span class="cx"> 
</span><span class="cx"> using namespace WebCore;
</span><span class="cx"> 
</span><span class="lines">@@ -41,8 +41,7 @@
</span><span class="cx"> 
</span><span class="cx"> Ref&lt;SocketStreamHandle&gt; WebSocketProvider::createSocketStreamHandle(const URL&amp; url, SocketStreamHandleClient&amp; client, SessionID sessionID, const String&amp; credentialPartition)
</span><span class="cx"> {
</span><del>-    // FIXME: This should return a proxy so we can do the actual network interactions in the NetworkProcess.
-    return SocketStreamHandleImpl::create(url, client, sessionID, credentialPartition);
</del><ins>+    return WebSocketStream::create(url, client, sessionID, credentialPartition);
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> } // namespace WebKit
</span></span></pre></div>
<a id="trunkSourceWebKit2WebProcessNetworkWebSocketStreamcpp"></a>
<div class="addfile"><h4>Added: trunk/Source/WebKit2/WebProcess/Network/WebSocketStream.cpp (0 => 214413)</h4>
<pre class="diff"><span>
<span class="info">--- 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)
</span><span class="lines">@@ -0,0 +1,158 @@
</span><ins>+/*
+ * 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 &quot;config.h&quot;
+#include &quot;WebSocketStream.h&quot;
+
+#include &quot;DataReference.h&quot;
+#include &quot;NetworkConnectionToWebProcessMessages.h&quot;
+#include &quot;NetworkProcessConnection.h&quot;
+#include &quot;NetworkSocketStreamMessages.h&quot;
+#include &quot;WebCoreArgumentCoders.h&quot;
+#include &quot;WebProcess.h&quot;
+#include &lt;WebCore/SessionID.h&gt;
+#include &lt;WebCore/SocketStreamError.h&gt;
+#include &lt;WebCore/SocketStreamHandleClient.h&gt;
+#include &lt;wtf/NeverDestroyed.h&gt;
+
+using namespace WebCore;
+
+namespace WebKit {
+
+static uint64_t nextAvailableIdentifier = 1;
+
+static HashMap&lt;uint64_t, WebSocketStream*&gt;&amp; globalWebSocketStreamMap()
+{
+    static NeverDestroyed&lt;HashMap&lt;uint64_t, WebSocketStream*&gt;&gt; globalMap;
+    return globalMap;
+}
+
+WebSocketStream* WebSocketStream::streamWithIdentifier(uint64_t identifier)
+{
+    return globalWebSocketStreamMap().get(identifier);
+}
+
+void WebSocketStream::networkProcessCrashed()
+{
+    for (auto&amp; stream : globalWebSocketStreamMap().values()) {
+        for (auto&amp; callback : stream-&gt;m_sendDataCallbacks.values())
+            callback(false);
+        stream-&gt;m_client.didFailSocketStream(*stream, SocketStreamError(0, { }, &quot;Network process crashed.&quot;));
+    }
+
+    globalWebSocketStreamMap().clear();
+}
+
+Ref&lt;WebSocketStream&gt; WebSocketStream::create(const URL&amp; url, SocketStreamHandleClient&amp; client, SessionID sessionID, const String&amp; credentialPartition)
+{
+    return adoptRef(*new WebSocketStream(url, client, sessionID, credentialPartition));
+}
+
+WebSocketStream::WebSocketStream(const WebCore::URL&amp; url, WebCore::SocketStreamHandleClient&amp; client, WebCore::SessionID sessionID, const String&amp; 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 &amp;WebProcess::singleton().networkConnection().connection();
+}
+
+uint64_t WebSocketStream::messageSenderDestinationID()
+{
+    return m_identifier;
+}
+
+void WebSocketStream::platformSend(const char* data, size_t length, Function&lt;void(bool)&gt;&amp;&amp; completionHandler)
+{
+    static uint64_t nextDataIdentifier = 1;
+    uint64_t dataIdentifier = nextDataIdentifier++;
+    send(Messages::NetworkSocketStream::SendData(IPC::DataReference(reinterpret_cast&lt;const uint8_t *&gt;(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&amp; data)
+{
+    m_client.didReceiveSocketStreamData(*this, reinterpret_cast&lt;const char*&gt;(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&amp;&amp; error)
+{
+    m_client.didFailSocketStream(*this, WTFMove(error));
+}
+
+} // namespace WebKit
</ins></span></pre></div>
<a id="trunkSourceWebKit2WebProcessNetworkWebSocketStreamh"></a>
<div class="addfile"><h4>Added: trunk/Source/WebKit2/WebProcess/Network/WebSocketStream.h (0 => 214413)</h4>
<pre class="diff"><span>
<span class="info">--- 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)
</span><span class="lines">@@ -0,0 +1,82 @@
</span><ins>+/*
+ * 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 &quot;MessageReceiver.h&quot;
+#include &quot;MessageSender.h&quot;
+#include &lt;WebCore/SessionID.h&gt;
+#include &lt;WebCore/SocketStreamHandle.h&gt;
+
+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&lt;WebSocketStream&gt; create(const WebCore::URL&amp;, WebCore::SocketStreamHandleClient&amp;, WebCore::SessionID, const String&amp; credentialPartition);
+    static void networkProcessCrashed();
+    static WebSocketStream* streamWithIdentifier(uint64_t);
+    
+    void didReceiveMessage(IPC::Connection&amp;, IPC::Decoder&amp;);
+    
+    // SocketStreamHandle
+    void platformSend(const char*, size_t, Function&lt;void(bool)&gt;&amp;&amp;) final;
+    void platformClose() final;
+    size_t bufferedAmount() final;
+
+    // Message receivers
+    void didOpenSocketStream();
+    void didCloseSocketStream();
+    void didReceiveSocketStreamData(const IPC::DataReference&amp;);
+    void didFailToReceiveSocketStreamData();
+    void didUpdateBufferedAmount(uint64_t);
+    void didFailSocketStream(WebCore::SocketStreamError&amp;&amp;);
+
+    void didSendData(uint64_t, bool);
+    
+private:
+    // MessageSender
+    IPC::Connection* messageSenderConnection() final;
+    uint64_t messageSenderDestinationID() final;
+
+    WebSocketStream(const WebCore::URL&amp;, WebCore::SocketStreamHandleClient&amp;, WebCore::SessionID, const String&amp; credentialPartition);
+    ~WebSocketStream();
+
+    size_t m_bufferedAmount { 0 };
+    uint64_t m_identifier { 0 };
+    WebCore::SocketStreamHandleClient&amp; m_client;
+    HashMap&lt;uint64_t, Function&lt;void(bool)&gt;&gt; m_sendDataCallbacks;
+};
+
+} // namespace WebKit
</ins></span></pre></div>
<a id="trunkSourceWebKit2WebProcessNetworkWebSocketStreammessagesin"></a>
<div class="addfile"><h4>Added: trunk/Source/WebKit2/WebProcess/Network/WebSocketStream.messages.in (0 => 214413)</h4>
<pre class="diff"><span>
<span class="info">--- 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)
</span><span class="lines">@@ -0,0 +1,32 @@
</span><ins>+# 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 -&gt; WebSocketStream {
+    DidOpenSocketStream()
+    DidCloseSocketStream()
+    DidReceiveSocketStreamData(IPC::DataReference data)
+    DidFailToReceiveSocketStreamData()
+    DidUpdateBufferedAmount(uint64_t bufferedAmount)
+    DidFailSocketStream(WebCore::SocketStreamError error)
+
+    DidSendData(uint64_t identifier, bool success)
+}
</ins></span></pre></div>
<a id="trunkSourceWebKit2WebProcessWebProcesscpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/WebProcess/WebProcess.cpp (214412 => 214413)</h4>
<pre class="diff"><span>
<span class="info">--- 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)
</span><span class="lines">@@ -63,6 +63,7 @@
</span><span class="cx"> #include &quot;WebProcessPoolMessages.h&quot;
</span><span class="cx"> #include &quot;WebProcessProxyMessages.h&quot;
</span><span class="cx"> #include &quot;WebResourceLoadStatisticsStoreMessages.h&quot;
</span><ins>+#include &quot;WebSocketStream.h&quot;
</ins><span class="cx"> #include &quot;WebsiteData.h&quot;
</span><span class="cx"> #include &quot;WebsiteDataType.h&quot;
</span><span class="cx"> #include &lt;JavaScriptCore/JSLock.h&gt;
</span><span class="lines">@@ -1125,6 +1126,7 @@
</span><span class="cx">     logDiagnosticMessageForNetworkProcessCrash();
</span><span class="cx"> 
</span><span class="cx">     m_webLoaderStrategy.networkProcessCrashed();
</span><ins>+    WebSocketStream::networkProcessCrashed();
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> WebLoaderStrategy&amp; WebProcess::webLoaderStrategy()
</span></span></pre></div>
<a id="trunkToolsChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Tools/ChangeLog (214412 => 214413)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Tools/ChangeLog        2017-03-27 13:38:34 UTC (rev 214412)
+++ trunk/Tools/ChangeLog        2017-03-27 15:43:34 UTC (rev 214413)
</span><span class="lines">@@ -1,3 +1,37 @@
</span><ins>+2017-03-27  Alex Christensen  &lt;achristensen@webkit.org&gt;
+
+        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.
+
</ins><span class="cx"> 2017-03-25  Jonathan Bedard  &lt;jbedard@apple.com&gt;
</span><span class="cx"> 
</span><span class="cx">         webkitpy: Use generalized device instead of platform specific one
</span></span></pre></div>
<a id="trunkToolsWebKitTestRunnerInjectedBundleBindingsTestRunneridl"></a>
<div class="modfile"><h4>Modified: trunk/Tools/WebKitTestRunner/InjectedBundle/Bindings/TestRunner.idl (214412 => 214413)</h4>
<pre class="diff"><span>
<span class="info">--- 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)
</span><span class="lines">@@ -270,4 +270,6 @@
</span><span class="cx">     void setOpenPanelFiles(object filesArray);
</span><span class="cx"> 
</span><span class="cx">     void setWebRTCLegacyAPIEnabled(boolean value);
</span><ins>+
+    void terminateNetworkProcess();
</ins><span class="cx"> };
</span></span></pre></div>
<a id="trunkToolsWebKitTestRunnerInjectedBundleTestRunnercpp"></a>
<div class="modfile"><h4>Modified: trunk/Tools/WebKitTestRunner/InjectedBundle/TestRunner.cpp (214412 => 214413)</h4>
<pre class="diff"><span>
<span class="info">--- 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)
</span><span class="lines">@@ -432,7 +432,12 @@
</span><span class="cx"> 
</span><span class="cx"> void TestRunner::setAllowsAnySSLCertificate(bool enabled)
</span><span class="cx"> {
</span><del>-    InjectedBundle::singleton().setAllowsAnySSLCertificate(enabled);
</del><ins>+    auto&amp; injectedBundle = InjectedBundle::singleton();
+    injectedBundle.setAllowsAnySSLCertificate(enabled);
+
+    WKRetainPtr&lt;WKStringRef&gt; messageName(AdoptWK, WKStringCreateWithUTF8CString(&quot;SetAllowsAnySSLCertificate&quot;));
+    WKRetainPtr&lt;WKBooleanRef&gt; messageBody(AdoptWK, WKBooleanCreate(enabled));
+    WKBundlePagePostSynchronousMessageForTesting(injectedBundle.page()-&gt;page(), messageName.get(), messageBody.get(), nullptr);
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> void TestRunner::setAllowUniversalAccessFromFileURLs(bool enabled)
</span><span class="lines">@@ -1101,6 +1106,12 @@
</span><span class="cx">     WKBundlePagePostMessage(InjectedBundle::singleton().page()-&gt;page(), messageName.get(), messageBody.get());
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+void TestRunner::terminateNetworkProcess()
+{
+    WKRetainPtr&lt;WKStringRef&gt; messageName(AdoptWK, WKStringCreateWithUTF8CString(&quot;TerminateNetworkProcess&quot;));
+    WKBundlePagePostMessage(InjectedBundle::singleton().page()-&gt;page(), messageName.get(), nullptr);
+}
+
</ins><span class="cx"> static unsigned nextUIScriptCallbackID()
</span><span class="cx"> {
</span><span class="cx">     static unsigned callbackID = FirstUIScriptCallbackID;
</span></span></pre></div>
<a id="trunkToolsWebKitTestRunnerInjectedBundleTestRunnerh"></a>
<div class="modfile"><h4>Modified: trunk/Tools/WebKitTestRunner/InjectedBundle/TestRunner.h (214412 => 214413)</h4>
<pre class="diff"><span>
<span class="info">--- 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)
</span><span class="lines">@@ -371,6 +371,8 @@
</span><span class="cx">     // Open panel
</span><span class="cx">     void setOpenPanelFiles(JSValueRef);
</span><span class="cx"> 
</span><ins>+    void terminateNetworkProcess();
+
</ins><span class="cx"> private:
</span><span class="cx">     TestRunner();
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkToolsWebKitTestRunnerTestControllercpp"></a>
<div class="modfile"><h4>Modified: trunk/Tools/WebKitTestRunner/TestController.cpp (214412 => 214413)</h4>
<pre class="diff"><span>
<span class="info">--- 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)
</span><span class="lines">@@ -888,6 +888,11 @@
</span><span class="cx"> #endif
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+void TestController::setAllowsAnySSLCertificate(bool allows)
+{
+    WKContextSetAllowsAnySSLCertificateForWebSocketTesting(platformContext(), allows);
+}
+
</ins><span class="cx"> static std::string testPath(WKURLRef url)
</span><span class="cx"> {
</span><span class="cx">     auto scheme = adoptWK(WKURLCopyScheme(url));
</span><span class="lines">@@ -2302,7 +2307,12 @@
</span><span class="cx"> {
</span><span class="cx">     WKResourceLoadStatisticsManagerResetToConsistentState();
</span><span class="cx"> }
</span><del>-    
</del><ins>+
+void TestController::terminateNetworkProcess()
+{
+    WKContextTerminateNetworkProcess(platformContext());
+}
+
</ins><span class="cx"> #if !PLATFORM(COCOA)
</span><span class="cx"> void TestController::platformWillRunTest(const TestInvocation&amp;)
</span><span class="cx"> {
</span></span></pre></div>
<a id="trunkToolsWebKitTestRunnerTestControllerh"></a>
<div class="modfile"><h4>Modified: trunk/Tools/WebKitTestRunner/TestController.h (214412 => 214413)</h4>
<pre class="diff"><span>
<span class="info">--- 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)
</span><span class="lines">@@ -133,6 +133,7 @@
</span><span class="cx">     void setHandlesAuthenticationChallenges(bool value) { m_handlesAuthenticationChallenges = value; }
</span><span class="cx">     void setAuthenticationUsername(String username) { m_authenticationUsername = username; }
</span><span class="cx">     void setAuthenticationPassword(String password) { m_authenticationPassword = password; }
</span><ins>+    void setAllowsAnySSLCertificate(bool);
</ins><span class="cx"> 
</span><span class="cx">     void setBlockAllPlugins(bool shouldBlock) { m_shouldBlockAllPlugins = shouldBlock; }
</span><span class="cx"> 
</span><span class="lines">@@ -167,6 +168,8 @@
</span><span class="cx">     WKArrayRef openPanelFileURLs() const { return m_openPanelFileURLs.get(); }
</span><span class="cx">     void setOpenPanelFileURLs(WKArrayRef fileURLs) { m_openPanelFileURLs = fileURLs; }
</span><span class="cx"> 
</span><ins>+    void terminateNetworkProcess();
+    
</ins><span class="cx"> private:
</span><span class="cx">     WKRetainPtr&lt;WKPageConfigurationRef&gt; generatePageConfiguration(WKContextConfigurationRef);
</span><span class="cx">     WKRetainPtr&lt;WKContextConfigurationRef&gt; generateContextConfiguration() const;
</span><span class="lines">@@ -192,6 +195,7 @@
</span><span class="cx">     void platformWillRunTest(const TestInvocation&amp;);
</span><span class="cx">     void platformRunUntil(bool&amp; done, double timeout);
</span><span class="cx">     void platformDidCommitLoadForFrame(WKPageRef, WKFrameRef);
</span><ins>+    WKContextRef platformContext();
</ins><span class="cx">     WKPreferencesRef platformPreferences();
</span><span class="cx">     void initializeInjectedBundlePath();
</span><span class="cx">     void initializeTestPluginDirectory();
</span></span></pre></div>
<a id="trunkToolsWebKitTestRunnerTestInvocationcpp"></a>
<div class="modfile"><h4>Modified: trunk/Tools/WebKitTestRunner/TestInvocation.cpp (214412 => 214413)</h4>
<pre class="diff"><span>
<span class="info">--- 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)
</span><span class="lines">@@ -719,6 +719,12 @@
</span><span class="cx">         return;
</span><span class="cx">     }
</span><span class="cx"> 
</span><ins>+    if (WKStringIsEqualToUTF8CString(messageName, &quot;TerminateNetworkProcess&quot;)) {
+        ASSERT(!messageBody);
+        TestController::singleton().terminateNetworkProcess();
+        return;
+    }
+
</ins><span class="cx">     if (WKStringIsEqualToUTF8CString(messageName, &quot;RunUIProcessScript&quot;)) {
</span><span class="cx">         WKDictionaryRef messageBodyDictionary = static_cast&lt;WKDictionaryRef&gt;(messageBody);
</span><span class="cx">         WKRetainPtr&lt;WKStringRef&gt; scriptKey(AdoptWK, WKStringCreateWithUTF8CString(&quot;Script&quot;));
</span><span class="lines">@@ -798,7 +804,12 @@
</span><span class="cx">         WKCookieManagerSetCookieStoragePartitioningEnabled(WKContextGetCookieManager(TestController::singleton().context()), WKBooleanGetValue(accept));
</span><span class="cx">         return nullptr;
</span><span class="cx">     }
</span><del>-    
</del><ins>+
+    if (WKStringIsEqualToUTF8CString(messageName, &quot;SetAllowsAnySSLCertificate&quot;)) {
+        TestController::singleton().setAllowsAnySSLCertificate(WKBooleanGetValue(static_cast&lt;WKBooleanRef&gt;(messageBody)));
+        return nullptr;
+    }
+
</ins><span class="cx">     if (WKStringIsEqualToUTF8CString(messageName, &quot;ImageCountInGeneralPasteboard&quot;)) {
</span><span class="cx">         unsigned count = TestController::singleton().imageCountInGeneralPasteboard();
</span><span class="cx">         WKRetainPtr&lt;WKUInt64Ref&gt; result(AdoptWK, WKUInt64Create(count));
</span></span></pre></div>
<a id="trunkToolsWebKitTestRunnercocoaTestControllerCocoamm"></a>
<div class="modfile"><h4>Modified: trunk/Tools/WebKitTestRunner/cocoa/TestControllerCocoa.mm (214412 => 214413)</h4>
<pre class="diff"><span>
<span class="info">--- 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)
</span><span class="lines">@@ -74,6 +74,15 @@
</span><span class="cx"> #endif
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+WKContextRef TestController::platformContext()
+{
+#if WK_API_ENABLED
+    return (WKContextRef)globalWebViewConfiguration.processPool;
+#else
+    return nullptr;
+#endif
+}
+
</ins><span class="cx"> WKPreferencesRef TestController::platformPreferences()
</span><span class="cx"> {
</span><span class="cx"> #if WK_API_ENABLED
</span></span></pre></div>
<a id="trunkToolsWebKitTestRunnergtkTestControllerGtkcpp"></a>
<div class="modfile"><h4>Modified: trunk/Tools/WebKitTestRunner/gtk/TestControllerGtk.cpp (214412 => 214413)</h4>
<pre class="diff"><span>
<span class="info">--- 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)
</span><span class="lines">@@ -133,9 +133,14 @@
</span><span class="cx">     // FIXME: Need to implement this to test showModalDialog.
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+WKContextRef TestController::platformContext()
+{
+    return nullptr;
+}
+
</ins><span class="cx"> const char* TestController::platformLibraryPathForTesting()
</span><span class="cx"> {
</span><del>-    return 0;
</del><ins>+    return nullptr;
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> void TestController::platformConfigureViewForTest(const TestInvocation&amp;)
</span></span></pre>
</div>
</div>

</body>
</html>