diff --git a/Tests/LibWeb/TestConfig.ini b/Tests/LibWeb/TestConfig.ini index 8309f1ec7a9..641e2fb71dd 100644 --- a/Tests/LibWeb/TestConfig.ini +++ b/Tests/LibWeb/TestConfig.ini @@ -15,3 +15,4 @@ Text/input/Worker/Worker-importScripts.html Text/input/Worker/Worker-location.html Text/input/Worker/Worker-module.html Text/input/Worker/Worker-performance.html +Text/input/Worker/Worker-postMessage-transfer.html diff --git a/Tests/LibWeb/Text/expected/Worker/Worker-postMessage-transfer.txt b/Tests/LibWeb/Text/expected/Worker/Worker-postMessage-transfer.txt new file mode 100644 index 00000000000..7db7e90e53f --- /dev/null +++ b/Tests/LibWeb/Text/expected/Worker/Worker-postMessage-transfer.txt @@ -0,0 +1 @@ +Message received from worker: Hello, world diff --git a/Tests/LibWeb/Text/input/Worker/Worker-postMessage-transfer.html b/Tests/LibWeb/Text/input/Worker/Worker-postMessage-transfer.html new file mode 100644 index 00000000000..7d8b1e9227e --- /dev/null +++ b/Tests/LibWeb/Text/input/Worker/Worker-postMessage-transfer.html @@ -0,0 +1,29 @@ + + diff --git a/Userland/Libraries/LibWeb/HTML/DedicatedWorkerGlobalScope.cpp b/Userland/Libraries/LibWeb/HTML/DedicatedWorkerGlobalScope.cpp index 213c4fee4b8..d8189d32c48 100644 --- a/Userland/Libraries/LibWeb/HTML/DedicatedWorkerGlobalScope.cpp +++ b/Userland/Libraries/LibWeb/HTML/DedicatedWorkerGlobalScope.cpp @@ -48,6 +48,7 @@ void DedicatedWorkerGlobalScope::finalize() WindowOrWorkerGlobalScopeMixin::finalize(); } +// https://html.spec.whatwg.org/multipage/workers.html#dom-dedicatedworkerglobalscope-postmessage-options WebIDL::ExceptionOr 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 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 DedicatedWorkerGlobalScope::post_message(JS::Value message, Vector> 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) \ diff --git a/Userland/Libraries/LibWeb/HTML/DedicatedWorkerGlobalScope.h b/Userland/Libraries/LibWeb/HTML/DedicatedWorkerGlobalScope.h index 15f19116d0a..438a11b2f68 100644 --- a/Userland/Libraries/LibWeb/HTML/DedicatedWorkerGlobalScope.h +++ b/Userland/Libraries/LibWeb/HTML/DedicatedWorkerGlobalScope.h @@ -26,6 +26,7 @@ public: virtual ~DedicatedWorkerGlobalScope() override; WebIDL::ExceptionOr post_message(JS::Value message, StructuredSerializeOptions const&); + WebIDL::ExceptionOr post_message(JS::Value message, Vector> const& transfer); void set_name(String name) { m_name = move(name); } String name() const { return m_name; } diff --git a/Userland/Libraries/LibWeb/HTML/DedicatedWorkerGlobalScope.idl b/Userland/Libraries/LibWeb/HTML/DedicatedWorkerGlobalScope.idl index d3084eb0728..0f0aa79ed50 100644 --- a/Userland/Libraries/LibWeb/HTML/DedicatedWorkerGlobalScope.idl +++ b/Userland/Libraries/LibWeb/HTML/DedicatedWorkerGlobalScope.idl @@ -5,8 +5,7 @@ interface DedicatedWorkerGlobalScope : WorkerGlobalScope { [Replaceable] readonly attribute DOMString name; - // FIXME: IDL overload issue here - // FIXME: undefined postMessage(any message, sequence transfer); + undefined postMessage(any message, sequence transfer); undefined postMessage(any message, optional StructuredSerializeOptions options = {}); undefined close();