mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-07-19 15:32:31 +00:00
LibWeb: Begin implementing SharedWorker
Some checks are pending
CI / Lagom (x86_64, Sanitizer_CI, false, ubuntu-24.04, Linux, GNU) (push) Waiting to run
CI / Lagom (arm64, Sanitizer_CI, false, macos-15, macOS, Clang) (push) Waiting to run
CI / Lagom (x86_64, Fuzzers_CI, false, ubuntu-24.04, Linux, Clang) (push) Waiting to run
CI / Lagom (x86_64, Sanitizer_CI, true, ubuntu-24.04, Linux, Clang) (push) Waiting to run
Package the js repl as a binary artifact / build-and-package (arm64, macos-15, macOS, macOS-universal2) (push) Waiting to run
Package the js repl as a binary artifact / build-and-package (x86_64, ubuntu-24.04, Linux, 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
Some checks are pending
CI / Lagom (x86_64, Sanitizer_CI, false, ubuntu-24.04, Linux, GNU) (push) Waiting to run
CI / Lagom (arm64, Sanitizer_CI, false, macos-15, macOS, Clang) (push) Waiting to run
CI / Lagom (x86_64, Fuzzers_CI, false, ubuntu-24.04, Linux, Clang) (push) Waiting to run
CI / Lagom (x86_64, Sanitizer_CI, true, ubuntu-24.04, Linux, Clang) (push) Waiting to run
Package the js repl as a binary artifact / build-and-package (arm64, macos-15, macOS, macOS-universal2) (push) Waiting to run
Package the js repl as a binary artifact / build-and-package (x86_64, ubuntu-24.04, Linux, 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
Shared workers are essentially just workers that may be accessed from scripts within the same origin. There are plenty of FIXMEs here (mostly building on existing worker FIXMEs that are already in place), but this lets us run the shared worker variants of WPT tests.
This commit is contained in:
parent
469d5ccc4b
commit
ea77092100
Notes:
github-actions[bot]
2025-05-02 21:49:00 +00:00
Author: https://github.com/trflynn89
Commit: ea77092100
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/4554
Reviewed-by: https://github.com/ADKaster
12 changed files with 392 additions and 6 deletions
68
Libraries/LibWeb/HTML/SharedWorkerGlobalScope.cpp
Normal file
68
Libraries/LibWeb/HTML/SharedWorkerGlobalScope.cpp
Normal file
|
@ -0,0 +1,68 @@
|
|||
/*
|
||||
* Copyright (c) 2025, Tim Flynn <trflynn89@ladybird.org>
|
||||
*
|
||||
* SPDX-License-Identifier: BSD-2-Clause
|
||||
*/
|
||||
|
||||
#include <LibWeb/Bindings/SharedWorkerExposedInterfaces.h>
|
||||
#include <LibWeb/HTML/SharedWorkerGlobalScope.h>
|
||||
#include <LibWeb/Page/Page.h>
|
||||
|
||||
namespace Web::HTML {
|
||||
|
||||
GC_DEFINE_ALLOCATOR(SharedWorkerGlobalScope);
|
||||
|
||||
HashTable<GC::RawRef<SharedWorkerGlobalScope>>& all_shared_worker_global_scopes()
|
||||
{
|
||||
static HashTable<GC::RawRef<SharedWorkerGlobalScope>> set;
|
||||
return set;
|
||||
}
|
||||
|
||||
SharedWorkerGlobalScope::SharedWorkerGlobalScope(JS::Realm& realm, GC::Ref<Web::Page> page, String name)
|
||||
: WorkerGlobalScope(realm, page)
|
||||
, m_name(move(name))
|
||||
{
|
||||
all_shared_worker_global_scopes().set(*this);
|
||||
}
|
||||
|
||||
SharedWorkerGlobalScope::~SharedWorkerGlobalScope() = default;
|
||||
|
||||
void SharedWorkerGlobalScope::initialize_web_interfaces_impl()
|
||||
{
|
||||
auto& realm = this->realm();
|
||||
|
||||
Bindings::add_shared_worker_exposed_interfaces(*this);
|
||||
|
||||
SharedWorkerGlobalScopeGlobalMixin::initialize(realm, *this);
|
||||
Base::initialize_web_interfaces_impl();
|
||||
}
|
||||
|
||||
void SharedWorkerGlobalScope::finalize()
|
||||
{
|
||||
Base::finalize();
|
||||
WindowOrWorkerGlobalScopeMixin::finalize();
|
||||
|
||||
all_shared_worker_global_scopes().remove(*this);
|
||||
}
|
||||
|
||||
// https://html.spec.whatwg.org/multipage/workers.html#dom-sharedworkerglobalscope-close
|
||||
void SharedWorkerGlobalScope::close()
|
||||
{
|
||||
// The close() method steps are to close a worker given this.
|
||||
close_a_worker();
|
||||
}
|
||||
|
||||
#define __ENUMERATE(attribute_name, event_name) \
|
||||
void SharedWorkerGlobalScope::set_##attribute_name(WebIDL::CallbackType* value) \
|
||||
{ \
|
||||
set_event_handler_attribute(event_name, move(value)); \
|
||||
} \
|
||||
\
|
||||
WebIDL::CallbackType* SharedWorkerGlobalScope::attribute_name() \
|
||||
{ \
|
||||
return event_handler_attribute(event_name); \
|
||||
}
|
||||
ENUMERATE_SHARED_WORKER_GLOBAL_SCOPE_EVENT_HANDLERS(__ENUMERATE)
|
||||
#undef __ENUMERATE
|
||||
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue