summaryrefslogtreecommitdiff
path: root/Userland/Libraries/LibWeb/HTML
diff options
context:
space:
mode:
Diffstat (limited to 'Userland/Libraries/LibWeb/HTML')
-rw-r--r--Userland/Libraries/LibWeb/HTML/BrowsingContextContainer.cpp36
-rw-r--r--Userland/Libraries/LibWeb/HTML/BrowsingContextContainer.h3
2 files changed, 20 insertions, 19 deletions
diff --git a/Userland/Libraries/LibWeb/HTML/BrowsingContextContainer.cpp b/Userland/Libraries/LibWeb/HTML/BrowsingContextContainer.cpp
index 3279798a6c..95b354d98d 100644
--- a/Userland/Libraries/LibWeb/HTML/BrowsingContextContainer.cpp
+++ b/Userland/Libraries/LibWeb/HTML/BrowsingContextContainer.cpp
@@ -1,5 +1,6 @@
/*
* Copyright (c) 2020-2021, Andreas Kling <kling@serenityos.org>
+ * Copyright (c) 2022, Linus Groh <linusg@serenityos.org>
*
* SPDX-License-Identifier: BSD-2-Clause
*/
@@ -35,25 +36,28 @@ void BrowsingContextContainer::inserted()
}
}
-Origin BrowsingContextContainer::content_origin() const
+// https://html.spec.whatwg.org/multipage/browsers.html#concept-bcc-content-document
+const DOM::Document* BrowsingContextContainer::content_document() const
{
- if (!m_nested_browsing_context || !m_nested_browsing_context->active_document())
- return {};
- return m_nested_browsing_context->active_document()->origin();
-}
+ // 1. If container's nested browsing context is null, then return null.
+ if (m_nested_browsing_context == nullptr)
+ return nullptr;
-bool BrowsingContextContainer::may_access_from_origin(const Origin& origin) const
-{
- if (auto* page = document().page()) {
- if (!page->is_same_origin_policy_enabled())
- return true;
- }
- return origin.is_same_origin(content_origin());
-}
+ // 2. Let context be container's nested browsing context.
+ auto const& context = *m_nested_browsing_context;
-const DOM::Document* BrowsingContextContainer::content_document() const
-{
- return m_nested_browsing_context ? m_nested_browsing_context->active_document() : nullptr;
+ // 3. Let document be context's active document.
+ auto const* document = context.active_document();
+
+ VERIFY(document);
+ VERIFY(m_document);
+
+ // 4. If document's origin and container's node document's origin are not same origin-domain, then return null.
+ if (!document->origin().is_same_origin_domain(m_document->origin()))
+ return nullptr;
+
+ // 5. Return document.
+ return document;
}
}
diff --git a/Userland/Libraries/LibWeb/HTML/BrowsingContextContainer.h b/Userland/Libraries/LibWeb/HTML/BrowsingContextContainer.h
index bde9bc394c..43f17da1a4 100644
--- a/Userland/Libraries/LibWeb/HTML/BrowsingContextContainer.h
+++ b/Userland/Libraries/LibWeb/HTML/BrowsingContextContainer.h
@@ -20,9 +20,6 @@ public:
const DOM::Document* content_document() const;
- Origin content_origin() const;
- bool may_access_from_origin(const Origin&) const;
-
virtual void inserted() override;
protected: