Browse Source

LibWeb: Add stubs for document.write and document.writeln

ACID3 test page throws exception about document.write. Let's at least
get rid of it by defining these stubs.

I added document.writeln too because it is similar.
Maciej 3 years ago
parent
commit
ed33ea13ab

+ 12 - 0
Userland/Libraries/LibWeb/DOM/Document.cpp

@@ -147,6 +147,18 @@ void Document::removed_last_ref()
     delete this;
     delete this;
 }
 }
 
 
+// https://html.spec.whatwg.org/multipage/dynamic-markup-insertion.html#dom-document-write
+void Document::write(Vector<String> const& strings)
+{
+    dbgln("TODO: document.write({})", strings);
+}
+
+// https://html.spec.whatwg.org/multipage/dynamic-markup-insertion.html#dom-document-writeln
+void Document::writeln(Vector<String> const& strings)
+{
+    dbgln("TODO: document.writeln({})", strings);
+}
+
 Origin Document::origin() const
 Origin Document::origin() const
 {
 {
     if (!m_url.is_valid())
     if (!m_url.is_valid())

+ 4 - 0
Userland/Libraries/LibWeb/DOM/Document.h

@@ -13,6 +13,7 @@
 #include <AK/OwnPtr.h>
 #include <AK/OwnPtr.h>
 #include <AK/String.h>
 #include <AK/String.h>
 #include <AK/URL.h>
 #include <AK/URL.h>
+#include <AK/Vector.h>
 #include <AK/WeakPtr.h>
 #include <AK/WeakPtr.h>
 #include <LibCore/Forward.h>
 #include <LibCore/Forward.h>
 #include <LibJS/Forward.h>
 #include <LibJS/Forward.h>
@@ -243,6 +244,9 @@ public:
 
 
     Window& window() { return *m_window; }
     Window& window() { return *m_window; }
 
 
+    void write(Vector<String> const& strings);
+    void writeln(Vector<String> const& strings);
+
     Window* default_view() { return m_window; }
     Window* default_view() { return m_window; }
 
 
     const String& content_type() const { return m_content_type; }
     const String& content_type() const { return m_content_type; }

+ 3 - 0
Userland/Libraries/LibWeb/DOM/Document.idl

@@ -16,6 +16,9 @@ interface Document : Node {
 
 
     readonly attribute Window? defaultView;
     readonly attribute Window? defaultView;
 
 
+    undefined write(DOMString... text);
+    undefined writeln(DOMString... text);
+
     attribute DOMString cookie;
     attribute DOMString cookie;
 
 
     readonly attribute USVString referrer;
     readonly attribute USVString referrer;