diff --git a/Userland/Libraries/LibWeb/HTML/Window.cpp b/Userland/Libraries/LibWeb/HTML/Window.cpp
index fb40af8e9d..7be0802bf7 100644
--- a/Userland/Libraries/LibWeb/HTML/Window.cpp
+++ b/Userland/Libraries/LibWeb/HTML/Window.cpp
@@ -1093,7 +1093,6 @@ WebIDL::ExceptionOr Window::initialize_web_interfaces(Badge Window::self() const
return verify_cast(relevant_realm(*this).global_environment().global_this_value());
}
+// https://html.spec.whatwg.org/multipage/nav-history-apis.html#dom-document-2
+JS::NonnullGCPtr Window::document() const
+{
+ // The document getter steps are to return this's associated Document.
+ return associated_document();
+}
+
// https://html.spec.whatwg.org/multipage/window-object.html#dom-frames
JS::NonnullGCPtr Window::frames() const
{
@@ -1551,12 +1557,6 @@ JS_DEFINE_NATIVE_FUNCTION(Window::parent_getter)
return parent;
}
-JS_DEFINE_NATIVE_FUNCTION(Window::document_getter)
-{
- auto* impl = TRY(impl_from(vm));
- return &impl->associated_document();
-}
-
// https://html.spec.whatwg.org/multipage/browsers.html#dom-frameelement
JS_DEFINE_NATIVE_FUNCTION(Window::frame_element_getter)
{
diff --git a/Userland/Libraries/LibWeb/HTML/Window.h b/Userland/Libraries/LibWeb/HTML/Window.h
index 189c4abb79..35a81d036f 100644
--- a/Userland/Libraries/LibWeb/HTML/Window.h
+++ b/Userland/Libraries/LibWeb/HTML/Window.h
@@ -142,6 +142,7 @@ public:
// JS API functions
JS::NonnullGCPtr window() const;
JS::NonnullGCPtr self() const;
+ JS::NonnullGCPtr document() const;
JS::NonnullGCPtr frames() const;
@@ -221,8 +222,6 @@ private:
JS_DECLARE_NATIVE_FUNCTION(length_getter);
JS_DECLARE_NATIVE_FUNCTION(top_getter);
- JS_DECLARE_NATIVE_FUNCTION(document_getter);
-
JS_DECLARE_NATIVE_FUNCTION(frame_element_getter);
JS_DECLARE_NATIVE_FUNCTION(location_getter);
diff --git a/Userland/Libraries/LibWeb/HTML/Window.idl b/Userland/Libraries/LibWeb/HTML/Window.idl
index f70ff80cd1..981837c0b0 100644
--- a/Userland/Libraries/LibWeb/HTML/Window.idl
+++ b/Userland/Libraries/LibWeb/HTML/Window.idl
@@ -1,3 +1,4 @@
+#import
#import
#import
#import
@@ -8,6 +9,7 @@ interface Window : EventTarget {
// the current browsing context
[LegacyUnforgeable] readonly attribute WindowProxy window;
[Replaceable] readonly attribute WindowProxy self;
+ [LegacyUnforgeable] readonly attribute Document document;
// other browsing contexts
[Replaceable] readonly attribute WindowProxy frames;