From ac329d0a18c15adf9bf3182f49a6ac1d6f936956 Mon Sep 17 00:00:00 2001 From: Andreas Kling Date: Fri, 4 Nov 2022 10:05:10 +0100 Subject: [PATCH] LibWeb: Make HTMLIFrameElement.contentWindow return the WindowProxy This fixes an issue where contentWindow was not accessible immediately after programmatically creating an iframe element. --- .../Libraries/LibWeb/HTML/BrowsingContextContainer.cpp | 8 +++----- Userland/Libraries/LibWeb/HTML/BrowsingContextContainer.h | 2 +- Userland/Libraries/LibWeb/HTML/HTMLIFrameElement.idl | 3 +-- 3 files changed, 5 insertions(+), 8 deletions(-) diff --git a/Userland/Libraries/LibWeb/HTML/BrowsingContextContainer.cpp b/Userland/Libraries/LibWeb/HTML/BrowsingContextContainer.cpp index 7b584560198..d7f62d8aab0 100644 --- a/Userland/Libraries/LibWeb/HTML/BrowsingContextContainer.cpp +++ b/Userland/Libraries/LibWeb/HTML/BrowsingContextContainer.cpp @@ -109,13 +109,11 @@ const DOM::Document* BrowsingContextContainer::get_svg_document() const return nullptr; } -HTML::Window* BrowsingContextContainer::content_window() const +HTML::WindowProxy* BrowsingContextContainer::content_window() { - // FIXME: This should return the WindowProxy - auto* document = content_document(); - if (!document) + if (!m_nested_browsing_context) return nullptr; - return const_cast(&document->window()); + return m_nested_browsing_context->window_proxy(); } // https://html.spec.whatwg.org/multipage/urls-and-fetching.html#matches-about:blank diff --git a/Userland/Libraries/LibWeb/HTML/BrowsingContextContainer.h b/Userland/Libraries/LibWeb/HTML/BrowsingContextContainer.h index 4ac104d25dd..f2f9b14a62f 100644 --- a/Userland/Libraries/LibWeb/HTML/BrowsingContextContainer.h +++ b/Userland/Libraries/LibWeb/HTML/BrowsingContextContainer.h @@ -24,7 +24,7 @@ public: const DOM::Document* content_document() const; DOM::Document const* content_document_without_origin_check() const; - HTML::Window* content_window() const; + HTML::WindowProxy* content_window(); DOM::Document const* get_svg_document() const; diff --git a/Userland/Libraries/LibWeb/HTML/HTMLIFrameElement.idl b/Userland/Libraries/LibWeb/HTML/HTMLIFrameElement.idl index f0d9ae5aef5..0ae7892f982 100644 --- a/Userland/Libraries/LibWeb/HTML/HTMLIFrameElement.idl +++ b/Userland/Libraries/LibWeb/HTML/HTMLIFrameElement.idl @@ -15,8 +15,7 @@ interface HTMLIFrameElement : HTMLElement { readonly attribute Document? contentDocument; - // FIXME: Should return a WindowProxy? - readonly attribute Window? contentWindow; + readonly attribute WindowProxy? contentWindow; [Reflect] attribute DOMString align; [Reflect] attribute DOMString scrolling;