From 73f77969a61f263c8042226cd0d24b1efdb6ed84 Mon Sep 17 00:00:00 2001 From: Andreas Kling Date: Fri, 5 Aug 2022 10:55:01 +0200 Subject: [PATCH] LibWeb: Add API for setting a document's referrer --- Userland/Libraries/LibWeb/DOM/Document.cpp | 8 ++++++-- Userland/Libraries/LibWeb/DOM/Document.h | 4 ++++ 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/Userland/Libraries/LibWeb/DOM/Document.cpp b/Userland/Libraries/LibWeb/DOM/Document.cpp index 35e5caa8fd..ad4922f5cf 100644 --- a/Userland/Libraries/LibWeb/DOM/Document.cpp +++ b/Userland/Libraries/LibWeb/DOM/Document.cpp @@ -1498,8 +1498,12 @@ bool Document::has_a_style_sheet_that_is_blocking_scripts() const String Document::referrer() const { - // FIXME: Return the document's actual referrer. - return ""; + return m_referrer; +} + +void Document::set_referrer(String referrer) +{ + m_referrer = referrer; } // https://html.spec.whatwg.org/multipage/browsers.html#fully-active diff --git a/Userland/Libraries/LibWeb/DOM/Document.h b/Userland/Libraries/LibWeb/DOM/Document.h index 49edb13afa..a34fcc0e9f 100644 --- a/Userland/Libraries/LibWeb/DOM/Document.h +++ b/Userland/Libraries/LibWeb/DOM/Document.h @@ -64,6 +64,7 @@ public: void set_cookie(String const&, Cookie::Source = Cookie::Source::NonHttp); String referrer() const; + void set_referrer(String); bool should_invalidate_styles_on_attribute_changes() const { return m_should_invalidate_styles_on_attribute_changes; } void set_should_invalidate_styles_on_attribute_changes(bool b) { m_should_invalidate_styles_on_attribute_changes = b; } @@ -483,6 +484,9 @@ private: // https://html.spec.whatwg.org/multipage/dom.html#is-initial-about:blank bool m_is_initial_about_blank { false }; + // https://html.spec.whatwg.org/multipage/dom.html#the-document's-referrer + String m_referrer { "" }; + // https://dom.spec.whatwg.org/#concept-document-origin HTML::Origin m_origin; };