aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com> 2022-06-17 04:10:21 -0700
committerGravatar Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com> 2022-06-17 04:10:21 -0700
commit5eaf6d713e8d65121d47874faea832058ac1abc1 (patch)
treeea57e9650499ef48e7d1a71911e9e59dd3876e1c
parentb4049016ca3517a2596acc8f574f52584e0cb241 (diff)
downloadbun-5eaf6d713e8d65121d47874faea832058ac1abc1.tar.gz
bun-5eaf6d713e8d65121d47874faea832058ac1abc1.tar.zst
bun-5eaf6d713e8d65121d47874faea832058ac1abc1.zip
Import most of `MessageEvent` from WebKit
-rw-r--r--src/javascript/jsc/bindings/ZigGlobalObject.cpp25
-rw-r--r--src/javascript/jsc/bindings/webcore/ActiveDOMObject.cpp195
-rw-r--r--src/javascript/jsc/bindings/webcore/ActiveDOMObject.h170
-rw-r--r--src/javascript/jsc/bindings/webcore/DOMClientIsoSubspaces.h2
-rw-r--r--src/javascript/jsc/bindings/webcore/DOMIsoSubspaces.h2
-rw-r--r--src/javascript/jsc/bindings/webcore/EventNames.h6
-rw-r--r--src/javascript/jsc/bindings/webcore/EventTargetFactory.cpp4
-rw-r--r--src/javascript/jsc/bindings/webcore/EventTargetHeaders.h4
-rw-r--r--src/javascript/jsc/bindings/webcore/JSMessageEvent.cpp520
-rw-r--r--src/javascript/jsc/bindings/webcore/JSMessageEvent.dep3
-rw-r--r--src/javascript/jsc/bindings/webcore/JSMessageEvent.h91
-rw-r--r--src/javascript/jsc/bindings/webcore/JSMessageEventCustom.cpp81
-rw-r--r--src/javascript/jsc/bindings/webcore/JSServiceWorker.h1
-rw-r--r--src/javascript/jsc/bindings/webcore/JSWindowProxy.h1
-rw-r--r--src/javascript/jsc/bindings/webcore/MessageEvent.cpp125
-rw-r--r--src/javascript/jsc/bindings/webcore/MessageEvent.h104
-rw-r--r--src/javascript/jsc/bindings/webcore/MessageEvent.idl59
-rw-r--r--src/javascript/jsc/bindings/webcore/TaskSource.h29
18 files changed, 1410 insertions, 12 deletions
diff --git a/src/javascript/jsc/bindings/ZigGlobalObject.cpp b/src/javascript/jsc/bindings/ZigGlobalObject.cpp
index 45a3aa729..6890c045b 100644
--- a/src/javascript/jsc/bindings/ZigGlobalObject.cpp
+++ b/src/javascript/jsc/bindings/ZigGlobalObject.cpp
@@ -82,6 +82,7 @@
#include "JSAbortController.h"
#include "JSEvent.h"
#include "JSErrorEvent.h"
+#include "JSCloseEvent.h"
#include "JSFetchHeaders.h"
#include "Process.h"
@@ -441,6 +442,17 @@ JSC_DEFINE_CUSTOM_GETTER(JSErrorEvent_getter,
WebCore::JSErrorEvent::getConstructor(JSC::getVM(lexicalGlobalObject), thisObject));
}
+JSC_DECLARE_CUSTOM_GETTER(JSCloseEvent_getter);
+
+JSC_DEFINE_CUSTOM_GETTER(JSCloseEvent_getter,
+ (JSC::JSGlobalObject * lexicalGlobalObject, JSC::EncodedJSValue thisValue,
+ JSC::PropertyName))
+{
+ Zig::GlobalObject* thisObject = JSC::jsCast<Zig::GlobalObject*>(lexicalGlobalObject);
+ return JSC::JSValue::encode(
+ WebCore::JSCloseEvent::getConstructor(JSC::getVM(lexicalGlobalObject), thisObject));
+}
+
JSC_DECLARE_CUSTOM_GETTER(JSEvent_getter);
JSC_DEFINE_CUSTOM_GETTER(JSEvent_getter,
@@ -1857,6 +1869,9 @@ void GlobalObject::addBuiltinGlobals(JSC::VM& vm)
putDirectCustomAccessor(vm, JSC::Identifier::fromString(vm, "ErrorEvent"_s), JSC::CustomGetterSetter::create(vm, JSErrorEvent_getter, nullptr),
JSC::PropertyAttribute::DontDelete | JSC::PropertyAttribute::ReadOnly);
+ putDirectCustomAccessor(vm, JSC::Identifier::fromString(vm, "CloseEvent"_s), JSC::CustomGetterSetter::create(vm, JSCloseEvent_getter, nullptr),
+ JSC::PropertyAttribute::DontDelete | JSC::PropertyAttribute::ReadOnly);
+
putDirectCustomAccessor(vm, JSC::Identifier::fromString(vm, "Buffer"_s), JSC::CustomGetterSetter::create(vm, JSBuffer_getter, nullptr),
JSC::PropertyAttribute::DontDelete | JSC::PropertyAttribute::ReadOnly);
putDirectCustomAccessor(vm, JSC::Identifier::fromString(vm, "TextEncoder"_s), JSC::CustomGetterSetter::create(vm, JSTextEncoder_getter, nullptr),
@@ -2016,11 +2031,13 @@ void GlobalObject::installAPIGlobals(JSClassRef* globals, int count, JSC::VM& vm
// JSC::PropertyAttribute::DontDelete | JSC::PropertyAttribute::ReadOnly);
extraStaticGlobals.releaseBuffer();
+}
- this->setRemoteDebuggingEnabled(true);
- // auto& server = Inspector::RemoteInspectorServer::singleton();
- // if (server.start("localhost", 9222)) {
- // }
+extern "C" bool JSC__JSGlobalObject__startRemoteInspector(JSC__JSGlobalObject* globalObject, unsigned char* host, uint16_t arg1)
+{
+ globalObject->setRemoteDebuggingEnabled(true);
+ auto& server = Inspector::RemoteInspectorServer::singleton();
+ return server.start(reinterpret_cast<const char*>(host), arg1);
}
template<typename Visitor>
diff --git a/src/javascript/jsc/bindings/webcore/ActiveDOMObject.cpp b/src/javascript/jsc/bindings/webcore/ActiveDOMObject.cpp
new file mode 100644
index 000000000..d2662f8e9
--- /dev/null
+++ b/src/javascript/jsc/bindings/webcore/ActiveDOMObject.cpp
@@ -0,0 +1,195 @@
+// /*
+// * Copyright (C) 2008 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. ``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
+// * 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 "ActiveDOMObject.h"
+
+// #include "Document.h"
+// #include "Event.h"
+// #include "EventLoop.h"
+// #include "ScriptExecutionContext.h"
+
+// namespace WebCore {
+
+// static inline ScriptExecutionContext* suitableScriptExecutionContext(ScriptExecutionContext* scriptExecutionContext)
+// {
+// // For detached documents, make sure we observe their context document instead.
+// // return is<Document>(scriptExecutionContext) ? &downcast<Document>(*scriptExecutionContext).contextDocument() : scriptExecutionContext;
+// return scriptExecutionContext;
+// }
+
+// inline ActiveDOMObject::ActiveDOMObject(ScriptExecutionContext* context, CheckedScriptExecutionContextType)
+// : ContextDestructionObserver(context)
+// {
+// // ASSERT(!is<Document>(context) || &downcast<Document>(context)->contextDocument() == downcast<Document>(context));
+// if (!context)
+// return;
+
+// ASSERT(context->isContextThread());
+// context->didCreateActiveDOMObject(*this);
+// }
+
+// ActiveDOMObject::ActiveDOMObject(ScriptExecutionContext* scriptExecutionContext)
+// : ActiveDOMObject(suitableScriptExecutionContext(scriptExecutionContext), CheckedScriptExecutionContext)
+// {
+// }
+
+// // ActiveDOMObject::ActiveDOMObject(Document* document)
+// // : ActiveDOMObject(document ? &document->contextDocument() : nullptr, CheckedScriptExecutionContext)
+// // {
+// // }
+
+// // ActiveDOMObject::ActiveDOMObject(Document& document)
+// // : ActiveDOMObject(&document.contextDocument(), CheckedScriptExecutionContext)
+// // {
+// // }
+
+// ActiveDOMObject::~ActiveDOMObject()
+// {
+// ASSERT(canCurrentThreadAccessThreadLocalData(m_creationThread));
+
+// // ActiveDOMObject may be inherited by a sub-class whose life-cycle
+// // exceeds that of the associated ScriptExecutionContext. In those cases,
+// // m_scriptExecutionContext would/should have been nullified by
+// // ContextDestructionObserver::contextDestroyed() (which we implement /
+// // inherit). Hence, we should ensure that this is not 0 before use it
+// // here.
+// auto* context = scriptExecutionContext();
+// if (!context)
+// return;
+
+// ASSERT(m_suspendIfNeededWasCalled);
+// ASSERT(context->isContextThread());
+// context->willDestroyActiveDOMObject(*this);
+// }
+
+// void ActiveDOMObject::suspendIfNeeded()
+// {
+// #if ASSERT_ENABLED
+// ASSERT(!m_suspendIfNeededWasCalled);
+// m_suspendIfNeededWasCalled = true;
+// #endif
+// if (auto* context = scriptExecutionContext())
+// context->suspendActiveDOMObjectIfNeeded(*this);
+// }
+
+// #if ASSERT_ENABLED
+
+// void ActiveDOMObject::assertSuspendIfNeededWasCalled() const
+// {
+// if (!m_suspendIfNeededWasCalled)
+// WTFLogAlways("Failed to call suspendIfNeeded() for %s", activeDOMObjectName());
+// ASSERT(m_suspendIfNeededWasCalled);
+// }
+
+// #endif // ASSERT_ENABLED
+
+// void ActiveDOMObject::suspend(ReasonForSuspension)
+// {
+// }
+
+// void ActiveDOMObject::resume()
+// {
+// }
+
+// void ActiveDOMObject::stop()
+// {
+// }
+
+// bool ActiveDOMObject::isContextStopped() const
+// {
+// return !scriptExecutionContext() || scriptExecutionContext()->activeDOMObjectsAreStopped();
+// }
+
+// bool ActiveDOMObject::isAllowedToRunScript() const
+// {
+// return scriptExecutionContext() && !scriptExecutionContext()->activeDOMObjectsAreStopped() && !scriptExecutionContext()->activeDOMObjectsAreSuspended();
+// }
+
+// void ActiveDOMObject::queueTaskInEventLoop(TaskSource source, Function<void()>&& function)
+// {
+// auto* context = scriptExecutionContext();
+// if (!context)
+// return;
+// context->eventLoop().queueTask(source, WTFMove(function));
+// }
+
+// class ActiveDOMObjectEventDispatchTask : public EventLoopTask {
+// public:
+// ActiveDOMObjectEventDispatchTask(TaskSource source, EventLoopTaskGroup& group, ActiveDOMObject& object, Function<void()>&& dispatchEvent)
+// : EventLoopTask(source, group)
+// , m_object(object)
+// , m_dispatchEvent(WTFMove(dispatchEvent))
+// {
+// ++m_object.m_pendingActivityInstanceCount;
+// }
+
+// ~ActiveDOMObjectEventDispatchTask()
+// {
+// ASSERT(m_object.m_pendingActivityInstanceCount);
+// --m_object.m_pendingActivityInstanceCount;
+// }
+
+// void execute() final
+// {
+// // If this task executes after the script execution context has been stopped, don't
+// // actually dispatch the event.
+// if (m_object.isAllowedToRunScript())
+// m_dispatchEvent();
+// }
+
+// private:
+// ActiveDOMObject& m_object;
+// Function<void()> m_dispatchEvent;
+// };
+
+// void ActiveDOMObject::queueTaskToDispatchEventInternal(EventTarget& target, TaskSource source, Ref<Event>&& event)
+// {
+// ASSERT(!event->target() || &target == event->target());
+// auto* context = scriptExecutionContext();
+// if (!context)
+// return;
+// auto& eventLoopTaskGroup = context->eventLoop();
+// auto task = makeUnique<ActiveDOMObjectEventDispatchTask>(source, eventLoopTaskGroup, *this, [target = Ref { target }, event = WTFMove(event)] {
+// target->dispatchEvent(event);
+// });
+// eventLoopTaskGroup.queueTask(WTFMove(task));
+// }
+
+// void ActiveDOMObject::queueCancellableTaskToDispatchEventInternal(EventTarget& target, TaskSource source, TaskCancellationGroup& cancellationGroup, Ref<Event>&& event)
+// {
+// ASSERT(!event->target() || &target == event->target());
+// auto* context = scriptExecutionContext();
+// if (!context)
+// return;
+// auto& eventLoopTaskGroup = context->eventLoop();
+// auto task = makeUnique<ActiveDOMObjectEventDispatchTask>(source, eventLoopTaskGroup, *this, CancellableTask(cancellationGroup, [target = Ref { target }, event = WTFMove(event)] {
+// target->dispatchEvent(event);
+// }));
+// eventLoopTaskGroup.queueTask(WTFMove(task));
+// }
+
+// } // namespace WebCore
diff --git a/src/javascript/jsc/bindings/webcore/ActiveDOMObject.h b/src/javascript/jsc/bindings/webcore/ActiveDOMObject.h
index e69de29bb..e483a46b7 100644
--- a/src/javascript/jsc/bindings/webcore/ActiveDOMObject.h
+++ b/src/javascript/jsc/bindings/webcore/ActiveDOMObject.h
@@ -0,0 +1,170 @@
+// /*
+// * Copyright (C) 2008 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. ``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
+// * 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 "ContextDestructionObserver.h"
+// #include "TaskSource.h"
+// #include <wtf/Assertions.h>
+// #include <wtf/CancellableTask.h>
+// #include <wtf/Forward.h>
+// #include <wtf/Function.h>
+// #include <wtf/RefCounted.h>
+// #include <wtf/Threading.h>
+
+// namespace WebCore {
+
+// class Document;
+// class Event;
+// class EventLoopTaskGroup;
+// class EventTarget;
+
+// enum class ReasonForSuspension {
+// JavaScriptDebuggerPaused,
+// WillDeferLoading,
+// BackForwardCache,
+// PageWillBeSuspended,
+// };
+
+// class WEBCORE_EXPORT ActiveDOMObject : public ContextDestructionObserver {
+// public:
+// // The suspendIfNeeded must be called exactly once after object construction to update
+// // the suspended state to match that of the ScriptExecutionContext.
+// void suspendIfNeeded();
+// void assertSuspendIfNeededWasCalled() const;
+
+// // This function is used by JS bindings to determine if the JS wrapper should be kept alive or not.
+// bool hasPendingActivity() const { return m_pendingActivityInstanceCount || virtualHasPendingActivity(); }
+
+// // However, the suspend function will sometimes be called even if canSuspendForDocumentSuspension() returns false.
+// // That happens in step-by-step JS debugging for example - in this case it would be incorrect
+// // to stop the object. Exact semantics of suspend is up to the object in cases like that.
+
+// virtual const char* activeDOMObjectName() const = 0;
+
+// // These functions must not have a side effect of creating or destroying
+// // any ActiveDOMObject. That means they must not result in calls to arbitrary JavaScript.
+// virtual void suspend(ReasonForSuspension);
+// virtual void resume();
+
+// // This function must not have a side effect of creating an ActiveDOMObject.
+// // That means it must not result in calls to arbitrary JavaScript.
+// // It can, however, have a side effect of deleting an ActiveDOMObject.
+// virtual void stop();
+
+// template<class T>
+// class PendingActivity : public RefCounted<PendingActivity<T>> {
+// public:
+// explicit PendingActivity(T& thisObject)
+// : m_thisObject(thisObject)
+// {
+// ++(m_thisObject->m_pendingActivityInstanceCount);
+// }
+
+// ~PendingActivity()
+// {
+// ASSERT(m_thisObject->m_pendingActivityInstanceCount > 0);
+// --(m_thisObject->m_pendingActivityInstanceCount);
+// }
+
+// private:
+// Ref<T> m_thisObject;
+// };
+
+// template<class T> Ref<PendingActivity<T>> makePendingActivity(T& thisObject)
+// {
+// ASSERT(&thisObject == this);
+// return adoptRef(*new PendingActivity<T>(thisObject));
+// }
+
+// bool isContextStopped() const;
+// bool isAllowedToRunScript() const;
+
+// template<typename T>
+// static void queueTaskKeepingObjectAlive(T& object, TaskSource source, Function<void ()>&& task)
+// {
+// object.queueTaskInEventLoop(source, [protectedObject = Ref { object }, activity = object.ActiveDOMObject::makePendingActivity(object), task = WTFMove(task)] () {
+// task();
+// });
+// }
+
+// template<typename T>
+// static void queueCancellableTaskKeepingObjectAlive(T& object, TaskSource source, TaskCancellationGroup& cancellationGroup, Function<void()>&& task)
+// {
+// CancellableTask cancellableTask(cancellationGroup, WTFMove(task));
+// object.queueTaskInEventLoop(source, [protectedObject = Ref { object }, activity = object.ActiveDOMObject::makePendingActivity(object), cancellableTask = WTFMove(cancellableTask)]() mutable {
+// cancellableTask();
+// });
+// }
+
+// template<typename EventTargetType>
+// static void queueTaskToDispatchEvent(EventTargetType& target, TaskSource source, Ref<Event>&& event)
+// {
+// target.queueTaskToDispatchEventInternal(target, source, WTFMove(event));
+// }
+
+// template<typename EventTargetType>
+// static void queueCancellableTaskToDispatchEvent(EventTargetType& target, TaskSource source, TaskCancellationGroup& cancellationGroup, Ref<Event>&& event)
+// {
+// target.queueCancellableTaskToDispatchEventInternal(target, source, cancellationGroup, WTFMove(event));
+// }
+
+// protected:
+// explicit ActiveDOMObject(ScriptExecutionContext*);
+// explicit ActiveDOMObject(Document*);
+// explicit ActiveDOMObject(Document&);
+// virtual ~ActiveDOMObject();
+
+// private:
+// enum CheckedScriptExecutionContextType { CheckedScriptExecutionContext };
+// ActiveDOMObject(ScriptExecutionContext*, CheckedScriptExecutionContextType);
+
+// // This is used by subclasses to indicate that they have pending activity, meaning that they would
+// // like the JS wrapper to stay alive (because they may still fire JS events).
+// virtual bool virtualHasPendingActivity() const { return false; }
+
+// void queueTaskInEventLoop(TaskSource, Function<void ()>&&);
+// void queueTaskToDispatchEventInternal(EventTarget&, TaskSource, Ref<Event>&&);
+// void queueCancellableTaskToDispatchEventInternal(EventTarget&, TaskSource, TaskCancellationGroup&, Ref<Event>&&);
+
+// uint64_t m_pendingActivityInstanceCount { 0 };
+// #if ASSERT_ENABLED
+// bool m_suspendIfNeededWasCalled { false };
+// Ref<Thread> m_creationThread { Thread::current() };
+// #endif
+
+// friend class ActiveDOMObjectEventDispatchTask;
+// };
+
+// #if !ASSERT_ENABLED
+
+// inline void ActiveDOMObject::assertSuspendIfNeededWasCalled() const
+// {
+// }
+
+// #endif
+
+// } // namespace WebCore
diff --git a/src/javascript/jsc/bindings/webcore/DOMClientIsoSubspaces.h b/src/javascript/jsc/bindings/webcore/DOMClientIsoSubspaces.h
index d48ff8060..b437e5879 100644
--- a/src/javascript/jsc/bindings/webcore/DOMClientIsoSubspaces.h
+++ b/src/javascript/jsc/bindings/webcore/DOMClientIsoSubspaces.h
@@ -427,7 +427,7 @@ public:
// std::unique_ptr<GCClient::IsoSubspace> m_clientSubspaceForInputEvent;
// std::unique_ptr<GCClient::IsoSubspace> m_clientSubspaceForKeyboardEvent;
// std::unique_ptr<GCClient::IsoSubspace> m_clientSubspaceForMessageChannel;
- // std::unique_ptr<GCClient::IsoSubspace> m_clientSubspaceForMessageEvent;
+ std::unique_ptr<GCClient::IsoSubspace> m_clientSubspaceForMessageEvent;
// std::unique_ptr<GCClient::IsoSubspace> m_clientSubspaceForMessagePort;
// std::unique_ptr<GCClient::IsoSubspace> m_clientSubspaceForMouseEvent;
// std::unique_ptr<GCClient::IsoSubspace> m_clientSubspaceForMutationEvent;
diff --git a/src/javascript/jsc/bindings/webcore/DOMIsoSubspaces.h b/src/javascript/jsc/bindings/webcore/DOMIsoSubspaces.h
index 2bc1626bb..66b94e359 100644
--- a/src/javascript/jsc/bindings/webcore/DOMIsoSubspaces.h
+++ b/src/javascript/jsc/bindings/webcore/DOMIsoSubspaces.h
@@ -420,7 +420,7 @@ public:
// std::unique_ptr<IsoSubspace> m_subspaceForInputEvent;
// std::unique_ptr<IsoSubspace> m_subspaceForKeyboardEvent;
// std::unique_ptr<IsoSubspace> m_subspaceForMessageChannel;
- // std::unique_ptr<IsoSubspace> m_subspaceForMessageEvent;
+ std::unique_ptr<IsoSubspace> m_subspaceForMessageEvent;
// std::unique_ptr<IsoSubspace> m_subspaceForMessagePort;
// std::unique_ptr<IsoSubspace> m_subspaceForMouseEvent;
// std::unique_ptr<IsoSubspace> m_subspaceForMutationEvent;
diff --git a/src/javascript/jsc/bindings/webcore/EventNames.h b/src/javascript/jsc/bindings/webcore/EventNames.h
index 2f098998e..ebd451814 100644
--- a/src/javascript/jsc/bindings/webcore/EventNames.h
+++ b/src/javascript/jsc/bindings/webcore/EventNames.h
@@ -32,7 +32,10 @@ namespace WebCore {
#define DOM_EVENT_NAMES_FOR_EACH(macro) \
macro(error) \
macro(abort) \
- macro(close)
+ macro(close) \
+ macro(open) \
+ macro(message) \
+ macro(messageerror)
// macro(DOMActivate) \
// macro(DOMCharacterDataModified) \
@@ -186,7 +189,6 @@ namespace WebCore {
// macro(obsolete) \
// macro(offline) \
// macro(online) \
- // macro(open) \
// macro(orientationchange) \
// macro(overflowchanged) \
// macro(pagehide) \
diff --git a/src/javascript/jsc/bindings/webcore/EventTargetFactory.cpp b/src/javascript/jsc/bindings/webcore/EventTargetFactory.cpp
index 133ac17dc..b52214fe0 100644
--- a/src/javascript/jsc/bindings/webcore/EventTargetFactory.cpp
+++ b/src/javascript/jsc/bindings/webcore/EventTargetFactory.cpp
@@ -247,8 +247,8 @@ JSC::JSValue toJS(JSC::JSGlobalObject* state, JSDOMGlobalObject* globalObject, E
// case WebKitMediaKeySessionEventTargetInterfaceType:
// return toJS(state, globalObject, static_cast<WebKitMediaKeySession&>(impl));
// #endif
- // case WebSocketEventTargetInterfaceType:
- // return toJS(state, globalObject, static_cast<WebSocket&>(impl));
+ case WebSocketEventTargetInterfaceType:
+ return toJS(state, globalObject, static_cast<WebSocket&>(impl));
// #if ENABLE(WEBXR)
// case WebXRLayerEventTargetInterfaceType:
// return toJS(state, globalObject, static_cast<WebXRLayer&>(impl));
diff --git a/src/javascript/jsc/bindings/webcore/EventTargetHeaders.h b/src/javascript/jsc/bindings/webcore/EventTargetHeaders.h
index 785ededd5..ae6ee0d3f 100644
--- a/src/javascript/jsc/bindings/webcore/EventTargetHeaders.h
+++ b/src/javascript/jsc/bindings/webcore/EventTargetHeaders.h
@@ -236,8 +236,8 @@
// #include "JSWebKitMediaKeySession.h"
// #include "WebKitMediaKeySession.h"
// #endif
-// #include "WebSocket.h"
-// #include "JSWebSocket.h"
+#include "WebSocket.h"
+#include "JSWebSocket.h"
// #if ENABLE(WEBXR)
// #include "JSWebXRLayer.h"
// #include "WebXRLayer.h"
diff --git a/src/javascript/jsc/bindings/webcore/JSMessageEvent.cpp b/src/javascript/jsc/bindings/webcore/JSMessageEvent.cpp
new file mode 100644
index 000000000..4b951a5a6
--- /dev/null
+++ b/src/javascript/jsc/bindings/webcore/JSMessageEvent.cpp
@@ -0,0 +1,520 @@
+/*
+ This file is part of the WebKit open source project.
+ This file has been generated by generate-bindings.pl. DO NOT MODIFY!
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ along with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ Boston, MA 02110-1301, USA.
+*/
+
+#include "config.h"
+#include "JSMessageEvent.h"
+#include "JavaScriptCore/ObjectConstructor.h"
+#include "ActiveDOMObject.h"
+#include "ExtendedDOMClientIsoSubspaces.h"
+#include "ExtendedDOMIsoSubspaces.h"
+#include "IDLTypes.h"
+#include "JSDOMAttribute.h"
+#include "JSDOMBinding.h"
+#include "JSDOMConstructor.h"
+#include "JSDOMConvertAny.h"
+#include "JSDOMConvertBase.h"
+#include "JSDOMConvertBoolean.h"
+#include "JSDOMConvertInterface.h"
+#include "JSDOMConvertNullable.h"
+#include "JSDOMConvertSequences.h"
+#include "JSDOMConvertStrings.h"
+#include "JSDOMConvertUnion.h"
+#include "JSDOMExceptionHandling.h"
+#include "JSDOMGlobalObject.h"
+#include "JSDOMGlobalObjectInlines.h"
+#include "JSDOMOperation.h"
+#include "JSDOMWrapperCache.h"
+// #include "JSMessagePort.h"
+#include "JSServiceWorker.h"
+#include "JSWindowProxy.h"
+#include "ScriptExecutionContext.h"
+#include "WebCoreJSClientData.h"
+#include <JavaScriptCore/HeapAnalyzer.h>
+#include <JavaScriptCore/JSArray.h>
+#include <JavaScriptCore/JSCInlines.h>
+#include <JavaScriptCore/JSDestructibleObjectHeapCellType.h>
+#include <JavaScriptCore/SlotVisitorMacros.h>
+#include <JavaScriptCore/SubspaceInlines.h>
+#include <variant>
+#include <wtf/GetPtr.h>
+#include <wtf/PointerPreparations.h>
+#include <wtf/URL.h>
+
+namespace WebCore {
+using namespace JSC;
+
+template<> MessageEvent::Init convertDictionary<MessageEvent::Init>(JSGlobalObject& lexicalGlobalObject, JSValue value)
+{
+ VM& vm = JSC::getVM(&lexicalGlobalObject);
+ auto throwScope = DECLARE_THROW_SCOPE(vm);
+ bool isNullOrUndefined = value.isUndefinedOrNull();
+ auto* object = isNullOrUndefined ? nullptr : value.getObject();
+ if (UNLIKELY(!isNullOrUndefined && !object)) {
+ throwTypeError(&lexicalGlobalObject, throwScope);
+ return {};
+ }
+ MessageEvent::Init result;
+ JSValue bubblesValue;
+ if (isNullOrUndefined)
+ bubblesValue = jsUndefined();
+ else {
+ bubblesValue = object->get(&lexicalGlobalObject, Identifier::fromString(vm, "bubbles"_s));
+ RETURN_IF_EXCEPTION(throwScope, {});
+ }
+ if (!bubblesValue.isUndefined()) {
+ result.bubbles = convert<IDLBoolean>(lexicalGlobalObject, bubblesValue);
+ RETURN_IF_EXCEPTION(throwScope, {});
+ } else
+ result.bubbles = false;
+ JSValue cancelableValue;
+ if (isNullOrUndefined)
+ cancelableValue = jsUndefined();
+ else {
+ cancelableValue = object->get(&lexicalGlobalObject, Identifier::fromString(vm, "cancelable"_s));
+ RETURN_IF_EXCEPTION(throwScope, {});
+ }
+ if (!cancelableValue.isUndefined()) {
+ result.cancelable = convert<IDLBoolean>(lexicalGlobalObject, cancelableValue);
+ RETURN_IF_EXCEPTION(throwScope, {});
+ } else
+ result.cancelable = false;
+ JSValue composedValue;
+ if (isNullOrUndefined)
+ composedValue = jsUndefined();
+ else {
+ composedValue = object->get(&lexicalGlobalObject, Identifier::fromString(vm, "composed"_s));
+ RETURN_IF_EXCEPTION(throwScope, {});
+ }
+ if (!composedValue.isUndefined()) {
+ result.composed = convert<IDLBoolean>(lexicalGlobalObject, composedValue);
+ RETURN_IF_EXCEPTION(throwScope, {});
+ } else
+ result.composed = false;
+ JSValue dataValue;
+ if (isNullOrUndefined)
+ dataValue = jsUndefined();
+ else {
+ dataValue = object->get(&lexicalGlobalObject, Identifier::fromString(vm, "data"_s));
+ RETURN_IF_EXCEPTION(throwScope, {});
+ }
+ if (!dataValue.isUndefined()) {
+ result.data = convert<IDLAny>(lexicalGlobalObject, dataValue);
+ RETURN_IF_EXCEPTION(throwScope, {});
+ } else
+ result.data = jsNull();
+ JSValue lastEventIdValue;
+ if (isNullOrUndefined)
+ lastEventIdValue = jsUndefined();
+ else {
+ lastEventIdValue = object->get(&lexicalGlobalObject, Identifier::fromString(vm, "lastEventId"_s));
+ RETURN_IF_EXCEPTION(throwScope, {});
+ }
+ if (!lastEventIdValue.isUndefined()) {
+ result.lastEventId = convert<IDLDOMString>(lexicalGlobalObject, lastEventIdValue);
+ RETURN_IF_EXCEPTION(throwScope, {});
+ } else
+ result.lastEventId = emptyString();
+ JSValue originValue;
+ if (isNullOrUndefined)
+ originValue = jsUndefined();
+ else {
+ originValue = object->get(&lexicalGlobalObject, Identifier::fromString(vm, "origin"_s));
+ RETURN_IF_EXCEPTION(throwScope, {});
+ }
+ if (!originValue.isUndefined()) {
+ result.origin = convert<IDLUSVString>(lexicalGlobalObject, originValue);
+ RETURN_IF_EXCEPTION(throwScope, {});
+ } else
+ result.origin = emptyString();
+ // JSValue portsValue;
+ // if (isNullOrUndefined)
+ // portsValue = jsUndefined();
+ // else {
+ // portsValue = object->get(&lexicalGlobalObject, Identifier::fromString(vm, "ports"_s));
+ // RETURN_IF_EXCEPTION(throwScope, { });
+ // }
+ // if (!portsValue.isUndefined()) {
+ // result.ports = convert<IDLSequence<IDLInterface<MessagePort>>>(lexicalGlobalObject, portsValue);
+ // RETURN_IF_EXCEPTION(throwScope, { });
+ // } else
+ // result.ports = Converter<IDLSequence<IDLInterface<MessagePort>>>::ReturnType{ };
+ JSValue sourceValue;
+ if (isNullOrUndefined)
+ sourceValue = jsUndefined();
+ else {
+ sourceValue = object->get(&lexicalGlobalObject, Identifier::fromString(vm, "source"_s));
+ RETURN_IF_EXCEPTION(throwScope, {});
+ }
+ // if (!sourceValue.isUndefined()) {
+ // result.source = convert<IDLNullable<IDLUnion<IDLInterface<WindowProxy>, IDLInterface<MessagePort>, IDLInterface<ServiceWorker>>>>(lexicalGlobalObject, sourceValue);
+ // RETURN_IF_EXCEPTION(throwScope, {});
+ // } else
+ result.source = std::nullopt;
+ return result;
+}
+
+// Functions
+
+static JSC_DECLARE_HOST_FUNCTION(jsMessageEventPrototypeFunction_initMessageEvent);
+
+// Attributes
+
+static JSC_DECLARE_CUSTOM_GETTER(jsMessageEventConstructor);
+static JSC_DECLARE_CUSTOM_GETTER(jsMessageEvent_origin);
+static JSC_DECLARE_CUSTOM_GETTER(jsMessageEvent_lastEventId);
+static JSC_DECLARE_CUSTOM_GETTER(jsMessageEvent_source);
+static JSC_DECLARE_CUSTOM_GETTER(jsMessageEvent_data);
+static JSC_DECLARE_CUSTOM_GETTER(jsMessageEvent_ports);
+
+class JSMessageEventPrototype final : public JSC::JSNonFinalObject {
+public:
+ using Base = JSC::JSNonFinalObject;
+ static JSMessageEventPrototype* create(JSC::VM& vm, JSDOMGlobalObject* globalObject, JSC::Structure* structure)
+ {
+ JSMessageEventPrototype* ptr = new (NotNull, JSC::allocateCell<JSMessageEventPrototype>(vm)) JSMessageEventPrototype(vm, globalObject, structure);
+ ptr->finishCreation(vm);
+ return ptr;
+ }
+
+ DECLARE_INFO;
+ template<typename CellType, JSC::SubspaceAccess>
+ static JSC::GCClient::IsoSubspace* subspaceFor(JSC::VM& vm)
+ {
+ STATIC_ASSERT_ISO_SUBSPACE_SHARABLE(JSMessageEventPrototype, Base);
+ return &vm.plainObjectSpace();
+ }
+ static JSC::Structure* createStructure(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::JSValue prototype)
+ {
+ return JSC::Structure::create(vm, globalObject, prototype, JSC::TypeInfo(JSC::ObjectType, StructureFlags), info());
+ }
+
+private:
+ JSMessageEventPrototype(JSC::VM& vm, JSC::JSGlobalObject*, JSC::Structure* structure)
+ : JSC::JSNonFinalObject(vm, structure)
+ {
+ }
+
+ void finishCreation(JSC::VM&);
+};
+STATIC_ASSERT_ISO_SUBSPACE_SHARABLE(JSMessageEventPrototype, JSMessageEventPrototype::Base);
+
+using JSMessageEventDOMConstructor = JSDOMConstructor<JSMessageEvent>;
+
+template<> EncodedJSValue JSC_HOST_CALL_ATTRIBUTES JSMessageEventDOMConstructor::construct(JSGlobalObject* lexicalGlobalObject, CallFrame* callFrame)
+{
+ VM& vm = lexicalGlobalObject->vm();
+ auto throwScope = DECLARE_THROW_SCOPE(vm);
+ auto* castedThis = jsCast<JSMessageEventDOMConstructor*>(callFrame->jsCallee());
+ ASSERT(castedThis);
+ if (UNLIKELY(callFrame->argumentCount() < 1))
+ return throwVMError(lexicalGlobalObject, throwScope, createNotEnoughArgumentsError(lexicalGlobalObject));
+ EnsureStillAliveScope argument0 = callFrame->uncheckedArgument(0);
+ auto type = convert<IDLAtomStringAdaptor<IDLDOMString>>(*lexicalGlobalObject, argument0.value());
+ RETURN_IF_EXCEPTION(throwScope, encodedJSValue());
+ EnsureStillAliveScope argument1 = callFrame->argument(1);
+ auto eventInitDict = convert<IDLDictionary<MessageEvent::Init>>(*lexicalGlobalObject, argument1.value());
+ RETURN_IF_EXCEPTION(throwScope, encodedJSValue());
+ auto object = MessageEvent::create(WTFMove(type), WTFMove(eventInitDict));
+ if constexpr (IsExceptionOr<decltype(object)>)
+ RETURN_IF_EXCEPTION(throwScope, {});
+ static_assert(TypeOrExceptionOrUnderlyingType<decltype(object)>::isRef);
+ auto jsValue = toJSNewlyCreated<IDLInterface<MessageEvent>>(*lexicalGlobalObject, *castedThis->globalObject(), throwScope, WTFMove(object));
+ if constexpr (IsExceptionOr<decltype(object)>)
+ RETURN_IF_EXCEPTION(throwScope, {});
+ setSubclassStructureIfNeeded<MessageEvent>(lexicalGlobalObject, callFrame, asObject(jsValue));
+ RETURN_IF_EXCEPTION(throwScope, {});
+ return JSValue::encode(jsValue);
+}
+JSC_ANNOTATE_HOST_FUNCTION(JSMessageEventDOMConstructorConstruct, JSMessageEventDOMConstructor::construct);
+
+template<> const ClassInfo JSMessageEventDOMConstructor::s_info = { "MessageEvent"_s, &Base::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(JSMessageEventDOMConstructor) };
+
+template<> JSValue JSMessageEventDOMConstructor::prototypeForStructure(JSC::VM& vm, const JSDOMGlobalObject& globalObject)
+{
+ return JSEvent::getConstructor(vm, &globalObject);
+}
+
+template<> void JSMessageEventDOMConstructor::initializeProperties(VM& vm, JSDOMGlobalObject& globalObject)
+{
+ putDirect(vm, vm.propertyNames->length, jsNumber(1), JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::DontEnum);
+ JSString* nameString = jsNontrivialString(vm, "MessageEvent"_s);
+ m_originalName.set(vm, this, nameString);
+ putDirect(vm, vm.propertyNames->name, nameString, JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::DontEnum);
+ putDirect(vm, vm.propertyNames->prototype, JSMessageEvent::prototype(vm, globalObject), JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::DontEnum | JSC::PropertyAttribute::DontDelete);
+}
+
+/* Hash table for prototype */
+
+static const HashTableValue JSMessageEventPrototypeTableValues[] = {
+ { "constructor"_s, static_cast<unsigned>(JSC::PropertyAttribute::DontEnum), NoIntrinsic, { (intptr_t) static_cast<PropertySlot::GetValueFunc>(jsMessageEventConstructor), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(0) } },
+ { "origin"_s, static_cast<unsigned>(JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute), NoIntrinsic, { (intptr_t) static_cast<PropertySlot::GetValueFunc>(jsMessageEvent_origin), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(0) } },
+ { "lastEventId"_s, static_cast<unsigned>(JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute), NoIntrinsic, { (intptr_t) static_cast<PropertySlot::GetValueFunc>(jsMessageEvent_lastEventId), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(0) } },
+ { "source"_s, static_cast<unsigned>(JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute), NoIntrinsic, { (intptr_t) static_cast<PropertySlot::GetValueFunc>(jsMessageEvent_source), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(0) } },
+ { "data"_s, static_cast<unsigned>(JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute), NoIntrinsic, { (intptr_t) static_cast<PropertySlot::GetValueFunc>(jsMessageEvent_data), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(0) } },
+ { "ports"_s, static_cast<unsigned>(JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute), NoIntrinsic, { (intptr_t) static_cast<PropertySlot::GetValueFunc>(jsMessageEvent_ports), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(0) } },
+ { "initMessageEvent"_s, static_cast<unsigned>(JSC::PropertyAttribute::Function), NoIntrinsic, { (intptr_t) static_cast<RawNativeFunction>(jsMessageEventPrototypeFunction_initMessageEvent), (intptr_t)(1) } },
+};
+
+const ClassInfo JSMessageEventPrototype::s_info = { "MessageEvent"_s, &Base::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(JSMessageEventPrototype) };
+
+void JSMessageEventPrototype::finishCreation(VM& vm)
+{
+ Base::finishCreation(vm);
+ reifyStaticProperties(vm, JSMessageEvent::info(), JSMessageEventPrototypeTableValues, *this);
+ JSC_TO_STRING_TAG_WITHOUT_TRANSITION();
+}
+
+const ClassInfo JSMessageEvent::s_info = { "MessageEvent"_s, &Base::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(JSMessageEvent) };
+
+JSMessageEvent::JSMessageEvent(Structure* structure, JSDOMGlobalObject& globalObject, Ref<MessageEvent>&& impl)
+ : JSEvent(structure, globalObject, WTFMove(impl))
+{
+}
+
+void JSMessageEvent::finishCreation(VM& vm)
+{
+ Base::finishCreation(vm);
+ ASSERT(inherits(info()));
+
+ // static_assert(!std::is_base_of<ActiveDOMObject, MessageEvent>::value, "Interface is not marked as [ActiveDOMObject] even though implementation class subclasses ActiveDOMObject.");
+
+ vm.heap.reportExtraMemoryAllocated(wrapped().memoryCost());
+}
+
+JSObject* JSMessageEvent::createPrototype(VM& vm, JSDOMGlobalObject& globalObject)
+{
+ return JSMessageEventPrototype::create(vm, &globalObject, JSMessageEventPrototype::createStructure(vm, &globalObject, JSEvent::prototype(vm, globalObject)));
+}
+
+JSObject* JSMessageEvent::prototype(VM& vm, JSDOMGlobalObject& globalObject)
+{
+ return getDOMPrototype<JSMessageEvent>(vm, globalObject);
+}
+
+JSValue JSMessageEvent::getConstructor(VM& vm, const JSGlobalObject* globalObject)
+{
+ return getDOMConstructor<JSMessageEventDOMConstructor, DOMConstructorID::MessageEvent>(vm, *jsCast<const JSDOMGlobalObject*>(globalObject));
+}
+
+JSC_DEFINE_CUSTOM_GETTER(jsMessageEventConstructor, (JSGlobalObject * lexicalGlobalObject, EncodedJSValue thisValue, PropertyName))
+{
+ VM& vm = JSC::getVM(lexicalGlobalObject);
+ auto throwScope = DECLARE_THROW_SCOPE(vm);
+ auto* prototype = jsDynamicCast<JSMessageEventPrototype*>(JSValue::decode(thisValue));
+ if (UNLIKELY(!prototype))
+ return throwVMTypeError(lexicalGlobalObject, throwScope);
+ return JSValue::encode(JSMessageEvent::getConstructor(JSC::getVM(lexicalGlobalObject), prototype->globalObject()));
+}
+
+static inline JSValue jsMessageEvent_originGetter(JSGlobalObject& lexicalGlobalObject, JSMessageEvent& thisObject)
+{
+ auto& vm = JSC::getVM(&lexicalGlobalObject);
+ auto throwScope = DECLARE_THROW_SCOPE(vm);
+ auto& impl = thisObject.wrapped();
+ RELEASE_AND_RETURN(throwScope, (toJS<IDLUSVString>(lexicalGlobalObject, throwScope, impl.origin())));
+}
+
+JSC_DEFINE_CUSTOM_GETTER(jsMessageEvent_origin, (JSGlobalObject * lexicalGlobalObject, EncodedJSValue thisValue, PropertyName attributeName))
+{
+ return IDLAttribute<JSMessageEvent>::get<jsMessageEvent_originGetter, CastedThisErrorBehavior::Assert>(*lexicalGlobalObject, thisValue, attributeName);
+}
+
+static inline JSValue jsMessageEvent_lastEventIdGetter(JSGlobalObject& lexicalGlobalObject, JSMessageEvent& thisObject)
+{
+ auto& vm = JSC::getVM(&lexicalGlobalObject);
+ auto throwScope = DECLARE_THROW_SCOPE(vm);
+ auto& impl = thisObject.wrapped();
+ RELEASE_AND_RETURN(throwScope, (toJS<IDLDOMString>(lexicalGlobalObject, throwScope, impl.lastEventId())));
+}
+
+JSC_DEFINE_CUSTOM_GETTER(jsMessageEvent_lastEventId, (JSGlobalObject * lexicalGlobalObject, EncodedJSValue thisValue, PropertyName attributeName))
+{
+ return IDLAttribute<JSMessageEvent>::get<jsMessageEvent_lastEventIdGetter, CastedThisErrorBehavior::Assert>(*lexicalGlobalObject, thisValue, attributeName);
+}
+
+static inline JSValue jsMessageEvent_sourceGetter(JSGlobalObject& lexicalGlobalObject, JSMessageEvent& thisObject)
+{
+ auto& vm = JSC::getVM(&lexicalGlobalObject);
+ return lexicalGlobalObject.globalThis();
+ // auto throwScope = DECLARE_THROW_SCOPE(vm);
+ // auto& impl = thisObject.wrapped();
+ // RELEASE_AND_RETURN(throwScope, (toJS<IDLNullable<IDLUnion<IDLInterface<WindowProxy>, IDLInterface<MessagePort>, IDLInterface<ServiceWorker>>>>(lexicalGlobalObject, *thisObject.globalObject(), throwScope, impl.source())));
+}
+
+JSC_DEFINE_CUSTOM_GETTER(jsMessageEvent_source, (JSGlobalObject * lexicalGlobalObject, EncodedJSValue thisValue, PropertyName attributeName))
+{
+ return IDLAttribute<JSMessageEvent>::get<jsMessageEvent_sourceGetter, CastedThisErrorBehavior::Assert>(*lexicalGlobalObject, thisValue, attributeName);
+}
+
+static inline JSValue jsMessageEvent_dataGetter(JSGlobalObject& lexicalGlobalObject, JSMessageEvent& thisObject)
+{
+ UNUSED_PARAM(lexicalGlobalObject);
+ return thisObject.data(lexicalGlobalObject);
+}
+
+JSC_DEFINE_CUSTOM_GETTER(jsMessageEvent_data, (JSGlobalObject * lexicalGlobalObject, EncodedJSValue thisValue, PropertyName attributeName))
+{
+ return IDLAttribute<JSMessageEvent>::get<jsMessageEvent_dataGetter, CastedThisErrorBehavior::Assert>(*lexicalGlobalObject, thisValue, attributeName);
+}
+
+static inline JSValue jsMessageEvent_portsGetter(JSGlobalObject& lexicalGlobalObject, JSMessageEvent& thisObject)
+{
+ UNUSED_PARAM(lexicalGlobalObject);
+ // TODO:
+ return JSArray::create(lexicalGlobalObject.vm(), lexicalGlobalObject.arrayStructureForIndexingTypeDuringAllocation(ArrayWithContiguous), 0);
+ // return thisObject.ports(lexicalGlobalObject);
+}
+
+JSC_DEFINE_CUSTOM_GETTER(jsMessageEvent_ports, (JSGlobalObject * lexicalGlobalObject, EncodedJSValue thisValue, PropertyName attributeName))
+{
+ return IDLAttribute<JSMessageEvent>::get<jsMessageEvent_portsGetter, CastedThisErrorBehavior::Assert>(*lexicalGlobalObject, thisValue, attributeName);
+}
+
+static inline JSC::EncodedJSValue jsMessageEventPrototypeFunction_initMessageEventBody(JSC::JSGlobalObject* lexicalGlobalObject, JSC::CallFrame* callFrame, typename IDLOperation<JSMessageEvent>::ClassParameter castedThis)
+{
+ auto& vm = JSC::getVM(lexicalGlobalObject);
+ auto throwScope = DECLARE_THROW_SCOPE(vm);
+ UNUSED_PARAM(throwScope);
+ UNUSED_PARAM(callFrame);
+ auto& impl = castedThis->wrapped();
+ if (UNLIKELY(callFrame->argumentCount() < 1))
+ return throwVMError(lexicalGlobalObject, throwScope, createNotEnoughArgumentsError(lexicalGlobalObject));
+ EnsureStillAliveScope argument0 = callFrame->uncheckedArgument(0);
+ auto type = convert<IDLAtomStringAdaptor<IDLDOMString>>(*lexicalGlobalObject, argument0.value());
+ RETURN_IF_EXCEPTION(throwScope, encodedJSValue());
+ EnsureStillAliveScope argument1 = callFrame->argument(1);
+ auto bubbles = convert<IDLBoolean>(*lexicalGlobalObject, argument1.value());
+ RETURN_IF_EXCEPTION(throwScope, encodedJSValue());
+ EnsureStillAliveScope argument2 = callFrame->argument(2);
+ auto cancelable = convert<IDLBoolean>(*lexicalGlobalObject, argument2.value());
+ RETURN_IF_EXCEPTION(throwScope, encodedJSValue());
+ EnsureStillAliveScope argument3 = callFrame->argument(3);
+ auto data = argument3.value().isUndefined() ? jsNull() : convert<IDLAny>(*lexicalGlobalObject, argument3.value());
+ RETURN_IF_EXCEPTION(throwScope, encodedJSValue());
+ EnsureStillAliveScope argument4 = callFrame->argument(4);
+ auto originArg = argument4.value().isUndefined() ? emptyString() : convert<IDLUSVString>(*lexicalGlobalObject, argument4.value());
+ RETURN_IF_EXCEPTION(throwScope, encodedJSValue());
+ EnsureStillAliveScope argument5 = callFrame->argument(5);
+ auto lastEventId = argument5.value().isUndefined() ? emptyString() : convert<IDLDOMString>(*lexicalGlobalObject, argument5.value());
+ RETURN_IF_EXCEPTION(throwScope, encodedJSValue());
+ EnsureStillAliveScope argument6 = callFrame->argument(6);
+ auto source = WebCore::MessageEventSource();
+ // RETURN_IF_EXCEPTION(throwScope, encodedJSValue());
+ // EnsureStillAliveScope argument7 = callFrame->argument(7);
+ // auto messagePorts = JSArray::create(lexicalGlobalObject.vm(), lexicalGlobalObject->arrayStructureForIndexingTypeDuringAllocation(ArrayWithContiguous), 0);
+ auto messagePorts = Converter<IDLSequence<IDLInterface<MessagePort>>>::ReturnType {};
+ RETURN_IF_EXCEPTION(throwScope, encodedJSValue());
+ RELEASE_AND_RETURN(throwScope, JSValue::encode(toJS<IDLUndefined>(*lexicalGlobalObject, throwScope, [&]() -> decltype(auto) { return impl.initMessageEvent(WTFMove(type), WTFMove(bubbles), WTFMove(cancelable), WTFMove(data), WTFMove(originArg), WTFMove(lastEventId), WTFMove(source), WTFMove(messagePorts)); })));
+}
+
+JSC_DEFINE_HOST_FUNCTION(jsMessageEventPrototypeFunction_initMessageEvent, (JSGlobalObject * lexicalGlobalObject, CallFrame* callFrame))
+{
+ return IDLOperation<JSMessageEvent>::call<jsMessageEventPrototypeFunction_initMessageEventBody>(*lexicalGlobalObject, *callFrame, "initMessageEvent");
+}
+
+JSC::GCClient::IsoSubspace* JSMessageEvent::subspaceForImpl(JSC::VM& vm)
+{
+ return WebCore::subspaceForImpl<JSMessageEvent, UseCustomHeapCellType::No>(
+ vm,
+ [](auto& spaces) { return spaces.m_clientSubspaceForMessageEvent.get(); },
+ [](auto& spaces, auto&& space) { spaces.m_clientSubspaceForMessageEvent = WTFMove(space); },
+ [](auto& spaces) { return spaces.m_subspaceForMessageEvent.get(); },
+ [](auto& spaces, auto&& space) { spaces.m_subspaceForMessageEvent = WTFMove(space); });
+}
+
+template<typename Visitor>
+void JSMessageEvent::visitChildrenImpl(JSCell* cell, Visitor& visitor)
+{
+ auto* thisObject = jsCast<JSMessageEvent*>(cell);
+ ASSERT_GC_OBJECT_INHERITS(thisObject, info());
+ Base::visitChildren(thisObject, visitor);
+ thisObject->visitAdditionalChildren(visitor);
+ visitor.reportExtraMemoryVisited(thisObject->wrapped().memoryCost());
+}
+
+DEFINE_VISIT_CHILDREN(JSMessageEvent);
+
+template<typename Visitor>
+void JSMessageEvent::visitOutputConstraints(JSCell* cell, Visitor& visitor)
+{
+ auto* thisObject = jsCast<JSMessageEvent*>(cell);
+ ASSERT_GC_OBJECT_INHERITS(thisObject, info());
+ Base::visitOutputConstraints(thisObject, visitor);
+ thisObject->visitAdditionalChildren(visitor);
+}
+
+template void JSMessageEvent::visitOutputConstraints(JSCell*, AbstractSlotVisitor&);
+template void JSMessageEvent::visitOutputConstraints(JSCell*, SlotVisitor&);
+size_t JSMessageEvent::estimatedSize(JSCell* cell, VM& vm)
+{
+ auto* thisObject = jsCast<JSMessageEvent*>(cell);
+ return Base::estimatedSize(thisObject, vm) + thisObject->wrapped().memoryCost();
+}
+
+void JSMessageEvent::analyzeHeap(JSCell* cell, HeapAnalyzer& analyzer)
+{
+ auto* thisObject = jsCast<JSMessageEvent*>(cell);
+ analyzer.setWrappedObjectForCell(cell, &thisObject->wrapped());
+ if (thisObject->scriptExecutionContext())
+ analyzer.setLabelForCell(cell, "url " + thisObject->scriptExecutionContext()->url().string());
+ Base::analyzeHeap(cell, analyzer);
+}
+
+#if ENABLE(BINDING_INTEGRITY)
+#if PLATFORM(WIN)
+#pragma warning(disable : 4483)
+extern "C" {
+extern void (*const __identifier("??_7MessageEvent@WebCore@@6B@")[])();
+}
+#else
+extern "C" {
+extern void* _ZTVN7WebCore12MessageEventE[];
+}
+#endif
+#endif
+
+JSC::JSValue toJSNewlyCreated(JSC::JSGlobalObject*, JSDOMGlobalObject* globalObject, Ref<MessageEvent>&& impl)
+{
+
+ if constexpr (std::is_polymorphic_v<MessageEvent>) {
+#if ENABLE(BINDING_INTEGRITY)
+ const void* actualVTablePointer = getVTablePointer(impl.ptr());
+#if PLATFORM(WIN)
+ void* expectedVTablePointer = __identifier("??_7MessageEvent@WebCore@@6B@");
+#else
+ void* expectedVTablePointer = &_ZTVN7WebCore12MessageEventE[2];
+#endif
+
+ // If you hit this assertion you either have a use after free bug, or
+ // MessageEvent has subclasses. If MessageEvent has subclasses that get passed
+ // to toJS() we currently require MessageEvent you to opt out of binding hardening
+ // by adding the SkipVTableValidation attribute to the interface IDL definition
+ RELEASE_ASSERT(actualVTablePointer == expectedVTablePointer);
+#endif
+ }
+ return createWrapper<MessageEvent>(globalObject, WTFMove(impl));
+}
+
+JSC::JSValue toJS(JSC::JSGlobalObject* lexicalGlobalObject, JSDOMGlobalObject* globalObject, MessageEvent& impl)
+{
+ return wrap(lexicalGlobalObject, globalObject, impl);
+}
+
+}
diff --git a/src/javascript/jsc/bindings/webcore/JSMessageEvent.dep b/src/javascript/jsc/bindings/webcore/JSMessageEvent.dep
new file mode 100644
index 000000000..da20f76fa
--- /dev/null
+++ b/src/javascript/jsc/bindings/webcore/JSMessageEvent.dep
@@ -0,0 +1,3 @@
+JSMessageEvent.h : Event.idl EventInit.idl
+Event.idl :
+EventInit.idl :
diff --git a/src/javascript/jsc/bindings/webcore/JSMessageEvent.h b/src/javascript/jsc/bindings/webcore/JSMessageEvent.h
new file mode 100644
index 000000000..85424d9ec
--- /dev/null
+++ b/src/javascript/jsc/bindings/webcore/JSMessageEvent.h
@@ -0,0 +1,91 @@
+/*
+ This file is part of the WebKit open source project.
+ This file has been generated by generate-bindings.pl. DO NOT MODIFY!
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ along with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ Boston, MA 02110-1301, USA.
+*/
+
+#pragma once
+
+#include "JSDOMConvertDictionary.h"
+#include "JSDOMWrapper.h"
+#include "JSEvent.h"
+#include "MessageEvent.h"
+
+namespace WebCore {
+
+class JSMessageEvent : public JSEvent {
+public:
+ using Base = JSEvent;
+ using DOMWrapped = MessageEvent;
+ static JSMessageEvent* create(JSC::Structure* structure, JSDOMGlobalObject* globalObject, Ref<MessageEvent>&& impl)
+ {
+ JSMessageEvent* ptr = new (NotNull, JSC::allocateCell<JSMessageEvent>(globalObject->vm())) JSMessageEvent(structure, *globalObject, WTFMove(impl));
+ ptr->finishCreation(globalObject->vm());
+ return ptr;
+ }
+
+ static JSC::JSObject* createPrototype(JSC::VM&, JSDOMGlobalObject&);
+ static JSC::JSObject* prototype(JSC::VM&, JSDOMGlobalObject&);
+ static size_t estimatedSize(JSCell*, JSC::VM&);
+
+ DECLARE_INFO;
+
+ static JSC::Structure* createStructure(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::JSValue prototype)
+ {
+ return JSC::Structure::create(vm, globalObject, prototype, JSC::TypeInfo(JSC::JSType(JSEventType), StructureFlags), info(), JSC::NonArray);
+ }
+
+ static JSC::JSValue getConstructor(JSC::VM&, const JSC::JSGlobalObject*);
+ template<typename, JSC::SubspaceAccess mode> static JSC::GCClient::IsoSubspace* subspaceFor(JSC::VM& vm)
+ {
+ if constexpr (mode == JSC::SubspaceAccess::Concurrently)
+ return nullptr;
+ return subspaceForImpl(vm);
+ }
+ static JSC::GCClient::IsoSubspace* subspaceForImpl(JSC::VM& vm);
+ DECLARE_VISIT_CHILDREN;
+ template<typename Visitor> void visitAdditionalChildren(Visitor&);
+
+ template<typename Visitor> static void visitOutputConstraints(JSCell*, Visitor&);
+ static void analyzeHeap(JSCell*, JSC::HeapAnalyzer&);
+
+ // Custom attributes
+ JSC::JSValue data(JSC::JSGlobalObject&) const;
+ JSC::JSValue ports(JSC::JSGlobalObject&) const;
+ MessageEvent& wrapped() const
+ {
+ return static_cast<MessageEvent&>(Base::wrapped());
+ }
+protected:
+ JSMessageEvent(JSC::Structure*, JSDOMGlobalObject&, Ref<MessageEvent>&&);
+
+ void finishCreation(JSC::VM&);
+};
+
+JSC::JSValue toJS(JSC::JSGlobalObject*, JSDOMGlobalObject*, MessageEvent&);
+inline JSC::JSValue toJS(JSC::JSGlobalObject* lexicalGlobalObject, JSDOMGlobalObject* globalObject, MessageEvent* impl) { return impl ? toJS(lexicalGlobalObject, globalObject, *impl) : JSC::jsNull(); }
+JSC::JSValue toJSNewlyCreated(JSC::JSGlobalObject*, JSDOMGlobalObject*, Ref<MessageEvent>&&);
+inline JSC::JSValue toJSNewlyCreated(JSC::JSGlobalObject* lexicalGlobalObject, JSDOMGlobalObject* globalObject, RefPtr<MessageEvent>&& impl) { return impl ? toJSNewlyCreated(lexicalGlobalObject, globalObject, impl.releaseNonNull()) : JSC::jsNull(); }
+
+template<> struct JSDOMWrapperConverterTraits<MessageEvent> {
+ using WrapperClass = JSMessageEvent;
+ using ToWrappedReturnType = MessageEvent*;
+};
+template<> MessageEvent::Init convertDictionary<MessageEvent::Init>(JSC::JSGlobalObject&, JSC::JSValue);
+
+
+} // namespace WebCore
diff --git a/src/javascript/jsc/bindings/webcore/JSMessageEventCustom.cpp b/src/javascript/jsc/bindings/webcore/JSMessageEventCustom.cpp
new file mode 100644
index 000000000..66390f86b
--- /dev/null
+++ b/src/javascript/jsc/bindings/webcore/JSMessageEventCustom.cpp
@@ -0,0 +1,81 @@
+/*
+ * Copyright (C) 2009 Google Inc. All rights reserved.
+ * Copyright (C) 2009-2021 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:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * 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.
+ * * Neither the name of Google Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND 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 THE COPYRIGHT
+ * OWNER OR 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 "JSMessageEvent.h"
+
+// #include "JSBlob.h"
+#include "JSDOMBinding.h"
+#include "JSDOMConvert.h"
+#include "JSDOMWindow.h"
+#include "JSEventTarget.h"
+// #include "JSMessagePort.h"
+#include <JavaScriptCore/JSArray.h>
+#include <JavaScriptCore/JSArrayBuffer.h>
+
+namespace WebCore {
+
+JSC::JSValue JSMessageEvent::ports(JSC::JSGlobalObject& lexicalGlobalObject) const
+{
+ return JSC::jsUndefined();
+}
+// auto throwScope = DECLARE_THROW_SCOPE(lexicalGlobalObject.vm());
+// return cachedPropertyValue(lexicalGlobalObject, *this, wrapped().cachedPorts(), [&] {
+// JSC::JSValue ports = toJS<IDLFrozenArray<IDLInterface<MessagePort>>>(lexicalGlobalObject, *globalObject(), throwScope, wrapped().ports());
+// return ports;
+// });
+// }
+
+JSC::JSValue JSMessageEvent::data(JSC::JSGlobalObject& lexicalGlobalObject) const
+{
+ return cachedPropertyValue(lexicalGlobalObject, *this, wrapped().cachedData(), [this, &lexicalGlobalObject] {
+ return WTF::switchOn(
+ wrapped().data(), [this](MessageEvent::JSValueTag) -> JSC::JSValue { return wrapped().jsData().getValue(JSC::jsNull()); },
+ // [this, &lexicalGlobalObject](const Ref<SerializedScriptValue>& data) {
+ // // FIXME: Is it best to handle errors by returning null rather than throwing an exception?
+ // return data->deserialize(lexicalGlobalObject, globalObject(), wrapped().ports(), SerializationErrorMode::NonThrowing); },
+ [&lexicalGlobalObject](const String& data) { return toJS<IDLDOMString>(lexicalGlobalObject, data); },
+ // [this, &lexicalGlobalObject](const Ref<Blob>& data) { return toJS<IDLInterface<Blob>>(lexicalGlobalObject, *globalObject(), data); },
+ [this, &lexicalGlobalObject](const Ref<ArrayBuffer>& data) { return toJS<IDLInterface<ArrayBuffer>>(lexicalGlobalObject, *globalObject(), data); });
+ });
+}
+
+template<typename Visitor>
+void JSMessageEvent::visitAdditionalChildren(Visitor& visitor)
+{
+ wrapped().jsData().visit(visitor);
+ wrapped().cachedData().visit(visitor);
+ wrapped().cachedPorts().visit(visitor);
+}
+
+DEFINE_VISIT_ADDITIONAL_CHILDREN(JSMessageEvent);
+
+} // namespace WebCore
diff --git a/src/javascript/jsc/bindings/webcore/JSServiceWorker.h b/src/javascript/jsc/bindings/webcore/JSServiceWorker.h
new file mode 100644
index 000000000..d067d0b5a
--- /dev/null
+++ b/src/javascript/jsc/bindings/webcore/JSServiceWorker.h
@@ -0,0 +1 @@
+// stub \ No newline at end of file
diff --git a/src/javascript/jsc/bindings/webcore/JSWindowProxy.h b/src/javascript/jsc/bindings/webcore/JSWindowProxy.h
new file mode 100644
index 000000000..d067d0b5a
--- /dev/null
+++ b/src/javascript/jsc/bindings/webcore/JSWindowProxy.h
@@ -0,0 +1 @@
+// stub \ No newline at end of file
diff --git a/src/javascript/jsc/bindings/webcore/MessageEvent.cpp b/src/javascript/jsc/bindings/webcore/MessageEvent.cpp
new file mode 100644
index 000000000..b210f4cec
--- /dev/null
+++ b/src/javascript/jsc/bindings/webcore/MessageEvent.cpp
@@ -0,0 +1,125 @@
+/*
+ * Copyright (C) 2007 Henry Mason (hmason@mac.com)
+ * Copyright (C) 2003-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. ``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
+ * 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 "root.h"
+#include "config.h"
+#include "MessageEvent.h"
+
+// #include "Blob.h"
+#include "EventNames.h"
+#include <JavaScriptCore/JSCInlines.h>
+// #include <wtf/IsoMallocInlines.h>
+
+namespace WebCore {
+
+using namespace JSC;
+
+WTF_MAKE_ISO_ALLOCATED_IMPL(MessageEvent);
+
+MessageEvent::MessageEvent() = default;
+
+inline MessageEvent::MessageEvent(const AtomString& type, Init&& initializer, IsTrusted isTrusted)
+ : Event(type, initializer, isTrusted)
+ , m_data(JSValueTag {})
+ , m_origin(initializer.origin)
+ , m_lastEventId(initializer.lastEventId)
+ , m_source(WTFMove(initializer.source))
+ // , m_ports(WTFMove(initializer.ports))
+ , m_jsData(initializer.data)
+{
+}
+
+inline MessageEvent::MessageEvent(const AtomString& type, DataType&& data, const String& origin, const String& lastEventId, std::optional<MessageEventSource>&& source /*, Vector<RefPtr<MessagePort>>&& ports*/)
+ : Event(type, CanBubble::No, IsCancelable::No)
+ , m_data(WTFMove(data))
+ , m_origin(origin)
+ , m_lastEventId(lastEventId)
+ , m_source(WTFMove(source))
+// , m_ports(WTFMove(ports))
+{
+}
+
+Ref<MessageEvent> MessageEvent::create(const AtomString& type, DataType&& data, const String& origin, const String& lastEventId, std::optional<MessageEventSource>&& source /*, Vector<RefPtr<MessagePort>>&& ports*/)
+{
+ return adoptRef(*new MessageEvent(type, WTFMove(data), origin, lastEventId, WTFMove(source) /*, /*WTFMove(ports)*/));
+}
+
+Ref<MessageEvent> MessageEvent::create(DataType&& data, const String& origin, const String& lastEventId, std::optional<MessageEventSource>&& source /*, Vector<RefPtr<MessagePort>>&& ports*/)
+{
+ return create(eventNames().messageEvent, WTFMove(data), origin, lastEventId, WTFMove(source) /*, /*WTFMove(ports)*/);
+}
+
+Ref<MessageEvent> MessageEvent::createForBindings()
+{
+ return adoptRef(*new MessageEvent);
+}
+
+Ref<MessageEvent> MessageEvent::create(const AtomString& type, Init&& initializer, IsTrusted isTrusted)
+{
+ return adoptRef(*new MessageEvent(type, WTFMove(initializer), isTrusted));
+}
+
+MessageEvent::~MessageEvent() = default;
+
+void MessageEvent::initMessageEvent(const AtomString& type, bool canBubble, bool cancelable, JSValue data, const String& origin, const String& lastEventId, std::optional<MessageEventSource>&& source /*, Vector<RefPtr<MessagePort>>&& ports*/)
+{
+ if (isBeingDispatched())
+ return;
+
+ initEvent(type, canBubble, cancelable);
+
+ {
+ Locker { m_concurrentDataAccessLock };
+ m_data = JSValueTag {};
+ }
+ // FIXME: This code is wrong: we should emit a write-barrier. Otherwise, GC can collect it.
+ // https://bugs.webkit.org/show_bug.cgi?id=236353
+ m_jsData.setWeakly(data);
+ m_cachedData.clear();
+ m_origin = origin;
+ m_lastEventId = lastEventId;
+ m_source = WTFMove(source);
+ // m_ports = WTFMove(ports);
+ m_cachedPorts.clear();
+}
+
+EventInterface MessageEvent::eventInterface() const
+{
+ return MessageEventInterfaceType;
+}
+
+size_t MessageEvent::memoryCost() const
+{
+ Locker { m_concurrentDataAccessLock };
+ return WTF::switchOn(
+ m_data, [](JSValueTag) -> size_t { return 0; },
+ // [](const Ref<SerializedScriptValue>& data) -> size_t { return data->memoryCost(); },
+ [](const String& string) -> size_t { return string.sizeInBytes(); },
+ // [](const Ref<Blob>& blob) -> size_t { return blob->size(); },
+ [](const Ref<ArrayBuffer>& buffer) -> size_t { return buffer->byteLength(); });
+}
+
+} // namespace WebCore
diff --git a/src/javascript/jsc/bindings/webcore/MessageEvent.h b/src/javascript/jsc/bindings/webcore/MessageEvent.h
new file mode 100644
index 000000000..4089e2ca1
--- /dev/null
+++ b/src/javascript/jsc/bindings/webcore/MessageEvent.h
@@ -0,0 +1,104 @@
+/*
+ * Copyright (C) 2007 Henry Mason (hmason@mac.com)
+ * Copyright (C) 2003-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. ``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
+ * 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 "Event.h"
+#include "JSValueInWrappedObject.h"
+// #include "MessagePort.h"
+// #include "SerializedScriptValue.h"
+// #include "ServiceWorker.h"
+// #include "WindowProxy.h"
+#include <variant>
+
+namespace WebCore {
+
+class MessagePort : public RefCounted<MessagePort> {
+};
+
+class MessageEventSource {
+};
+
+class MessageEvent final : public Event {
+ WTF_MAKE_ISO_ALLOCATED(MessageEvent);
+
+public:
+ struct JSValueTag {
+ };
+ // using DataType = std::variant<JSValueTag, Ref<SerializedScriptValue>, String, Ref<Blob>, Ref<ArrayBuffer>>;
+ using DataType = std::variant<JSValueTag, String, Ref<ArrayBuffer>>;
+ static Ref<MessageEvent> create(const AtomString& type, DataType&&, const String& origin = {}, const String& lastEventId = {}, std::optional<MessageEventSource>&& = std::nullopt /*, Vector<RefPtr<MessagePort>>&& = {}*/);
+ static Ref<MessageEvent> create(DataType&&, const String& origin = {}, const String& lastEventId = {}, std::optional<MessageEventSource>&& = std::nullopt /*, Vector<RefPtr<MessagePort>>&& = {}*/);
+ static Ref<MessageEvent> createForBindings();
+
+ struct Init : EventInit {
+ JSC::JSValue data;
+ String origin;
+ String lastEventId;
+ std::optional<MessageEventSource> source;
+ // Vector<RefPtr<MessagePort>> ports;
+ };
+ static Ref<MessageEvent> create(const AtomString& type, Init&&, IsTrusted = IsTrusted::No);
+
+ virtual ~MessageEvent();
+
+ void initMessageEvent(const AtomString& type, bool canBubble, bool cancelable, JSC::JSValue data, const String& origin, const String& lastEventId, std::optional<MessageEventSource>&& /*, Vector<RefPtr<MessagePort>>&&*/);
+
+ const String& origin() const { return m_origin; }
+ const String& lastEventId() const { return m_lastEventId; }
+ const std::optional<MessageEventSource>& source() const { return m_source; }
+ // const Vector<RefPtr<MessagePort>>& ports() const { return m_ports; }
+
+ const DataType& data() const { return m_data; }
+
+ JSValueInWrappedObject& jsData() { return m_jsData; }
+ JSValueInWrappedObject& cachedData() { return m_cachedData; }
+ JSValueInWrappedObject& cachedPorts() { return m_cachedPorts; }
+
+ size_t memoryCost() const;
+
+private:
+ MessageEvent();
+ MessageEvent(const AtomString& type, Init&&, IsTrusted);
+ MessageEvent(const AtomString& type, DataType&&, const String& origin, const String& lastEventId = {}, std::optional<MessageEventSource>&& = std::nullopt /*, Vector<RefPtr<MessagePort>>&& = {}*/);
+
+ EventInterface eventInterface() const final;
+
+ DataType m_data;
+ String m_origin;
+ String m_lastEventId;
+ std::optional<MessageEventSource> m_source;
+ // Vector<RefPtr<MessagePort>> m_ports;
+
+ JSValueInWrappedObject m_jsData;
+ JSValueInWrappedObject m_cachedData;
+ JSValueInWrappedObject m_cachedPorts;
+
+ mutable Lock m_concurrentDataAccessLock;
+};
+
+} // namespace WebCore
diff --git a/src/javascript/jsc/bindings/webcore/MessageEvent.idl b/src/javascript/jsc/bindings/webcore/MessageEvent.idl
new file mode 100644
index 000000000..dff0a218a
--- /dev/null
+++ b/src/javascript/jsc/bindings/webcore/MessageEvent.idl
@@ -0,0 +1,59 @@
+/*
+ * Copyright (C) 2007 Henry Mason <hmason@mac.com>
+ * Copyright (C) 2011 Google Inc. All rights reserved.
+ * Copyright (C) 2016 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. ``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
+ * 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.
+ *
+ */
+
+#if defined(ENABLE_SERVICE_WORKER) && ENABLE_SERVICE_WORKER
+typedef (WindowProxy or MessagePort or ServiceWorker) MessageEventSource;
+#else
+typedef (WindowProxy or MessagePort) MessageEventSource;
+#endif
+
+[
+ Exposed=(Window,Worker,AudioWorklet),
+ JSCustomMarkFunction,
+ ReportExtraMemoryCost,
+] interface MessageEvent : Event {
+ constructor([AtomString] DOMString type, optional MessageEventInit eventInitDict);
+
+ readonly attribute USVString origin;
+ readonly attribute DOMString lastEventId;
+ readonly attribute MessageEventSource? source;
+ [CustomGetter] readonly attribute any data;
+ [CustomGetter] readonly attribute FrozenArray<MessagePort> ports;
+
+ undefined initMessageEvent([AtomString] DOMString type, optional boolean bubbles = false, optional boolean cancelable = false,
+ optional any data = null, optional USVString originArg = "", optional DOMString lastEventId = "", optional MessageEventSource? source = null,
+ optional sequence<MessagePort> messagePorts = []);
+};
+
+dictionary MessageEventInit : EventInit {
+ any data = null;
+ USVString origin = "";
+ DOMString lastEventId = "";
+ MessageEventSource? source = null;
+ sequence<MessagePort> ports = [];
+};
diff --git a/src/javascript/jsc/bindings/webcore/TaskSource.h b/src/javascript/jsc/bindings/webcore/TaskSource.h
new file mode 100644
index 000000000..2c0a128e8
--- /dev/null
+++ b/src/javascript/jsc/bindings/webcore/TaskSource.h
@@ -0,0 +1,29 @@
+#pragma once
+
+namespace WebCore {
+
+enum class TaskSource : uint8_t {
+ DOMManipulation,
+ DatabaseAccess,
+ FileReading,
+ FontLoading,
+ Geolocation,
+ IdleTask,
+ IndexedDB,
+ MediaElement,
+ Microtask,
+ Networking,
+ PerformanceTimeline,
+ Permission,
+ PostedMessageQueue,
+ Speech,
+ UserInteraction,
+ WebGL,
+ WebXR,
+ WebSocket,
+
+ // Internal to WebCore
+ InternalAsyncTask, // Safe to re-order or delay.
+};
+
+} // namespace WebCore