mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-07-06 00:51:51 +00:00
Some checks are pending
CI / macOS, arm64, Sanitizer_CI, Clang (push) Waiting to run
CI / Linux, x86_64, Fuzzers_CI, Clang (push) Waiting to run
CI / Linux, x86_64, Sanitizer_CI, GNU (push) Waiting to run
CI / Linux, x86_64, Sanitizer_CI, Clang (push) Waiting to run
Package the js repl as a binary artifact / macOS, arm64 (push) Waiting to run
Package the js repl as a binary artifact / Linux, x86_64 (push) Waiting to run
Run test262 and test-wasm / run_and_update_results (push) Waiting to run
Lint Code / lint (push) Waiting to run
Label PRs with merge conflicts / auto-labeler (push) Waiting to run
Push notes / build (push) Waiting to run
This change implements following behavior defined in the spec: https://html.spec.whatwg.org/multipage/web-messaging.html#examples-5 > The start() method, whether called explicitly or implicitly (by setting onmessage), starts the flow of messages: messages posted on message ports are initially paused, so that they don't get dropped on the floor before the script has had a chance to set up its handlers. Now we don't read bytes from the underlying transport socket until the message port transitions to the enabled state. This required the following places to explicitly enable the message port, because now, when it actually matters, we must do so, or otherwise sent messages will get stuck: - `onmessage` attribute setter in DedicatedWorkerGlobalScope, because it implicitly sets the onmessage handler for the worker's underlying port. - Stream API operations where the message port enabling steps were previously marked as FIXMEs.
43 lines
1.2 KiB
C++
43 lines
1.2 KiB
C++
/*
|
|
* Copyright (c) 2024, Andrew Kaster <akaster@serenityos.org>
|
|
*
|
|
* SPDX-License-Identifier: BSD-2-Clause
|
|
*/
|
|
|
|
#pragma once
|
|
|
|
#include <LibWeb/Bindings/DedicatedWorkerGlobalScopeGlobalMixin.h>
|
|
#include <LibWeb/Bindings/WorkerGlobalScopePrototype.h>
|
|
#include <LibWeb/HTML/WorkerGlobalScope.h>
|
|
|
|
namespace Web::HTML {
|
|
|
|
class DedicatedWorkerGlobalScope
|
|
: public WorkerGlobalScope
|
|
, public Bindings::DedicatedWorkerGlobalScopeGlobalMixin {
|
|
WEB_PLATFORM_OBJECT(DedicatedWorkerGlobalScope, WorkerGlobalScope);
|
|
GC_DECLARE_ALLOCATOR(DedicatedWorkerGlobalScope);
|
|
|
|
public:
|
|
virtual ~DedicatedWorkerGlobalScope() override;
|
|
|
|
WebIDL::ExceptionOr<void> post_message(JS::Value message, StructuredSerializeOptions const&);
|
|
WebIDL::ExceptionOr<void> post_message(JS::Value message, Vector<GC::Root<JS::Object>> const& transfer);
|
|
|
|
void close();
|
|
|
|
WebIDL::CallbackType* onmessage();
|
|
void set_onmessage(WebIDL::CallbackType* callback);
|
|
|
|
WebIDL::CallbackType* onmessageerror();
|
|
void set_onmessageerror(WebIDL::CallbackType* callback);
|
|
|
|
virtual void finalize() override;
|
|
|
|
private:
|
|
DedicatedWorkerGlobalScope(JS::Realm&, GC::Ref<Web::Page>);
|
|
|
|
virtual void initialize_web_interfaces_impl() override;
|
|
};
|
|
|
|
}
|