mirror of
https://github.com/zebrajr/ladybird.git
synced 2025-12-06 00:19:53 +01:00
LibWeb: Allow WebSockets to be established within workers
Previously, we would crash when attempting to establish a web socket connection from inside a worker, as we were assuming that the ESO's global object was a `Window`.
This commit is contained in:
parent
8939ae8522
commit
0c0595bb31
|
|
@ -20,7 +20,7 @@
|
|||
#include <LibWeb/HTML/EventNames.h>
|
||||
#include <LibWeb/HTML/MessageEvent.h>
|
||||
#include <LibWeb/HTML/Origin.h>
|
||||
#include <LibWeb/HTML/Window.h>
|
||||
#include <LibWeb/HTML/WindowOrWorkerGlobalScope.h>
|
||||
#include <LibWeb/Loader/ResourceLoader.h>
|
||||
#include <LibWeb/WebIDL/AbstractOperations.h>
|
||||
#include <LibWeb/WebIDL/Buffers.h>
|
||||
|
|
@ -123,8 +123,9 @@ ErrorOr<void> WebSocket::establish_web_socket_connection(URL::URL& url_record, V
|
|||
{
|
||||
// FIXME: Integrate properly with FETCH as per https://fetch.spec.whatwg.org/#websocket-opening-handshake
|
||||
|
||||
auto& window = verify_cast<HTML::Window>(client.global_object());
|
||||
auto origin_string = window.associated_document().origin().serialize();
|
||||
auto* window_or_worker = dynamic_cast<HTML::WindowOrWorkerGlobalScopeMixin*>(&client.global_object());
|
||||
VERIFY(window_or_worker);
|
||||
auto origin_string = MUST(window_or_worker->origin()).to_byte_string();
|
||||
|
||||
Vector<ByteString> protcol_byte_strings;
|
||||
for (auto const& protocol : protocols)
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user