Truly independent web browser
LibWeb+LibWebView+WebContent: Let a same-document traversal not yield
Shannon Booth2f4cf39aa14c
diff --git a/Libraries/LibWeb/HTML/HistoryExecutor.cpp b/Libraries/LibWeb/HTML/HistoryExecutor.cppindex 614908a3cd5..e85b2c240b2 100644--- a/Libraries/LibWeb/HTML/HistoryExecutor.cpp+++ b/Libraries/LibWeb/HTML/HistoryExecutor.cpp@@ -273,7 +273,7 @@ void HistoryExecutor::enqueue_changing_navigable_continuation(CrossProcessId opeon_complete->function()(ChangingNavigableHistoryStepJobDisposition::Ready, continuation->update_only, target_document_id);}-void HistoryExecutor::run_ui_changing_navigable_history_job(CrossProcessId operation_id, CrossProcessId navigable_id, SessionHistoryEntryDescriptor target_entry_descriptor, UserNavigationInvolvement user_involvement, Optional<Bindings::NavigationType> navigation_type, TraversalYieldsTo traversal_yields_to, Optional<Utf16String> canceled_navigation_id, Optional<Utf16String> finalized_navigation_id, Optional<NavigationSourceSnapshot> navigation_source_snapshot, GC::Ref<OnChangingNavigableHistoryStepJobComplete> on_complete, Optional<HistoryNavigationPopulation> population)+void HistoryExecutor::run_ui_changing_navigable_history_job(CrossProcessId operation_id, CrossProcessId navigable_id, SessionHistoryEntryDescriptor target_entry_descriptor, UserNavigationInvolvement user_involvement, Optional<Bindings::NavigationType> navigation_type, Optional<Utf16String> finalized_navigation_id, Optional<NavigationSourceSnapshot> navigation_source_snapshot, GC::Ref<OnChangingNavigableHistoryStepJobComplete> on_complete, Optional<HistoryNavigationPopulation> population){auto& operation = ensure_history_operation(operation_id);auto pending_document = operation.pending_document;@@ -329,39 +329,21 @@ void HistoryExecutor::run_ui_changing_navigable_history_job(CrossProcessId opera// job. Retain that exact local entry instead of repeating the global-step lookup in WebContent.NonnullRefPtr claimed_target_entry = local_target_entry.release_nonnull();- // 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 establish- // that ordering. A proven-newer navigation owns the visible outcome, so abandon the traversal without committing- // its canonical target step.- //- // A navigation this process started before it learned of a same-document traversal reaches the UI process after- // the traversal. Apart from the admitted navigation the traversal canceled, a navigation still awaiting the UI- // process is such a newer navigation.- auto yields_to_unadmitted_navigation = [&] {- auto ongoing_navigation = navigable->ongoing_navigation();- auto const* navigation_id = ongoing_navigation.get_pointer<Utf16String>();- return navigation_id- && canceled_navigation_id != *navigation_id- && navigable->has_navigation_parked_for_population(*navigation_id);- };- if (traversal_yields_to == TraversalYieldsTo::AdmittedNavigation- || (traversal_yields_to == TraversalYieldsTo::UnadmittedNavigation && yields_to_unadmitted_navigation())) {- on_complete->function()(ChangingNavigableHistoryStepJobDisposition::Stale, false, {});- return;- }-// 8.2. Set navigable's current session history entry to targetEntry.navigable->set_current_session_history_entry(claimed_target_entry);// AD-HOC: The UI operation owns the authoritative traversal tracker, mirrored here when the changing job begins.// As in browsers, only a traversal or reload sets it to "traversal". A push or replace leaves a newer// navigation's ID in place, as that navigation goes on and commits after this one, and nulls the ID of the- // navigation it finalizes. See https://github.com/whatwg/html/issues/12581.+ // navigation it finalizes. A same-document traversal leaves the navigation's ID in place too.+ // See https://github.com/whatwg/html/issues/12581.+ auto is_same_document_traversal = navigation_type == Bindings::NavigationType::Traverse+ && claimed_target_entry->document_state()->document_id() == navigable->active_document_id()+ && !claimed_target_entry->document_state()->reload_pending();if (navigation_type.has_value() && first_is_one_of(*navigation_type, Bindings::NavigationType::Push, Bindings::NavigationType::Replace)) {if (finalized_navigation_id.has_value() && navigable->ongoing_navigation() == *finalized_navigation_id)navigable->set_ongoing_navigation_without_informing_navigation_api(Empty {});- } else {+ } else if (!is_same_document_traversal) {navigable->set_ongoing_navigation_without_informing_navigation_api(HTML::LocalNavigable::Traversal::Tag);}diff --git a/Libraries/LibWeb/HTML/HistoryExecutor.h b/Libraries/LibWeb/HTML/HistoryExecutor.hindex 741efad52ca..70156013f77 100644--- a/Libraries/LibWeb/HTML/HistoryExecutor.h+++ b/Libraries/LibWeb/HTML/HistoryExecutor.h@@ -67,7 +67,7 @@ public:void finalize_same_document_navigation(GC::Ref<LocalNavigable>, NonnullRefPtr<SessionHistoryEntry>, RefPtr<SessionHistoryEntry> entry_to_replace, HistoryHandlingBehavior, UserNavigationInvolvement, Optional<SessionHistoryEntryPersistedState> previous_entry_persisted_state);void run_ui_beforeunload_check(Vector<CrossProcessId> navigable_ids, Optional<SessionHistoryEntryDescriptor> target_entry, Optional<UserNavigationInvolvement> user_involvement_for_navigate_event, UnloadPromptShown, GC::Ref<GC::Function<void(CheckIfUnloadingIsCanceledResult, UnloadPromptShown)>>);- void run_ui_changing_navigable_history_job(CrossProcessId operation_id, CrossProcessId navigable_id, SessionHistoryEntryDescriptor target_entry_descriptor, UserNavigationInvolvement, Optional<Bindings::NavigationType>, TraversalYieldsTo, Optional<Utf16String> canceled_navigation_id, Optional<Utf16String> finalized_navigation_id, Optional<NavigationSourceSnapshot>, GC::Ref<OnChangingNavigableHistoryStepJobComplete>, Optional<HistoryNavigationPopulation> = {});+ void run_ui_changing_navigable_history_job(CrossProcessId operation_id, CrossProcessId navigable_id, SessionHistoryEntryDescriptor target_entry_descriptor, UserNavigationInvolvement, Optional<Bindings::NavigationType>, Optional<Utf16String> finalized_navigation_id, Optional<NavigationSourceSnapshot>, GC::Ref<OnChangingNavigableHistoryStepJobComplete>, Optional<HistoryNavigationPopulation> = {});bool resume_history_navigation_population(CrossProcessId operation_id, HistoryNavigationPopulation&&);void apply_ui_changing_navigable_continuation(CrossProcessId operation_id, CrossProcessId navigable_id, SessionHistoryEntryIdentity target_entry_identity, HistoryObjectLengthAndIndex, Vector<SessionHistoryEntryDescriptor> entries_for_navigation_api, GC::Ref<OnChangingNavigableContinuationApplied>);void unload_displayed_document_and_apply_ui_changing_navigable_continuation(CrossProcessId operation_id, CrossProcessId navigable_id, SessionHistoryEntryIdentity target_entry_identity, HistoryObjectLengthAndIndex, Vector<SessionHistoryEntryDescriptor> entries_for_navigation_api, GC::Ref<OnChangingNavigableContinuationApplied>);diff --git a/Libraries/LibWebCommon/HTML/ApplyHistoryStep.h b/Libraries/LibWebCommon/HTML/ApplyHistoryStep.hindex 0a5e1f784b2..3825d432bde 100644--- a/Libraries/LibWebCommon/HTML/ApplyHistoryStep.h+++ b/Libraries/LibWebCommon/HTML/ApplyHistoryStep.h@@ -37,15 +37,6 @@ enum class ChangingNavigableHistoryStepJobDisposition : u8 {Stale,};-// AD-HOC: A same-document traversal yields to a newer navigation of its navigable.-enum class TraversalYieldsTo : u8 {- Nothing,- // The UI process admitted a navigation after the traversal.- AdmittedNavigation,- // The navigable's process started a navigation before it learned of the traversal.- UnadmittedNavigation,-};-enum class UnloadPromptShown : bool {No,Yes,diff --git a/Libraries/LibWebView/ApplyHistoryStep.cpp b/Libraries/LibWebView/ApplyHistoryStep.cppindex 5c5854d9b81..892636c30bd 100644--- a/Libraries/LibWebView/ApplyHistoryStep.cpp+++ b/Libraries/LibWebView/ApplyHistoryStep.cpp@@ -158,7 +158,7 @@ void ApplyHistoryStep::get_changing_and_nonchanging_navigables()m_traversable.queue_navigation_api_state_clear_task(*this, changing_navigable);// 4. Set navigable's ongoing navigation to "traversal".- set_ongoing_navigation_to_traversal(changing_navigable, navigable, *target_entry);+ set_ongoing_navigation_to_traversal(navigable, *target_entry);}run_changing_navigable_jobs();@@ -468,47 +468,33 @@ Web::HTML::SessionHistoryEntryDescriptor ChangingNavigable::target_entry_descripreturn descriptor;}-void ApplyHistoryStep::set_ongoing_navigation_to_traversal(ChangingNavigable& changing_navigable, CanonicalNavigable& navigable, CanonicalSessionHistoryEntry const& target_entry)+void ApplyHistoryStep::set_ongoing_navigation_to_traversal(CanonicalNavigable& navigable, CanonicalSessionHistoryEntry const& target_entry){// AD-HOC: As in browsers, a push or replace leaves the ongoing navigation alone: a newer navigation goes on, and- // commits after it. See https://github.com/whatwg/html/issues/12581.+ // commits after it. So does a same-document traversal, where the spec sets "traversal" and so drops the+ // navigation. See https://github.com/whatwg/html/issues/12581.// NB: An update for a navigable's creation or destruction changes the document of no navigable but one its creation// already marked as traversing.if (m_navigation_type != Web::Bindings::NavigationType::Traverse && m_navigation_type != Web::Bindings::NavigationType::Reload)return;+ if (navigable.active_document_is(target_entry) && !target_entry.document_state->reload_pending)+ return;- // AD-HOC: A navigation admitted after the operation goes on, as the newest, and the operation leaves the navigable- // to it. That leaves the navigable's current entry with its document: a reload's target entry was current- // already, and a same-document traversal's has the active document. A traversal that crosses documents- // has made current an entry whose document only it activates, and aborts the navigation, as specified.- // The specification's traversal queue does not model Ladybird's independently admitted UI-process- // navigations. See https://github.com/whatwg/html/issues/12581.- auto ongoing_navigation_id = navigable.ongoing_navigation_id();- auto ongoing_navigation = ongoing_navigation_id.has_value() ? navigable.navigation_with_id(*ongoing_navigation_id) : nullptr;- auto newer_navigation_was_admitted = ongoing_navigation && ongoing_navigation->sequence_number > m_operation_sequence_number;-- // The marker cancels navigation-start requests that arrive while this operation is on the traversal queue, matching- // navigate()'s "if navigable's ongoing navigation is 'traversal', then return".- if (!navigable.active_document_is(target_entry) || target_entry.document_state->reload_pending) {- if (m_navigation_type == Web::Bindings::NavigationType::Reload && newer_navigation_was_admitted)+ // AD-HOC: A navigation admitted after a reload goes on, as the newest, and the reload leaves the navigable to it,+ // its target entry being current already. A traversal that crosses documents has made current an entry+ // whose document only it activates, and aborts the navigation, as specified. The specification's traversal+ // queue does not model Ladybird's independently admitted UI-process navigations.+ // See https://github.com/whatwg/html/issues/12581.+ if (m_navigation_type == Web::Bindings::NavigationType::Reload) {+ auto ongoing_navigation_id = navigable.ongoing_navigation_id();+ auto ongoing_navigation = ongoing_navigation_id.has_value() ? navigable.navigation_with_id(*ongoing_navigation_id) : nullptr;+ if (ongoing_navigation && ongoing_navigation->sequence_number > m_operation_sequence_number)return;- navigable.set_ongoing_navigation_to_traversal(m_operation_id);- return;}- if (m_navigation_type != Web::Bindings::NavigationType::Traverse)- return;-- // AD-HOC: A same-document traversal does not install the marker. A navigation racing one genuinely started before- // this step ran in its own process. Its navigate() saw no traversal, and the admission recheck must not- // misattribute that ordering and drop the navigation the step has to yield to.- if (newer_navigation_was_admitted) {- changing_navigable.traversal_yields_to = Web::HTML::TraversalYieldsTo::AdmittedNavigation;- return;- }- changing_navigable.traversal_yields_to = Web::HTML::TraversalYieldsTo::UnadmittedNavigation;- changing_navigable.canceled_navigation_id = ongoing_navigation_id.copy();- navigable.clear_ongoing_navigation();+ // The marker cancels navigation-start requests that arrive while this operation is on the traversal queue, matching+ // navigate()'s "if navigable's ongoing navigation is 'traversal', then return".+ navigable.set_ongoing_navigation_to_traversal(m_operation_id);}ChangingNavigable* ApplyHistoryStep::changing_navigable(Web::HTML::CrossProcessId navigable_id) constdiff --git a/Libraries/LibWebView/ApplyHistoryStep.h b/Libraries/LibWebView/ApplyHistoryStep.hindex 2febff74cf8..dae67330c7e 100644--- a/Libraries/LibWebView/ApplyHistoryStep.h+++ b/Libraries/LibWebView/ApplyHistoryStep.h@@ -12,7 +12,6 @@#include <AK/NonnullOwnPtr.h>#include <AK/Optional.h>#include <AK/RefPtr.h>-#include <AK/Utf16String.h>#include <AK/Vector.h>#include <AK/WeakPtr.h>#include <LibCore/Promise.h>@@ -65,9 +64,6 @@ struct WEBVIEW_API ChangingNavigable {// Nothing more comes from the process running the job, and it counts towards completedChangeJobs.bool job_ended { false };- // AD-HOC: What a same-document traversal yields to, with the admitted navigation it canceled.- Web::HTML::TraversalYieldsTo traversal_yields_to { Web::HTML::TraversalYieldsTo::Nothing };- Optional<Utf16String> canceled_navigation_id {};// The run's part of the continuation, which the process running the job applies with the rest.struct Continuation {Web::HTML::HistoryObjectLengthAndIndex history_object_length_and_index;@@ -157,7 +153,7 @@ private:void set_current_session_history_step();CanonicalSessionHistoryEntry* append_the_claimed_target_entry_again(CanonicalNavigable&, CanonicalSessionHistoryEntry& claimed_target_entry);- void set_ongoing_navigation_to_traversal(ChangingNavigable&, CanonicalNavigable&, CanonicalSessionHistoryEntry const&);+ void set_ongoing_navigation_to_traversal(CanonicalNavigable&, CanonicalSessionHistoryEntry const&);void return_result(Web::HTML::HistoryStepResult);CanonicalTraversable& m_traversable;diff --git a/Libraries/LibWebView/CanonicalNavigable.cpp b/Libraries/LibWebView/CanonicalNavigable.cppindex 479cf247a84..576e2c2bc8f 100644--- a/Libraries/LibWebView/CanonicalNavigable.cpp+++ b/Libraries/LibWebView/CanonicalNavigable.cpp@@ -1158,7 +1158,7 @@ bool CanonicalNavigable::active_document_is(CanonicalSessionHistoryEntry const&void CanonicalNavigable::did_commit_navigation(CanonicalSessionHistoryEntry& entry, Web::HTML::HostedNavigableState hosted_state, u64 operation_sequence_number, Optional<Utf16String const&> navigation_id, RefPtr<WebContentPage> host){- // A navigation admitted after the operation, such as one a same-document traversal yields to, is newer than it.+ // A navigation admitted after the operation, such as one admitted during a same-document traversal, is newer than it.auto ongoing_navigation_id = this->ongoing_navigation_id();auto ongoing_navigation = ongoing_navigation_id.has_value() ? navigation_with_id(*ongoing_navigation_id) : nullptr;auto commits_ongoing_navigation = !ongoing_navigationdiff --git a/Libraries/LibWebView/CanonicalTraversable.cpp b/Libraries/LibWebView/CanonicalTraversable.cppindex ee98933b3a3..c4f02342249 100644--- a/Libraries/LibWebView/CanonicalTraversable.cpp+++ b/Libraries/LibWebView/CanonicalTraversable.cpp@@ -1426,8 +1426,6 @@ bool CanonicalTraversable::run_changing_navigable_history_step_job(ApplyHistorySoperation.operation_id, navigable_id,changing_navigable.target_entry_descriptor(), run.user_involvement(),run.navigation_type(),- changing_navigable.traversal_yields_to,- changing_navigable.canceled_navigation_id,finalized_navigation_id,run.source_snapshot_params());return true;diff --git a/Services/WebContent/ConnectionFromClient.cpp b/Services/WebContent/ConnectionFromClient.cppindex 52c3bfff883..5248f521df3 100644--- a/Services/WebContent/ConnectionFromClient.cpp+++ b/Services/WebContent/ConnectionFromClient.cpp@@ -602,14 +602,14 @@ void ConnectionFromClient::continue_history_navigation_population(Web::PageId paif (history_executor.resume_history_navigation_population(operation_id, move(population)))return;auto user_involvement = population.request.user_involvement;- history_executor.run_ui_changing_navigable_history_job(operation_id, navigable_id, move(target_entry), user_involvement, navigation_type, Web::HTML::TraversalYieldsTo::Nothing, {}, {}, {},+ history_executor.run_ui_changing_navigable_history_job(operation_id, navigable_id, move(target_entry), user_involvement, navigation_type, {}, {},GC::create_function(Web::HTML::main_thread_event_loop().heap(), [this, page_id, operation_id, navigable_id](Web::HTML::ChangingNavigableHistoryStepJobDisposition disposition, bool update_only, Optional<Web::HTML::CrossProcessId> target_document_id) {async_changing_navigable_history_job_ready(page_id, operation_id, navigable_id, disposition, update_only, target_document_id);}),move(population));}-void ConnectionFromClient::run_changing_navigable_history_job(Web::PageId page_id, Web::HTML::CrossProcessId operation_id, Web::HTML::CrossProcessId navigable_id, Web::HTML::SessionHistoryEntryDescriptor target_entry, Web::HTML::UserNavigationInvolvement user_involvement, Optional<Web::Bindings::NavigationType> navigation_type, Web::HTML::TraversalYieldsTo traversal_yields_to, Optional<Utf16String> canceled_navigation_id, Optional<Utf16String> finalized_navigation_id, Optional<Web::HTML::NavigationSourceSnapshot> source_snapshot_params)+void ConnectionFromClient::run_changing_navigable_history_job(Web::PageId page_id, Web::HTML::CrossProcessId operation_id, Web::HTML::CrossProcessId navigable_id, Web::HTML::SessionHistoryEntryDescriptor target_entry, Web::HTML::UserNavigationInvolvement user_involvement, Optional<Web::Bindings::NavigationType> navigation_type, Optional<Utf16String> finalized_navigation_id, Optional<Web::HTML::NavigationSourceSnapshot> source_snapshot_params){auto page = this->page(page_id);if (!page.has_value()) {@@ -617,7 +617,7 @@ void ConnectionFromClient::run_changing_navigable_history_job(Web::PageId page_ireturn;}- page->page().history_executor().run_ui_changing_navigable_history_job(operation_id, navigable_id, move(target_entry), user_involvement, navigation_type, traversal_yields_to, move(canceled_navigation_id), move(finalized_navigation_id), move(source_snapshot_params), GC::create_function(Web::HTML::main_thread_event_loop().heap(), [this, page_id, operation_id, navigable_id](Web::HTML::ChangingNavigableHistoryStepJobDisposition disposition, bool update_only, Optional<Web::HTML::CrossProcessId> target_document_id) {+ page->page().history_executor().run_ui_changing_navigable_history_job(operation_id, navigable_id, move(target_entry), user_involvement, navigation_type, move(finalized_navigation_id), move(source_snapshot_params), GC::create_function(Web::HTML::main_thread_event_loop().heap(), [this, page_id, operation_id, navigable_id](Web::HTML::ChangingNavigableHistoryStepJobDisposition disposition, bool update_only, Optional<Web::HTML::CrossProcessId> target_document_id) {async_changing_navigable_history_job_ready(page_id, operation_id, navigable_id, disposition, update_only, target_document_id);}));}diff --git a/Services/WebContent/ConnectionFromClient.h b/Services/WebContent/ConnectionFromClient.hindex d8285594376..2498f6034c2 100644--- a/Services/WebContent/ConnectionFromClient.h+++ b/Services/WebContent/ConnectionFromClient.h@@ -142,7 +142,7 @@ private:virtual void run_beforeunload_check(Web::PageId page_id, Web::HTML::CrossProcessId check_id, Vector<Web::HTML::CrossProcessId> navigable_ids, Optional<Web::HTML::SessionHistoryEntryDescriptor> target_entry, Optional<Web::HTML::UserNavigationInvolvement> user_involvement_for_navigate_event, Web::HTML::UnloadPromptShown unload_prompt_shown) override;virtual void discard_embedded_page(Web::PageId page_id) override;virtual void queue_navigation_api_state_clear_task(Web::PageId page_id, Web::HTML::CrossProcessId navigable_id) override;- virtual void run_changing_navigable_history_job(Web::PageId page_id, Web::HTML::CrossProcessId operation_id, Web::HTML::CrossProcessId navigable_id, Web::HTML::SessionHistoryEntryDescriptor target_entry, Web::HTML::UserNavigationInvolvement user_involvement, Optional<Web::Bindings::NavigationType> navigation_type, Web::HTML::TraversalYieldsTo traversal_yields_to, Optional<Utf16String> canceled_navigation_id, Optional<Utf16String> finalized_navigation_id, Optional<Web::HTML::NavigationSourceSnapshot> source_snapshot_params) override;+ virtual void run_changing_navigable_history_job(Web::PageId page_id, Web::HTML::CrossProcessId operation_id, Web::HTML::CrossProcessId navigable_id, Web::HTML::SessionHistoryEntryDescriptor target_entry, Web::HTML::UserNavigationInvolvement user_involvement, Optional<Web::Bindings::NavigationType> navigation_type, Optional<Utf16String> finalized_navigation_id, Optional<Web::HTML::NavigationSourceSnapshot> source_snapshot_params) override;virtual void clear_ongoing_history_traversal(Web::PageId page_id, Web::HTML::CrossProcessId operation_id, Web::HTML::CrossProcessId navigable_id) override;virtual void apply_changing_navigable_continuation(Web::PageId page_id, Web::HTML::CrossProcessId operation_id, Web::HTML::CrossProcessId navigable_id, Web::HTML::SessionHistoryEntryIdentity target_entry, u64 script_history_length, u64 script_history_index, Vector<Web::HTML::SessionHistoryEntryDescriptor> entries_for_navigation_api) override;virtual void unload_displayed_document_and_apply_changing_navigable_continuation(Web::PageId page_id, Web::HTML::CrossProcessId operation_id, Web::HTML::CrossProcessId navigable_id, Web::HTML::SessionHistoryEntryIdentity target_entry, u64 script_history_length, u64 script_history_index, Vector<Web::HTML::SessionHistoryEntryDescriptor> entries_for_navigation_api) override;diff --git a/Services/WebContent/WebContentServer.ipc b/Services/WebContent/WebContentServer.ipcindex d7e4f2c156b..9dc0e48a575 100644--- a/Services/WebContent/WebContentServer.ipc+++ b/Services/WebContent/WebContentServer.ipc@@ -118,7 +118,7 @@ endpoint WebContentServer routed by Web::PageId page_iddiscard_embedded_page(Web::PageId page_id) =|queue_navigation_api_state_clear_task(Web::PageId page_id, Web::HTML::CrossProcessId navigable_id) =|continue_history_navigation_population(Web::PageId page_id, Web::HTML::CrossProcessId operation_id, Web::HTML::SessionHistoryEntryDescriptor target_entry, Optional<Web::Bindings::NavigationType> navigation_type, Web::HTML::HistoryNavigationPopulation population) =|- run_changing_navigable_history_job(Web::PageId page_id, Web::HTML::CrossProcessId operation_id, Web::HTML::CrossProcessId navigable_id, Web::HTML::SessionHistoryEntryDescriptor target_entry, Web::HTML::UserNavigationInvolvement user_involvement, Optional<Web::Bindings::NavigationType> navigation_type, Web::HTML::TraversalYieldsTo traversal_yields_to, Optional<Utf16String> canceled_navigation_id, Optional<Utf16String> finalized_navigation_id, Optional<Web::HTML::NavigationSourceSnapshot> source_snapshot_params) =|+ run_changing_navigable_history_job(Web::PageId page_id, Web::HTML::CrossProcessId operation_id, Web::HTML::CrossProcessId navigable_id, Web::HTML::SessionHistoryEntryDescriptor target_entry, Web::HTML::UserNavigationInvolvement user_involvement, Optional<Web::Bindings::NavigationType> navigation_type, Optional<Utf16String> finalized_navigation_id, Optional<Web::HTML::NavigationSourceSnapshot> source_snapshot_params) =|clear_ongoing_history_traversal(Web::PageId page_id, Web::HTML::CrossProcessId operation_id, Web::HTML::CrossProcessId navigable_id) =|apply_changing_navigable_continuation(Web::PageId page_id, Web::HTML::CrossProcessId operation_id, Web::HTML::CrossProcessId navigable_id, Web::HTML::SessionHistoryEntryIdentity target_entry, u64 script_history_length, u64 script_history_index, Vector<Web::HTML::SessionHistoryEntryDescriptor> entries_for_navigation_api) =|unload_displayed_document_and_apply_changing_navigable_continuation(Web::PageId page_id, Web::HTML::CrossProcessId operation_id, Web::HTML::CrossProcessId navigable_id, Web::HTML::SessionHistoryEntryIdentity target_entry, u64 script_history_length, u64 script_history_index, Vector<Web::HTML::SessionHistoryEntryDescriptor> entries_for_navigation_api) =|diff --git a/Tests/LibWeb/Text/expected/navigation/navigation-not-dropped-by-concurrent-traversal.txt b/Tests/LibWeb/Text/expected/navigation/navigation-not-dropped-by-concurrent-traversal.txtindex e33bed7c2f5..1932ddfdb65 100644--- a/Tests/LibWeb/Text/expected/navigation/navigation-not-dropped-by-concurrent-traversal.txt+++ b/Tests/LibWeb/Text/expected/navigation/navigation-not-dropped-by-concurrent-traversal.txt@@ -1 +1 @@-victim-loaded+destination-loaded 2 entriesdiff --git a/Tests/LibWeb/Text/input/navigation/navigation-not-dropped-by-concurrent-traversal.html b/Tests/LibWeb/Text/input/navigation/navigation-not-dropped-by-concurrent-traversal.htmlindex 53f6e6434d9..22ac9ef89f2 100644--- a/Tests/LibWeb/Text/input/navigation/navigation-not-dropped-by-concurrent-traversal.html+++ b/Tests/LibWeb/Text/input/navigation/navigation-not-dropped-by-concurrent-traversal.html@@ -1,16 +1,17 @@<!DOCTYPE html><script src="../include.js"></script><script>- // A cross-document navigation admitted after a traversal must supersede that traversal. The history-queue flush- // makes the pushed entry deterministic; requesting back and navigation from one task then gives the UI process- // an ordered traversal followed by a newer navigation without rewriting LocalNavigable's state in a test hook.+ // A cross-document navigation started after a same-document traversal is not dropped by it, as in Chromium and+ // Gecko: the traversal applies, and the navigation goes on and commits after it, clearing the pushed entry as+ // forward history. The history-queue flush makes the pushed entry deterministic; requesting back and navigation+ // from one task then gives the UI process an ordered traversal followed by a newer navigation.asyncTest(async (done) => {const server = httpTestServer();- const victim = await server.createEcho("GET", "/navigation-not-dropped-by-concurrent-traversal-victim", {+ const destination = await server.createEcho("GET", "/navigation-not-dropped-by-concurrent-traversal-destination", {status: 200,headers: { "Content-Type": "text/html" },- body: `<!doctype html><script>top.postMessage("victim-loaded", "*")<\/script>`,+ body: `<!doctype html><script>top.postMessage(\`destination-loaded \${navigation.entries().length} entries\`, "*")<\/script>`,});const trigger = await server.createEcho("GET", "/navigation-not-dropped-by-concurrent-traversal-trigger", {@@ -23,7 +24,7 @@top.postMessage("history-pushed", "*");} else if (e.data === "race") {history.back();- location.href = "${victim}";+ location.href = "${destination}";}});top.postMessage("trigger-ready", "*");@@ -42,9 +43,9 @@println("FAIL: cross-document navigation was dropped");done();}, 10000);- } else if (e.data === "victim-loaded") {+ } else if (e.data.startsWith("destination-loaded")) {clearTimeout(stallTimer);- println("victim-loaded");+ println(e.data);done();}});