diff --git a/Userland/Libraries/LibWeb/HTML/Window.cpp b/Userland/Libraries/LibWeb/HTML/Window.cpp
index 7e1a809896..780fdc5375 100644
--- a/Userland/Libraries/LibWeb/HTML/Window.cpp
+++ b/Userland/Libraries/LibWeb/HTML/Window.cpp
@@ -880,10 +880,10 @@ JS::NonnullGCPtr Window::frames() const
}
// https://html.spec.whatwg.org/multipage/window-object.html#dom-length
-u32 Window::length() const
+u32 Window::length()
{
// The length getter steps are to return this's associated Document's document-tree child navigables's size.
- return static_cast(document_tree_child_browsing_context_count());
+ return associated_document().document_tree_child_navigables().size();
}
// https://html.spec.whatwg.org/multipage/nav-history-apis.html#dom-top
diff --git a/Userland/Libraries/LibWeb/HTML/Window.h b/Userland/Libraries/LibWeb/HTML/Window.h
index bcc323d563..2b8f47dfe1 100644
--- a/Userland/Libraries/LibWeb/HTML/Window.h
+++ b/Userland/Libraries/LibWeb/HTML/Window.h
@@ -136,7 +136,7 @@ public:
void focus();
JS::NonnullGCPtr frames() const;
- u32 length() const;
+ u32 length();
JS::GCPtr top() const;
JS::GCPtr parent() const;
JS::GCPtr frame_element() const;