LibWeb: Implement DedicatedWorkerGlobalScope postMessage(msg, transfer)

Unfortunately the added test (which passes locally) is skipped as it is
based off other Worker tests which are also skipped due to being flakey
in CI.
This commit is contained in:
Shannon Booth 2024-10-28 20:14:18 +13:00 committed by Andreas Kling
commit 755b63132b
Notes: github-actions[bot] 2024-10-28 22:33:18 +00:00
6 changed files with 43 additions and 2 deletions

View file

@ -48,6 +48,7 @@ void DedicatedWorkerGlobalScope::finalize()
WindowOrWorkerGlobalScopeMixin::finalize();
}
// https://html.spec.whatwg.org/multipage/workers.html#dom-dedicatedworkerglobalscope-postmessage-options
WebIDL::ExceptionOr<void> DedicatedWorkerGlobalScope::post_message(JS::Value message, StructuredSerializeOptions const& options)
{
// The postMessage(message, transfer) and postMessage(message, options) methods on DedicatedWorkerGlobalScope objects act as if,
@ -56,6 +57,15 @@ WebIDL::ExceptionOr<void> DedicatedWorkerGlobalScope::post_message(JS::Value mes
return m_internal_port->post_message(message, options);
}
// https://html.spec.whatwg.org/multipage/workers.html#dom-dedicatedworkerglobalscope-postmessage
WebIDL::ExceptionOr<void> DedicatedWorkerGlobalScope::post_message(JS::Value message, Vector<JS::Handle<JS::Object>> const& transfer)
{
// The postMessage(message, transfer) and postMessage(message, options) methods on DedicatedWorkerGlobalScope objects act as if,
// when invoked, it immediately invoked the respective postMessage(message, transfer) and postMessage(message, options)
// on the port, with the same arguments, and returned the same return value.
return m_internal_port->post_message(message, transfer);
}
#undef __ENUMERATE
#define __ENUMERATE(attribute_name, event_name) \
void DedicatedWorkerGlobalScope::set_##attribute_name(WebIDL::CallbackType* value) \

View file

@ -26,6 +26,7 @@ public:
virtual ~DedicatedWorkerGlobalScope() override;
WebIDL::ExceptionOr<void> post_message(JS::Value message, StructuredSerializeOptions const&);
WebIDL::ExceptionOr<void> post_message(JS::Value message, Vector<JS::Handle<JS::Object>> const& transfer);
void set_name(String name) { m_name = move(name); }
String name() const { return m_name; }

View file

@ -5,8 +5,7 @@
interface DedicatedWorkerGlobalScope : WorkerGlobalScope {
[Replaceable] readonly attribute DOMString name;
// FIXME: IDL overload issue here
// FIXME: undefined postMessage(any message, sequence<object> transfer);
undefined postMessage(any message, sequence<object> transfer);
undefined postMessage(any message, optional StructuredSerializeOptions options = {});
undefined close();