diff --git a/Libraries/LibWeb/WebSockets/WebSocket.cpp b/Libraries/LibWeb/WebSockets/WebSocket.cpp index f555dc2e81f..25decfc1bc7 100644 --- a/Libraries/LibWeb/WebSockets/WebSocket.cpp +++ b/Libraries/LibWeb/WebSockets/WebSocket.cpp @@ -24,6 +24,7 @@ #include #include #include +#include #include #include #include @@ -97,11 +98,13 @@ WebIDL::ExceptionOr> WebSocket::construct_impl(JS::Realm& rea web_socket->set_url(*url_record); // 11. Let client be this’s relevant settings object. - auto& client = relevant_settings_object; + // 12. Run this step in parallel: + Platform::EventLoopPlugin::the().deferred_invoke(GC::create_function(vm.heap(), [web_socket, url_record, protocols_sequence = move(protocols_sequence)]() { + auto& client = HTML::relevant_settings_object(*web_socket); - // FIXME: 12. Run this step in parallel: - // 1. Establish a WebSocket connection given urlRecord, protocols, and client. [FETCH] - TRY_OR_THROW_OOM(vm, web_socket->establish_web_socket_connection(*url_record, protocols_sequence, client)); + // 1. Establish a WebSocket connection given urlRecord, protocols, and client. [FETCH] + (void)web_socket->establish_web_socket_connection(*url_record, protocols_sequence, client); + })); return web_socket; } @@ -119,7 +122,7 @@ void WebSocket::initialize(JS::Realm& realm) WEB_SET_PROTOTYPE_FOR_INTERFACE(WebSocket); } -ErrorOr WebSocket::establish_web_socket_connection(URL::URL& url_record, Vector& protocols, HTML::EnvironmentSettingsObject& client) +ErrorOr WebSocket::establish_web_socket_connection(URL::URL const& url_record, Vector const& protocols, HTML::EnvironmentSettingsObject& client) { // FIXME: Integrate properly with FETCH as per https://fetch.spec.whatwg.org/#websocket-opening-handshake diff --git a/Libraries/LibWeb/WebSockets/WebSocket.h b/Libraries/LibWeb/WebSockets/WebSocket.h index 48955fc3df9..d92f5573eaf 100644 --- a/Libraries/LibWeb/WebSockets/WebSocket.h +++ b/Libraries/LibWeb/WebSockets/WebSocket.h @@ -65,7 +65,7 @@ private: virtual void initialize(JS::Realm&) override; - ErrorOr establish_web_socket_connection(URL::URL& url_record, Vector& protocols, HTML::EnvironmentSettingsObject& client); + ErrorOr establish_web_socket_connection(URL::URL const& url_record, Vector const& protocols, HTML::EnvironmentSettingsObject& client); URL::URL m_url; String m_binary_type { "blob"_string };