mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-07-05 00:21:52 +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
|
@ -10,6 +10,7 @@
|
|||
#include <LibWeb/HTML/MessagePort.h>
|
||||
#include <LibWeb/HTML/Scripting/Environments.h>
|
||||
#include <LibWeb/HTML/Scripting/WindowEnvironmentSettingsObject.h>
|
||||
#include <LibWeb/HTML/SharedWorker.h>
|
||||
#include <LibWeb/HTML/Worker.h>
|
||||
|
||||
namespace Web::HTML {
|
||||
|
@ -82,14 +83,14 @@ WebIDL::ExceptionOr<GC::Ref<Worker>> Worker::create(String const& script_url, Wo
|
|||
|
||||
// 9. Run this step in parallel:
|
||||
// 1. Run a worker given worker, worker URL, outside settings, outside port, and options.
|
||||
worker->run_a_worker(url.value(), outside_settings, *outside_port, options);
|
||||
run_a_worker(worker, url.value(), outside_settings, *outside_port, options);
|
||||
|
||||
// 10. Return worker
|
||||
return worker;
|
||||
}
|
||||
|
||||
// https://html.spec.whatwg.org/multipage/workers.html#run-a-worker
|
||||
void Worker::run_a_worker(URL::URL& url, EnvironmentSettingsObject& outside_settings, GC::Ptr<MessagePort> port, WorkerOptions const& options)
|
||||
void run_a_worker(Variant<GC::Ref<Worker>, GC::Ref<SharedWorker>> worker, URL::URL& url, EnvironmentSettingsObject& outside_settings, GC::Ptr<MessagePort> port, WorkerOptions const& options)
|
||||
{
|
||||
// 1. Let is shared be true if worker is a SharedWorker object, and false otherwise.
|
||||
// FIXME: SharedWorker support
|
||||
|
@ -107,10 +108,11 @@ void Worker::run_a_worker(URL::URL& url, EnvironmentSettingsObject& outside_sett
|
|||
// 5. Let unsafeWorkerCreationTime be the unsafe shared current time.
|
||||
|
||||
// 6. Let agent be the result of obtaining a dedicated/shared worker agent given outside settings
|
||||
// and is shared. Run the rest of these steps in that agent.
|
||||
// and is shared. Run the rest of these steps in that agent.
|
||||
|
||||
// Note: This spawns a new process to act as the 'agent' for the worker.
|
||||
m_agent = outside_settings.realm().create<WorkerAgentParent>(url, options, port, outside_settings);
|
||||
auto agent = outside_settings.realm().create<WorkerAgentParent>(url, options, port, outside_settings);
|
||||
worker.visit([&](auto worker) { worker->set_agent(agent); });
|
||||
}
|
||||
|
||||
// https://html.spec.whatwg.org/multipage/workers.html#dom-worker-terminate
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue