diff --git a/Userland/Libraries/LibWeb/HTML/Window.cpp b/Userland/Libraries/LibWeb/HTML/Window.cpp
index c75579fd70..561a9c35bf 100644
--- a/Userland/Libraries/LibWeb/HTML/Window.cpp
+++ b/Userland/Libraries/LibWeb/HTML/Window.cpp
@@ -11,10 +11,12 @@
#include
#include
#include
+#include
#include
#include
#include
#include
+#include
#include
#include
#include
@@ -1135,8 +1137,9 @@ WebIDL::ExceptionOr Window::initialize_web_interfaces(Badgevalue.as_accessor();
+ location_accessor.set_setter(JS::NativeFunction::create(realm, location_setter, 1, "location", &realm, {}, "set"sv));
// WebAssembly "namespace"
define_direct_property("WebAssembly", MUST_OR_THROW_OOM(heap().allocate(realm, realm)), JS::Attribute::Enumerable | JS::Attribute::Configurable);
@@ -1222,6 +1225,13 @@ void Window::set_name(String const& name)
browsing_context()->set_name(name.to_deprecated_string());
}
+// https://html.spec.whatwg.org/multipage/nav-history-apis.html#dom-location
+JS::NonnullGCPtr Window::location() const
+{
+ // The Window object's location getter steps are to return this's Location object.
+ return *m_location;
+}
+
// https://html.spec.whatwg.org/multipage/window-object.html#dom-frames
JS::NonnullGCPtr Window::frames() const
{
@@ -1632,12 +1642,6 @@ JS_DEFINE_NATIVE_FUNCTION(Window::event_setter)
REPLACEABLE_PROPERTY_SETTER(Window, event);
}
-JS_DEFINE_NATIVE_FUNCTION(Window::location_getter)
-{
- auto* impl = TRY(impl_from(vm));
- return impl->m_location;
-}
-
JS_DEFINE_NATIVE_FUNCTION(Window::location_setter)
{
auto* impl = TRY(impl_from(vm));
diff --git a/Userland/Libraries/LibWeb/HTML/Window.h b/Userland/Libraries/LibWeb/HTML/Window.h
index 10b1aac64d..31785872b2 100644
--- a/Userland/Libraries/LibWeb/HTML/Window.h
+++ b/Userland/Libraries/LibWeb/HTML/Window.h
@@ -14,6 +14,7 @@
#include
#include
#include
+#include
#include
#include
#include
@@ -23,7 +24,6 @@
#include
#include
#include
-#include
namespace Web::HTML {
@@ -142,6 +142,7 @@ public:
JS::NonnullGCPtr document() const;
String name() const;
void set_name(String const&);
+ JS::NonnullGCPtr location() const;
JS::NonnullGCPtr frames() const;
@@ -209,9 +210,6 @@ private:
public:
HTML::Origin origin() const;
- HTML::Location* location() { return m_location; }
- HTML::Location const* location() const { return m_location; }
-
virtual JS::ThrowCompletionOr internal_set_prototype_of(JS::Object* prototype) override;
CrossOriginPropertyDescriptorMap const& cross_origin_property_descriptor_map() const { return m_cross_origin_property_descriptor_map; }
@@ -223,7 +221,6 @@ private:
JS_DECLARE_NATIVE_FUNCTION(frame_element_getter);
- JS_DECLARE_NATIVE_FUNCTION(location_getter);
JS_DECLARE_NATIVE_FUNCTION(location_setter);
JS_DECLARE_NATIVE_FUNCTION(performance_getter);
diff --git a/Userland/Libraries/LibWeb/HTML/Window.idl b/Userland/Libraries/LibWeb/HTML/Window.idl
index 1b282460f7..0475c89d2d 100644
--- a/Userland/Libraries/LibWeb/HTML/Window.idl
+++ b/Userland/Libraries/LibWeb/HTML/Window.idl
@@ -11,6 +11,7 @@ interface Window : EventTarget {
[Replaceable] readonly attribute WindowProxy self;
[LegacyUnforgeable] readonly attribute Document document;
attribute DOMString name;
+ [PutForwards=href, LegacyUnforgeable] readonly attribute Location location;
// other browsing contexts
[Replaceable] readonly attribute WindowProxy frames;