From 14e1513077042269dff99f512884c798a54b1219 Mon Sep 17 00:00:00 2001 From: Andrew Kaster Date: Sat, 8 Oct 2022 17:32:03 -0600 Subject: [PATCH] LibWeb: Remove the workaround "Worker Window" from Workers We can now properly add the prototypes and constructors to the global object of the Worker's inner realm, so we don't need this window for anything anymore. --- .../LibWeb/HTML/Scripting/WorkerEnvironmentSettingsObject.h | 4 ++++ Userland/Libraries/LibWeb/HTML/Worker.cpp | 4 ---- Userland/Libraries/LibWeb/HTML/Worker.h | 3 --- 3 files changed, 4 insertions(+), 7 deletions(-) diff --git a/Userland/Libraries/LibWeb/HTML/Scripting/WorkerEnvironmentSettingsObject.h b/Userland/Libraries/LibWeb/HTML/Scripting/WorkerEnvironmentSettingsObject.h index cac5fb546a..e2e2ba6dc9 100644 --- a/Userland/Libraries/LibWeb/HTML/Scripting/WorkerEnvironmentSettingsObject.h +++ b/Userland/Libraries/LibWeb/HTML/Scripting/WorkerEnvironmentSettingsObject.h @@ -7,6 +7,7 @@ #pragma once #include +#include #include #include @@ -33,6 +34,9 @@ public: auto host_defined = make(*settings_object, *intrinsics); realm->set_host_defined(move(host_defined)); + // FIXME: Shared workers should use the shared worker method + Bindings::add_dedicated_worker_exposed_interfaces(realm->global_object(), *realm); + return *settings_object; } diff --git a/Userland/Libraries/LibWeb/HTML/Worker.cpp b/Userland/Libraries/LibWeb/HTML/Worker.cpp index 942ec5d655..ea796a3e0f 100644 --- a/Userland/Libraries/LibWeb/HTML/Worker.cpp +++ b/Userland/Libraries/LibWeb/HTML/Worker.cpp @@ -128,10 +128,6 @@ void Worker::run_a_worker(AK::URL& url, EnvironmentSettingsObject& outside_setti auto& console_object = *realm_execution_context->realm->intrinsics().console_object(); m_worker_realm = realm_execution_context->realm; - // FIXME: Remove this once we don't need a hack Window (for prototypes and constructors) in workers anymore. - m_worker_window = HTML::Window::create(*m_worker_realm); - m_worker_realm->set_global_object(m_worker_scope, nullptr); - m_console = adopt_ref(*new WorkerDebugConsoleClient(console_object.console())); console_object.console().set_client(*m_console); diff --git a/Userland/Libraries/LibWeb/HTML/Worker.h b/Userland/Libraries/LibWeb/HTML/Worker.h index 17bde2e1cc..38dc64a411 100644 --- a/Userland/Libraries/LibWeb/HTML/Worker.h +++ b/Userland/Libraries/LibWeb/HTML/Worker.h @@ -89,9 +89,6 @@ private: // NOTE: These are inside the worker VM. JS::GCPtr m_worker_realm; JS::GCPtr 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 m_worker_window; void run_a_worker(AK::URL& url, EnvironmentSettingsObject& outside_settings, MessagePort& outside_port, WorkerOptions const& options); };