From a835f313f7df7900742176b145143b5c93931915 Mon Sep 17 00:00:00 2001 From: Andreas Kling Date: Sat, 3 Sep 2022 15:26:30 +0200 Subject: [PATCH] LibWeb: Make Document::is_fully_active() more robust We were missing a check for null browsing context container documents. --- Userland/Libraries/LibWeb/DOM/Document.cpp | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/Userland/Libraries/LibWeb/DOM/Document.cpp b/Userland/Libraries/LibWeb/DOM/Document.cpp index 21ffb80ef7..6aa2c76809 100644 --- a/Userland/Libraries/LibWeb/DOM/Document.cpp +++ b/Userland/Libraries/LibWeb/DOM/Document.cpp @@ -1471,7 +1471,18 @@ bool Document::is_fully_active() const { // A Document d is said to be fully active when d's browsing context is non-null, d's browsing context's active document is d, // and either d's browsing context is a top-level browsing context, or d's browsing context's container document is fully active. - return browsing_context() && browsing_context()->active_document() == this && (browsing_context()->is_top_level() || browsing_context()->container_document()->is_fully_active()); + auto* browsing_context = this->browsing_context(); + if (!browsing_context) + return false; + if (browsing_context->active_document() != this) + return false; + if (browsing_context->is_top_level()) + return true; + if (auto* browsing_context_container_document = browsing_context->container_document()) { + if (browsing_context_container_document->is_fully_active()) + return true; + } + return false; } // https://html.spec.whatwg.org/multipage/browsers.html#active-document