mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-06-02 08:22:55 +00: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
Notes:
github-actions[bot]
2024-09-23 12:50:06 +00:00
Author: https://github.com/tcl3
Commit: 0c0595bb31
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/1498
1 changed files with 4 additions and 3 deletions
|
@ -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…
Add table
Add a link
Reference in a new issue