diff --git a/Userland/Libraries/LibWeb/DOM/Document.cpp b/Userland/Libraries/LibWeb/DOM/Document.cpp index 6362a06d5fd4da6..38fb7e99b8b4d43 100644 --- a/Userland/Libraries/LibWeb/DOM/Document.cpp +++ b/Userland/Libraries/LibWeb/DOM/Document.cpp @@ -499,6 +499,17 @@ WebIDL::ExceptionOr Document::open(String const&, String const&) return this; } +// https://html.spec.whatwg.org/multipage/dynamic-markup-insertion.html#dom-document-open-window +WebIDL::ExceptionOr> Document::open(String const& url, String const& name, String const& features) +{ + // 1. If this is not fully active, then throw an "InvalidAccessError" DOMException exception. + if (!is_fully_active()) + return WebIDL::InvalidAccessError::create(realm(), "Cannot perform open on a document that isn't fully active."sv); + + // 2. Return the result of running the window open steps with url, name, and features. + return window().open_impl(url, name, features); +} + // https://html.spec.whatwg.org/multipage/dynamic-markup-insertion.html#closing-the-input-stream WebIDL::ExceptionOr Document::close() { diff --git a/Userland/Libraries/LibWeb/DOM/Document.h b/Userland/Libraries/LibWeb/DOM/Document.h index 3cf09999a2fc8a1..b55e7284f6fa242 100644 --- a/Userland/Libraries/LibWeb/DOM/Document.h +++ b/Userland/Libraries/LibWeb/DOM/Document.h @@ -33,6 +33,7 @@ #include #include #include +#include #include namespace Web::DOM { @@ -295,6 +296,7 @@ class Document WebIDL::ExceptionOr writeln(Vector const& strings); WebIDL::ExceptionOr open(String const& = "", String const& = ""); + WebIDL::ExceptionOr> open(String const& url, String const& name, String const& features); WebIDL::ExceptionOr close(); HTML::Window* default_view() { return m_window.ptr(); } diff --git a/Userland/Libraries/LibWeb/DOM/Document.idl b/Userland/Libraries/LibWeb/DOM/Document.idl index 1c667c7e84f42a8..473d59254b9842b 100644 --- a/Userland/Libraries/LibWeb/DOM/Document.idl +++ b/Userland/Libraries/LibWeb/DOM/Document.idl @@ -43,8 +43,7 @@ interface Document : Node { readonly attribute Window? defaultView; [CEReactions] Document open(optional DOMString unused1, optional DOMString unused2); - // FIXME: implement ExceptionOr Document::open(...) - // WindowProxy? open(USVString url, DOMString name, DOMString features); + WindowProxy? open(USVString url, DOMString name, DOMString features); [CEReactions] undefined close(); [CEReactions] undefined write(DOMString... text); [CEReactions] undefined writeln(DOMString... text);