mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-07-29 12:19:54 +00:00
LibWeb/HTML: Hook up a WorkerAgent for web workers
This commit is contained in:
parent
5290ebfe19
commit
041ff0c7ff
Notes:
github-actions[bot]
2025-04-25 14:45:27 +00:00
Author: https://github.com/shannonbooth
Commit: 041ff0c7ff
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/4453
10 changed files with 78 additions and 12 deletions
|
@ -40,6 +40,7 @@
|
|||
#include <LibWeb/HTML/Scripting/SimilarOriginWindowAgent.h>
|
||||
#include <LibWeb/HTML/Scripting/SyntheticRealmSettings.h>
|
||||
#include <LibWeb/HTML/Scripting/TemporaryExecutionContext.h>
|
||||
#include <LibWeb/HTML/Scripting/WorkerAgent.h>
|
||||
#include <LibWeb/HTML/ShadowRealmGlobalScope.h>
|
||||
#include <LibWeb/HTML/Window.h>
|
||||
#include <LibWeb/HTML/WindowProxy.h>
|
||||
|
@ -72,15 +73,28 @@ HTML::Script* active_script()
|
|||
});
|
||||
}
|
||||
|
||||
void initialize_main_thread_vm(HTML::EventLoop::Type type)
|
||||
static NonnullOwnPtr<JS::Agent> create_agent(GC::Heap& heap, AgentType type)
|
||||
{
|
||||
switch (type) {
|
||||
case AgentType::SimilarOriginWindow:
|
||||
return HTML::SimilarOriginWindowAgent::create(heap);
|
||||
case AgentType::DedicatedWorker:
|
||||
case AgentType::SharedWorker:
|
||||
return HTML::WorkerAgent::create(heap, JS::Agent::CanBlock::Yes);
|
||||
case AgentType::ServiceWorker:
|
||||
return HTML::WorkerAgent::create(heap, JS::Agent::CanBlock::No);
|
||||
default:
|
||||
break;
|
||||
}
|
||||
VERIFY_NOT_REACHED();
|
||||
}
|
||||
|
||||
void initialize_main_thread_vm(AgentType type)
|
||||
{
|
||||
VERIFY(!s_main_thread_vm);
|
||||
|
||||
s_main_thread_vm = JS::VM::create();
|
||||
s_main_thread_vm->set_agent(HTML::SimilarOriginWindowAgent::create());
|
||||
|
||||
auto& agent = as<HTML::Agent>(*s_main_thread_vm->agent());
|
||||
agent.event_loop = s_main_thread_vm->heap().allocate<HTML::EventLoop>(type);
|
||||
s_main_thread_vm->set_agent(create_agent(s_main_thread_vm->heap(), type));
|
||||
|
||||
s_main_thread_vm->on_unimplemented_property_access = [](auto const& object, auto const& property_key) {
|
||||
dbgln("FIXME: Unimplemented IDL interface: '{}.{}'", object.class_name(), property_key.to_string());
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue