summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTimothy Flynn <trflynn89@pm.me>2022-11-08 12:56:40 -0500
committerTim Flynn <trflynn89@pm.me>2022-11-08 19:58:34 -0500
commit2d5381fd916f346222faa7ab8f4ec0f2cdef3e08 (patch)
tree03ded937f9b3f45ee941c200453ec70e7d109ba0
parentf7c212a19dd9a3e33521f92ccb63ded27e72ab7c (diff)
downloadserenity-2d5381fd916f346222faa7ab8f4ec0f2cdef3e08.zip
LibWeb: Add a flag to track when a browsing context has been discarded
-rw-r--r--Userland/Libraries/LibWeb/HTML/BrowsingContext.cpp2
-rw-r--r--Userland/Libraries/LibWeb/HTML/BrowsingContext.h3
2 files changed, 5 insertions, 0 deletions
diff --git a/Userland/Libraries/LibWeb/HTML/BrowsingContext.cpp b/Userland/Libraries/LibWeb/HTML/BrowsingContext.cpp
index b87ca7bb30..a371771aeb 100644
--- a/Userland/Libraries/LibWeb/HTML/BrowsingContext.cpp
+++ b/Userland/Libraries/LibWeb/HTML/BrowsingContext.cpp
@@ -1329,6 +1329,8 @@ void BrowsingContext::set_system_visibility_state(VisibilityState visibility_sta
// https://html.spec.whatwg.org/multipage/window-object.html#a-browsing-context-is-discarded
void BrowsingContext::discard()
{
+ m_has_been_discarded = true;
+
// 1. Discard all Document objects for all the entries in browsingContext's session history.
for (auto& entry : m_session_history) {
if (entry.document)
diff --git a/Userland/Libraries/LibWeb/HTML/BrowsingContext.h b/Userland/Libraries/LibWeb/HTML/BrowsingContext.h
index 5de51ab530..6ac3a860de 100644
--- a/Userland/Libraries/LibWeb/HTML/BrowsingContext.h
+++ b/Userland/Libraries/LibWeb/HTML/BrowsingContext.h
@@ -243,6 +243,7 @@ public:
// https://html.spec.whatwg.org/multipage/window-object.html#a-browsing-context-is-discarded
void discard();
+ bool has_been_discarded() const { return m_has_been_discarded; }
// https://html.spec.whatwg.org/multipage/window-object.html#close-a-browsing-context
void close();
@@ -305,6 +306,8 @@ private:
JS::GCPtr<BrowsingContext> m_last_child;
JS::GCPtr<BrowsingContext> m_next_sibling;
JS::GCPtr<BrowsingContext> m_previous_sibling;
+
+ bool m_has_been_discarded { false };
};
HTML::Origin determine_the_origin(BrowsingContext const& browsing_context, Optional<AK::URL> url, SandboxingFlagSet sandbox_flags, Optional<HTML::Origin> invocation_origin);