LibWeb: Return a WindowProxy from document.defaultView

This aligns our implementation with the most recent specification steps.
This commit is contained in:
Tim Ledbetter 2024-09-21 06:25:26 +01:00 committed by Andreas Kling
commit 089139f09d
Notes: github-actions[bot] 2024-09-21 08:06:25 +00:00
6 changed files with 38 additions and 8 deletions

View file

@ -698,6 +698,22 @@ WebIDL::ExceptionOr<void> Document::close()
return {};
}
// https://html.spec.whatwg.org/multipage/nav-history-apis.html#dom-document-defaultview
JS::GCPtr<HTML::WindowProxy> Document::default_view()
{
// If this's browsing context is null, then return null.
if (!browsing_context())
return {};
// 2. Return this's browsing context's WindowProxy object.
return browsing_context()->window_proxy();
}
JS::GCPtr<HTML::WindowProxy const> Document::default_view() const
{
return const_cast<Document*>(this)->default_view();
}
HTML::Origin Document::origin() const
{
return m_origin;