From 38531ce7cfc5139c20a948b7e324dea861d561bf Mon Sep 17 00:00:00 2001 From: Aliaksandr Kalenik Date: Thu, 2 Nov 2023 10:09:01 +0100 Subject: [PATCH] LibWeb: Do not unload during same-document history step application See https://github.com/whatwg/html/pull/9904 --- .../LibWeb/HTML/TraversableNavigable.cpp | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/Userland/Libraries/LibWeb/HTML/TraversableNavigable.cpp b/Userland/Libraries/LibWeb/HTML/TraversableNavigable.cpp index 32f25f0322f..cfdec1ed13c 100644 --- a/Userland/Libraries/LibWeb/HTML/TraversableNavigable.cpp +++ b/Userland/Libraries/LibWeb/HTML/TraversableNavigable.cpp @@ -424,15 +424,18 @@ void TraversableNavigable::apply_the_history_step(int step, Optionalunload(target_entry->document_state->document()); + // 1. If targetEntry's document does not equal displayedDocument, then: + if (target_entry->document_state->document().ptr() != displayed_document.ptr()) { + // 1. Unload displayedDocument given targetEntry's document. + displayed_document->unload(target_entry->document_state->document()); - // 2. For each childNavigable of displayedDocument's descendant navigables, queue a global task on the navigation and traversal task source given - // childNavigable's active window to unload childNavigable's active document. - for (auto child_navigable : displayed_document->descendant_navigables()) { - queue_global_task(Task::Source::NavigationAndTraversal, *navigable->active_window(), [child_navigable] { - child_navigable->active_document()->unload(); - }); + // 2. For each childNavigable of displayedDocument's descendant navigables, queue a global task on the navigation and traversal task source given + // childNavigable's active window to unload childNavigable's active document. + for (auto child_navigable : displayed_document->descendant_navigables()) { + queue_global_task(Task::Source::NavigationAndTraversal, *navigable->active_window(), [child_navigable] { + child_navigable->active_document()->unload(); + }); + } } // 3. Activate history entry targetEntry for navigable.