WebKit Bugzilla
Attachment 371789 Details for
Bug 198568
: Use NSURLSession for WebSocket
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
New Account
|
Log In
Remember
[x]
|
Forgot Password
Login:
[x]
[patch]
Patch
bug-198568-20190610161131.patch (text/plain), 120.58 KB, created by
youenn fablet
on 2019-06-10 16:11:36 PDT
(
hide
)
Description:
Patch
Filename:
MIME Type:
Creator:
youenn fablet
Created:
2019-06-10 16:11:36 PDT
Size:
120.58 KB
patch
obsolete
>Subversion Revision: 246050 >diff --git a/Source/WTF/ChangeLog b/Source/WTF/ChangeLog >index 7147b2acbd991af9ba7ef96a064abdf3c1eb6181..f4fc99918f3a15de61d98a0bc535088278fef06f 100644 >--- a/Source/WTF/ChangeLog >+++ b/Source/WTF/ChangeLog >@@ -1,3 +1,13 @@ >+2019-06-05 Youenn Fablet <youenn@apple.com> >+ >+ Use NSURLSession for WebSocket >+ https://bugs.webkit.org/show_bug.cgi?id=198568 >+ >+ Reviewed by NOBODY (OOPS!). >+ >+ * wtf/Platform.h: >+ Introduce compile flag for WebSocket NSURLSession >+ > 2019-06-03 Commit Queue <commit-queue@webkit.org> > > Unreviewed, rolling out r246022. >diff --git a/Source/WebCore/ChangeLog b/Source/WebCore/ChangeLog >index 039281ee2533fefddcd29123a7c63890a90868fd..c7d25843d4d7a71b487cf363c3d61e5c1319bfc2 100644 >--- a/Source/WebCore/ChangeLog >+++ b/Source/WebCore/ChangeLog >@@ -1,3 +1,28 @@ >+2019-06-05 Youenn Fablet <youenn@apple.com> >+ >+ Use NSURLSession for WebSocket >+ https://bugs.webkit.org/show_bug.cgi?id=198568 >+ >+ Reviewed by NOBODY (OOPS!). >+ >+ Add a runtime flag to either choose the new WebSocket code path or the previously existing one. >+ The switch is done at WebSocket channel API level which offers the necessary high level API to abstract the two code paths. >+ By default, we continue using the current WebSocket implementation. >+ Covered by manual testing on current WebSocket tests. >+ >+ * Modules/websockets/ThreadableWebSocketChannel.cpp: >+ (WebCore::ThreadableWebSocketChannel::create): >+ * Modules/websockets/WebSocketChannel.cpp: >+ (WebCore::WebSocketChannel::document): >+ * Modules/websockets/WebSocketChannel.h: >+ * WebCore.xcodeproj/project.pbxproj: >+ * page/RuntimeEnabledFeatures.h: >+ (WebCore::RuntimeEnabledFeatures::isNSURLSessionWebSocketEnabled const): >+ (WebCore::RuntimeEnabledFeatures::setIsNSURLSessionWebSocketEnabled): >+ * page/SocketProvider.cpp: >+ (WebCore::SocketProvider::createWebSocketChannel): >+ * page/SocketProvider.h: >+ > 2019-06-03 Youenn Fablet <youenn@apple.com> > > Allow resizing of camera video feeds to very small resolutions >diff --git a/Source/WebKit/ChangeLog b/Source/WebKit/ChangeLog >index 4215d485aaf038b415ff629b6695889aaff43819..33dacccd08293babb72803a32900af1a927ea31d 100644 >--- a/Source/WebKit/ChangeLog >+++ b/Source/WebKit/ChangeLog >@@ -1,3 +1,118 @@ >+2019-06-05 Youenn Fablet <youenn@apple.com> >+ >+ Use NSURLSession for WebSocket >+ https://bugs.webkit.org/show_bug.cgi?id=198568 >+ >+ Reviewed by NOBODY (OOPS!). >+ >+ Implement socket channel provider on WebProcess level by sending IPC to NetworkProcess. >+ On NetworkProcess side, use NSURLSession API to implement the WebSocket functionality. >+ This is a partial implementation: >+ - inspector integration is not working. >+ - some error cases are not well handled or are not producing the same error messages. >+ - some features are not implemented (extensions, subprotocols, handshake authentication challenge, cookie handling...). >+ >+ * CMakeLists.txt: >+ * DerivedSources-input.xcfilelist: >+ * DerivedSources-output.xcfilelist: >+ * DerivedSources.make: >+ * NetworkProcess/NetworkConnectionToWebProcess.cpp: >+ (WebKit::NetworkConnectionToWebProcess::didReceiveMessage): >+ (WebKit::NetworkConnectionToWebProcess::createSocketChannel): >+ (WebKit::NetworkConnectionToWebProcess::removeSocketChannel): >+ * NetworkProcess/NetworkConnectionToWebProcess.h: >+ * NetworkProcess/NetworkConnectionToWebProcess.messages.in: >+ * NetworkProcess/NetworkSession.cpp: >+ (WebKit::NetworkSession::createWebSocketTask): >+ * NetworkProcess/NetworkSession.h: >+ (WebKit::NetworkSession::removeWebSocketTask): >+ (WebKit::NetworkSession::addWebSocketTask): >+ * NetworkProcess/NetworkSocketChannel.cpp: Added. >+ (WebKit::NetworkSocketChannel::create): >+ (WebKit::NetworkSocketChannel::NetworkSocketChannel): >+ (WebKit::NetworkSocketChannel::~NetworkSocketChannel): >+ (WebKit::NetworkSocketChannel::sendString): >+ (WebKit::NetworkSocketChannel::sendData): >+ (WebKit::NetworkSocketChannel::finishClosingIfPossible): >+ (WebKit::NetworkSocketChannel::close): >+ (WebKit::NetworkSocketChannel::didConnect): >+ (WebKit::NetworkSocketChannel::didReceiveText): >+ (WebKit::NetworkSocketChannel::didReceiveBinaryData): >+ (WebKit::NetworkSocketChannel::didClose): >+ (WebKit::NetworkSocketChannel::messageSenderConnection const): >+ * NetworkProcess/NetworkSocketChannel.h: Added. >+ * NetworkProcess/NetworkSocketChannel.messages.in: Added. >+ * NetworkProcess/NetworkSocketStream.messages.in: >+ * NetworkProcess/WebSocketTask.h: Added. >+ (WebKit::WebSocketTask::sendString): >+ (WebKit::WebSocketTask::sendData): >+ (WebKit::WebSocketTask::close): >+ (WebKit::WebSocketTask::cancel): >+ (WebKit::WebSocketTask::resume): >+ * NetworkProcess/cocoa/NetworkSessionCocoa.h: >+ * NetworkProcess/cocoa/NetworkSessionCocoa.mm: >+ (-[WKNetworkSessionDelegate existingWebSocketTask:]): >+ (-[WKNetworkSessionDelegate URLSession:webSocketTask:didOpenWithProtocol:]): >+ (-[WKNetworkSessionDelegate URLSession:webSocketTask:didCloseWithCode:reason:]): >+ (WebKit::NetworkSessionCocoa::continueDidReceiveChallenge): >+ (WebKit::NetworkSessionCocoa::createWebSocketTask): >+ (WebKit::NetworkSessionCocoa::addWebSocketTask): >+ (WebKit::NetworkSessionCocoa::removeWebSocketTask): >+ (WebKit::NetworkSessionCocoa::webSocketDataTaskForIdentifier): >+ * NetworkProcess/cocoa/WebSocketTaskCocoa.h: Added. >+ * NetworkProcess/cocoa/WebSocketTaskCocoa.mm: Added. >+ (WebKit::WebSocketTask::WebSocketTask): >+ (WebKit::WebSocketTask::~WebSocketTask): >+ (WebKit::WebSocketTask::readNextMessage): >+ (WebKit::WebSocketTask::cancel): >+ (WebKit::WebSocketTask::resume): >+ (WebKit::WebSocketTask::didConnect): >+ (WebKit::WebSocketTask::didClose): >+ (WebKit::WebSocketTask::sendString): >+ (WebKit::WebSocketTask::sendData): >+ (WebKit::WebSocketTask::close): >+ (WebKit::WebSocketTask::identifier const): >+ * Shared/WebPreferences.yaml: >+ * WebKit.xcodeproj/project.pbxproj: >+ * WebProcess/Network/NetworkProcessConnection.cpp: >+ (WebKit::NetworkProcessConnection::didReceiveMessage): >+ * WebProcess/Network/WebSocketChannel.cpp: Added. >+ (WebKit::WebSocketChannel::create): >+ (WebKit::WebSocketChannel::WebSocketChannel): >+ (WebKit::WebSocketChannel::~WebSocketChannel): >+ (WebKit::WebSocketChannel::messageSenderConnection const): >+ (WebKit::WebSocketChannel::messageSenderDestinationID const): >+ (WebKit::WebSocketChannel::subprotocol): >+ (WebKit::WebSocketChannel::extensions): >+ (WebKit::WebSocketChannel::connect): >+ (WebKit::WebSocketChannel::send): >+ (WebKit::WebSocketChannel::bufferedAmount const): >+ (WebKit::WebSocketChannel::close): >+ (WebKit::WebSocketChannel::fail): >+ (WebKit::WebSocketChannel::disconnect): >+ (WebKit::WebSocketChannel::didConnect): >+ (WebKit::WebSocketChannel::didReceiveText): >+ (WebKit::WebSocketChannel::didReceiveBinaryData): >+ (WebKit::WebSocketChannel::didClose): >+ (WebKit::WebSocketChannel::didFail): >+ (WebKit::WebSocketChannel::networkProcessCrashed): >+ * WebProcess/Network/WebSocketChannel.h: Added. >+ * WebProcess/Network/WebSocketChannel.messages.in: Added. >+ * WebProcess/Network/WebSocketChannelManager.cpp: Added. >+ (WebKit::WebSocketChannelManager::createWebSocketChannel): >+ (WebKit::WebSocketChannelManager::networkProcessCrashed): >+ (WebKit::WebSocketChannelManager::didReceiveMessage): >+ * WebProcess/Network/WebSocketChannelManager.h: Added. >+ * WebProcess/Network/WebSocketProvider.cpp: >+ (WebKit::WebSocketProvider::createWebSocketChannel): >+ * WebProcess/Network/WebSocketProvider.h: >+ * WebProcess/Network/WebSocketStream.cpp: >+ * WebProcess/Network/WebSocketStream.messages.in: >+ * WebProcess/WebProcess.cpp: >+ (WebKit::WebProcess::networkProcessConnectionClosed): >+ * WebProcess/WebProcess.h: >+ (WebKit::WebProcess::webSocketChannelManager): >+ > 2019-06-03 Wenson Hsieh <wenson_hsieh@apple.com> > > Implement an internal switch to turn idempotent text autosizing and viewport rules off >diff --git a/Source/WTF/wtf/Platform.h b/Source/WTF/wtf/Platform.h >index 332eb3e7a8c223d7c091b6eabfaa1d8a8bc24c8d..c5f0a6d2dd5499f3ce4d44201625eec23bc6698d 100644 >--- a/Source/WTF/wtf/Platform.h >+++ b/Source/WTF/wtf/Platform.h >@@ -1555,6 +1555,10 @@ > #define USE_REALPATH_FOR_DLOPEN_PREFLIGHT 1 > #endif > >+#if (PLATFORM(MAC) && __MAC_OS_X_VERSION_MIN_REQUIRED >= 101500) || (PLATFORM(IOS_FAMILY) && __IPHONE_OS_VERSION_MIN_REQUIRED >= 130000) || (PLATFORM(WATCHOS) && __WATCH_OS_VERSION_MIN_REQUIRED >= 60000) || (PLATFORM(APPLETV) && __TV_OS_VERSION_MIN_REQUIRED >= 130000) >+#define HAVE_NSURLSESSION_WEBSOCKET 1 >+#endif >+ > #if (PLATFORM(MAC) && __MAC_OS_X_VERSION_MIN_REQUIRED >= 101500) || (PLATFORM(IOS) && __IPHONE_OS_VERSION_MIN_REQUIRED >= 130000) || (PLATFORM(WATCHOS) && __WATCH_OS_VERSION_MIN_REQUIRED >= 60000) || (PLATFORM(APPLETV) && __TV_OS_VERSION_MIN_REQUIRED >= 130000) > #define HAVE_AVPLAYER_RESOURCE_CONSERVATION_LEVEL 1 > #endif >diff --git a/Source/WebCore/Headers.cmake b/Source/WebCore/Headers.cmake >index f46e1be6947c7311616fad65b5f788bcf6e1e8a1..b6c3a626849d42d145a520dd67520e1a68d89917 100644 >--- a/Source/WebCore/Headers.cmake >+++ b/Source/WebCore/Headers.cmake >@@ -149,6 +149,16 @@ set(WebCore_PRIVATE_FRAMEWORK_HEADERS > Modules/webdatabase/DatabaseTracker.h > Modules/webdatabase/OriginLock.h > >+ Modules/websockets/ThreadableWebSocketChannel.h >+ Modules/websockets/WebSocketChannel.h >+ Modules/websockets/WebSocketChannelClient.h >+ Modules/websockets/WebSocketDeflateFramer.h >+ Modules/websockets/WebSocketDeflater.h >+ Modules/websockets/WebSocketExtensionDispatcher.h >+ Modules/websockets/WebSocketExtensionProcessor.h >+ Modules/websockets/WebSocketFrame.h >+ Modules/websockets/WebSocketHandshake.h >+ > accessibility/AXObjectCache.h > accessibility/AXTextStateChangeIntent.h > accessibility/AccessibilityListBox.h >@@ -506,6 +516,7 @@ set(WebCore_PRIVATE_FRAMEWORK_HEADERS > fileapi/BlobPropertyBag.h > fileapi/File.h > fileapi/FileList.h >+ fileapi/FileReaderLoaderClient.h > > history/BackForwardClient.h > history/BackForwardController.h >diff --git a/Source/WebCore/Modules/websockets/ThreadableWebSocketChannel.cpp b/Source/WebCore/Modules/websockets/ThreadableWebSocketChannel.cpp >index 8299bb9e6ac9d897b59b8068a6687f5da752b528..860e4ca3e7a6afcbce3d0bc3c77405fcd337d54c 100644 >--- a/Source/WebCore/Modules/websockets/ThreadableWebSocketChannel.cpp >+++ b/Source/WebCore/Modules/websockets/ThreadableWebSocketChannel.cpp >@@ -31,9 +31,14 @@ > #include "config.h" > #include "ThreadableWebSocketChannel.h" > >+#include "ContentRuleListResults.h" > #include "Document.h" >+#include "Page.h" >+#include "RuntimeEnabledFeatures.h" > #include "ScriptExecutionContext.h" >+#include "SocketProvider.h" > #include "ThreadableWebSocketChannelClientWrapper.h" >+#include "UserContentProvider.h" > #include "WebSocketChannel.h" > #include "WebSocketChannelClient.h" > #include "WorkerGlobalScope.h" >@@ -51,7 +56,48 @@ Ref<ThreadableWebSocketChannel> ThreadableWebSocketChannel::create(ScriptExecuti > return WorkerThreadableWebSocketChannel::create(workerGlobalScope, client, makeString("webSocketChannelMode", runLoop.createUniqueId()), provider); > } > >- return WebSocketChannel::create(downcast<Document>(context), client, provider); >+ auto& document = downcast<Document>(context); >+ >+#if HAVE(NSURLSESSION_WEBSOCKET) >+ if (RuntimeEnabledFeatures::sharedFeatures().isNSURLSessionWebSocketEnabled()) { >+ if (auto channel = provider.createWebSocketChannel(document, client)) >+ return channel.releaseNonNull(); >+ } >+#endif >+ return WebSocketChannel::create(document, client, provider); >+} >+ >+Optional<ThreadableWebSocketChannel::ValidatedURL> ThreadableWebSocketChannel::validateURL(Document& document, const URL& requestedURL) >+{ >+ ValidatedURL validatedURL { requestedURL, true }; >+#if ENABLE(CONTENT_EXTENSIONS) >+ if (auto* page = document.page()) { >+ if (auto* documentLoader = document.loader()) { >+ auto results = page->userContentProvider().processContentRuleListsForLoad(validatedURL.url, ContentExtensions::ResourceType::Raw, *documentLoader); >+ if (results.summary.blockedLoad) >+ return { }; >+ if (results.summary.madeHTTPS) { >+ ASSERT(validatedURL.url.protocolIs("ws")); >+ validatedURL.url.setProtocol("wss"); >+ } >+ validatedURL.areCookiesAllowed = !results.summary.blockedCookies; >+ } >+ } >+#endif >+ return validatedURL; >+} >+ >+Optional<ResourceRequest> ThreadableWebSocketChannel::webSocketConnectRequest(Document& document, const URL& url) >+{ >+ auto validatedURL = validateURL(document, url); >+ if (!validatedURL) >+ return { }; >+ >+ ResourceRequest request { validatedURL->url }; >+ request.setHTTPUserAgent(document.userAgent(validatedURL->url)); >+ request.setDomainForCachePartition(document.domainForCachePartition()); >+ request.setAllowCookies(validatedURL->areCookiesAllowed); >+ return request; > } > > } // namespace WebCore >diff --git a/Source/WebCore/Modules/websockets/ThreadableWebSocketChannel.h b/Source/WebCore/Modules/websockets/ThreadableWebSocketChannel.h >index a85dfd7744cd479ab123d332711ee8f23d101d63..d6a8377981526dd31163d97c7b7936d5b93400c1 100644 >--- a/Source/WebCore/Modules/websockets/ThreadableWebSocketChannel.h >+++ b/Source/WebCore/Modules/websockets/ThreadableWebSocketChannel.h >@@ -32,6 +32,7 @@ > > #include <wtf/Forward.h> > #include <wtf/Noncopyable.h> >+#include <wtf/URL.h> > > namespace JSC { > class ArrayBuffer; >@@ -40,6 +41,8 @@ class ArrayBuffer; > namespace WebCore { > > class Blob; >+class Document; >+class ResourceRequest; > class ScriptExecutionContext; > class SocketProvider; > class WebSocketChannelClient; >@@ -57,7 +60,7 @@ public: > SendFail > }; > >- virtual void connect(const URL&, const String& protocol) = 0; >+ virtual bool connect(const URL&, const String& protocol) = 0; > virtual String subprotocol() = 0; // Will be available after didConnect() callback is invoked. > virtual String extensions() = 0; // Will be available after didConnect() callback is invoked. > virtual SendResult send(const String& message) = 0; >@@ -79,6 +82,13 @@ protected: > virtual ~ThreadableWebSocketChannel() = default; > virtual void refThreadableWebSocketChannel() = 0; > virtual void derefThreadableWebSocketChannel() = 0; >+ >+ struct ValidatedURL { >+ URL url; >+ bool areCookiesAllowed { true }; >+ }; >+ static Optional<ValidatedURL> validateURL(Document&, const URL&); >+ WEBCORE_EXPORT static Optional<ResourceRequest> webSocketConnectRequest(Document&, const URL&); > }; > > } // namespace WebCore >diff --git a/Source/WebCore/Modules/websockets/WebSocket.cpp b/Source/WebCore/Modules/websockets/WebSocket.cpp >index 2a035246b7f2bd27dd24bea0ea08adb9b7d7a613..4dae753b5bfd8f1d5c7ecd97cea706fd52a8e7d7 100644 >--- a/Source/WebCore/Modules/websockets/WebSocket.cpp >+++ b/Source/WebCore/Modules/websockets/WebSocket.cpp >@@ -205,6 +205,21 @@ ExceptionOr<void> WebSocket::connect(const String& url, const String& protocol) > return connect(url, Vector<String> { 1, protocol }); > } > >+void WebSocket::failAsynchronously() >+{ >+ m_pendingActivity = makePendingActivity(*this); >+ >+ // We must block this connection. Instead of throwing an exception, we indicate this >+ // using the error event. But since this code executes as part of the WebSocket's >+ // constructor, we have to wait until the constructor has completed before firing the >+ // event; otherwise, users can't connect to the event. >+ >+ scriptExecutionContext()->postTask([this, protectedThis = makeRef(*this)](auto&) { >+ this->dispatchOrQueueErrorEvent(); >+ this->stop(); >+ }); >+} >+ > ExceptionOr<void> WebSocket::connect(const String& url, const Vector<String>& protocols) > { > LOG(Network, "WebSocket %p connect() url='%s'", this, url.utf8().data()); >@@ -291,18 +306,7 @@ ExceptionOr<void> WebSocket::connect(const String& url, const Vector<String>& pr > Document& document = downcast<Document>(context); > RefPtr<Frame> frame = document.frame(); > if (!frame || !frame->loader().mixedContentChecker().canRunInsecureContent(document.securityOrigin(), m_url)) { >- m_pendingActivity = makePendingActivity(*this); >- >- // We must block this connection. Instead of throwing an exception, we indicate this >- // using the error event. But since this code executes as part of the WebSocket's >- // constructor, we have to wait until the constructor has completed before firing the >- // event; otherwise, users can't connect to the event. >- >- document.postTask([this, protectedThis = makeRef(*this)](auto&) { >- this->dispatchOrQueueErrorEvent(); >- this->stop(); >- }); >- >+ failAsynchronously(); > return { }; > } > } >@@ -311,7 +315,11 @@ ExceptionOr<void> WebSocket::connect(const String& url, const Vector<String>& pr > if (!protocols.isEmpty()) > protocolString = joinStrings(protocols, subprotocolSeparator()); > >- m_channel->connect(m_url, protocolString); >+ if (!m_channel->connect(m_url, protocolString)) { >+ failAsynchronously(); >+ return { }; >+ } >+ > m_pendingActivity = makePendingActivity(*this); > > return { }; >diff --git a/Source/WebCore/Modules/websockets/WebSocket.h b/Source/WebCore/Modules/websockets/WebSocket.h >index 55cc4c0cfc5bf4bbbc6c3a56136a209de34afd26..86efff76b677b6e22192f6ad86a9338124733552 100644 >--- a/Source/WebCore/Modules/websockets/WebSocket.h >+++ b/Source/WebCore/Modules/websockets/WebSocket.h >@@ -128,6 +128,8 @@ private: > > size_t getFramingOverhead(size_t payloadSize); > >+ void failAsynchronously(); >+ > enum class BinaryType { Blob, ArrayBuffer }; > > RefPtr<ThreadableWebSocketChannel> m_channel; >diff --git a/Source/WebCore/Modules/websockets/WebSocketChannel.cpp b/Source/WebCore/Modules/websockets/WebSocketChannel.cpp >index b4ccc89c4fd2ae45c642e278cb548aa35456ac85..5c3fbfe5f88642b61043ca4a933e06808edd88f0 100644 >--- a/Source/WebCore/Modules/websockets/WebSocketChannel.cpp >+++ b/Source/WebCore/Modules/websockets/WebSocketChannel.cpp >@@ -81,46 +81,28 @@ WebSocketChannel::~WebSocketChannel() > LOG(Network, "WebSocketChannel %p dtor", this); > } > >-void WebSocketChannel::connect(const URL& requestedURL, const String& protocol) >+bool WebSocketChannel::connect(const URL& requestedURL, const String& protocol) > { > LOG(Network, "WebSocketChannel %p connect()", this); > >- URL url = requestedURL; >-#if ENABLE(CONTENT_EXTENSIONS) >- if (auto* page = m_document->page()) { >- if (auto* documentLoader = m_document->loader()) { >- auto results = page->userContentProvider().processContentRuleListsForLoad(url, ContentExtensions::ResourceType::Raw, *documentLoader); >- if (results.summary.blockedLoad) { >- Ref<WebSocketChannel> protectedThis(*this); >- callOnMainThread([protectedThis = WTFMove(protectedThis)] { >- if (protectedThis->m_client) >- protectedThis->m_client->didReceiveMessageError(); >- }); >- return; >- } >- if (results.summary.madeHTTPS) { >- ASSERT(url.protocolIs("ws")); >- url.setProtocol("wss"); >- if (m_client) >- m_client->didUpgradeURL(); >- } >- if (results.summary.blockedCookies) >- m_allowCookies = false; >- } >- } >-#endif >- >+ auto validatedURL = validateURL(*m_document, requestedURL); >+ if (!validatedURL) >+ return false; > ASSERT(!m_handle); > ASSERT(!m_suspended); >- >+ >+ if (validatedURL->url != requestedURL && m_client) >+ m_client->didUpgradeURL(); >+ >+ m_allowCookies = validatedURL->areCookiesAllowed; > String userAgent = m_document->userAgent(m_document->url()); > String clientOrigin = m_document->securityOrigin().toString(); >- m_handshake = std::make_unique<WebSocketHandshake>(url, protocol, userAgent, clientOrigin, m_allowCookies); >+ m_handshake = std::make_unique<WebSocketHandshake>(validatedURL->url, protocol, userAgent, clientOrigin, m_allowCookies); > m_handshake->reset(); > if (m_deflateFramer.canDeflate()) > m_handshake->addExtensionProcessor(m_deflateFramer.createExtensionProcessor()); > if (m_identifier) >- InspectorInstrumentation::didCreateWebSocket(m_document.get(), m_identifier, url); >+ InspectorInstrumentation::didCreateWebSocket(m_document.get(), m_identifier, validatedURL->url); > > if (Frame* frame = m_document->frame()) { > ref(); >@@ -129,6 +111,12 @@ void WebSocketChannel::connect(const URL& requestedURL, const String& protocol) > String partition = m_document->domainForCachePartition(); > m_handle = m_socketProvider->createSocketStreamHandle(m_handshake->url(), *this, sessionID, partition, frame->loader().networkingContext()); > } >+ return true; >+} >+ >+Document* WebSocketChannel::document() >+{ >+ return m_document.get(); > } > > String WebSocketChannel::subprotocol() >diff --git a/Source/WebCore/Modules/websockets/WebSocketChannel.h b/Source/WebCore/Modules/websockets/WebSocketChannel.h >index 49bab547da8a8d77d5be5e4573afcde794128fda..66d20e0e286f8db7099e2289e84185a748a0b0ac 100644 >--- a/Source/WebCore/Modules/websockets/WebSocketChannel.h >+++ b/Source/WebCore/Modules/websockets/WebSocketChannel.h >@@ -56,7 +56,7 @@ class SocketStreamHandle; > class SocketStreamError; > class WebSocketChannelClient; > >-class WebSocketChannel : public RefCounted<WebSocketChannel>, public SocketStreamHandleClient, public ThreadableWebSocketChannel, public FileReaderLoaderClient >+class WebSocketChannel final : public RefCounted<WebSocketChannel>, public SocketStreamHandleClient, public ThreadableWebSocketChannel, public FileReaderLoaderClient > { > WTF_MAKE_FAST_ALLOCATED; > public: >@@ -68,19 +68,19 @@ public: > bool send(const char* data, int length); > > // ThreadableWebSocketChannel functions. >- void connect(const URL&, const String& protocol) override; >- String subprotocol() override; >- String extensions() override; >- ThreadableWebSocketChannel::SendResult send(const String& message) override; >- ThreadableWebSocketChannel::SendResult send(const JSC::ArrayBuffer&, unsigned byteOffset, unsigned byteLength) override; >- ThreadableWebSocketChannel::SendResult send(Blob&) override; >- unsigned bufferedAmount() const override; >- void close(int code, const String& reason) override; // Start closing handshake. >- void fail(const String& reason) override; >- void disconnect() override; >- >- void suspend() override; >- void resume() override; >+ bool connect(const URL&, const String& protocol) final; >+ String subprotocol() final; >+ String extensions() final; >+ ThreadableWebSocketChannel::SendResult send(const String& message) final; >+ ThreadableWebSocketChannel::SendResult send(const JSC::ArrayBuffer&, unsigned byteOffset, unsigned byteLength) final; >+ ThreadableWebSocketChannel::SendResult send(Blob&) final; >+ unsigned bufferedAmount() const final; >+ void close(int code, const String& reason) final; // Start closing handshake. >+ void fail(const String& reason) final; >+ void disconnect() final; >+ >+ void suspend() final; >+ void resume() final; > > // SocketStreamHandleClient functions. > void didOpenSocketStream(SocketStreamHandle&) final; >@@ -124,7 +124,7 @@ public: > using RefCounted<WebSocketChannel>::ref; > using RefCounted<WebSocketChannel>::deref; > >- Document* document() { return m_document.get(); } >+ Document* document(); > > protected: > void refThreadableWebSocketChannel() override { ref(); } >diff --git a/Source/WebCore/Modules/websockets/WorkerThreadableWebSocketChannel.cpp b/Source/WebCore/Modules/websockets/WorkerThreadableWebSocketChannel.cpp >index 8421b1456997068fbcfa4c6d8050be8121e87d35..5cb15ed37f9c5a9f3458d3ebb7ffdf7a1798ced9 100644 >--- a/Source/WebCore/Modules/websockets/WorkerThreadableWebSocketChannel.cpp >+++ b/Source/WebCore/Modules/websockets/WorkerThreadableWebSocketChannel.cpp >@@ -63,10 +63,11 @@ WorkerThreadableWebSocketChannel::~WorkerThreadableWebSocketChannel() > m_bridge->disconnect(); > } > >-void WorkerThreadableWebSocketChannel::connect(const URL& url, const String& protocol) >+bool WorkerThreadableWebSocketChannel::connect(const URL& url, const String& protocol) > { > if (m_bridge) > m_bridge->connect(url, protocol); >+ return true; > } > > String WorkerThreadableWebSocketChannel::subprotocol() >@@ -155,12 +156,12 @@ WorkerThreadableWebSocketChannel::Peer::~Peer() > m_mainWebSocketChannel->disconnect(); > } > >-void WorkerThreadableWebSocketChannel::Peer::connect(const URL& url, const String& protocol) >+bool WorkerThreadableWebSocketChannel::Peer::connect(const URL& url, const String& protocol) > { > ASSERT(isMainThread()); > if (!m_mainWebSocketChannel) >- return; >- m_mainWebSocketChannel->connect(url, protocol); >+ return false; >+ return m_mainWebSocketChannel->connect(url, protocol); > } > > void WorkerThreadableWebSocketChannel::Peer::send(const String& message) >@@ -403,7 +404,8 @@ void WorkerThreadableWebSocketChannel::Bridge::connect(const URL& url, const Str > ASSERT_UNUSED(context, context.isDocument()); > ASSERT(peer); > >- peer->connect(url, protocol); >+ if (!peer->connect(url, protocol)) >+ peer->didReceiveMessageError(); > }); > } > >diff --git a/Source/WebCore/Modules/websockets/WorkerThreadableWebSocketChannel.h b/Source/WebCore/Modules/websockets/WorkerThreadableWebSocketChannel.h >index 3895e44967507c5ee99cc22f43e721f291375ff8..1d0e36e8fbf75335c6f34e08d745ca56b2072977 100644 >--- a/Source/WebCore/Modules/websockets/WorkerThreadableWebSocketChannel.h >+++ b/Source/WebCore/Modules/websockets/WorkerThreadableWebSocketChannel.h >@@ -45,7 +45,7 @@ class WorkerGlobalScope; > class WorkerLoaderProxy; > class WorkerRunLoop; > >-class WorkerThreadableWebSocketChannel : public RefCounted<WorkerThreadableWebSocketChannel>, public ThreadableWebSocketChannel { >+class WorkerThreadableWebSocketChannel final : public RefCounted<WorkerThreadableWebSocketChannel>, public ThreadableWebSocketChannel { > WTF_MAKE_FAST_ALLOCATED; > public: > static Ref<ThreadableWebSocketChannel> create(WorkerGlobalScope& workerGlobalScope, WebSocketChannelClient& client, const String& taskMode, SocketProvider& provider) >@@ -55,18 +55,18 @@ public: > virtual ~WorkerThreadableWebSocketChannel(); > > // ThreadableWebSocketChannel functions. >- void connect(const URL&, const String& protocol) override; >- String subprotocol() override; >- String extensions() override; >- ThreadableWebSocketChannel::SendResult send(const String& message) override; >- ThreadableWebSocketChannel::SendResult send(const JSC::ArrayBuffer&, unsigned byteOffset, unsigned byteLength) override; >- ThreadableWebSocketChannel::SendResult send(Blob&) override; >- unsigned bufferedAmount() const override; >- void close(int code, const String& reason) override; >- void fail(const String& reason) override; >- void disconnect() override; // Will suppress didClose(). >- void suspend() override; >- void resume() override; >+ bool connect(const URL&, const String& protocol) final; >+ String subprotocol() final; >+ String extensions() final; >+ ThreadableWebSocketChannel::SendResult send(const String& message) final; >+ ThreadableWebSocketChannel::SendResult send(const JSC::ArrayBuffer&, unsigned byteOffset, unsigned byteLength) final; >+ ThreadableWebSocketChannel::SendResult send(Blob&) final; >+ unsigned bufferedAmount() const final; >+ void close(int code, const String& reason) final; >+ void fail(const String& reason) final; >+ void disconnect() final; // Will suppress didClose(). >+ void suspend() final; >+ void resume() final; > > // Generated by the bridge. The Peer and its bridge should have identical > // lifetimes. >@@ -76,7 +76,7 @@ public: > Peer(Ref<ThreadableWebSocketChannelClientWrapper>&&, WorkerLoaderProxy&, ScriptExecutionContext&, const String& taskMode, SocketProvider&); > ~Peer(); > >- void connect(const URL&, const String& protocol); >+ bool connect(const URL&, const String& protocol); > void send(const String& message); > void send(const JSC::ArrayBuffer&); > void send(Blob&); >diff --git a/Source/WebCore/WebCore.xcodeproj/project.pbxproj b/Source/WebCore/WebCore.xcodeproj/project.pbxproj >index 8334a9fd89b3a27134d5bab1b35a39ea82281605..6cf283a1ebb70a25df59bde708c9fbbb82db87f6 100644 >--- a/Source/WebCore/WebCore.xcodeproj/project.pbxproj >+++ b/Source/WebCore/WebCore.xcodeproj/project.pbxproj >@@ -2826,10 +2826,10 @@ > 97AABD1E14FA09D5007457AE /* WebSocketChannel.h in Headers */ = {isa = PBXBuildFile; fileRef = 97AABD0314FA09D5007457AE /* WebSocketChannel.h */; settings = {ATTRIBUTES = (Private, ); }; }; > 97AABD1F14FA09D5007457AE /* WebSocketChannelClient.h in Headers */ = {isa = PBXBuildFile; fileRef = 97AABD0414FA09D5007457AE /* WebSocketChannelClient.h */; settings = {ATTRIBUTES = (Private, ); }; }; > 97AABD2114FA09D5007457AE /* WebSocketDeflater.h in Headers */ = {isa = PBXBuildFile; fileRef = 97AABD0614FA09D5007457AE /* WebSocketDeflater.h */; settings = {ATTRIBUTES = (Private, ); }; }; >- 97AABD2314FA09D5007457AE /* WebSocketExtensionDispatcher.h in Headers */ = {isa = PBXBuildFile; fileRef = 97AABD0814FA09D5007457AE /* WebSocketExtensionDispatcher.h */; }; >+ 97AABD2314FA09D5007457AE /* WebSocketExtensionDispatcher.h in Headers */ = {isa = PBXBuildFile; fileRef = 97AABD0814FA09D5007457AE /* WebSocketExtensionDispatcher.h */; settings = {ATTRIBUTES = (Private, ); }; }; > 97AABD2414FA09D5007457AE /* WebSocketExtensionProcessor.h in Headers */ = {isa = PBXBuildFile; fileRef = 97AABD0914FA09D5007457AE /* WebSocketExtensionProcessor.h */; settings = {ATTRIBUTES = (Private, ); }; }; > 97AABD2514FA09D5007457AE /* WebSocketFrame.h in Headers */ = {isa = PBXBuildFile; fileRef = 97AABD0A14FA09D5007457AE /* WebSocketFrame.h */; settings = {ATTRIBUTES = (Private, ); }; }; >- 97AABD2714FA09D5007457AE /* WebSocketHandshake.h in Headers */ = {isa = PBXBuildFile; fileRef = 97AABD0C14FA09D5007457AE /* WebSocketHandshake.h */; }; >+ 97AABD2714FA09D5007457AE /* WebSocketHandshake.h in Headers */ = {isa = PBXBuildFile; fileRef = 97AABD0C14FA09D5007457AE /* WebSocketHandshake.h */; settings = {ATTRIBUTES = (Private, ); }; }; > 97AABD2D14FA09D5007457AE /* WorkerThreadableWebSocketChannel.h in Headers */ = {isa = PBXBuildFile; fileRef = 97AABD1214FA09D5007457AE /* WorkerThreadableWebSocketChannel.h */; settings = {ATTRIBUTES = (Private, ); }; }; > 97B8FFD116AE7F960038388D /* CharacterReferenceParserInlines.h in Headers */ = {isa = PBXBuildFile; fileRef = 97B8FFCF16AE7F920038388D /* CharacterReferenceParserInlines.h */; }; > 97BC69DD1505F076001B74AC /* ChangeVersionWrapper.h in Headers */ = {isa = PBXBuildFile; fileRef = 97BC69D91505F076001B74AC /* ChangeVersionWrapper.h */; }; >diff --git a/Source/WebCore/page/RuntimeEnabledFeatures.h b/Source/WebCore/page/RuntimeEnabledFeatures.h >index 1b9ddaccb8cf3bcdafd70904688cfee466944599..d1aee6e5a7c85baf871e5cbd8788b48c670ec683 100644 >--- a/Source/WebCore/page/RuntimeEnabledFeatures.h >+++ b/Source/WebCore/page/RuntimeEnabledFeatures.h >@@ -365,6 +365,9 @@ public: > > WEBCORE_EXPORT static RuntimeEnabledFeatures& sharedFeatures(); > >+ bool isNSURLSessionWebSocketEnabled() const { return m_isNSURLSessionWebSocketEnabled; } >+ void setIsNSURLSessionWebSocketEnabled(bool isEnabled) { m_isNSURLSessionWebSocketEnabled = isEnabled; } >+ > private: > // Never instantiate. > RuntimeEnabledFeatures(); >@@ -550,6 +553,8 @@ private: > > bool m_linkPreloadResponsiveImagesEnabled { false }; > >+ bool m_isNSURLSessionWebSocketEnabled { false }; >+ > friend class WTF::NeverDestroyed<RuntimeEnabledFeatures>; > }; > >diff --git a/Source/WebCore/page/SocketProvider.cpp b/Source/WebCore/page/SocketProvider.cpp >index 46af7f479819ab4e0de82334d6e040c2bf58ad38..803ac83155ff4df1becf75cd4710f6fbf7bbc32a 100644 >--- a/Source/WebCore/page/SocketProvider.cpp >+++ b/Source/WebCore/page/SocketProvider.cpp >@@ -27,6 +27,7 @@ > #include "SocketProvider.h" > > #include "SocketStreamHandleImpl.h" >+#include "ThreadableWebSocketChannel.h" > > namespace WebCore { > >@@ -34,5 +35,10 @@ Ref<SocketStreamHandle> SocketProvider::createSocketStreamHandle(const URL& url, > { > return SocketStreamHandleImpl::create(url, client, sessionID, credentialPartition, { }, provider); > } >- >+ >+RefPtr<ThreadableWebSocketChannel> SocketProvider::createWebSocketChannel(Document&, WebSocketChannelClient&) >+{ >+ return nullptr; >+} >+ > } >diff --git a/Source/WebCore/page/SocketProvider.h b/Source/WebCore/page/SocketProvider.h >index e016b4d2c0da7353c08b64e298c33009392ba4c2..5f56f150255ab9b3c86f9dbd1ecdb60685ccc9c7 100644 >--- a/Source/WebCore/page/SocketProvider.h >+++ b/Source/WebCore/page/SocketProvider.h >@@ -31,15 +31,21 @@ > > namespace WebCore { > >+class ThreadableWebSocketChannel; >+class ScriptExecutionContext; > class StorageSessionProvider; > class ScriptExecutionContext; > class SocketStreamHandle; > class SocketStreamHandleClient; >+class WebSocketChannelClient; > > class WEBCORE_EXPORT SocketProvider : public ThreadSafeRefCounted<SocketProvider> { > public: > static Ref<SocketProvider> create() { return adoptRef(*new SocketProvider); } > virtual Ref<SocketStreamHandle> createSocketStreamHandle(const URL&, SocketStreamHandleClient&, PAL::SessionID, const String& credentialPartition, const StorageSessionProvider*); >+ >+ virtual RefPtr<ThreadableWebSocketChannel> createWebSocketChannel(Document&, WebSocketChannelClient&); >+ > virtual ~SocketProvider() { }; > }; > >diff --git a/Source/WebKit/CMakeLists.txt b/Source/WebKit/CMakeLists.txt >index b8e08c1fb42b17b46792fdbb96b81720121759f0..6f79c8647a612dc04a02aac823d7495844d4c921 100644 >--- a/Source/WebKit/CMakeLists.txt >+++ b/Source/WebKit/CMakeLists.txt >@@ -111,6 +111,7 @@ set(WebKit_MESSAGES_IN_FILES > NetworkProcess/NetworkContentRuleListManager.messages.in > NetworkProcess/NetworkProcess.messages.in > NetworkProcess/NetworkResourceLoader.messages.in >+ NetworkProcess/NetworkSocketChannel.messages.in > NetworkProcess/NetworkSocketStream.messages.in > > NetworkProcess/ServiceWorker/ServiceWorkerFetchTask.messages.in >@@ -176,6 +177,7 @@ set(WebKit_MESSAGES_IN_FILES > > WebProcess/Network/NetworkProcessConnection.messages.in > WebProcess/Network/WebResourceLoader.messages.in >+ WebProcess/Network/WebSocketChannel.messages.in > WebProcess/Network/WebSocketStream.messages.in > > WebProcess/Notifications/WebNotificationManager.messages.in >diff --git a/Source/WebKit/DerivedSources-input.xcfilelist b/Source/WebKit/DerivedSources-input.xcfilelist >index e4f4b2ba345133e3dd0c951aad349a89d52f39c5..0fb8423b5cccf7d26339425cd7a73f4b2c0d2e89 100644 >--- a/Source/WebKit/DerivedSources-input.xcfilelist >+++ b/Source/WebKit/DerivedSources-input.xcfilelist >@@ -20,6 +20,7 @@ $(PROJECT_DIR)/NetworkProcess/NetworkConnectionToWebProcess.messages.in > $(PROJECT_DIR)/NetworkProcess/NetworkContentRuleListManager.messages.in > $(PROJECT_DIR)/NetworkProcess/NetworkProcess.messages.in > $(PROJECT_DIR)/NetworkProcess/NetworkResourceLoader.messages.in >+$(PROJECT_DIR)/NetworkProcess/NetworkSocketChannel.messages.in > $(PROJECT_DIR)/NetworkProcess/NetworkSocketStream.messages.in > $(PROJECT_DIR)/NetworkProcess/ServiceWorker/ServiceWorkerFetchTask.messages.in > $(PROJECT_DIR)/NetworkProcess/ServiceWorker/WebSWServerConnection.messages.in >@@ -95,6 +96,7 @@ $(PROJECT_DIR)/WebProcess/FullScreen/WebFullScreenManager.messages.in > $(PROJECT_DIR)/WebProcess/Geolocation/WebGeolocationManager.messages.in > $(PROJECT_DIR)/WebProcess/Network/NetworkProcessConnection.messages.in > $(PROJECT_DIR)/WebProcess/Network/WebResourceLoader.messages.in >+$(PROJECT_DIR)/WebProcess/Network/WebSocketChannel.messages.in > $(PROJECT_DIR)/WebProcess/Network/WebSocketStream.messages.in > $(PROJECT_DIR)/WebProcess/Network/webrtc/WebMDNSRegister.messages.in > $(PROJECT_DIR)/WebProcess/Network/webrtc/WebRTCMonitor.messages.in >diff --git a/Source/WebKit/DerivedSources-output.xcfilelist b/Source/WebKit/DerivedSources-output.xcfilelist >index 426b8675df4b430b4f3cea6f8570e4a20c6b12b3..fe0a6c00402c5355405451491d4d8df74473c793 100644 >--- a/Source/WebKit/DerivedSources-output.xcfilelist >+++ b/Source/WebKit/DerivedSources-output.xcfilelist >@@ -48,6 +48,8 @@ $(BUILT_PRODUCTS_DIR)/DerivedSources/WebKit2/NetworkRTCSocketMessageReceiver.cpp > $(BUILT_PRODUCTS_DIR)/DerivedSources/WebKit2/NetworkRTCSocketMessages.h > $(BUILT_PRODUCTS_DIR)/DerivedSources/WebKit2/NetworkResourceLoaderMessageReceiver.cpp > $(BUILT_PRODUCTS_DIR)/DerivedSources/WebKit2/NetworkResourceLoaderMessages.h >+$(BUILT_PRODUCTS_DIR)/DerivedSources/WebKit2/NetworkSocketChannelMessageReceiver.cpp >+$(BUILT_PRODUCTS_DIR)/DerivedSources/WebKit2/NetworkSocketChannelMessages.h > $(BUILT_PRODUCTS_DIR)/DerivedSources/WebKit2/NetworkSocketStreamMessageReceiver.cpp > $(BUILT_PRODUCTS_DIR)/DerivedSources/WebKit2/NetworkSocketStreamMessages.h > $(BUILT_PRODUCTS_DIR)/DerivedSources/WebKit2/PlaybackSessionManagerMessageReceiver.cpp >@@ -192,6 +194,8 @@ $(BUILT_PRODUCTS_DIR)/DerivedSources/WebKit2/WebSWServerConnectionMessageReceive > $(BUILT_PRODUCTS_DIR)/DerivedSources/WebKit2/WebSWServerConnectionMessages.h > $(BUILT_PRODUCTS_DIR)/DerivedSources/WebKit2/WebSWServerToContextConnectionMessageReceiver.cpp > $(BUILT_PRODUCTS_DIR)/DerivedSources/WebKit2/WebSWServerToContextConnectionMessages.h >+$(BUILT_PRODUCTS_DIR)/DerivedSources/WebKit2/WebSocketChannelMessageReceiver.cpp >+$(BUILT_PRODUCTS_DIR)/DerivedSources/WebKit2/WebSocketChannelMessages.h > $(BUILT_PRODUCTS_DIR)/DerivedSources/WebKit2/WebSocketStreamMessageReceiver.cpp > $(BUILT_PRODUCTS_DIR)/DerivedSources/WebKit2/WebSocketStreamMessages.h > $(BUILT_PRODUCTS_DIR)/DerivedSources/WebKit2/WebUserContentControllerMessageReceiver.cpp >diff --git a/Source/WebKit/DerivedSources.make b/Source/WebKit/DerivedSources.make >index c11b3f8ebeed42de041b3dd4c9d512afd4ed67b0..5393c5bd7f097945002f10322efce0531632c3ff 100644 >--- a/Source/WebKit/DerivedSources.make >+++ b/Source/WebKit/DerivedSources.make >@@ -116,6 +116,7 @@ MESSAGE_RECEIVERS = \ > NetworkRTCProvider \ > NetworkRTCSocket \ > NetworkResourceLoader \ >+ NetworkSocketChannel \ > NetworkSocketStream \ > PlaybackSessionManager \ > PlaybackSessionManagerProxy \ >@@ -182,6 +183,7 @@ MESSAGE_RECEIVERS = \ > WebSWContextManagerConnection \ > WebSWServerConnection \ > WebSWServerToContextConnection \ >+ WebSocketChannel \ > WebSocketStream \ > WebUserContentController \ > WebUserContentControllerProxy \ >diff --git a/Source/WebKit/NetworkProcess/NetworkConnectionToWebProcess.cpp b/Source/WebKit/NetworkProcess/NetworkConnectionToWebProcess.cpp >index 92c8b7ae44fb3b774d6b0598c419c383feb0920e..560e6fd196d9e42651249c2dcf2d522c1e011c30 100644 >--- a/Source/WebKit/NetworkProcess/NetworkConnectionToWebProcess.cpp >+++ b/Source/WebKit/NetworkProcess/NetworkConnectionToWebProcess.cpp >@@ -41,6 +41,8 @@ > #include "NetworkResourceLoader.h" > #include "NetworkResourceLoaderMessages.h" > #include "NetworkSession.h" >+#include "NetworkSocketChannel.h" >+#include "NetworkSocketChannelMessages.h" > #include "NetworkSocketStream.h" > #include "NetworkSocketStreamMessages.h" > #include "PingLoad.h" >@@ -157,6 +159,12 @@ void NetworkConnectionToWebProcess::didReceiveMessage(IPC::Connection& connectio > return; > } > >+ if (decoder.messageReceiverName() == Messages::NetworkSocketChannel::messageReceiverName()) { >+ if (auto* channel = m_networkSocketChannels.get(decoder.destinationID())) >+ channel->didReceiveMessage(connection, decoder); >+ return; >+ } >+ > if (decoder.messageReceiverName() == Messages::NetworkProcess::messageReceiverName()) { > m_networkProcess->didReceiveNetworkProcessMessage(connection, decoder); > return; >@@ -347,10 +355,17 @@ void NetworkConnectionToWebProcess::createSocketStream(URL&& url, PAL::SessionID > m_networkSocketStreams.set(identifier, NetworkSocketStream::create(m_networkProcess.get(), WTFMove(url), sessionID, cachePartition, identifier, m_connection, WTFMove(token))); > } > >-void NetworkConnectionToWebProcess::destroySocketStream(uint64_t identifier) >+void NetworkConnectionToWebProcess::createSocketChannel(PAL::SessionID sessionID, const ResourceRequest& request, const String& protocol, uint64_t identifier) >+{ >+ ASSERT(!m_networkSocketChannels.contains(identifier)); >+ if (auto channel = NetworkSocketChannel::create(*this, sessionID, request, protocol, identifier)) >+ m_networkSocketChannels.add(identifier, WTFMove(channel)); >+} >+ >+void NetworkConnectionToWebProcess::removeSocketChannel(uint64_t identifier) > { >- ASSERT(m_networkSocketStreams.get(identifier)); >- m_networkSocketStreams.remove(identifier); >+ ASSERT(m_networkSocketChannels.contains(identifier)); >+ m_networkSocketChannels.remove(identifier); > } > > void NetworkConnectionToWebProcess::cleanupForSuspension(Function<void()>&& completionHandler) >diff --git a/Source/WebKit/NetworkProcess/NetworkConnectionToWebProcess.h b/Source/WebKit/NetworkProcess/NetworkConnectionToWebProcess.h >index 06d57968828658e168c2c81f7281f1f960c804ba..74161ff296515ffef881559ebe72a131cdb5293e 100644 >--- a/Source/WebKit/NetworkProcess/NetworkConnectionToWebProcess.h >+++ b/Source/WebKit/NetworkProcess/NetworkConnectionToWebProcess.h >@@ -60,6 +60,7 @@ namespace WebKit { > > class NetworkProcess; > class NetworkResourceLoader; >+class NetworkSocketChannel; > class NetworkSocketStream; > class WebIDBConnectionToClient; > class WebSWServerConnection; >@@ -149,6 +150,8 @@ public: > void webPageWasRemoved(PAL::SessionID, WebCore::PageIdentifier); > void webProcessSessionChanged(PAL::SessionID newSessionID, const Vector<WebCore::PageIdentifier>& pages); > >+ void removeSocketChannel(uint64_t identifier); >+ > private: > NetworkConnectionToWebProcess(NetworkProcess&, IPC::Connection::Identifier); > >@@ -195,8 +198,9 @@ private: > void setCaptureExtraNetworkLoadMetricsEnabled(bool); > > void createSocketStream(URL&&, PAL::SessionID, String cachePartition, uint64_t); >- void destroySocketStream(uint64_t); >- >+ >+ void createSocketChannel(PAL::SessionID, const WebCore::ResourceRequest&, const String& protocol, uint64_t identifier); >+ > void ensureLegacyPrivateBrowsingSession(); > > #if ENABLE(INDEXED_DATABASE) >@@ -283,6 +287,7 @@ private: > Ref<NetworkProcess> m_networkProcess; > > HashMap<uint64_t, RefPtr<NetworkSocketStream>> m_networkSocketStreams; >+ HashMap<uint64_t, std::unique_ptr<NetworkSocketChannel>> m_networkSocketChannels; > NetworkResourceLoadMap m_networkResourceLoaders; > HashMap<String, RefPtr<WebCore::BlobDataFileReference>> m_blobDataFileReferences; > Vector<ResourceNetworkActivityTracker> m_networkActivityTrackers; >diff --git a/Source/WebKit/NetworkProcess/NetworkConnectionToWebProcess.messages.in b/Source/WebKit/NetworkProcess/NetworkConnectionToWebProcess.messages.in >index 833e74fcf6003eb83ac1de2d8c6bfc0ff25b9fc3..22077eaddbe0e6dec0cbc62f5eeddfa40303cf67 100644 >--- a/Source/WebKit/NetworkProcess/NetworkConnectionToWebProcess.messages.in >+++ b/Source/WebKit/NetworkProcess/NetworkConnectionToWebProcess.messages.in >@@ -52,6 +52,7 @@ messages -> NetworkConnectionToWebProcess LegacyReceiver { > SetCaptureExtraNetworkLoadMetricsEnabled(bool enabled) > > CreateSocketStream(URL url, PAL::SessionID sessionID, String cachePartition, uint64_t identifier) >+ CreateSocketChannel(PAL::SessionID sessionID, WebCore::ResourceRequest request, String protocol, uint64_t identifier) > > EnsureLegacyPrivateBrowsingSession() > >diff --git a/Source/WebKit/NetworkProcess/NetworkSession.cpp b/Source/WebKit/NetworkProcess/NetworkSession.cpp >index 1d0a8ab9ba750b371749a51bc2b45b26d101c5b6..3544fa4cc5f83e9744f4dff36415e2caa42a459e 100644 >--- a/Source/WebKit/NetworkProcess/NetworkSession.cpp >+++ b/Source/WebKit/NetworkProcess/NetworkSession.cpp >@@ -36,6 +36,8 @@ > #include "WebPageProxy.h" > #include "WebPageProxyMessages.h" > #include "WebProcessProxy.h" >+#include "WebSocketTask.h" >+#include <WebCore/AdClickAttribution.h> > #include <WebCore/CookieJar.h> > #include <WebCore/NetworkStorageSession.h> > #include <WebCore/ResourceRequest.h> >@@ -204,4 +206,9 @@ void NetworkSession::removeKeptAliveLoad(NetworkResourceLoader& loader) > m_keptAliveLoads.remove(loader); > } > >+std::unique_ptr<WebSocketTask> NetworkSession::createWebSocketTask(NetworkSocketChannel&, const WebCore::ResourceRequest&, const String& protocol) >+{ >+ return nullptr; >+} >+ > } // namespace WebKit >diff --git a/Source/WebKit/NetworkProcess/NetworkSession.h b/Source/WebKit/NetworkProcess/NetworkSession.h >index 8ca7e3174414d7c8ee26d80c17c9a9d221658f72..f9d22ab0aeb8a7b8f1ff7a86c266f1d3d9ba74e9 100644 >--- a/Source/WebKit/NetworkProcess/NetworkSession.h >+++ b/Source/WebKit/NetworkProcess/NetworkSession.h >@@ -53,7 +53,9 @@ class NetworkDataTask; > class NetworkProcess; > class NetworkResourceLoader; > class StorageManager; >+class NetworkSocketChannel; > class WebResourceLoadStatisticsStore; >+class WebSocketTask; > struct NetworkSessionCreationParameters; > > enum class WebsiteDataType; >@@ -101,6 +103,10 @@ public: > PrefetchCache& prefetchCache() { return m_prefetchCache; } > void clearPrefetchCache() { m_prefetchCache.clear(); } > >+ virtual std::unique_ptr<WebSocketTask> createWebSocketTask(NetworkSocketChannel&, const WebCore::ResourceRequest&, const String& protocol); >+ virtual void removeWebSocketTask(WebSocketTask&) { } >+ virtual void addWebSocketTask(WebSocketTask&) { } >+ > protected: > NetworkSession(NetworkProcess&, PAL::SessionID, const String& localStorageDirectory, SandboxExtension::Handle&); > >diff --git a/Source/WebKit/NetworkProcess/NetworkSocketChannel.cpp b/Source/WebKit/NetworkProcess/NetworkSocketChannel.cpp >new file mode 100644 >index 0000000000000000000000000000000000000000..9483adabbc1bf177a0be695cad311ab6494f9116 >--- /dev/null >+++ b/Source/WebKit/NetworkProcess/NetworkSocketChannel.cpp >@@ -0,0 +1,125 @@ >+/* >+ * Copyright (C) 2019 Apple Inc. All rights reserved. >+ * >+ * Redistribution and use in source and binary forms, with or without >+ * modification, are permitted provided that the following conditions >+ * are met: >+ * 1. Redistributions of source code must retain the above copyright >+ * notice, this list of conditions and the following disclaimer. >+ * 2. Redistributions in binary form must reproduce the above copyright >+ * notice, this list of conditions and the following disclaimer in the >+ * documentation and/or other materials provided with the distribution. >+ * >+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' >+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, >+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR >+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS >+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR >+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF >+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS >+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN >+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) >+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF >+ * THE POSSIBILITY OF SUCH DAMAGE. >+ */ >+ >+#include "config.h" >+#include "NetworkSocketChannel.h" >+ >+#include "DataReference.h" >+#include "NetworkConnectionToWebProcess.h" >+#include "NetworkProcess.h" >+#include "NetworkSession.h" >+#include "WebSocketChannelMessages.h" >+#include "WebSocketTask.h" >+ >+namespace WebKit { >+using namespace WebCore; >+ >+std::unique_ptr<NetworkSocketChannel> NetworkSocketChannel::create(NetworkConnectionToWebProcess& connection, PAL::SessionID sessionID, const ResourceRequest& request, const String& protocol, uint64_t identifier) >+{ >+ auto result = std::make_unique<NetworkSocketChannel>(connection, connection.networkProcess().networkSession(sessionID), request, protocol, identifier); >+ if (!result->m_socket) { >+ result->didClose(0, "Cannot create a web socket task"_s); >+ return nullptr; >+ } >+ return result; >+} >+ >+NetworkSocketChannel::NetworkSocketChannel(NetworkConnectionToWebProcess& connection, RefPtr<NetworkSession>&& session, const ResourceRequest& request, const String& protocol, uint64_t identifier) >+ : m_connectionToWebProcess(connection) >+ , m_identifier(identifier) >+ , m_session(WTFMove(session)) >+{ >+ if (!m_session) >+ return; >+ >+ m_socket = m_session->createWebSocketTask(*this, request, protocol); >+ >+ m_session->addWebSocketTask(*m_socket); >+ m_socket->resume(); >+} >+ >+NetworkSocketChannel::~NetworkSocketChannel() >+{ >+ if (!m_socket) >+ return; >+ >+ m_socket->cancel(); >+ m_session->removeWebSocketTask(*m_socket); >+} >+ >+void NetworkSocketChannel::sendString(const String& message, CompletionHandler<void()>&& callback) >+{ >+ m_socket->sendString(message, WTFMove(callback)); >+} >+ >+void NetworkSocketChannel::sendData(const IPC::DataReference& data, CompletionHandler<void()>&& callback) >+{ >+ m_socket->sendData(data, WTFMove(callback)); >+} >+ >+void NetworkSocketChannel::finishClosingIfPossible() >+{ >+ if (m_state == State::Open) { >+ m_state = State::Closing; >+ return; >+ } >+ ASSERT(m_state == State::Closing); >+ m_state = State::Closed; >+ m_connectionToWebProcess.removeSocketChannel(m_identifier); >+} >+ >+void NetworkSocketChannel::close(int32_t code, const String& reason) >+{ >+ m_socket->close(code, reason); >+ finishClosingIfPossible(); >+} >+ >+void NetworkSocketChannel::didConnect() >+{ >+ send(Messages::WebSocketChannel::DidConnect { }); >+} >+ >+void NetworkSocketChannel::didReceiveText(const String& text) >+{ >+ send(Messages::WebSocketChannel::DidReceiveText { text }); >+} >+ >+void NetworkSocketChannel::didReceiveBinaryData(const uint8_t* data, size_t length) >+{ >+ send(Messages::WebSocketChannel::DidReceiveBinaryData { { data, length } }); >+} >+ >+void NetworkSocketChannel::didClose(unsigned short code, const String& reason) >+{ >+ send(Messages::WebSocketChannel::DidClose { code, reason }); >+ finishClosingIfPossible(); >+} >+ >+IPC::Connection* NetworkSocketChannel::messageSenderConnection() const >+{ >+ return &m_connectionToWebProcess.connection(); >+} >+ >+} // namespace WebKit >diff --git a/Source/WebKit/NetworkProcess/NetworkSocketChannel.h b/Source/WebKit/NetworkProcess/NetworkSocketChannel.h >new file mode 100644 >index 0000000000000000000000000000000000000000..d07693745fb9709919ff0972fa8e0eeffd616f76 >--- /dev/null >+++ b/Source/WebKit/NetworkProcess/NetworkSocketChannel.h >@@ -0,0 +1,85 @@ >+/* >+ * Copyright (C) 2019 Apple Inc. All rights reserved. >+ * >+ * Redistribution and use in source and binary forms, with or without >+ * modification, are permitted provided that the following conditions >+ * are met: >+ * 1. Redistributions of source code must retain the above copyright >+ * notice, this list of conditions and the following disclaimer. >+ * 2. Redistributions in binary form must reproduce the above copyright >+ * notice, this list of conditions and the following disclaimer in the >+ * documentation and/or other materials provided with the distribution. >+ * >+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' >+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, >+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR >+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS >+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR >+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF >+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS >+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN >+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) >+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF >+ * THE POSSIBILITY OF SUCH DAMAGE. >+ */ >+ >+#pragma once >+ >+#include "MessageReceiver.h" >+#include "MessageSender.h" >+#include <pal/SessionID.h> >+#include <wtf/CompletionHandler.h> >+ >+namespace WebCore { >+class ResourceRequest; >+} >+ >+namespace IPC { >+class Connection; >+class Decoder; >+class DataReference; >+} >+ >+namespace WebKit { >+ >+class WebSocketTask; >+class NetworkConnectionToWebProcess; >+class NetworkProcess; >+class NetworkSession; >+ >+class NetworkSocketChannel : public IPC::MessageSender, public IPC::MessageReceiver { >+public: >+ static std::unique_ptr<NetworkSocketChannel> create(NetworkConnectionToWebProcess&, PAL::SessionID, const WebCore::ResourceRequest&, const String& protocol, uint64_t identifier); >+ >+ NetworkSocketChannel(NetworkConnectionToWebProcess&, RefPtr<NetworkSession>&&, const WebCore::ResourceRequest&, const String& protocol, uint64_t identifier); >+ ~NetworkSocketChannel(); >+ >+ void didReceiveMessage(IPC::Connection&, IPC::Decoder&); >+ >+ friend class WebSocketTask; >+ >+private: >+ void didConnect(); >+ void didReceiveText(const String&); >+ void didReceiveBinaryData(const uint8_t* data, size_t length); >+ void didClose(unsigned short code, const String& reason); >+ >+ void sendString(const String&, CompletionHandler<void()>&&); >+ void sendData(const IPC::DataReference&, CompletionHandler<void()>&&); >+ void close(int32_t code, const String& reason); >+ >+ IPC::Connection* messageSenderConnection() const final; >+ uint64_t messageSenderDestinationID() const final { return m_identifier; } >+ >+ void finishClosingIfPossible(); >+ >+ NetworkConnectionToWebProcess& m_connectionToWebProcess; >+ uint64_t m_identifier; >+ RefPtr<NetworkSession> m_session; >+ std::unique_ptr<WebSocketTask> m_socket; >+ >+ enum class State { Open, Closing, Closed }; >+ State m_state { State::Open }; >+}; >+ >+} // namespace WebKit >diff --git a/Source/WebKit/NetworkProcess/NetworkSocketChannel.messages.in b/Source/WebKit/NetworkProcess/NetworkSocketChannel.messages.in >new file mode 100644 >index 0000000000000000000000000000000000000000..7de834d625871094d596d8d82b5341803a614e51 >--- /dev/null >+++ b/Source/WebKit/NetworkProcess/NetworkSocketChannel.messages.in >@@ -0,0 +1,27 @@ >+# Copyright (C) 2019 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 -> NetworkSocketChannel { >+ SendString(String message) -> () Async >+ SendData(IPC::DataReference data) -> () Async >+ Close(int32_t code, String reason) >+} >diff --git a/Source/WebKit/NetworkProcess/WebSocketTask.h b/Source/WebKit/NetworkProcess/WebSocketTask.h >new file mode 100644 >index 0000000000000000000000000000000000000000..939f601860d1b1b416b003adc1ba09eb0fb2c42d >--- /dev/null >+++ b/Source/WebKit/NetworkProcess/WebSocketTask.h >@@ -0,0 +1,48 @@ >+/* >+ * Copyright (C) 2019 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 >+ >+#if PLATFORM(COCOA) && HAVE(NSURLSESSION_WEBSOCKET) >+#include "WebSocketTaskCocoa.h" >+#else >+ >+namespace WebKit { >+ >+class WebSocketTask { >+public: >+ typedef uint64_t TaskIdentifier; >+ >+ void sendString(const String&, CompletionHandler<void()>&&) { } >+ void sendData(const IPC::DataReference&, CompletionHandler<void()>&&) { } >+ void close(int32_t code, const String& reason) { } >+ >+ void cancel() { } >+ void resume() { } >+}; >+ >+} // namespace WebKit >+ >+#endif >diff --git a/Source/WebKit/NetworkProcess/cocoa/NetworkSessionCocoa.h b/Source/WebKit/NetworkProcess/cocoa/NetworkSessionCocoa.h >index 2c31d878499bceca19112af3a61a6697b0a2292f..b2d752a4ad0ea9f65212e640ea5357572776edaf 100644 >--- a/Source/WebKit/NetworkProcess/cocoa/NetworkSessionCocoa.h >+++ b/Source/WebKit/NetworkProcess/cocoa/NetworkSessionCocoa.h >@@ -31,10 +31,12 @@ OBJC_CLASS NSURLSession; > OBJC_CLASS NSURLSessionDownloadTask; > OBJC_CLASS NSOperationQueue; > OBJC_CLASS WKNetworkSessionDelegate; >+OBJC_CLASS WKNetworkSessionWebSocketDelegate; > > #include "DownloadID.h" > #include "NetworkDataTaskCocoa.h" > #include "NetworkSession.h" >+#include "WebSocketTask.h" > #include <WebCore/NetworkLoadMetrics.h> > #include <wtf/HashMap.h> > >@@ -62,6 +64,8 @@ public: > NetworkDataTaskCocoa* dataTaskForIdentifier(NetworkDataTaskCocoa::TaskIdentifier, WebCore::StoredCredentialsPolicy); > NSURLSessionDownloadTask* downloadTaskWithResumeData(NSData*); > >+ WebSocketTask* webSocketDataTaskForIdentifier(WebSocketTask::TaskIdentifier); >+ > void addDownloadID(NetworkDataTaskCocoa::TaskIdentifier, DownloadID); > DownloadID downloadID(NetworkDataTaskCocoa::TaskIdentifier); > DownloadID takeDownloadID(NetworkDataTaskCocoa::TaskIdentifier); >@@ -82,10 +86,19 @@ private: > bool shouldLogCookieInformation() const override { return m_shouldLogCookieInformation; } > Seconds loadThrottleLatency() const override { return m_loadThrottleLatency; } > >+#if HAVE(NSURLSESSION_WEBSOCKET) >+ std::unique_ptr<WebSocketTask> createWebSocketTask(NetworkSocketChannel&, const WebCore::ResourceRequest&, const String& protocol) final; >+ void addWebSocketTask(WebSocketTask&) final; >+ void removeWebSocketTask(WebSocketTask&) final; >+#endif >+ > HashMap<NetworkDataTaskCocoa::TaskIdentifier, NetworkDataTaskCocoa*> m_dataTaskMapWithCredentials; > HashMap<NetworkDataTaskCocoa::TaskIdentifier, NetworkDataTaskCocoa*> m_dataTaskMapWithoutState; > HashMap<NetworkDataTaskCocoa::TaskIdentifier, NetworkDataTaskCocoa*> m_dataTaskMapEphemeralStatelessCookieless; > HashMap<NetworkDataTaskCocoa::TaskIdentifier, DownloadID> m_downloadMap; >+#if HAVE(NSURLSESSION_WEBSOCKET) >+ HashMap<NetworkDataTaskCocoa::TaskIdentifier, WebSocketTask*> m_webSocketDataTaskMap; >+#endif > > RetainPtr<NSURLSession> m_sessionWithCredentialStorage; > RetainPtr<WKNetworkSessionDelegate> m_sessionWithCredentialStorageDelegate; >diff --git a/Source/WebKit/NetworkProcess/cocoa/NetworkSessionCocoa.mm b/Source/WebKit/NetworkProcess/cocoa/NetworkSessionCocoa.mm >index 5de9e6745cf4ba62b5e428ea4504584c52bd8869..2b4ae21a14804454e23fb7f24521481d0d8b069a 100644 >--- a/Source/WebKit/NetworkProcess/cocoa/NetworkSessionCocoa.mm >+++ b/Source/WebKit/NetworkProcess/cocoa/NetworkSessionCocoa.mm >@@ -35,6 +35,7 @@ > #import "NetworkLoad.h" > #import "NetworkProcess.h" > #import "NetworkSessionCreationParameters.h" >+#import "WebSocketTask.h" > #import <Foundation/NSURLSession.h> > #import <WebCore/Credential.h> > #import <WebCore/FormDataStreamMac.h> >@@ -323,7 +324,11 @@ static String stringForSSLCipher(SSLCipherSuite cipher) > } > #endif > >-@interface WKNetworkSessionDelegate : NSObject <NSURLSessionDataDelegate> { >+@interface WKNetworkSessionDelegate : NSObject <NSURLSessionDataDelegate >+#if HAVE(NSURLSESSION_WEBSOCKET) >+ , NSURLSessionWebSocketDelegate >+#endif >+> { > RefPtr<WebKit::NetworkSessionCocoa> _session; > bool _withCredentials; > } >@@ -807,6 +812,34 @@ - (void)URLSession:(NSURLSession *)session dataTask:(NSURLSessionDataTask *)data > } > } > >+#if HAVE(NSURLSESSION_WEBSOCKET) >+- (WebSocketTask*)existingWebSocketTask:(NSURLSessionWebSocketTask *)task >+{ >+ if (!_session) >+ return nullptr; >+ >+ if (!task) >+ return nullptr; >+ >+ return _session->webSocketDataTaskForIdentifier(task.taskIdentifier); >+} >+ >+ >+- (void)URLSession:(NSURLSession *)session webSocketTask:(NSURLSessionWebSocketTask *)task didOpenWithProtocol:(NSString *) protocol >+{ >+ if (auto* webSocketTask = [self existingWebSocketTask:task]) >+ webSocketTask->didConnect(); >+} >+ >+- (void)URLSession:(NSURLSession *)session webSocketTask:(NSURLSessionWebSocketTask *)task didCloseWithCode:(NSURLSessionWebSocketCloseCode)closeCode reason:(NSData *)reason >+{ >+ if (auto* webSocketTask = [self existingWebSocketTask:task]) { >+ auto reason = adoptNS([[NSString alloc] initWithData:[task closeReason] encoding:NSUTF8StringEncoding]); >+ webSocketTask->didClose(closeCode, reason.get()); >+ } >+} >+#endif >+ > @end > > namespace WebKit { >@@ -1136,6 +1169,14 @@ bool NetworkSessionCocoa::allowsSpecificHTTPSCertificateForHost(const WebCore::A > void NetworkSessionCocoa::continueDidReceiveChallenge(const WebCore::AuthenticationChallenge& challenge, NetworkDataTaskCocoa::TaskIdentifier taskIdentifier, NetworkDataTaskCocoa* networkDataTask, CompletionHandler<void(WebKit::AuthenticationChallengeDisposition, const WebCore::Credential&)>&& completionHandler) > { > if (!networkDataTask) { >+#if HAVE(NSURLSESSION_WEBSOCKET) >+ if (auto* webSocketTask = webSocketDataTaskForIdentifier(taskIdentifier)) { >+ // FIXME: Handle challenges for web socket. >+ completionHandler(AuthenticationChallengeDisposition::PerformDefaultHandling, { }); >+ return; >+ } >+#endif >+ > auto downloadID = this->downloadID(taskIdentifier); > if (downloadID.downloadID()) { > if (auto* download = networkProcess().downloadManager().download(downloadID)) { >@@ -1194,4 +1235,30 @@ DMFWebsitePolicyMonitor *NetworkSessionCocoa::deviceManagementPolicyMonitor() > #endif > } > >+#if HAVE(NSURLSESSION_WEBSOCKET) >+std::unique_ptr<WebSocketTask> NetworkSessionCocoa::createWebSocketTask(NetworkSocketChannel& channel, const WebCore::ResourceRequest& request, const String& protocol) >+{ >+ // FIXME: Use protocol. >+ RetainPtr<NSURLSessionWebSocketTask> task = [m_sessionWithCredentialStorage.get() webSocketTaskWithRequest: request.nsURLRequest(WebCore::HTTPBodyUpdatePolicy::DoNotUpdateHTTPBody)]; >+ return std::make_unique<WebSocketTask>(channel, WTFMove(task)); >+} >+ >+void NetworkSessionCocoa::addWebSocketTask(WebSocketTask& task) >+{ >+ ASSERT(!m_webSocketDataTaskMap.contains(task.identifier())); >+ m_webSocketDataTaskMap.add(task.identifier(), &task); >+} >+ >+void NetworkSessionCocoa::removeWebSocketTask(WebSocketTask& task) >+{ >+ ASSERT(m_webSocketDataTaskMap.contains(task.identifier())); >+ m_webSocketDataTaskMap.remove(task.identifier()); >+} >+ >+WebSocketTask* NetworkSessionCocoa::webSocketDataTaskForIdentifier(WebSocketTask::TaskIdentifier identifier) >+{ >+ return m_webSocketDataTaskMap.get(identifier); >+} >+ >+#endif > } >diff --git a/Source/WebKit/NetworkProcess/cocoa/WebSocketTaskCocoa.h b/Source/WebKit/NetworkProcess/cocoa/WebSocketTaskCocoa.h >new file mode 100644 >index 0000000000000000000000000000000000000000..852fe52a7210bebf33a0bfef231264ff0f6a2d1f >--- /dev/null >+++ b/Source/WebKit/NetworkProcess/cocoa/WebSocketTaskCocoa.h >@@ -0,0 +1,71 @@ >+/* >+ * Copyright (C) 2019 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 >+ >+#if HAVE(NSURLSESSION_WEBSOCKET) >+ >+#include <wtf/RetainPtr.h> >+#include <wtf/WeakPtr.h> >+ >+OBJC_CLASS NSURLSessionWebSocketTask; >+ >+namespace IPC { >+class DataReference; >+} >+ >+namespace WebKit { >+class NetworkSession; >+class NetworkSocketChannel; >+ >+class WebSocketTask : public CanMakeWeakPtr<WebSocketTask> { >+public: >+ WebSocketTask(NetworkSocketChannel&, RetainPtr<NSURLSessionWebSocketTask>&&); >+ ~WebSocketTask(); >+ >+ void sendString(const String&, CompletionHandler<void()>&&); >+ void sendData(const IPC::DataReference&, CompletionHandler<void()>&&); >+ void close(int32_t code, const String& reason); >+ >+ void didConnect(); >+ void didClose(unsigned short code, const String& reason); >+ >+ void cancel(); >+ void resume(); >+ >+ typedef uint64_t TaskIdentifier; >+ TaskIdentifier identifier() const; >+ >+private: >+ void readNextMessage(); >+ >+ NetworkSocketChannel& m_channel; >+ RetainPtr<NSURLSessionWebSocketTask> m_task; >+ bool m_receivedDidClose { false }; >+}; >+ >+} // namespace WebKit >+ >+#endif >diff --git a/Source/WebKit/NetworkProcess/cocoa/WebSocketTaskCocoa.mm b/Source/WebKit/NetworkProcess/cocoa/WebSocketTaskCocoa.mm >new file mode 100644 >index 0000000000000000000000000000000000000000..e1372594adde85edf5781ce4d40fc1ce39f69600 >--- /dev/null >+++ b/Source/WebKit/NetworkProcess/cocoa/WebSocketTaskCocoa.mm >@@ -0,0 +1,124 @@ >+/* >+ * Copyright (C) 2016-2018 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. >+ */ >+ >+#import "config.h" >+#import "WebSocketTaskCocoa.h" >+ >+#if HAVE(NSURLSESSION_WEBSOCKET) >+ >+#import "DataReference.h" >+#import "NetworkSocketChannel.h" >+#import <Foundation/NSURLSession.h> >+#import <wtf/BlockPtr.h> >+ >+namespace WebKit { >+ >+WebSocketTask::WebSocketTask(NetworkSocketChannel& channel, RetainPtr<NSURLSessionWebSocketTask>&& task) >+ : m_channel(channel) >+ , m_task(WTFMove(task)) >+{ >+ readNextMessage(); >+} >+ >+WebSocketTask::~WebSocketTask() >+{ >+} >+ >+void WebSocketTask::readNextMessage() >+{ >+ [m_task receiveMessageWithCompletionHandler: makeBlockPtr([this, weakThis = makeWeakPtr(this)](NSURLSessionWebSocketMessage* _Nullable message, NSError * _Nullable error) { >+ if (!weakThis) >+ return; >+ >+ if (error || !message) { >+ // FIXME: this is a workaround and we should instead expect a didClose call. >+ didClose(1000, "Unknown error"); >+ return; >+ } >+ if (message.type == NSURLSessionWebSocketMessageTypeString) >+ m_channel.didReceiveText(message.string); >+ else >+ m_channel.didReceiveBinaryData(static_cast<const uint8_t*>(message.data.bytes), message.data.length); >+ >+ readNextMessage(); >+ }).get()]; >+} >+ >+void WebSocketTask::cancel() >+{ >+ [m_task cancel]; >+} >+ >+void WebSocketTask::resume() >+{ >+ [m_task resume]; >+} >+ >+void WebSocketTask::didConnect() >+{ >+ m_channel.didConnect(); >+} >+ >+void WebSocketTask::didClose(unsigned short code, const String& reason) >+{ >+ if (m_receivedDidClose) >+ return; >+ >+ m_receivedDidClose = true; >+ m_channel.didClose(code, reason); >+} >+ >+void WebSocketTask::sendString(const String& text , CompletionHandler<void()>&& callback) >+{ >+ auto message = adoptNS([[NSURLSessionWebSocketMessage alloc] initWithString: text]); >+ [m_task sendMessage: message.get() completionHandler: makeBlockPtr([callback = WTFMove(callback)](NSError * _Nullable) mutable { >+ callback(); >+ }).get()]; >+} >+ >+void WebSocketTask::sendData(const IPC::DataReference& data, CompletionHandler<void()>&& callback) >+{ >+ auto nsData = adoptNS([[NSData alloc] initWithBytes:data.data() length:data.size()]); >+ auto message = adoptNS([[NSURLSessionWebSocketMessage alloc] initWithData: nsData.get()]); >+ [m_task sendMessage: message.get() completionHandler: makeBlockPtr([callback = WTFMove(callback)](NSError * _Nullable) mutable { >+ callback(); >+ }).get()]; >+} >+ >+void WebSocketTask::close(int32_t code, const String& reason) >+{ >+ NSURLSessionWebSocketCloseCode closeCode = code == WebSocketChannel::CloseEventCodeNotSpecified ? 1005 : code; >+ auto nsData = adoptNS([[NSData alloc] initWithBytes:reason.utf8().data() length:reason.sizeInBytes()]); >+ [m_task cancelWithCloseCode: closeCode reason: nsData.get()]; >+} >+ >+WebSocketTask::TaskIdentifier WebSocketTask::identifier() const >+{ >+ return [m_task taskIdentifier]; >+} >+ >+} >+ >+#endif >diff --git a/Source/WebKit/Shared/WebPreferences.yaml b/Source/WebKit/Shared/WebPreferences.yaml >index e2e9fe605e33bb5ff4b260aa831425722e3a053a..16ddc4f8c9bd83176659266a184409fa686fd16f 100644 >--- a/Source/WebKit/Shared/WebPreferences.yaml >+++ b/Source/WebKit/Shared/WebPreferences.yaml >@@ -1703,6 +1703,14 @@ LinkPreloadResponsiveImagesEnabled: > webcoreBinding: RuntimeEnabledFeatures > category: experimental > >+IsNSURLSessionWebSocketEnabled: >+ type: bool >+ defaultValue: false >+ humanReadableName: "NSURLSession WebSocket" >+ humanReadableDescription: "Use NSURLSession WebSocket API" >+ category: internal >+ webcoreBinding: RuntimeEnabledFeatures >+ > # Deprecated > > ICECandidateFilteringEnabled: >diff --git a/Source/WebKit/Sources.txt b/Source/WebKit/Sources.txt >index 75982f7268a9a6bd45936cd35471f21c43c3edfa..f082549d79514206037787c9e2fe8d5fe960dd8d 100644 >--- a/Source/WebKit/Sources.txt >+++ b/Source/WebKit/Sources.txt >@@ -39,6 +39,7 @@ NetworkProcess/NetworkResourceLoadMap.cpp > NetworkProcess/NetworkResourceLoader.cpp > NetworkProcess/NetworkSession.cpp > NetworkProcess/NetworkSessionCreationParameters.cpp >+NetworkProcess/NetworkSocketChannel.cpp > NetworkProcess/NetworkSocketStream.cpp > NetworkProcess/PingLoad.cpp > NetworkProcess/PreconnectTask.cpp >@@ -481,6 +482,8 @@ WebProcess/MediaStream/UserMediaPermissionRequestManager.cpp > WebProcess/Network/NetworkProcessConnection.cpp > WebProcess/Network/WebLoaderStrategy.cpp > WebProcess/Network/WebResourceLoader.cpp >+WebProcess/Network/WebSocketChannel.cpp >+WebProcess/Network/WebSocketChannelManager.cpp > WebProcess/Network/WebSocketProvider.cpp > WebProcess/Network/WebSocketStream.cpp > >diff --git a/Source/WebKit/WebKit.xcodeproj/project.pbxproj b/Source/WebKit/WebKit.xcodeproj/project.pbxproj >index 56e0df09cdfbfd85278fa06ce07f8fe8d3c2b6e0..0c0968b17adb61ba164ab8951d57b43a88692774 100644 >--- a/Source/WebKit/WebKit.xcodeproj/project.pbxproj >+++ b/Source/WebKit/WebKit.xcodeproj/project.pbxproj >@@ -777,6 +777,7 @@ > 31BA924E148831260062EDB5 /* WebNotificationManagerMessages.h in Headers */ = {isa = PBXBuildFile; fileRef = 31BA9249148830810062EDB5 /* WebNotificationManagerMessages.h */; }; > 31D5929F166E060000E6BF02 /* WebPlugInClient.h in Headers */ = {isa = PBXBuildFile; fileRef = 31D5929D166E060000E6BF02 /* WebPlugInClient.h */; }; > 31D755C11D91B81500843BD1 /* WKTextChecker.h in Headers */ = {isa = PBXBuildFile; fileRef = 314888FF1D91B11D00377042 /* WKTextChecker.h */; settings = {ATTRIBUTES = (Private, ); }; }; >+ 31F060E11654318500F3281C /* NetworkSocketChannelMessageReceiver.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 31F060DD1654317500F3281C /* NetworkSocketChannelMessageReceiver.cpp */; }; > 330934471315B9220097A7BC /* WebCookieManagerMessageReceiver.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 330934431315B9220097A7BC /* WebCookieManagerMessageReceiver.cpp */; }; > 330934481315B9220097A7BC /* WebCookieManagerMessages.h in Headers */ = {isa = PBXBuildFile; fileRef = 330934441315B9220097A7BC /* WebCookieManagerMessages.h */; }; > 330934491315B9220097A7BC /* WebCookieManagerProxyMessageReceiver.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 330934451315B9220097A7BC /* WebCookieManagerProxyMessageReceiver.cpp */; }; >@@ -872,6 +873,7 @@ > 4112EDE020E407A500BEA92A /* com.ftsafe.NPAPI-Core-Safe-SoftKeybaord.plugin.rfc1034identifier.sb in Copy Plug-in Sandbox Profiles */ = {isa = PBXBuildFile; fileRef = 4112EDD220E4077300BEA92A /* com.ftsafe.NPAPI-Core-Safe-SoftKeybaord.plugin.rfc1034identifier.sb */; }; > 411A8DDB20DDD1AC0060D34F /* WKMockMediaDevice.h in Headers */ = {isa = PBXBuildFile; fileRef = 411A8DD920DDB6050060D34F /* WKMockMediaDevice.h */; settings = {ATTRIBUTES = (Private, ); }; }; > 411B22641E371BA6004F7363 /* LibWebRTCNetwork.h in Headers */ = {isa = PBXBuildFile; fileRef = 411B22621E371244004F7363 /* LibWebRTCNetwork.h */; }; >+ 41287D4E225D1ECB009A3E26 /* WebSocketTaskCocoa.mm in Sources */ = {isa = PBXBuildFile; fileRef = 41287D4B225C05C4009A3E26 /* WebSocketTaskCocoa.mm */; }; > 413075AB1DE85F330039EC69 /* NetworkRTCSocket.h in Headers */ = {isa = PBXBuildFile; fileRef = 413075991DE84FB00039EC69 /* NetworkRTCSocket.h */; }; > 413075AC1DE85F370039EC69 /* NetworkRTCMonitor.h in Headers */ = {isa = PBXBuildFile; fileRef = 4130759B1DE84FB00039EC69 /* NetworkRTCMonitor.h */; }; > 413075AD1DE85F580039EC69 /* LibWebRTCSocket.h in Headers */ = {isa = PBXBuildFile; fileRef = 413075A01DE85EE70039EC69 /* LibWebRTCSocket.h */; }; >@@ -884,6 +886,9 @@ > 414DD37A20BF49A5006959FB /* com.cisco.webex.plugin.gpc64.sb in Copy Plug-in Sandbox Profiles */ = {isa = PBXBuildFile; fileRef = 414DD37820BF43EA006959FB /* com.cisco.webex.plugin.gpc64.sb */; }; > 414DEDD71F9EDDE50047C40D /* ServiceWorkerProcessProxy.h in Headers */ = {isa = PBXBuildFile; fileRef = 414DEDD51F9EDDDF0047C40D /* ServiceWorkerProcessProxy.h */; }; > 4157E4B020E2ECDF00A6C0D7 /* com.google.o1dbrowserplugin.sb in Copy Plug-in Sandbox Profiles */ = {isa = PBXBuildFile; fileRef = 4157E4AF20E2EC9800A6C0D7 /* com.google.o1dbrowserplugin.sb */; }; >+ 417915AF2256BB7500D6F97E /* WebSocketChannel.h in Headers */ = {isa = PBXBuildFile; fileRef = 417915AD2256BB7400D6F97E /* WebSocketChannel.h */; }; >+ 417915B12256C0D600D6F97E /* WebSocketChannelManager.h in Headers */ = {isa = PBXBuildFile; fileRef = 417915B02256C0D600D6F97E /* WebSocketChannelManager.h */; }; >+ 417915B92257046F00D6F97E /* NetworkSocketChannel.h in Headers */ = {isa = PBXBuildFile; fileRef = 417915B62257046E00D6F97E /* NetworkSocketChannel.h */; }; > 41897ED11F415D680016FA42 /* WebCacheStorageConnection.h in Headers */ = {isa = PBXBuildFile; fileRef = 41897ECD1F415D5C0016FA42 /* WebCacheStorageConnection.h */; }; > 41897ED81F415D8A0016FA42 /* CacheStorageEngine.h in Headers */ = {isa = PBXBuildFile; fileRef = 41897ED21F415D850016FA42 /* CacheStorageEngine.h */; }; > 41897EDA1F415D8A0016FA42 /* CacheStorageEngineConnection.h in Headers */ = {isa = PBXBuildFile; fileRef = 41897ED41F415D850016FA42 /* CacheStorageEngineConnection.h */; }; >@@ -893,6 +898,7 @@ > 41DC459C1E3DBB2800B11F51 /* LibWebRTCSocketClient.h in Headers */ = {isa = PBXBuildFile; fileRef = 41DC459A1E3DBB2400B11F51 /* LibWebRTCSocketClient.h */; }; > 41DC459F1E3DBDA500B11F51 /* WebRTCSocket.h in Headers */ = {isa = PBXBuildFile; fileRef = 41FAF5F31E3BFE7F001AE678 /* WebRTCSocket.h */; }; > 41DE7C6C22278F1E00532B65 /* ServiceWorkerFetchTask.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 41518536222704F6005430C6 /* ServiceWorkerFetchTask.cpp */; }; >+ 41F060E11654318500F3281C /* WebSocketChannelMessageReceiver.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 41F060DD1654317500F3281C /* WebSocketChannelMessageReceiver.cpp */; }; > 41FABD2A1F4DE001006A6C97 /* CacheStorageEngineCache.h in Headers */ = {isa = PBXBuildFile; fileRef = 41FABD281F4DDFDC006A6C97 /* CacheStorageEngineCache.h */; }; > 41FAF5F51E3C0649001AE678 /* WebRTCResolver.h in Headers */ = {isa = PBXBuildFile; fileRef = 41FAF5F41E3C0641001AE678 /* WebRTCResolver.h */; }; > 41FAF5F81E3C1021001AE678 /* LibWebRTCResolver.h in Headers */ = {isa = PBXBuildFile; fileRef = 41FAF5F61E3C0B47001AE678 /* LibWebRTCResolver.h */; }; >@@ -2931,6 +2937,7 @@ > 31D5929D166E060000E6BF02 /* WebPlugInClient.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WebPlugInClient.h; sourceTree = "<group>"; }; > 31EA25D0134F78B2005B1452 /* NativeWebMouseEventMac.mm */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.objcpp; path = NativeWebMouseEventMac.mm; sourceTree = "<group>"; }; > 31EA25D3134F78D6005B1452 /* NativeWebMouseEvent.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = NativeWebMouseEvent.h; sourceTree = "<group>"; }; >+ 31F060DD1654317500F3281C /* NetworkSocketChannelMessageReceiver.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; name = NetworkSocketChannelMessageReceiver.cpp; path = DerivedSources/WebKit2/NetworkSocketChannelMessageReceiver.cpp; sourceTree = BUILT_PRODUCTS_DIR; }; > 32DBCF5E0370ADEE00C91783 /* WebKit2Prefix.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WebKit2Prefix.h; sourceTree = "<group>"; }; > 330934431315B9220097A7BC /* WebCookieManagerMessageReceiver.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = WebCookieManagerMessageReceiver.cpp; path = DerivedSources/WebKit2/WebCookieManagerMessageReceiver.cpp; sourceTree = BUILT_PRODUCTS_DIR; }; > 330934441315B9220097A7BC /* WebCookieManagerMessages.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = WebCookieManagerMessages.h; path = DerivedSources/WebKit2/WebCookieManagerMessages.h; sourceTree = BUILT_PRODUCTS_DIR; }; >@@ -3071,6 +3078,9 @@ > 411A8DD920DDB6050060D34F /* WKMockMediaDevice.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WKMockMediaDevice.h; sourceTree = "<group>"; }; > 411A8DDA20DDB6050060D34F /* WKMockMediaDevice.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = WKMockMediaDevice.cpp; sourceTree = "<group>"; }; > 411B22621E371244004F7363 /* LibWebRTCNetwork.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = LibWebRTCNetwork.h; path = Network/webrtc/LibWebRTCNetwork.h; sourceTree = "<group>"; }; >+ 41287D4B225C05C4009A3E26 /* WebSocketTaskCocoa.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = WebSocketTaskCocoa.mm; sourceTree = "<group>"; }; >+ 41287D4C225C05C5009A3E26 /* WebSocketTaskCocoa.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WebSocketTaskCocoa.h; sourceTree = "<group>"; }; >+ 41287D4D225C161F009A3E26 /* WebSocketTask.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WebSocketTask.h; sourceTree = "<group>"; }; > 413075981DE84FB00039EC69 /* NetworkRTCSocket.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = NetworkRTCSocket.cpp; sourceTree = "<group>"; }; > 413075991DE84FB00039EC69 /* NetworkRTCSocket.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = NetworkRTCSocket.h; sourceTree = "<group>"; }; > 4130759A1DE84FB00039EC69 /* NetworkRTCMonitor.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = NetworkRTCMonitor.cpp; sourceTree = "<group>"; }; >@@ -3104,6 +3114,14 @@ > 4151E5C31FBB90A900E47E2D /* FormDataReference.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = FormDataReference.h; sourceTree = "<group>"; }; > 4157853021276B6F00DD3800 /* copy-webcontent-resources-to-private-headers.sh */ = {isa = PBXFileReference; lastKnownFileType = text.script.sh; path = "copy-webcontent-resources-to-private-headers.sh"; sourceTree = "<group>"; }; > 4157E4AF20E2EC9800A6C0D7 /* com.google.o1dbrowserplugin.sb */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = com.google.o1dbrowserplugin.sb; sourceTree = "<group>"; }; >+ 417915AC2256BB7400D6F97E /* WebSocketChannel.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = WebSocketChannel.cpp; path = Network/WebSocketChannel.cpp; sourceTree = "<group>"; }; >+ 417915AD2256BB7400D6F97E /* WebSocketChannel.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = WebSocketChannel.h; path = Network/WebSocketChannel.h; sourceTree = "<group>"; }; >+ 417915B02256C0D600D6F97E /* WebSocketChannelManager.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = WebSocketChannelManager.h; path = Network/WebSocketChannelManager.h; sourceTree = "<group>"; }; >+ 417915B22256C2E200D6F97E /* WebSocketChannelManager.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = WebSocketChannelManager.cpp; path = Network/WebSocketChannelManager.cpp; sourceTree = "<group>"; }; >+ 417915B42256D1A700D6F97E /* WebSocketChannel.messages.in */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; name = WebSocketChannel.messages.in; path = Network/WebSocketChannel.messages.in; sourceTree = "<group>"; }; >+ 417915B62257046E00D6F97E /* NetworkSocketChannel.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = NetworkSocketChannel.h; sourceTree = "<group>"; }; >+ 417915B72257046E00D6F97E /* NetworkSocketChannel.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = NetworkSocketChannel.cpp; sourceTree = "<group>"; }; >+ 417915B82257046E00D6F97E /* NetworkSocketChannel.messages.in */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = NetworkSocketChannel.messages.in; sourceTree = "<group>"; }; > 41897ECC1F415D5C0016FA42 /* WebCacheStorageProvider.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = WebCacheStorageProvider.cpp; sourceTree = "<group>"; }; > 41897ECD1F415D5C0016FA42 /* WebCacheStorageConnection.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = WebCacheStorageConnection.h; sourceTree = "<group>"; }; > 41897ECE1F415D5C0016FA42 /* WebCacheStorageConnection.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = WebCacheStorageConnection.cpp; sourceTree = "<group>"; }; >@@ -3132,6 +3150,7 @@ > 41DC459A1E3DBB2400B11F51 /* LibWebRTCSocketClient.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = LibWebRTCSocketClient.h; sourceTree = "<group>"; }; > 41DC459D1E3DBCF000B11F51 /* WebRTCSocket.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = WebRTCSocket.cpp; path = Network/webrtc/WebRTCSocket.cpp; sourceTree = "<group>"; }; > 41DC45A01E3DC53C00B11F51 /* WebRTCResolver.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = WebRTCResolver.cpp; path = Network/webrtc/WebRTCResolver.cpp; sourceTree = "<group>"; }; >+ 41F060DD1654317500F3281C /* WebSocketChannelMessageReceiver.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; name = WebSocketChannelMessageReceiver.cpp; path = DerivedSources/WebKit2/WebSocketChannelMessageReceiver.cpp; sourceTree = BUILT_PRODUCTS_DIR; }; > 41FABD281F4DDFDC006A6C97 /* CacheStorageEngineCache.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CacheStorageEngineCache.h; sourceTree = "<group>"; }; > 41FAF5F31E3BFE7F001AE678 /* WebRTCSocket.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = WebRTCSocket.h; path = Network/webrtc/WebRTCSocket.h; sourceTree = "<group>"; }; > 41FAF5F41E3C0641001AE678 /* WebRTCResolver.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = WebRTCResolver.h; path = Network/webrtc/WebRTCResolver.h; sourceTree = "<group>"; }; >@@ -6571,6 +6590,11 @@ > 510AFFB716542048001BA05E /* WebResourceLoader.cpp */, > 510AFFB816542048001BA05E /* WebResourceLoader.h */, > 510AFFCE16542CBD001BA05E /* WebResourceLoader.messages.in */, >+ 417915AC2256BB7400D6F97E /* WebSocketChannel.cpp */, >+ 417915AD2256BB7400D6F97E /* WebSocketChannel.h */, >+ 417915B42256D1A700D6F97E /* WebSocketChannel.messages.in */, >+ 417915B22256C2E200D6F97E /* WebSocketChannelManager.cpp */, >+ 417915B02256C0D600D6F97E /* WebSocketChannelManager.h */, > 5C7706731D111D8B0012700F /* WebSocketProvider.cpp */, > 5C7C88DC1D0F41A0009D2F6D /* WebSocketProvider.h */, > 5C0B177A1E7C884F00E9123C /* WebSocketStream.cpp */, >@@ -6640,6 +6664,9 @@ > 5C20CB9E1BB0DD1800895BB1 /* NetworkSession.h */, > 5C89DF5621AF61FF004645E8 /* NetworkSessionCreationParameters.cpp */, > 5C84CF901F96AC4E00B6705A /* NetworkSessionCreationParameters.h */, >+ 417915B72257046E00D6F97E /* NetworkSocketChannel.cpp */, >+ 417915B62257046E00D6F97E /* NetworkSocketChannel.h */, >+ 417915B82257046E00D6F97E /* NetworkSocketChannel.messages.in */, > 5C0B177D1E7C886700E9123C /* NetworkSocketStream.cpp */, > 5C0B177E1E7C886700E9123C /* NetworkSocketStream.h */, > 5C0B177F1E7C886700E9123C /* NetworkSocketStream.messages.in */, >@@ -6649,6 +6676,7 @@ > 83A0ED331F747CC7003299EB /* PreconnectTask.cpp */, > 83A0ED321F747CC6003299EB /* PreconnectTask.h */, > E1B78470163F24690007B692 /* RemoteNetworkingContext.h */, >+ 41287D4D225C161F009A3E26 /* WebSocketTask.h */, > ); > path = NetworkProcess; > sourceTree = "<group>"; >@@ -7156,6 +7184,8 @@ > 7EC4F0F918E4A945008056AF /* NetworkProcessCocoa.mm */, > 532159501DBAE6D70054AA3C /* NetworkSessionCocoa.h */, > 5C20CB9B1BB0DCD200895BB1 /* NetworkSessionCocoa.mm */, >+ 41287D4C225C05C5009A3E26 /* WebSocketTaskCocoa.h */, >+ 41287D4B225C05C4009A3E26 /* WebSocketTaskCocoa.mm */, > ); > path = cocoa; > sourceTree = "<group>"; >@@ -8614,6 +8644,7 @@ > 51F060DD1654317500F3281E /* NetworkRTCMonitorMessageReceiver.cpp */, > 51F060DD1654317500F3282E /* NetworkRTCProviderMessageReceiver.cpp */, > 51F060DD1654317500F3281D /* NetworkRTCSocketMessageReceiver.cpp */, >+ 31F060DD1654317500F3281C /* NetworkSocketChannelMessageReceiver.cpp */, > 5C0B17741E7C879C00E9123C /* NetworkSocketStreamMessageReceiver.cpp */, > 5C0B17751E7C879C00E9123C /* NetworkSocketStreamMessages.h */, > 1A2D8437127F65D5001EB962 /* NPObjectMessageReceiverMessageReceiver.cpp */, >@@ -8744,6 +8775,7 @@ > 51F060DD1654317500F3281F /* WebRTCMonitorMessageReceiver.cpp */, > 51F060DD1654317500F3282C /* WebRTCResolverMessageReceiver.cpp */, > 51F060DD1654317500F3281C /* WebRTCSocketMessageReceiver.cpp */, >+ 41F060DD1654317500F3281C /* WebSocketChannelMessageReceiver.cpp */, > 5C0B17761E7C879C00E9123C /* WebSocketStreamMessageReceiver.cpp */, > 5C0B17771E7C879C00E9123C /* WebSocketStreamMessages.h */, > 517A530E1F47A84300DCDC0A /* WebSWClientConnectionMessageReceiver.cpp */, >@@ -9398,6 +9430,7 @@ > 413075AB1DE85F330039EC69 /* NetworkRTCSocket.h in Headers */, > 5C20CBA01BB1ECD800895BB1 /* NetworkSession.h in Headers */, > 532159551DBAE7290054AA3C /* NetworkSessionCocoa.h in Headers */, >+ 417915B92257046F00D6F97E /* NetworkSocketChannel.h in Headers */, > 31A2EC5614899C0900810D71 /* NotificationPermissionRequest.h in Headers */, > 3131261F148FF82C00BA2A39 /* NotificationPermissionRequestManager.h in Headers */, > 31A2EC521489981900810D71 /* NotificationPermissionRequestManagerProxy.h in Headers */, >@@ -9787,6 +9820,8 @@ > F430E9422247335F005FE053 /* WebsiteMetaViewportPolicy.h in Headers */, > 0EDE85032004E75D00030560 /* WebsitePopUpPolicy.h in Headers */, > 71FB810B2260627E00323677 /* WebsiteSimulatedMouseEventsDispatchPolicy.h in Headers */, >+ 417915AF2256BB7500D6F97E /* WebSocketChannel.h in Headers */, >+ 417915B12256C0D600D6F97E /* WebSocketChannelManager.h in Headers */, > C149380922347104000CD707 /* WebSpeechSynthesisClient.h in Headers */, > 836034A01ACB34D600626549 /* WebSQLiteDatabaseTracker.h in Headers */, > 1A52C0F81A38CDC70016160A /* WebStorageNamespaceProvider.h in Headers */, >@@ -11028,6 +11063,7 @@ > 51F060E11654318500F3281E /* NetworkRTCMonitorMessageReceiver.cpp in Sources */, > 51F060E11654318500F3282E /* NetworkRTCProviderMessageReceiver.cpp in Sources */, > 51F060E11654318500F3281D /* NetworkRTCSocketMessageReceiver.cpp in Sources */, >+ 31F060E11654318500F3281C /* NetworkSocketChannelMessageReceiver.cpp in Sources */, > 5C0B17781E7C880E00E9123C /* NetworkSocketStreamMessageReceiver.cpp in Sources */, > 2D92A790212B6AD400F493FD /* NPIdentifierData.cpp in Sources */, > 2D913446212CF9F000128AFD /* NPJSObject.cpp in Sources */, >@@ -11313,7 +11349,9 @@ > 51F060E11654318500F3281F /* WebRTCMonitorMessageReceiver.cpp in Sources */, > 51F060E11654318500F3282C /* WebRTCResolverMessageReceiver.cpp in Sources */, > 51F060E11654318500F3281C /* WebRTCSocketMessageReceiver.cpp in Sources */, >+ 41F060E11654318500F3281C /* WebSocketChannelMessageReceiver.cpp in Sources */, > 5C0B17791E7C882100E9123C /* WebSocketStreamMessageReceiver.cpp in Sources */, >+ 41287D4E225D1ECB009A3E26 /* WebSocketTaskCocoa.mm in Sources */, > 517A530F1F47A86200DCDC0A /* WebSWClientConnectionMessageReceiver.cpp in Sources */, > 460F488F1F996F7100CF4B87 /* WebSWContextManagerConnectionMessageReceiver.cpp in Sources */, > 9356F2DF2152B72300E6D5DF /* WebSWOriginStore.cpp in Sources */, >diff --git a/Source/WebKit/WebProcess/Network/NetworkProcessConnection.cpp b/Source/WebKit/WebProcess/Network/NetworkProcessConnection.cpp >index 161f8da41fa86e611fd943107dfe6f63640c3e2e..0349ca3712c8db45536648cccf41ed57e90f3887 100644 >--- a/Source/WebKit/WebProcess/Network/NetworkProcessConnection.cpp >+++ b/Source/WebKit/WebProcess/Network/NetworkProcessConnection.cpp >@@ -51,6 +51,8 @@ > #include "WebSWContextManagerConnection.h" > #include "WebSWContextManagerConnectionMessages.h" > #include "WebServiceWorkerProvider.h" >+#include "WebSocketChannel.h" >+#include "WebSocketChannelMessages.h" > #include "WebSocketStream.h" > #include "WebSocketStreamMessages.h" > #include <WebCore/CachedResource.h> >@@ -88,6 +90,10 @@ void NetworkProcessConnection::didReceiveMessage(IPC::Connection& connection, IP > stream->didReceiveMessage(connection, decoder); > return; > } >+ if (decoder.messageReceiverName() == Messages::WebSocketChannel::messageReceiverName()) { >+ WebProcess::singleton().webSocketChannelManager().didReceiveMessage(connection, decoder); >+ return; >+ } > if (decoder.messageReceiverName() == Messages::WebPage::messageReceiverName()) { > if (auto* webPage = WebProcess::singleton().webPage(makeObjectIdentifier<PageIdentifierType>(decoder.destinationID()))) > webPage->didReceiveWebPageMessage(connection, decoder); >diff --git a/Source/WebKit/WebProcess/Network/WebSocketChannel.cpp b/Source/WebKit/WebProcess/Network/WebSocketChannel.cpp >new file mode 100644 >index 0000000000000000000000000000000000000000..6c9913cd366b2ea8efc641b5370fceb2bbf20395 >--- /dev/null >+++ b/Source/WebKit/WebProcess/Network/WebSocketChannel.cpp >@@ -0,0 +1,206 @@ >+/* >+ * Copyright (C) 2019 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 othe r materials provided with the distribution. >+ * >+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' >+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, >+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR >+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS >+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR >+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF >+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS >+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN >+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) >+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF >+ * THE POSSIBILITY OF SUCH DAMAGE. >+ */ >+ >+#include "config.h" >+#include "WebSocketChannel.h" >+ >+#include "DataReference.h" >+#include "NetworkConnectionToWebProcessMessages.h" >+#include "NetworkProcessConnection.h" >+#include "NetworkSocketChannelMessages.h" >+#include "WebCoreArgumentCoders.h" >+#include "WebProcess.h" >+#include <WebCore/Document.h> >+#include <WebCore/NotImplemented.h> >+#include <WebCore/WebSocketChannel.h> >+#include <WebCore/WebSocketChannelClient.h> >+#include <pal/SessionID.h> >+ >+namespace WebKit { >+ >+Ref<WebSocketChannel> WebSocketChannel::create(WebCore::Document& document, WebCore::WebSocketChannelClient& client) >+{ >+ return adoptRef(*new WebSocketChannel(document, client)); >+} >+ >+WebSocketChannel::WebSocketChannel(WebCore::Document& document, WebCore::WebSocketChannelClient& client) >+ : m_document(makeWeakPtr(document)) >+ , m_client(makeWeakPtr(client)) >+{ >+} >+ >+WebSocketChannel::~WebSocketChannel() >+{ >+} >+ >+IPC::Connection* WebSocketChannel::messageSenderConnection() const >+{ >+ return &WebProcess::singleton().ensureNetworkProcessConnection().connection(); >+} >+ >+uint64_t WebSocketChannel::messageSenderDestinationID() const >+{ >+ return identifier(); >+} >+ >+String WebSocketChannel::subprotocol() >+{ >+ // FIXME: support subprotocol. >+ return emptyString(); >+} >+ >+String WebSocketChannel::extensions() >+{ >+ // FIXME: support extensions. >+ return emptyString(); >+} >+ >+bool WebSocketChannel::connect(const URL& url, const String& protocol) >+{ >+ if (!m_document) >+ return false; >+ >+ auto request = webSocketConnectRequest(*m_document, url); >+ if (!request) >+ return false; >+ >+ if (request->url() != url && m_client) >+ m_client->didUpgradeURL(); >+ >+ MessageSender::send(Messages::NetworkConnectionToWebProcess::CreateSocketChannel { m_document->sessionID(), *request, protocol, identifier() }); >+ return true; >+} >+ >+WebSocketChannel::SendResult WebSocketChannel::send(const String& message) >+{ >+ auto byteLength = message.sizeInBytes(); >+ m_bufferedAmount += byteLength; >+ >+ CompletionHandler<void()> completionHandler = [this, protectedThis = makeRef(*this), byteLength] { >+ m_bufferedAmount -= byteLength; >+ if (m_client) >+ m_client->didUpdateBufferedAmount(m_bufferedAmount); >+ }; >+ sendWithAsyncReply(Messages::NetworkSocketChannel::SendString { message }, WTFMove(completionHandler)); >+ return SendSuccess; >+} >+ >+WebSocketChannel::SendResult WebSocketChannel::send(const JSC::ArrayBuffer& binaryData, unsigned byteOffset, unsigned byteLength) >+{ >+ m_bufferedAmount += byteLength; >+ if (m_client) >+ m_client->didUpdateBufferedAmount(m_bufferedAmount); >+ >+ CompletionHandler<void()> completionHandler = [this, protectedThis = makeRef(*this), byteLength] { >+ m_bufferedAmount -= byteLength; >+ if (m_client) >+ m_client->didUpdateBufferedAmount(m_bufferedAmount); >+ }; >+ sendWithAsyncReply(Messages::NetworkSocketChannel::SendData { IPC::DataReference { static_cast<const uint8_t*>(binaryData.data()) + byteOffset, byteLength } }, WTFMove(completionHandler)); >+ return SendSuccess; >+} >+ >+WebSocketChannel::SendResult WebSocketChannel::send(WebCore::Blob&) >+{ >+ notImplemented(); >+ return SendFail; >+} >+ >+unsigned WebSocketChannel::bufferedAmount() const >+{ >+ return m_bufferedAmount; >+} >+ >+void WebSocketChannel::close(int code, const String& reason) >+{ >+ m_isClosing = true; >+ if (m_client) >+ m_client->didStartClosingHandshake(); >+ >+ ASSERT(code >= 0 || code == WebCore::WebSocketChannel::CloseEventCodeNotSpecified); >+ >+ MessageSender::send(Messages::NetworkSocketChannel::Close { code, reason }); >+} >+ >+void WebSocketChannel::fail(const String& reason) >+{ >+ MessageSender::send(Messages::NetworkSocketChannel::Close { 0, reason }); >+} >+ >+void WebSocketChannel::disconnect() >+{ >+ MessageSender::send(Messages::NetworkSocketChannel::Close { 0, { } }); >+} >+ >+void WebSocketChannel::didConnect() >+{ >+ if (m_isClosing) >+ return; >+ >+ if (m_client) >+ m_client->didConnect(); >+} >+ >+void WebSocketChannel::didReceiveText(const String& message) >+{ >+ if (m_isClosing) >+ return; >+ >+ if (m_client) >+ m_client->didReceiveMessage(message); >+} >+ >+void WebSocketChannel::didReceiveBinaryData(const IPC::DataReference& data) >+{ >+ if (m_isClosing) >+ return; >+ >+ if (m_client) >+ m_client->didReceiveBinaryData(data.vector()); >+} >+ >+void WebSocketChannel::didClose(unsigned short code, const String& reason) >+{ >+ if (!m_client) >+ return; >+ >+ if (code == WebCore::WebSocketChannel::CloseEventCodeNormalClosure) >+ m_client->didStartClosingHandshake(); >+ >+ m_client->didClose(m_bufferedAmount, (m_isClosing || code == WebCore::WebSocketChannel::CloseEventCodeNormalClosure) ? WebCore::WebSocketChannelClient::ClosingHandshakeComplete : WebCore::WebSocketChannelClient::ClosingHandshakeIncomplete, code, reason); >+} >+ >+void WebSocketChannel::didFail() >+{ >+ if (m_client) >+ m_client->didReceiveMessageError(); >+} >+ >+void WebSocketChannel::networkProcessCrashed() >+{ >+ didFail(); >+} >+ >+} // namespace WebKit >diff --git a/Source/WebKit/WebProcess/Network/WebSocketChannel.h b/Source/WebKit/WebProcess/Network/WebSocketChannel.h >new file mode 100644 >index 0000000000000000000000000000000000000000..927dd5c81ad9240637ec66503a70fae6cb6409ad >--- /dev/null >+++ b/Source/WebKit/WebProcess/Network/WebSocketChannel.h >@@ -0,0 +1,91 @@ >+/* >+ * Copyright (C) 2019 Apple Inc. All rights reserved. >+ * >+ * Redistribution and use in source and binary forms, with or without >+ * modification, are permitted provided that the following conditions >+ * are met: >+ * 1. Redistributions of source code must retain the above copyright >+ * notice, this list of conditions and the following disclaimer. >+ * 2. Redistributions in binary form must reproduce the above copyright >+ * notice, this list of conditions and the following disclaimer in the >+ * documentation and/or other materials provided with the distribution. >+ * >+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' >+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, >+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR >+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS >+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR >+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF >+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS >+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN >+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) >+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF >+ * THE POSSIBILITY OF SUCH DAMAGE. >+ */ >+ >+#pragma once >+ >+#include "MessageReceiver.h" >+#include "MessageSender.h" >+#include <WebCore/ThreadableWebSocketChannel.h> >+#include <pal/SessionID.h> >+#include <wtf/Identified.h> >+#include <wtf/WeakPtr.h> >+ >+namespace IPC { >+class Connection; >+class Decoder; >+class DataReference; >+} >+ >+namespace WebKit { >+ >+class WebSocketChannel : public IPC::MessageSender, public IPC::MessageReceiver, public WebCore::ThreadableWebSocketChannel, public RefCounted<WebSocketChannel>, public Identified<WebSocketChannel> { >+public: >+ static Ref<WebSocketChannel> create(WebCore::Document&, WebCore::WebSocketChannelClient&); >+ ~WebSocketChannel(); >+ >+ void didReceiveMessage(IPC::Connection&, IPC::Decoder&); >+ >+ void networkProcessCrashed(); >+ void didFail(); >+ >+ using RefCounted<WebSocketChannel>::ref; >+ using RefCounted<WebSocketChannel>::deref; >+ >+private: >+ WebSocketChannel(WebCore::Document&, WebCore::WebSocketChannelClient&); >+ >+ // ThreadableWebSocketChannel >+ bool connect(const URL&, const String& protocol) final; >+ String subprotocol() final; >+ String extensions() final; >+ SendResult send(const String& message) final; >+ SendResult send(const JSC::ArrayBuffer&, unsigned byteOffset, unsigned byteLength) final; >+ SendResult send(WebCore::Blob&) final; >+ unsigned bufferedAmount() const final; >+ void close(int code, const String& reason) final; >+ void fail(const String& reason) final; >+ void disconnect() final; >+ void suspend() final { }; >+ void resume() final { }; >+ void refThreadableWebSocketChannel() final { ref(); } >+ void derefThreadableWebSocketChannel() final { deref(); } >+ >+ // Message receivers >+ void didConnect(); >+ void didReceiveText(const String&); >+ void didReceiveBinaryData(const IPC::DataReference&); >+ void didClose(unsigned short code, const String&); >+ >+ // MessageSender >+ IPC::Connection* messageSenderConnection() const final; >+ uint64_t messageSenderDestinationID() const final; >+ >+ WeakPtr<WebCore::Document> m_document; >+ WeakPtr<WebCore::WebSocketChannelClient> m_client; >+ size_t m_bufferedAmount { 0 }; >+ bool m_isClosing { false }; >+}; >+ >+} // namespace WebKit >diff --git a/Source/WebKit/WebProcess/Network/WebSocketChannel.messages.in b/Source/WebKit/WebProcess/Network/WebSocketChannel.messages.in >new file mode 100644 >index 0000000000000000000000000000000000000000..7ef413baa6077b49641895560253cf6b520b96d8 >--- /dev/null >+++ b/Source/WebKit/WebProcess/Network/WebSocketChannel.messages.in >@@ -0,0 +1,28 @@ >+# 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) A RISING IN ANY WAY OUT OF THE USE >+# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. >+ >+messages -> WebSocketChannel { >+ DidConnect() >+ DidClose(unsigned short code, String reason) >+ DidReceiveText(String message) >+ DidReceiveBinaryData(IPC::DataReference data) >+} >diff --git a/Source/WebKit/WebProcess/Network/WebSocketChannelManager.cpp b/Source/WebKit/WebProcess/Network/WebSocketChannelManager.cpp >new file mode 100644 >index 0000000000000000000000000000000000000000..942005b8ff4a616d2be363cabece7bee8958ed44 >--- /dev/null >+++ b/Source/WebKit/WebProcess/Network/WebSocketChannelManager.cpp >@@ -0,0 +1,52 @@ >+/* >+ * Copyright (C) 2019 Apple Inc. All rights reserved. >+ * >+ * Redistribution and use in source and binary forms, with or without >+ * modification, are permitted provided that the following conditions >+ * are met: >+ * 1. Redistributions of source code must retain the above copyright >+ * notice, this list of conditions and the following disclaimer. >+ * 2. Redistributions in binary form must reproduce the above copyright >+ * notice, this list of conditions and the following disclaimer in the >+ * documentation and/or other materials provided with the distribution. >+ * >+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' >+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, >+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR >+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS >+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR >+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF >+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS >+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN >+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) >+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF >+ * THE POSSIBILITY OF SUCH DAMAGE. >+ */ >+ >+#include "config.h" >+#include "WebSocketChannelManager.h" >+ >+namespace WebKit { >+ >+RefPtr<WebCore::ThreadableWebSocketChannel> WebSocketChannelManager::createWebSocketChannel(WebCore::Document& document, WebCore::WebSocketChannelClient& client) >+{ >+ auto channel = WebSocketChannel::create(document, client); >+ m_channels.add(channel->identifier(), channel.copyRef()); >+ return channel; >+} >+ >+void WebSocketChannelManager::networkProcessCrashed() >+{ >+ auto channels = WTFMove(m_channels); >+ for (auto& channel : channels.values()) >+ channel->networkProcessCrashed(); >+} >+ >+void WebSocketChannelManager::didReceiveMessage(IPC::Connection& connection, IPC::Decoder& decoder) >+{ >+ auto iterator = m_channels.find(decoder.destinationID()); >+ if (iterator != m_channels.end()) >+ iterator->value->didReceiveMessage(connection, decoder); >+} >+ >+} // namespace WebKit >diff --git a/Source/WebKit/WebProcess/Network/WebSocketChannelManager.h b/Source/WebKit/WebProcess/Network/WebSocketChannelManager.h >new file mode 100644 >index 0000000000000000000000000000000000000000..7dc04afcaff5fcdcc91cdd60612be43ad1f494ef >--- /dev/null >+++ b/Source/WebKit/WebProcess/Network/WebSocketChannelManager.h >@@ -0,0 +1,54 @@ >+/* >+ * Copyright (C) 2019 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 "WebSocketChannel.h" >+ >+namespace IPC { >+class Connection; >+class Decoder; >+} >+ >+namespace WebCore { >+class Document; >+class ThreadableWebSocketChannel; >+} >+ >+namespace WebKit { >+ >+class WebSocketChannelManager { >+public: >+ WebSocketChannelManager() = default; >+ RefPtr<WebCore::ThreadableWebSocketChannel> createWebSocketChannel(WebCore::Document&, WebCore::WebSocketChannelClient&); >+ >+ void networkProcessCrashed(); >+ void didReceiveMessage(IPC::Connection&, IPC::Decoder&); >+ >+private: >+ HashMap<uint64_t, Ref<WebSocketChannel>> m_channels; >+}; >+ >+} // namespace WebKit >diff --git a/Source/WebKit/WebProcess/Network/WebSocketProvider.cpp b/Source/WebKit/WebProcess/Network/WebSocketProvider.cpp >index 54709dbb90f6f0aa9e5cc7c5f411515e2b6b37af..1bc6941ecd816b9147a81acdae280159ebb67608 100644 >--- a/Source/WebKit/WebProcess/Network/WebSocketProvider.cpp >+++ b/Source/WebKit/WebProcess/Network/WebSocketProvider.cpp >@@ -41,4 +41,9 @@ Ref<SocketStreamHandle> WebSocketProvider::createSocketStreamHandle(const URL& u > return WebSocketStream::create(url, client, sessionID, credentialPartition); > } > >+RefPtr<WebCore::ThreadableWebSocketChannel> WebSocketProvider::createWebSocketChannel(Document& document, WebCore::WebSocketChannelClient& client) >+{ >+ return WebProcess::singleton().webSocketChannelManager().createWebSocketChannel(document, client); >+} >+ > } // namespace WebKit >diff --git a/Source/WebKit/WebProcess/Network/WebSocketProvider.h b/Source/WebKit/WebProcess/Network/WebSocketProvider.h >index 290b99c5ecc9bd2929a04a3de3b366d89507d3c5..73e4ce81f1d98911405e1fc488cc07889a2328c7 100644 >--- a/Source/WebKit/WebProcess/Network/WebSocketProvider.h >+++ b/Source/WebKit/WebProcess/Network/WebSocketProvider.h >@@ -33,6 +33,7 @@ class WebSocketProvider final : public WebCore::SocketProvider { > public: > static Ref<WebSocketProvider> create() { return adoptRef(*new WebSocketProvider); } > Ref<WebCore::SocketStreamHandle> createSocketStreamHandle(const URL&, WebCore::SocketStreamHandleClient&, PAL::SessionID, const String& credentialPartition, const WebCore::StorageSessionProvider*) final; >+ RefPtr<WebCore::ThreadableWebSocketChannel> createWebSocketChannel(WebCore::Document&, WebCore::WebSocketChannelClient&) final; > virtual ~WebSocketProvider() { } > }; > >diff --git a/Source/WebKit/WebProcess/Network/WebSocketStream.cpp b/Source/WebKit/WebProcess/Network/WebSocketStream.cpp >index 1fb6961fff0bad631de1092c04cf268e2c278c4c..06091f057ca26ccb3afc2655431f600aebd45051 100644 >--- a/Source/WebKit/WebProcess/Network/WebSocketStream.cpp >+++ b/Source/WebKit/WebProcess/Network/WebSocketStream.cpp >@@ -8,7 +8,7 @@ > * 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. >+ * documentation and/or othe r 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, >diff --git a/Source/WebKit/WebProcess/Network/WebSocketStream.messages.in b/Source/WebKit/WebProcess/Network/WebSocketStream.messages.in >index e7591770f333c3d522ed67e8d7e90918c680c649..fa44103de6100dfd039a3b61bde2c2e14a8b82e9 100644 >--- a/Source/WebKit/WebProcess/Network/WebSocketStream.messages.in >+++ b/Source/WebKit/WebProcess/Network/WebSocketStream.messages.in >@@ -1,4 +1,4 @@ >-# Copyright (C) 2017 Apple Inc. All rights reserved. >+# Copyright (C) 2019 Apple Inc. All rights reserved. > # > # Redistribution and use in source and binary forms, with or without > # modification, are permitted provided that the following conditions >diff --git a/Source/WebKit/WebProcess/WebCoreSupport/ios/WebPreviewLoaderClient.h b/Source/WebKit/WebProcess/WebCoreSupport/ios/WebPreviewLoaderClient.h >index be887ad8a7f0b657d1fa451d1833cf1cd44b5375..8a8a98474715cfe613020284e0d16c10d4ef5615 100644 >--- a/Source/WebKit/WebProcess/WebCoreSupport/ios/WebPreviewLoaderClient.h >+++ b/Source/WebKit/WebProcess/WebCoreSupport/ios/WebPreviewLoaderClient.h >@@ -26,6 +26,7 @@ > #pragma once > > #include "QuickLookDocumentData.h" >+#include <WebCore/PageIdentifier.h> > #include <WebCore/PreviewLoaderClient.h> > #include <wtf/text/WTFString.h> > >diff --git a/Source/WebKit/WebProcess/WebProcess.cpp b/Source/WebKit/WebProcess/WebProcess.cpp >index 6174b0a3bb0b374ae984d3ab1bd8bf2373bd57af..28055139782cb0c340b2011250b625deb8216329 100644 >--- a/Source/WebKit/WebProcess/WebProcess.cpp >+++ b/Source/WebKit/WebProcess/WebProcess.cpp >@@ -1316,6 +1316,7 @@ void WebProcess::networkProcessConnectionClosed(NetworkProcessConnection* connec > > m_webLoaderStrategy.networkProcessCrashed(); > WebSocketStream::networkProcessCrashed(); >+ m_webSocketChannelManager.networkProcessCrashed(); > > for (auto& page : m_pageMap.values()) { > page->stopAllURLSchemeTasks(); >diff --git a/Source/WebKit/WebProcess/WebProcess.h b/Source/WebKit/WebProcess/WebProcess.h >index 8b63f2947b573710df4b2a9fac934468bd24f2c2..a6444210deffe3d66ffaee7e905bdbf862a6c934 100644 >--- a/Source/WebKit/WebProcess/WebProcess.h >+++ b/Source/WebKit/WebProcess/WebProcess.h >@@ -38,6 +38,7 @@ > #include "WebInspectorInterruptDispatcher.h" > #include "WebProcessCreationParameters.h" > #include "WebSQLiteDatabaseTracker.h" >+#include "WebSocketChannelManager.h" > #include <WebCore/ActivityState.h> > #include <WebCore/PageIdentifier.h> > #include <WebCore/RegistrableDomain.h> >@@ -266,6 +267,7 @@ public: > WebAutomationSessionProxy* automationSessionProxy() { return m_automationSessionProxy.get(); } > > WebCacheStorageProvider& cacheStorageProvider() { return m_cacheStorageProvider.get(); } >+ WebSocketChannelManager& webSocketChannelManager() { return m_webSocketChannelManager; } > > #if PLATFORM(IOS_FAMILY) > void accessibilityProcessSuspendedNotification(bool); >@@ -499,6 +501,7 @@ private: > WebLoaderStrategy& m_webLoaderStrategy; > > Ref<WebCacheStorageProvider> m_cacheStorageProvider; >+ WebSocketChannelManager m_webSocketChannelManager; > > std::unique_ptr<LibWebRTCNetwork> m_libWebRTCNetwork; > >diff --git a/LayoutTests/imported/w3c/resources/import-expectations.json b/LayoutTests/imported/w3c/resources/import-expectations.json >index 270cbe18a435fe6f2550f6b5875428b3b0765b54..55435e9459573bdf5e015ec9735c8575755bcc82 100644 >--- a/LayoutTests/imported/w3c/resources/import-expectations.json >+++ b/LayoutTests/imported/w3c/resources/import-expectations.json >@@ -352,7 +352,8 @@ > "web-platform-tests/webmessaging/": "import", > "web-platform-tests/webrtc": "import", > "web-platform-tests/webrtc/legacy": "skip", >- "web-platform-tests/websockets": "skip", >+ "web-platform-tests/websocket": "import", >+ "web-platform-tests/websockets": "import", > "web-platform-tests/webstorage": "skip", > "web-platform-tests/webusb": "skip", > "web-platform-tests/webvr": "skip", >diff --git a/LayoutTests/imported/w3c/resources/resource-files.json b/LayoutTests/imported/w3c/resources/resource-files.json >index 1d4396ac1a398db5fe3c3257e073e130f5117af0..7127e22ed881f47bd9c67f50faf43e22a63f3401 100644 >--- a/LayoutTests/imported/w3c/resources/resource-files.json >+++ b/LayoutTests/imported/w3c/resources/resource-files.json >@@ -1139,6 +1139,13 @@ > "web-platform-tests/webmessaging/support/ChildWindowPostMessage.htm", > "web-platform-tests/webmessaging/without-ports/019-1.html", > "web-platform-tests/webmessaging/without-ports/020-1.html", >+ "web-platform-tests/websockets/multi-globals/support/incumbent.sub.html", >+ "web-platform-tests/websockets/multi-globals/support/relevant.html", >+ "web-platform-tests/websockets/unload-a-document/001-1.html", >+ "web-platform-tests/websockets/unload-a-document/001-2.html", >+ "web-platform-tests/websockets/unload-a-document/002-1.html", >+ "web-platform-tests/websockets/unload-a-document/002-2.html", >+ "web-platform-tests/websockets/unload-a-document/005-1.html", > "web-platform-tests/workers/data-url-shared-window.html", > "web-platform-tests/workers/non-automated/application-cache-dedicated.html", > "web-platform-tests/workers/non-automated/infinite-nested.html", >diff --git a/LayoutTests/tests-options.json b/LayoutTests/tests-options.json >index 63008c24dd8e77d3420039e925e4d99e86fc466a..2e7ec3e5506a4b79e7328b624db4baa3c1c40229 100644 >--- a/LayoutTests/tests-options.json >+++ b/LayoutTests/tests-options.json >@@ -1721,6 +1721,60 @@ > "imported/w3c/web-platform-tests/webrtc/RTCRtpSender-transport.https.html": [ > "slow" > ], >+ "imported/w3c/web-platform-tests/websockets/binary/002.html": [ >+ "slow" >+ ], >+ "imported/w3c/web-platform-tests/websockets/binary/004.html": [ >+ "slow" >+ ], >+ "imported/w3c/web-platform-tests/websockets/constructor/013.html": [ >+ "slow" >+ ], >+ "imported/w3c/web-platform-tests/websockets/constructor/014.html": [ >+ "slow" >+ ], >+ "imported/w3c/web-platform-tests/websockets/cookies/005.html": [ >+ "slow" >+ ], >+ "imported/w3c/web-platform-tests/websockets/cookies/007.html": [ >+ "slow" >+ ], >+ "imported/w3c/web-platform-tests/websockets/extended-payload-length.html": [ >+ "slow" >+ ], >+ "imported/w3c/web-platform-tests/websockets/interfaces/WebSocket/bufferedAmount/bufferedAmount-large.html": [ >+ "slow" >+ ], >+ "imported/w3c/web-platform-tests/websockets/interfaces/WebSocket/close/close-connecting.html": [ >+ "slow" >+ ], >+ "imported/w3c/web-platform-tests/websockets/interfaces/WebSocket/events/016.html": [ >+ "slow" >+ ], >+ "imported/w3c/web-platform-tests/websockets/interfaces/WebSocket/send/005.html": [ >+ "slow" >+ ], >+ "imported/w3c/web-platform-tests/websockets/interfaces/WebSocket/send/010.html": [ >+ "slow" >+ ], >+ "imported/w3c/web-platform-tests/websockets/keeping-connection-open/001.html": [ >+ "slow" >+ ], >+ "imported/w3c/web-platform-tests/websockets/opening-handshake/002.html": [ >+ "slow" >+ ], >+ "imported/w3c/web-platform-tests/websockets/opening-handshake/003.html": [ >+ "slow" >+ ], >+ "imported/w3c/web-platform-tests/websockets/unload-a-document/002.html": [ >+ "slow" >+ ], >+ "imported/w3c/web-platform-tests/websockets/unload-a-document/004.html": [ >+ "slow" >+ ], >+ "imported/w3c/web-platform-tests/websockets/unload-a-document/005.html": [ >+ "slow" >+ ], > "imported/w3c/web-platform-tests/xhr/progress-events-response-data-gzip.htm": [ > "slow" > ],
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Formatted Diff
|
Diff
Attachments on
bug 198568
:
371620
|
371622
|
371623
|
371630
|
371747
|
371753
|
371759
|
371760
|
371761
|
371762
|
371763
|
371770
|
371771
|
371774
|
371777
|
371789
|
371896
|
371997