summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndreas Kling <kling@serenityos.org>2020-09-22 18:24:49 +0200
committerAndreas Kling <kling@serenityos.org>2020-09-22 20:10:20 +0200
commitb4a35377162d1d92c64b004549a03c7d807b2189 (patch)
treea592c7f38ea9c1efa4d617df72b33e0d5f68e80f
parent618dcbe405a5d8c345d0c3c655e9cf29d1a68056 (diff)
downloadserenity-b4a35377162d1d92c64b004549a03c7d807b2189.zip
LibWeb: Add WindowObject::origin()
This is a convenience getter to retrieve the security origin of a DOM window's document.
-rw-r--r--Libraries/LibWeb/Bindings/WindowObject.cpp6
-rw-r--r--Libraries/LibWeb/Bindings/WindowObject.h2
2 files changed, 8 insertions, 0 deletions
diff --git a/Libraries/LibWeb/Bindings/WindowObject.cpp b/Libraries/LibWeb/Bindings/WindowObject.cpp
index ff4a6cf45b..7050b200b6 100644
--- a/Libraries/LibWeb/Bindings/WindowObject.cpp
+++ b/Libraries/LibWeb/Bindings/WindowObject.cpp
@@ -44,6 +44,7 @@
#include <LibWeb/Bindings/XMLHttpRequestPrototype.h>
#include <LibWeb/DOM/Document.h>
#include <LibWeb/DOM/Window.h>
+#include <LibWeb/Origin.h>
namespace Web {
namespace Bindings {
@@ -93,6 +94,11 @@ void WindowObject::visit_children(Visitor& visitor)
visitor.visit(m_xhr_prototype);
}
+Origin WindowObject::origin() const
+{
+ return impl().document().origin();
+}
+
static DOM::Window* impl_from(JS::Interpreter& interpreter, JS::GlobalObject& global_object)
{
auto* this_object = interpreter.this_value(global_object).to_object(interpreter, global_object);
diff --git a/Libraries/LibWeb/Bindings/WindowObject.h b/Libraries/LibWeb/Bindings/WindowObject.h
index 8b01a5ae3b..7feee05818 100644
--- a/Libraries/LibWeb/Bindings/WindowObject.h
+++ b/Libraries/LibWeb/Bindings/WindowObject.h
@@ -44,6 +44,8 @@ public:
DOM::Window& impl() { return *m_impl; }
const DOM::Window& impl() const { return *m_impl; }
+ Origin origin() const;
+
XMLHttpRequestPrototype* xhr_prototype() { return m_xhr_prototype; }
XMLHttpRequestConstructor* xhr_constructor() { return m_xhr_constructor; }