LibWeb: Make Event.currentTarget return WindowProxy instead of Window

Make WindowProxy implement the EventTarget interface. Add a new method
current_target_for_bindings() that returns a WindowProxy object instead
of directly exposing the Window object.

These changes fixes several WPT tests that contain `window ===
currentTarget`.
This commit is contained in:
mikiubo 2025-10-06 01:32:55 +02:00 committed by Jelle Raaijmakers
parent 373b2838db
commit d4df0e1db9
Notes: github-actions[bot] 2025-10-15 13:38:06 +00:00
17 changed files with 103 additions and 27 deletions

View file

@ -10,13 +10,14 @@
#include <LibGC/Ptr.h>
#include <LibJS/Forward.h>
#include <LibJS/Runtime/Object.h>
#include <LibWeb/DOM/EventTarget.h>
#include <LibWeb/Export.h>
#include <LibWeb/Forward.h>
namespace Web::HTML {
class WEB_API WindowProxy final : public JS::Object {
JS_OBJECT(WindowProxy, JS::Object);
class WEB_API WindowProxy final : public DOM::EventTarget {
WEB_PLATFORM_OBJECT(WindowProxy, DOM::EventTarget)
GC_DECLARE_ALLOCATOR(WindowProxy);
public:
@ -33,8 +34,6 @@ public:
virtual JS::ThrowCompletionOr<bool> internal_delete(JS::PropertyKey const&) override;
virtual JS::ThrowCompletionOr<GC::RootVector<JS::Value>> internal_own_property_keys() const override;
virtual bool eligible_for_own_property_enumeration_fast_path() const override final { return false; }
GC::Ptr<Window> window() const { return m_window; }
void set_window(GC::Ref<Window>);
@ -43,6 +42,8 @@ public:
private:
explicit WindowProxy(JS::Realm&);
virtual bool is_window_or_worker_global_scope_mixin() const final { return true; }
virtual bool is_html_window_proxy() const override { return true; }
virtual void visit_edges(JS::Cell::Visitor&) override;