diff --git a/Userland/Libraries/LibWeb/HTML/WebSocket.cpp b/Userland/Libraries/LibWeb/HTML/WebSocket.cpp
index f20fe1a87e..2c79cf52db 100644
--- a/Userland/Libraries/LibWeb/HTML/WebSocket.cpp
+++ b/Userland/Libraries/LibWeb/HTML/WebSocket.cpp
@@ -6,6 +6,7 @@
#include
#include
+#include
#include
#include
#include
@@ -209,14 +210,27 @@ void WebSocket::on_message(ByteBuffer message, bool is_text)
return;
if (is_text) {
auto text_message = String(ReadonlyBytes(message));
- MessageEventInit event_init {};
+ MessageEventInit event_init;
event_init.data = JS::js_string(wrapper()->vm(), text_message);
event_init.origin = url();
dispatch_event(MessageEvent::create(EventNames::message, event_init));
return;
}
- // type indicates that the data is Binary and binaryType is "blob"
- // type indicates that the data is Binary and binaryType is "arraybuffer"
+
+ if (m_binary_type == "blob") {
+ // type indicates that the data is Binary and binaryType is "blob"
+ TODO();
+ } else if (m_binary_type == "arraybuffer") {
+ // type indicates that the data is Binary and binaryType is "arraybuffer"
+ auto& global_object = wrapper()->global_object();
+ MessageEventInit event_init;
+ event_init.data = JS::ArrayBuffer::create(global_object, message);
+ event_init.origin = url();
+ dispatch_event(MessageEvent::create(EventNames::message, event_init));
+ return;
+ }
+
+ dbgln("Unsupported WebSocket message type {}", m_binary_type);
TODO();
}