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
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

@ -11,6 +11,7 @@
#include <LibJS/Runtime/PropertyDescriptor.h>
#include <LibJS/Runtime/PropertyKey.h>
#include <LibWeb/DOM/Document.h>
#include <LibWeb/DOM/EventTarget.h>
#include <LibWeb/HTML/CrossOrigin/AbstractOperations.h>
#include <LibWeb/HTML/CrossOrigin/Reporting.h>
#include <LibWeb/HTML/Scripting/Environments.h>
@ -24,7 +25,7 @@ GC_DEFINE_ALLOCATOR(WindowProxy);
// 7.4 The WindowProxy exotic object, https://html.spec.whatwg.org/multipage/window-object.html#the-windowproxy-exotic-object
WindowProxy::WindowProxy(JS::Realm& realm)
: JS::Object(realm, nullptr, MayInterfereWithIndexedPropertyAccess::Yes)
: DOM::EventTarget(realm, MayInterfereWithIndexedPropertyAccess::Yes)
{
}