1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-31 16:38:10 +00:00

LibWeb: Give web workers a (totally hacky) Window object

This is *not* according to spec, however we currently store prototypes
and constructors on Window, so the only way for objects in a worker
context to become fully formed is to make a Window.

Long-term we should clean this up and remove the worker window object,
but for now it allows workers to exist without asserting.
This commit is contained in:
Andreas Kling 2022-09-05 12:19:41 +02:00
parent ddc018fb75
commit e97cc671ea
3 changed files with 25 additions and 20 deletions

View file

@ -80,13 +80,18 @@ private:
NonnullOwnPtr<JS::Interpreter> m_interpreter;
WeakPtr<WorkerEnvironmentSettingsObject> m_inner_settings;
JS::VM::InterpreterExecutionScope m_interpreter_scope;
JS::GCPtr<JS::Realm> m_worker_realm;
RefPtr<WorkerDebugConsoleClient> m_console;
JS::GCPtr<JS::Object> m_worker_scope;
JS::NonnullGCPtr<MessagePort> m_implicit_port;
JS::GCPtr<MessagePort> m_outside_port;
// NOTE: These are inside the worker VM.
JS::GCPtr<JS::Realm> m_worker_realm;
JS::GCPtr<JS::Object> m_worker_scope;
// FIXME: This is a mega-hack but necessary because HTML::Window holds all the prototypes and constructors.
// There should be *no* Window object in a Worker context.
JS::GCPtr<HTML::Window> m_worker_window;
void run_a_worker(AK::URL& url, EnvironmentSettingsObject& outside_settings, MessagePort& outside_port, WorkerOptions const options);
};