From 7b67fa706fd2dabfda3c72a752ac70d8c95bb060 Mon Sep 17 00:00:00 2001 From: Andrew Kaster Date: Wed, 5 Jun 2024 16:22:49 -0600 Subject: [PATCH] DOM: Check for navigable destruction in declarative refresh timer If the Document's navigable has been destroyed since we started this timer, or it's no longer the active document of its navigable, we shouldn't navigate to it. --- Userland/Libraries/LibWeb/DOM/Document.cpp | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/Userland/Libraries/LibWeb/DOM/Document.cpp b/Userland/Libraries/LibWeb/DOM/Document.cpp index a1df85e293e..90b544713d8 100644 --- a/Userland/Libraries/LibWeb/DOM/Document.cpp +++ b/Userland/Libraries/LibWeb/DOM/Document.cpp @@ -4062,8 +4062,11 @@ void Document::shared_declarative_refresh_steps(StringView input, JS::GCPtrnavigate({ .url = url_record, .source_document = *this })); + auto navigable = this->navigable(); + if (!navigable || navigable->has_been_destroyed()) + return; + + MUST(navigable->navigate({ .url = url_record, .source_document = *this, .history_handling = Bindings::NavigationHistoryBehavior::Replace })); }); // For the purposes of the previous paragraph, a refresh is said to have come due as soon as the later of the