Truly independent web browser
LibWeb+LibWebView: Decide which navigables a creation update skips
Shannon Booth5d269da9db15
diff --git a/Libraries/LibWeb/HTML/HistoryExecutor.cpp b/Libraries/LibWeb/HTML/HistoryExecutor.cppindex bcc84b068ed..eaaf0eecf06 100644--- a/Libraries/LibWeb/HTML/HistoryExecutor.cpp+++ b/Libraries/LibWeb/HTML/HistoryExecutor.cpp@@ -293,25 +293,6 @@ bool HistoryExecutor::run_changing_navigable_history_step_job_impl(ChangingNavigreturn false;}- // https://html.spec.whatwg.org/multipage/browsing-the-web.html#update-for-navigable-creation/destruction- // AD-HOC: Unconditionally populating a document here could unload and re-navigate a frame because an unrelated- // navigable was created or destroyed — which no other engine does. So we skip such applying-the-target-- // entry-would-cross-documents navigables here.- // https://github.com/whatwg/html/issues/12724- // Nor do we take a navigable from a navigation that has already started: its container's requested- // navigation owns the ongoing navigation ID and eventual document activation.- // A navigable still awaiting the update for its creation has only its initial about:blank, and populates- // the entry its nested history kept, which supersedes its container's navigation.- if (!job.navigation_type.has_value()) {- bool would_cross_documents = claimed_target_entry->document_state()->document_id() != navigable->active_document_id()- || claimed_target_entry->document_state()->reload_pending();- bool restores_kept_entry = would_cross_documents && !navigable->has_session_history_entry_and_ready_for_navigation();- if (!restores_kept_entry && (would_cross_documents || navigable->ongoing_navigation().has<Utf16String>())) {- on_complete->function()({ ChangingNavigableHistoryStepJobDisposition::Skipped, nullptr });- return false;- }- }-// https://html.spec.whatwg.org/multipage/nav-history-apis.html#fire-a-traverse-navigate-event// The UI process is the canonical coordinator for navigation starts and history operations. Only it can prove// that a navigation was admitted after this traversal; the presence of a local navigation ID does not establishdiff --git a/Libraries/LibWebView/ApplyHistoryStep.cpp b/Libraries/LibWebView/ApplyHistoryStep.cppindex 815a25f9b2a..a2f12befbf2 100644--- a/Libraries/LibWebView/ApplyHistoryStep.cpp+++ b/Libraries/LibWebView/ApplyHistoryStep.cpp@@ -181,6 +181,20 @@ void ApplyHistoryStep::run_changing_navigable_jobs()continue;}+ // AD-HOC: Unconditionally populating a document here could unload and re-navigate a frame because an+ // unrelated navigable was created or destroyed, which no other engine does. So an update for a+ // navigable's creation or destruction leaves a navigable alone if a navigation has claimed it, or if+ // the update would change its document. A navigable its creation marked as traversing is the+ // exception: it populates the entry its nested history kept.+ // See https://github.com/whatwg/html/issues/12724.+ if (!m_navigation_type.has_value()) {+ auto crosses_documents = !navigable->active_document_is(*target_entry) || target_entry->document_state->reload_pending;+ if (navigable->ongoing_navigation_id().has_value() || (crosses_documents && !navigable->ongoing_navigation().has<CanonicalNavigable::Traversal>())) {+ changing_navigable_job_completed(navigable_id, Web::HTML::ChangingNavigableHistoryStepJobDisposition::Skipped);+ continue;+ }+ }+ApplyHistoryStepJobs::ChangingNavigableHistoryStepJob job {.navigable_id = navigable_id,.target_entry = *target_entry,@@ -507,6 +521,11 @@ void ApplyHistoryStep::set_ongoing_navigation_to_traversal(CanonicalNavigable& nreturn;}+ // AD-HOC: An update for a navigable's creation or destruction changes the document of no navigable but one its+ // creation already marked as traversing. See https://github.com/whatwg/html/issues/12724.+ if (!m_navigation_type.has_value())+ return;+auto target_document_is_active_document = navigable.active_document_is(target_entry);auto traversal_crosses_documents = !target_document_is_active_document|| target_entry.document_state->reload_pending;@@ -528,11 +547,6 @@ void ApplyHistoryStep::set_ongoing_navigation_to_traversal(CanonicalNavigable& nreturn;}- // AD-HOC: A navigable creation/destruction update skips a navigable already claimed by its requested navigation.- // See https://github.com/whatwg/html/issues/12724.- if (!m_navigation_type.has_value() && ongoing_navigation_id.has_value())- return;-Optional<Utf16String> canceled_navigation_id;if (m_navigation_type == Web::Bindings::NavigationType::Traverse) {if (is_same_document_traversal && ongoing_navigation_id.has_value())