diff --git a/Libraries/LibWeb/DOM/EventTarget.cpp b/Libraries/LibWeb/DOM/EventTarget.cpp index 37d859b6a10..4650d861c34 100644 --- a/Libraries/LibWeb/DOM/EventTarget.cpp +++ b/Libraries/LibWeb/DOM/EventTarget.cpp @@ -67,7 +67,7 @@ void EventTarget::initialize(JS::Realm& realm) // FIXME: We can't do this for HTML::Window or HTML::WorkerGlobalScope, as this will run when creating the initial global object. // During this time, the ESO is not setup, so it will cause a nullptr dereference in host_defined_intrinsics. - if (!is(this)) + if (!is_window_or_worker_global_scope_mixin()) WEB_SET_PROTOTYPE_FOR_INTERFACE(EventTarget); } diff --git a/Libraries/LibWeb/DOM/EventTarget.h b/Libraries/LibWeb/DOM/EventTarget.h index 7db61acef51..b7ab5fcb21d 100644 --- a/Libraries/LibWeb/DOM/EventTarget.h +++ b/Libraries/LibWeb/DOM/EventTarget.h @@ -59,6 +59,8 @@ public: bool has_event_listener(FlyString const& type) const; bool has_event_listeners() const; + virtual bool is_window_or_worker_global_scope_mixin() const { return false; } + protected: explicit EventTarget(JS::Realm&, MayInterfereWithIndexedPropertyAccess = MayInterfereWithIndexedPropertyAccess::No); diff --git a/Libraries/LibWeb/HTML/Window.h b/Libraries/LibWeb/HTML/Window.h index 7b427d03443..6a2429ec349 100644 --- a/Libraries/LibWeb/HTML/Window.h +++ b/Libraries/LibWeb/HTML/Window.h @@ -269,6 +269,8 @@ public: private: explicit Window(JS::Realm&); + virtual bool is_window_or_worker_global_scope_mixin() const final { return true; } + virtual void visit_edges(Cell::Visitor&) override; virtual void finalize() override; diff --git a/Libraries/LibWeb/HTML/WorkerGlobalScope.h b/Libraries/LibWeb/HTML/WorkerGlobalScope.h index adc240681b1..7c70631f436 100644 --- a/Libraries/LibWeb/HTML/WorkerGlobalScope.h +++ b/Libraries/LibWeb/HTML/WorkerGlobalScope.h @@ -112,6 +112,8 @@ protected: GC::Ptr m_internal_port; private: + virtual bool is_window_or_worker_global_scope_mixin() const final { return true; } + virtual void visit_edges(Cell::Visitor&) override; GC::Ptr m_location;