Truly independent web browser
LibWebView: Hold a navigable's ongoing navigation as the spec does
Shannon Booth26eafad5a5c8
diff --git a/Libraries/LibWebView/ApplyHistoryStep.cpp b/Libraries/LibWebView/ApplyHistoryStep.cppindex 2a2a9f2490e..e01c640ef7b 100644--- a/Libraries/LibWebView/ApplyHistoryStep.cpp+++ b/Libraries/LibWebView/ApplyHistoryStep.cpp@@ -511,9 +511,11 @@ void ApplyHistoryStep::set_ongoing_navigation_to_traversal(CanonicalNavigable& n// does not model Ladybird's independently admitted UI-process navigations.// See https://github.com/whatwg/html/issues/12581.auto is_cross_document_traversal = m_navigation_type == Web::Bindings::NavigationType::Traverse && traversal_crosses_documents;+ auto ongoing_navigation_id = navigable.ongoing_navigation_id();+ auto const* ongoing_navigation = ongoing_navigation_id.has_value() ? navigable.navigation_with_id(*ongoing_navigation_id) : nullptr;if (!is_cross_document_traversal- && navigable.ongoing_navigation()- && navigable.ongoing_navigation()->sequence_number > m_operation_sequence_number) {+ && ongoing_navigation+ && ongoing_navigation->sequence_number > m_operation_sequence_number) {if (is_same_document_traversal)m_same_document_traversal_yields.set(navigable.id(), { Web::HTML::TraversalYieldsTo::AdmittedNavigation, {} });return;@@ -523,19 +525,19 @@ void ApplyHistoryStep::set_ongoing_navigation_to_traversal(CanonicalNavigable& nif (m_navigation_type.has_value()&& first_is_one_of(*m_navigation_type, Web::Bindings::NavigationType::Push, Web::Bindings::NavigationType::Replace)&& target_document_is_active_document- && navigable.ongoing_navigation()) {+ && ongoing_navigation_id.has_value()) {return;}// 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() && navigable.ongoing_navigation())+ 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 (auto const* ongoing_navigation = navigable.ongoing_navigation(); is_same_document_traversal && ongoing_navigation)- canceled_navigation_id = ongoing_navigation->navigation_id;+ if (is_same_document_traversal && ongoing_navigation_id.has_value())+ canceled_navigation_id = *ongoing_navigation_id;navigable.clear_ongoing_navigation();}diff --git a/Libraries/LibWebView/CanonicalNavigable.cpp b/Libraries/LibWebView/CanonicalNavigable.cppindex 7799e16755f..611e909cc18 100644--- a/Libraries/LibWebView/CanonicalNavigable.cpp+++ b/Libraries/LibWebView/CanonicalNavigable.cpp@@ -55,21 +55,18 @@ static Utf16String generate_a_random_uuid()return Utf16String::from_ascii_without_validation(uuid.bytes());}+// The page with the source document, running the navigation's steps before the page to host its document takes over.WebContentPage* CanonicalNavigation::worker() const{- return state.visit(- [](Admitted const&) -> WebContentPage* { return nullptr; },- [](EvaluatingJavaScriptURL const&) -> WebContentPage* { return nullptr; },- [](Populating const&) -> WebContentPage* { return nullptr; },- [](auto const& state) -> WebContentPage* { return state.worker.ptr(); });+ if (state.has<CheckingIfUnloadingIsCanceled>() || state.has<CreatingNavigationParams>() || state.has<AcquiringResponseBody>())+ return page.ptr();+ return nullptr;}WebContentPage* CanonicalNavigation::host() const{- if (auto const* evaluating = state.get_pointer<EvaluatingJavaScriptURL>())- return evaluating->host.ptr();- if (auto const* populating = state.get_pointer<Populating>())- return populating->host.ptr();+ if (state.has<EvaluatingJavaScriptURL>() || state.has<Populating>() || state.has<Finalizing>())+ return page.ptr();return nullptr;}@@ -78,8 +75,8 @@ NavigationLoader* CanonicalNavigation::loader() constreturn state.visit([](CreatingNavigationParams const& state) -> NavigationLoader* { return state.loader.ptr(); },[](AcquiringResponseBody const& state) -> NavigationLoader* { return state.loader.ptr(); },- [](ChoosingHost const& state) -> NavigationLoader* { return state.loader.ptr(); },[](Populating const& state) -> NavigationLoader* { return state.loader.ptr(); },+ [](Finalizing const& state) -> NavigationLoader* { return state.loader.ptr(); },[](auto const&) -> NavigationLoader* { return nullptr; });}@@ -245,7 +242,7 @@ void CanonicalNavigable::begin_navigation(Web::HTML::PreparedNavigationDescripto// id is navigationId, status is "pending", and url is url.// 18. If navigable's ongoing navigation is "traversal", then:- if (ongoing_navigation_is_traversal()) {+ if (m_ongoing_navigation.has<Traversal>()) {// FIXME: 1. Invoke WebDriver BiDi navigation failed with navigable and a new WebDriver BiDi navigation status// whose id is navigationId, status is "canceled", and url is url.@@ -266,15 +263,17 @@ void CanonicalNavigable::begin_navigation(Web::HTML::PreparedNavigationDescriptoreturn;// 19. Set the ongoing navigation for navigable to navigationId.- set_ongoing_navigation({- .url = url,- .navigation_id = navigation_id,- .sequence_number = traversable.next_sequence_number(),- });+ // NB: It is set with the navigation's steps: evaluating a javascript: URL from step 20, or those step 23 runs.// 20. If url's scheme is "javascript", then:if (is_javascript_url) {- ongoing_navigation()->state = CanonicalNavigation::EvaluatingJavaScriptURL { *host };+ set_ongoing_navigation({+ .url = url,+ .navigation_id = navigation_id,+ .sequence_number = traversable.next_sequence_number(),+ .state = CanonicalNavigation::EvaluatingJavaScriptURL {},+ .page = host,+ });if (is_top_level_traversable() && host->displays_tab())host->begin_top_level_load(url);@@ -323,9 +322,15 @@ void CanonicalNavigable::begin_navigation(Web::HTML::PreparedNavigationDescripto.navigation_api_key = generate_a_random_uuid(),.navigation_api_id = generate_a_random_uuid(),};- auto& ongoing = *ongoing_navigation();- ongoing.retry = prepare_navigation_to_retry(start_request);- ongoing.state = CanonicalNavigation::CheckingIfUnloadingIsCanceled { *worker, move(start_request) };+ auto retry = prepare_navigation_to_retry(start_request);+ set_ongoing_navigation({+ .url = url,+ .navigation_id = navigation_id,+ .retry = move(retry),+ .sequence_number = traversable.next_sequence_number(),+ .state = CanonicalNavigation::CheckingIfUnloadingIsCanceled { move(start_request) },+ .page = worker,+ });worker->async_set_ongoing_navigation(id(), navigation_id);worker->begin_navigation_unload_check(*this, navigation_id);}@@ -344,7 +349,7 @@ Optional<URL::Origin> CanonicalNavigable::take_routed_navigation_initiator_origivoid CanonicalNavigable::begin_navigation_waiting_for_traversal(){- if (!m_navigation_waiting_for_traversal.has_value() || ongoing_navigation_is_traversal())+ if (!m_navigation_waiting_for_traversal.has_value() || m_ongoing_navigation.has<Traversal>())return;begin_navigation(m_navigation_waiting_for_traversal.release_value());}@@ -815,8 +820,8 @@ ErrorOr<CanonicalNavigable::PageToPopulateDocument> CanonicalNavigable::obtain_presponse_document->document_id = Application::the().allocate_ui_process_cross_process_id();auto document = create_and_initialize_a_document(*response_document);loader.set_document(*document, *this);- if (ongoing_navigation() && ongoing_navigation()->history_entry == &entry)- populate_document_for_ongoing_navigation(document, loader.result().inline_content_origin);+ if (auto* navigation = uncommitted_navigation(); navigation && navigation->history_entry == &entry)+ populate_document_for_navigation(*navigation, document, loader.result().inline_content_origin);elsepopulate_document(document_state, document, loader.result().inline_content_origin);@@ -864,10 +869,10 @@ void CanonicalNavigable::populate_document(NonnullRefPtr<CanonicalDocumentState>m_document_state_populated_by_history_job = move(document_state);}-void CanonicalNavigable::populate_document_for_ongoing_navigation(NonnullRefPtr<CanonicalDocument> document, Optional<URL::Origin> inline_content_origin)+void CanonicalNavigable::populate_document_for_navigation(CanonicalNavigation& navigation, NonnullRefPtr<CanonicalDocument> document, Optional<URL::Origin> inline_content_origin){- VERIFY(ongoing_navigation() && ongoing_navigation()->history_entry);- NonnullRefPtr document_state = ongoing_navigation()->history_entry->document_state;+ VERIFY(navigation.history_entry);+ NonnullRefPtr document_state = navigation.history_entry->document_state;document->determine_whether_it_is_local_file_content(blob_url_store());if (document->is_local_file_content())document_state->held_local_file_content = true;@@ -879,15 +884,15 @@ void CanonicalNavigable::populate_document_for_ongoing_navigation(NonnullRefPtr<// NB: newDocument's URL is the active document's, as the process hosting both reports it. Whatever URL it reports,// newDocument holds no local file content and displays no WebUI unless the active document does, as its contents// come from that process.-void CanonicalNavigable::populate_document_for_javascript_url(NonnullRefPtr<CanonicalSessionHistoryEntry> history_entry, NonnullRefPtr<CanonicalDocument> document)+void CanonicalNavigable::populate_document_for_javascript_url(CanonicalNavigation& navigation, NonnullRefPtr<CanonicalSessionHistoryEntry> history_entry, NonnullRefPtr<CanonicalDocument> document){document->determine_whether_it_is_local_file_content(blob_url_store());if (document->is_local_file_content() && !active_document().is_local_file_content())return;if (document->web_ui_host().has_value() && document->web_ui_host() != active_document().web_ui_host())return;- ongoing_navigation()->history_entry = move(history_entry);- populate_document_for_ongoing_navigation(move(document));+ navigation.history_entry = move(history_entry);+ populate_document_for_navigation(navigation, move(document));}// The process hosting a document populated for the navigable created it with an origin other than its navigation@@ -925,22 +930,6 @@ void CanonicalNavigable::did_create_populated_document_with_an_origin_of_its_ownpopulated_document->document = move(document);}-// A newer navigation can start before the history operation finalizing this one applies the history step.-bool CanonicalNavigable::take_navigation_to_finalize(Utf16String const& navigation_id, WebContentPage const& page)-{- auto* navigation = ongoing_navigation();- if (!navigation || navigation->navigation_id != navigation_id || navigation->host() != &page)- return false;- if (navigation->history_entry && navigation->history_entry->document_state->populated_document.has_value()) {- if (m_document_state_populated_by_history_job)- abandon_populated_document(m_document_state_populated_by_history_job.release_nonnull());- m_document_state_populated_by_history_job = navigation->history_entry->document_state;- }- m_navigation_being_finalized = move(*navigation);- m_ongoing_navigation = Empty {};- return true;-}-void CanonicalNavigable::abandon_populated_document(CanonicalDocument const& document){RefPtr<CanonicalDocumentState> document_state_holding_document;@@ -1211,10 +1200,12 @@ 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.- auto commits_ongoing_navigation = !ongoing_navigation()+ auto ongoing_navigation_id = this->ongoing_navigation_id();+ auto const* ongoing_navigation = ongoing_navigation_id.has_value() ? navigation_with_id(*ongoing_navigation_id) : nullptr;+ auto commits_ongoing_navigation = !ongoing_navigation|| (navigation_id.has_value()- ? navigation_id == ongoing_navigation()->navigation_id- : ongoing_navigation()->sequence_number < operation_sequence_number);+ ? *navigation_id == ongoing_navigation->navigation_id+ : ongoing_navigation->sequence_number < operation_sequence_number);auto active_document_changed = !active_document_is(entry);NonnullRefPtr previous_document = active_document();@@ -1289,29 +1280,102 @@ void CanonicalNavigable::did_commit_navigation(CanonicalSessionHistoryEntry& entOptional<Utf16String> load_navigation_id;if (navigation_id.has_value())load_navigation_id = *navigation_id;- else if (ongoing_navigation())- load_navigation_id = ongoing_navigation()->navigation_id;+ else if (ongoing_navigation)+ load_navigation_id = ongoing_navigation->navigation_id;m_active_document_load = ActiveDocumentLoad { .navigation_id = move(load_navigation_id) };}clear_ongoing_navigation();}-void CanonicalNavigable::set_ongoing_navigation(CanonicalNavigation ongoing_navigation)+Optional<Utf16String const&> CanonicalNavigable::ongoing_navigation_id() const+{+ if (auto const* navigation_id = m_ongoing_navigation.get_pointer<Utf16String>())+ return *navigation_id;+ return {};+}++CanonicalNavigation* CanonicalNavigable::navigation_with_id(Utf16String const& navigation_id)+{+ for (auto& navigation : m_navigations) {+ if (navigation->navigation_id == navigation_id)+ return navigation.ptr();+ }+ return nullptr;+}++CanonicalNavigation const* CanonicalNavigable::navigation_with_id(Utf16String const& navigation_id) const+{+ return const_cast<CanonicalNavigable&>(*this).navigation_with_id(navigation_id);+}++CanonicalNavigation* CanonicalNavigable::uncommitted_navigation()+{+ auto navigation_id = ongoing_navigation_id();+ if (!navigation_id.has_value())+ return nullptr;+ auto* navigation = navigation_with_id(*navigation_id);+ return navigation && !navigation->is_finalizing() ? navigation : nullptr;+}++CanonicalNavigation const* CanonicalNavigable::uncommitted_navigation() const+{+ return const_cast<CanonicalNavigable&>(*this).uncommitted_navigation();+}++CanonicalNavigation const* CanonicalNavigable::navigation_being_finalized() const+{+ for (size_t i = m_navigations.size(); i > 0; --i) {+ if (m_navigations[i - 1]->is_finalizing())+ return m_navigations[i - 1].ptr();+ }+ return nullptr;+}++// https://html.spec.whatwg.org/multipage/browsing-the-web.html#set-the-ongoing-navigation+// NB: The steps of a navigation the ongoing navigation no longer names end, unless they appended its finalization. The+// page evaluating a javascript: URL goes on with it, and reports how it ends (whatwg/html#12120).+void CanonicalNavigable::set_the_ongoing_navigation(OngoingNavigation value)+{+ m_ongoing_navigation = move(value);++ auto ongoing_navigation_id = this->ongoing_navigation_id();+ Vector<NonnullOwnPtr<CanonicalNavigation>> ended_navigations;+ for (size_t i = 0; i < m_navigations.size();) {+ auto const& navigation = *m_navigations[i];+ auto ends = !navigation.is_finalizing()+ && (!ongoing_navigation_id.has_value() || navigation.navigation_id != *ongoing_navigation_id)+ && !navigation.state.has<CanonicalNavigation::EvaluatingJavaScriptURL>();+ if (ends)+ ended_navigations.append(m_navigations.take(i));+ else+ ++i;+ }++ // The document populated for an ended navigation is not going to be activated.+ for (auto const& navigation : ended_navigations) {+ if (navigation->history_entry)+ abandon_populated_document(navigation->history_entry->document_state);+ }+}++void CanonicalNavigable::set_ongoing_navigation(CanonicalNavigation navigation){// NB: Taken before the handle covering this navigation's start is dropped below, so that a revoked entry is not// let go of in between.- auto blob_url = BlobURLHandle::for_url(blob_url_store(), ongoing_navigation.url);+ auto blob_url = BlobURLHandle::for_url(blob_url_store(), navigation.url);- clear_ongoing_navigation();+ auto navigation_id = navigation.navigation_id;+ m_navigations.append(make<CanonicalNavigation>(move(navigation)));+ set_the_ongoing_navigation(move(navigation_id));+ m_pending_navigation_blob_url = {};m_navigation_blob_url = move(blob_url);- m_ongoing_navigation = move(ongoing_navigation);}void CanonicalNavigable::set_ongoing_navigation_to_traversal(Web::HTML::CrossProcessId operation_id){- VERIFY(!ongoing_navigation());- m_ongoing_navigation = Traversal { operation_id };+ VERIFY(!ongoing_navigation_id().has_value());+ set_the_ongoing_navigation(Traversal { operation_id });}void CanonicalNavigable::clear_ongoing_navigation_traversal(Web::HTML::CrossProcessId operation_id)@@ -1320,21 +1384,24 @@ void CanonicalNavigable::clear_ongoing_navigation_traversal(Web::HTML::CrossProcm_ongoing_navigation = Empty {};}-void CanonicalNavigable::clear_ongoing_navigation_state()+void CanonicalNavigable::clear_ongoing_navigation(){- m_ongoing_navigation = Empty {};+ set_the_ongoing_navigation(Empty {});// NB: The navigation this covered has either been announced, and is held below, or is not coming.m_pending_navigation_blob_url = {};m_navigation_blob_url = {};}-void CanonicalNavigable::clear_ongoing_navigation()+void CanonicalNavigable::end_navigation(CanonicalNavigation& navigation){- // The document populated for the navigation is not going to be activated.- if (ongoing_navigation() && ongoing_navigation()->history_entry)- abandon_populated_document(ongoing_navigation()->history_entry->document_state);- clear_ongoing_navigation_state();+ if (auto navigation_id = ongoing_navigation_id(); navigation_id.has_value() && *navigation_id == navigation.navigation_id)+ m_ongoing_navigation = Empty {};+ auto index = m_navigations.find_first_index_if([&](auto const& candidate) { return candidate.ptr() == &navigation; });+ VERIFY(index.has_value());+ auto ended_navigation = m_navigations.take(*index);+ if (ended_navigation->history_entry)+ abandon_populated_document(ended_navigation->history_entry->document_state);}BlobURLStore* CanonicalNavigable::blob_url_store() const@@ -1349,64 +1416,54 @@ void CanonicalNavigable::retain_blob_url_token(URL::BlobURLEntry::Token token)m_pending_navigation_blob_url = BlobURLHandle { *store, token };}-void CanonicalNavigable::set_navigation_host(WebContentPage& page)-{- auto& navigation = *ongoing_navigation();- auto loader = move(navigation.state.get<CanonicalNavigation::ChoosingHost>().loader);- navigation.state = CanonicalNavigation::Populating { page, move(loader) };-}--bool CanonicalNavigable::cancel_navigation_for_client(WebContentClient& client)+void CanonicalNavigable::cancel_navigation_for_client(WebContentClient& client){- if (!ongoing_navigation())- return false;-auto is_page_of_client = [&](WebContentPage const* page) {return page && &page->client() == &client;};- if (!is_page_of_client(ongoing_navigation()->worker()) && !is_page_of_client(ongoing_navigation()->host()))- return false;-- clear_ongoing_navigation();- return true;+ Vector<CanonicalNavigation*> canceled_navigations;+ for (auto& navigation : m_navigations) {+ if (!navigation->is_finalizing() && (is_page_of_client(navigation->worker()) || is_page_of_client(navigation->host())))+ canceled_navigations.append(navigation.ptr());+ }+ for (auto* navigation : canceled_navigations)+ end_navigation(*navigation);}// The history operation finalizing a navigation is over. The document populated for it, if it was not activated, is not// going to be.void CanonicalNavigable::did_finish_finalizing_navigation(Utf16String const& navigation_id, Web::HTML::HistoryStepResult result){- if (!m_navigation_being_finalized.has_value() || m_navigation_being_finalized->navigation_id != navigation_id)+ auto* navigation = navigation_with_id(navigation_id);+ if (!navigation || !navigation->is_finalizing())return;- auto navigation = m_navigation_being_finalized.release_value();- if (navigation.history_entry)- abandon_populated_document(navigation.history_entry->document_state);- if (result != Web::HTML::HistoryStepResult::Applied && m_active_document_load.navigation_id == navigation.navigation_id)+ end_navigation(*navigation);+ if (result != Web::HTML::HistoryStepResult::Applied && m_active_document_load.navigation_id == navigation_id)clear_active_document_load();}void CanonicalNavigable::did_cancel_navigation(Utf16String navigation_id){- if (tracked_load_navigation_id() != navigation_id)- return;-- auto canceled_ongoing_navigation = has_uncommitted_navigation();- if (canceled_ongoing_navigation)- clear_ongoing_navigation();- else+ auto* navigation = navigation_with_id(navigation_id);+ auto canceled_uncommitted_navigation = navigation && !navigation->is_finalizing();+ auto is_tracked_load = tracked_load_navigation_id() == navigation_id;+ if (canceled_uncommitted_navigation)+ end_navigation(*navigation);+ else if (is_tracked_load)clear_active_document_load();- if (!is_top_level_traversable())+ if (!is_tracked_load || !is_top_level_traversable())return;if (auto view = top_level_traversable().view(); view.has_value())- view->did_cancel_loading({}, canceled_ongoing_navigation);+ view->did_cancel_loading({}, canceled_uncommitted_navigation);}Optional<Utf16String> CanonicalNavigable::tracked_load_navigation_id() const{- if (auto const* navigation = ongoing_navigation())+ if (auto navigation_id = ongoing_navigation_id(); navigation_id.has_value())+ return *navigation_id;+ if (auto const* navigation = navigation_being_finalized())return navigation->navigation_id;- if (m_navigation_being_finalized.has_value())- return m_navigation_being_finalized->navigation_id;return m_active_document_load.navigation_id;}diff --git a/Libraries/LibWebView/CanonicalNavigable.h b/Libraries/LibWebView/CanonicalNavigable.hindex 57f7810e766..c534b2e9193 100644--- a/Libraries/LibWebView/CanonicalNavigable.h+++ b/Libraries/LibWebView/CanonicalNavigable.h@@ -91,21 +91,22 @@ public:RefPtr<CanonicalDocument> document_with_id(Web::HTML::CrossProcessId) const;void populate_document(NonnullRefPtr<CanonicalDocumentState>, NonnullRefPtr<CanonicalDocument>, Optional<URL::Origin> inline_content_origin = {});- void populate_document_for_ongoing_navigation(NonnullRefPtr<CanonicalDocument>, Optional<URL::Origin> inline_content_origin = {});+ void populate_document_for_navigation(CanonicalNavigation&, NonnullRefPtr<CanonicalDocument>, Optional<URL::Origin> inline_content_origin = {});// Populates nothing for a document that would hold access the active document lacks.- void populate_document_for_javascript_url(NonnullRefPtr<CanonicalSessionHistoryEntry>, NonnullRefPtr<CanonicalDocument>);+ void populate_document_for_javascript_url(CanonicalNavigation&, NonnullRefPtr<CanonicalSessionHistoryEntry>, NonnullRefPtr<CanonicalDocument>);void did_create_populated_document_with_an_origin_of_its_own(WebContentPage const& host, Web::HTML::CrossProcessId document_id, Web::HTML::PopulatedDocumentOrigin, Web::HTML::EnvironmentId const& environment_id);- bool take_navigation_to_finalize(Utf16String const& navigation_id, WebContentPage const&);void abandon_populated_document(CanonicalDocument const&);void place_populated_document(CanonicalDocument&, WebContentPage&);- // The document states holding a populated document: the ongoing navigation's history entry's, and the one a history- // job is to activate.+ // The document states holding a populated document: the history entries' of the navigations under way, and the one a+ // history job is to activate.template<typename Callback>void for_each_populated_document_state(Callback callback) const{- if (auto const* navigation = ongoing_navigation(); navigation && navigation->history_entry && navigation->history_entry->document_state->populated_document.has_value())- callback(*navigation->history_entry->document_state);+ for (auto const& navigation : m_navigations) {+ if (navigation->history_entry && navigation->history_entry->document_state->populated_document.has_value())+ callback(*navigation->history_entry->document_state);+ }if (m_document_state_populated_by_history_job)callback(*m_document_state_populated_by_history_job);}@@ -214,10 +215,21 @@ public:void did_commit_navigation(CanonicalSessionHistoryEntry&, Web::HTML::HostedNavigableState, u64 operation_sequence_number, Optional<Utf16String const&> navigation_id, RefPtr<WebContentPage> host);// https://html.spec.whatwg.org/multipage/browsing-the-web.html#ongoing-navigation- // The navigation, if the navigable's ongoing navigation is a navigation ID rather than "traversal" or null.- CanonicalNavigation* ongoing_navigation() { return m_ongoing_navigation.get_pointer<CanonicalNavigation>(); }- CanonicalNavigation const* ongoing_navigation() const { return m_ongoing_navigation.get_pointer<CanonicalNavigation>(); }- bool ongoing_navigation_is_traversal() const { return m_ongoing_navigation.has<Traversal>(); }+ // NB: "traversal" names the history operation that set it, so that another operation leaves it alone.+ struct Traversal {+ Web::HTML::CrossProcessId operation_id;+ };+ using OngoingNavigation = Variant<Empty, Traversal, Utf16String>;+ OngoingNavigation const& ongoing_navigation() const { return m_ongoing_navigation; }+ Optional<Utf16String const&> ongoing_navigation_id() const;++ CanonicalNavigation* navigation_with_id(Utf16String const&);+ CanonicalNavigation const* navigation_with_id(Utf16String const&) const;+ // The navigation the ongoing navigation names, until its finalization is appended.+ CanonicalNavigation* uncommitted_navigation();+ CanonicalNavigation const* uncommitted_navigation() const;+ bool has_uncommitted_navigation() const { return uncommitted_navigation(); }+ CanonicalNavigation const* navigation_being_finalized() const;// Held so that revoking a blob URL cannot take the entry away from a navigation on its way to this navigable, or// from the document it loaded. Session history holds none, so a revoked blob URL cannot be traversed back to.@@ -227,12 +239,8 @@ public:void set_ongoing_navigation_to_traversal(Web::HTML::CrossProcessId operation_id);void clear_ongoing_navigation_traversal(Web::HTML::CrossProcessId operation_id);void clear_ongoing_navigation();- void clear_ongoing_navigation_state();- void set_navigation_host(WebContentPage&);- bool cancel_navigation_for_client(WebContentClient&);- CanonicalNavigation const* navigation_being_finalized() const { return m_navigation_being_finalized.has_value() ? &*m_navigation_being_finalized : nullptr; }+ void cancel_navigation_for_client(WebContentClient&);void did_finish_finalizing_navigation(Utf16String const& navigation_id, Web::HTML::HistoryStepResult);- bool has_uncommitted_navigation() const { return ongoing_navigation(); }void did_cancel_navigation(Utf16String navigation_id);Optional<Utf16String> tracked_load_navigation_id() const;@@ -252,11 +260,10 @@ private:RefPtr<CanonicalDocumentState> m_document_state_populated_by_history_job;RefPtr<CanonicalSessionHistoryEntry> m_current_session_history_entry;RefPtr<CanonicalSessionHistoryEntry> m_active_session_history_entry;- struct Traversal {- Web::HTML::CrossProcessId operation_id;- };- Variant<Empty, Traversal, CanonicalNavigation> m_ongoing_navigation;- Optional<CanonicalNavigation> m_navigation_being_finalized;+ void set_the_ongoing_navigation(OngoingNavigation);+ void end_navigation(CanonicalNavigation&);+ OngoingNavigation m_ongoing_navigation;+ Vector<NonnullOwnPtr<CanonicalNavigation>> m_navigations;Optional<Web::HTML::PreparedNavigationDescriptor> m_navigation_waiting_for_traversal;struct RoutedNavigation {Utf16String navigation_id;diff --git a/Libraries/LibWebView/CanonicalNavigation.h b/Libraries/LibWebView/CanonicalNavigation.hindex 57a7d277ace..d521f4c61c6 100644--- a/Libraries/LibWebView/CanonicalNavigation.h+++ b/Libraries/LibWebView/CanonicalNavigation.h@@ -23,57 +23,55 @@namespace WebView {-// https://html.spec.whatwg.org/multipage/browsing-the-web.html#ongoing-navigation-// A navigable's navigation, from its admission until its document is activated or it is canceled or superseded, with-// what it acquires on the way.+// https://html.spec.whatwg.org/multipage/browsing-the-web.html#navigate+// The steps navigate runs for one navigation, from its admission until its document is activated or it ends without+// one. They go on after the navigable's ongoing navigation stops being their navigation ID only once their+// finalization is appended, or while a javascript: URL is evaluated.class CanonicalNavigation {+ AK_ALLOC_WITH_KMALLOC;+public:- // Admitted, before navigate runs its steps in parallel.- struct Admitted { };// Navigating to a javascript: URL, in the page with the document it is evaluated against.- struct EvaluatingJavaScriptURL {- NonnullRefPtr<WebContentPage> host;- };+ struct EvaluatingJavaScriptURL { };// Navigate, step 23.1: checking if unloading is canceled, in the page with the source document.struct CheckingIfUnloadingIsCanceled {- NonnullRefPtr<WebContentPage> worker;Web::HTML::NavigationStartRequest start_request;};// Attempting to populate the history entry's document, steps 1 to 4, in the page with the source document.struct CreatingNavigationParams {- NonnullRefPtr<WebContentPage> worker;NonnullOwnPtr<NavigationLoader> loader;};- // Acquiring the response body, in the page with the source document.+ // NB: The page with the source document hands the response body over to the page to host the document.struct AcquiringResponseBody {- NonnullRefPtr<WebContentPage> worker;- NonnullOwnPtr<NavigationLoader> loader;- };- // Choosing the page to host the document the response creates.- struct ChoosingHost {- NonnullRefPtr<WebContentPage> worker;NonnullOwnPtr<NavigationLoader> loader;};// Attempting to populate the history entry's document, step 5 on, in the page to host it.struct Populating {- NonnullRefPtr<WebContentPage> host;NonnullOwnPtr<NavigationLoader> loader;};- using State = Variant<Admitted, EvaluatingJavaScriptURL, CheckingIfUnloadingIsCanceled, CreatingNavigationParams, AcquiringResponseBody, ChoosingHost, Populating>;+ // Attempting to populate the history entry's document is over, and its completion steps appended finalizing the+ // navigation to the traversal queue.+ struct Finalizing {+ OwnPtr<NavigationLoader> loader;+ };+ using State = Variant<EvaluatingJavaScriptURL, CheckingIfUnloadingIsCanceled, CreatingNavigationParams, AcquiringResponseBody, Populating, Finalizing>;- Optional<URL::URL> url {};- Optional<Utf16String> navigation_id {};+ URL::URL url;+ Utf16String navigation_id;// The navigation to make again if the user stops this one and reloads, or a crash cuts it short. Kept from the start// request, which population uses up. A javascript: URL has none.Optional<Web::HTML::PreparedNavigationDescriptor> retry {};u64 sequence_number { 0 };- State state { Admitted {} };- // Navigate's historyEntry, from step 23.6 on, whose document state holds the document populated for it.+ State state;+ // The page running the navigation's steps.+ RefPtr<WebContentPage> page {};+ // Navigate's historyEntry, whose document state holds the document populated for it.RefPtr<CanonicalSessionHistoryEntry> history_entry {};WebContentPage* worker() const;WebContentPage* host() const;NavigationLoader* loader() const;+ bool is_finalizing() const { return state.has<Finalizing>(); }};WEBVIEW_API Web::HTML::PreparedNavigationDescriptor prepare_navigation_to_retry(Web::HTML::PreparedNavigationDescriptor);diff --git a/Libraries/LibWebView/CanonicalTraversable.cpp b/Libraries/LibWebView/CanonicalTraversable.cppindex 52691610bc7..22abf425ef6 100644--- a/Libraries/LibWebView/CanonicalTraversable.cpp+++ b/Libraries/LibWebView/CanonicalTraversable.cpp@@ -1218,7 +1218,7 @@ Optional<CanonicalTraversable::BrowserHistoryTraversalDiagnostic> CanonicalTrave};}-// The navigation a cross-document navigation's finalization took from its navigable at its queue position.+// The navigation a cross-document navigation's finalization finalizes.CanonicalNavigation const* CanonicalTraversable::finalized_navigation(HistoryOperation const& operation) const{auto const* parameters = operation.parameters.get_pointer<Web::FinalizeCrossDocumentNavigationHistoryOperationParameters>();@@ -1227,8 +1227,8 @@ CanonicalNavigation const* CanonicalTraversable::finalized_navigation(HistoryOpeauto navigable = find(parameters->navigable_id);if (!navigable.has_value())return nullptr;- auto const* navigation = navigable->navigation_being_finalized();- return navigation && navigation->navigation_id == parameters->navigation_id ? navigation : nullptr;+ auto const* navigation = navigable->navigation_with_id(parameters->navigation_id);+ return navigation && navigation->is_finalizing() ? navigation : nullptr;}void CanonicalTraversable::recover_from_web_content_process_crash(OnHistoryOperationComplete on_complete)@@ -2113,13 +2113,19 @@ void CanonicalTraversable::did_attempt_to_populate_the_history_entry_document(Weauto navigable = find(parameters.navigable_id);if (!navigable.has_value())return;- auto* navigation = navigable->ongoing_navigation();- if (!navigation || navigation->navigation_id != parameters.navigation_id || navigation->host() != &source_page)+ auto* navigation = navigable->navigation_with_id(parameters.navigation_id);+ if (!navigation || navigation->is_finalizing() || navigation->host() != &source_page)return;+ auto is_javascript_url_navigation = navigation->state.has<CanonicalNavigation::EvaluatingJavaScriptURL>();+ OwnPtr<NavigationLoader> loader;+ if (auto* populating = navigation->state.get_pointer<CanonicalNavigation::Populating>())+ loader = move(populating->loader);+ navigation->state = CanonicalNavigation::Finalizing { move(loader) };+// NB: Populating historyEntry's document saves state in the entry, which the page that populated it reports.auto history_entry_descriptor = Web::HTML::create_session_history_entry_descriptor(parameters.history_entry, 0);- if (!navigation->state.has<CanonicalNavigation::EvaluatingJavaScriptURL>()) {+ if (!is_javascript_url_navigation) {if (!navigation->history_entry)return;if (history_entry_descriptor.document_state.id == navigation->history_entry->document_state->id@@ -2139,6 +2145,12 @@ void CanonicalTraversable::did_attempt_to_populate_the_history_entry_document(We// NB: The process running a javascript: URL navigation evaluates it, creates newDocument in navigable's active// browsing context, and reports historyEntry. The UI process runs the steps that decide newDocument's origin,// and populates the document it holds for historyEntry's document state.++ // 3. Set the ongoing navigation for targetNavigable to null.+ // NB: The process running the navigation set it before evaluating the URL.+ if (auto ongoing_navigation_id = navigable->ongoing_navigation_id(); ongoing_navigation_id.has_value() && *ongoing_navigation_id == parameters.navigation_id)+ navigable->clear_ongoing_navigation();+auto const& initiator_origin = history_entry->document_state->initiator_origin;// 4. If initiatorOrigin is not same origin-domain with targetNavigable's active document's origin, then return.@@ -2173,7 +2185,7 @@ void CanonicalTraversable::did_attempt_to_populate_the_history_entry_document(We// 12. Let historyEntry be a new session history entry, with// URL: entryToReplace's URL// document state: documentState- navigable->populate_document_for_javascript_url(move(history_entry), navigable->create_and_initialize_a_document(response_document));+ navigable->populate_document_for_javascript_url(*navigation, move(history_entry), navigable->create_and_initialize_a_document(response_document));}void CanonicalTraversable::enqueue_history_operation(Web::HTML::CrossProcessId operation_id, Web::HistoryOperationParameters request, RefPtr<WebContentPage> requesting_page, u64 sequence_number, OnHistoryOperationComplete on_complete)@@ -2193,7 +2205,7 @@ void CanonicalTraversable::enqueue_history_operation(Web::HTML::CrossProcessId oif (auto const* parameters = request.get_pointer<Web::NavigableCreationHistoryOperationParameters>()) {auto navigable = find(parameters->navigable_id);auto current_step = m_session_history.current_step();- if (navigable.has_value() && current_step.has_value() && !navigable->ongoing_navigation()+ if (navigable.has_value() && current_step.has_value() && !navigable->ongoing_navigation_id().has_value()&& m_session_history.get_the_target_history_entry(*navigable, *current_step)) {navigable->set_ongoing_navigation_to_traversal(operation_id);}@@ -2569,10 +2581,10 @@ void CanonicalTraversable::run_direct_history_operation(HistoryOperation& operat// Flush is a queue barrier; completing at the queue position is the whole operation.finish_history_operation(operation.operation_id, Web::HTML::HistoryStepResult::Applied, {});},- [&](Web::FinalizeCrossDocumentNavigationHistoryOperationParameters const& parameters) {- // The navigation is committed from here on. One that a newer navigation replaced meanwhile is not finalized.- auto navigable = find(parameters.navigable_id);- if (!navigable.has_value() || !operation.initiating_page || !navigable->take_navigation_to_finalize(parameters.navigation_id, *operation.initiating_page)) {+ [&](Web::FinalizeCrossDocumentNavigationHistoryOperationParameters const&) {+ // A navigation that ended before its completion steps appended this has nothing to finalize.+ auto const* navigation = finalized_navigation(operation);+ if (!navigation || navigation->host() != operation.initiating_page.ptr()) {finish_history_operation(operation.operation_id, Web::HTML::HistoryStepResult::Applied, {});return;}@@ -2626,11 +2638,12 @@ void CanonicalTraversable::finalize_a_cross_document_navigation(HistoryOperation}// NB: historyEntry is the navigation's. A javascript: URL navigation whose document was refused has none.- if (!navigable->navigation_being_finalized()->history_entry) {+ auto const* navigation = finalized_navigation(operation);+ if (!navigation || !navigation->history_entry) {finish_history_operation(operation.operation_id, Web::HTML::HistoryStepResult::NoMatchingEntry, {});return;}- NonnullRefPtr history_entry = *navigable->navigation_being_finalized()->history_entry;+ NonnullRefPtr history_entry = *navigation->history_entry;// 1. Assert: this is running on navigable's traversable navigable's session history traversal queue.VERIFY(operation.queue_promise);diff --git a/Libraries/LibWebView/ViewImplementation.cpp b/Libraries/LibWebView/ViewImplementation.cppindex 73379bbb588..518f6f98a10 100644--- a/Libraries/LibWebView/ViewImplementation.cpp+++ b/Libraries/LibWebView/ViewImplementation.cpp@@ -3248,8 +3248,8 @@ void ViewImplementation::dump_session_history(StringView reason, SessionHistoryDauto traversal = traversable().browser_history_traversal_for_testing();Optional<URL::URL> loading_url;- if (traversable().ongoing_navigation())- loading_url = traversable().ongoing_navigation()->url;+ if (auto const* navigation = traversable().uncommitted_navigation())+ loading_url = navigation->url;// The page displaying the tab can have lost its process, as when a crash recovery ends.auto const* connection = page().routed_connection();@@ -3375,12 +3375,12 @@ void ViewImplementation::respawn_web_content_process_after_crash()Optional<ViewImplementation::NavigationToRetry> ViewImplementation::navigation_to_retry_for_ongoing_navigation() const{- auto const* navigation = traversable().ongoing_navigation();+ auto const* navigation = traversable().uncommitted_navigation();if (!navigation)navigation = traversable().navigation_being_finalized();- if (!navigation || !navigation->url.has_value())+ if (!navigation)return {};- return NavigationToRetry { *navigation->url, navigation->retry };+ return NavigationToRetry { navigation->url, navigation->retry };}void ViewImplementation::retry_navigation(NavigationToRetry retry, Web::Bindings::NavigationHistoryBehavior history_handling)diff --git a/Libraries/LibWebView/WebContentPage.cpp b/Libraries/LibWebView/WebContentPage.cppindex cfe8edca8ed..f795695b75b 100644--- a/Libraries/LibWebView/WebContentPage.cpp+++ b/Libraries/LibWebView/WebContentPage.cpp@@ -301,46 +301,53 @@ bool WebContentPage::continue_navigation_population_in_selected_process(Web::HTMif (!navigable.has_value())return false;- auto* ongoing_navigation = navigable->ongoing_navigation();- auto* acquiring = ongoing_navigation && ongoing_navigation->navigation_id == navigation_id- ? ongoing_navigation->state.get_pointer<CanonicalNavigation::AcquiringResponseBody>()- : nullptr;- if (!acquiring)+ auto* navigation = navigable->navigation_with_id(navigation_id);+ if (!navigation || !navigation->state.has<CanonicalNavigation::AcquiringResponseBody>())return false;- ongoing_navigation->state = CanonicalNavigation::ChoosingHost { acquiring->worker, move(acquiring->loader) };- NonnullRefPtr history_entry = *ongoing_navigation->history_entry;- auto host_or_error = navigable->obtain_page_to_populate_document(history_entry, *ongoing_navigation->loader(), *this);+ NonnullRefPtr history_entry = *navigation->history_entry;+ auto host_or_error = navigable->obtain_page_to_populate_document(history_entry, *navigation->loader(), *this);if (host_or_error.is_error()) {warnln("Unable to obtain a page to populate the navigation's document: {}", host_or_error.error());return false;}auto host = host_or_error.release_value().page;- auto& loader = *navigable->ongoing_navigation()->loader();- navigable->set_navigation_host(*host);- auto finish_handoff = [page = NonnullRefPtr<WebContentPage>(*this), host, navigable_id, navigation_id](bool succeeded) {- if (!page->is_open())+ // Obtaining the page can replace the tab's process, whose change callbacks can end the navigation.+ navigation = navigable->navigation_with_id(navigation_id);+ if (!navigation || !navigation->state.has<CanonicalNavigation::AcquiringResponseBody>())+ return false;++ auto& acquiring = navigation->state.get<CanonicalNavigation::AcquiringResponseBody>();+ auto loader = move(acquiring.loader);+ auto weak_loader = loader->make_weak_ptr();+ navigation->state = CanonicalNavigation::Populating { move(loader) };+ navigation->page = host;++ auto finish_handoff = [host, navigable_id, navigation_id, weak_loader](bool succeeded) {+ if (!weak_loader || !host->is_open())return;- auto navigable = page->population_worker_navigable(navigable_id);+ auto navigable = host->traversable().top_level_traversable().find(navigable_id);if (!navigable.has_value())return;- auto const& navigation = navigable->ongoing_navigation();- if (!navigation.has_value() || navigation->navigation_id != navigation_id || navigation->phase != CanonicalNavigation::Phase::Populating || !navigation->loader)+ auto* navigation = navigable->navigation_with_id(navigation_id);+ if (!navigation || !navigation->state.has<CanonicalNavigation::Populating>() || navigation->loader() != weak_loader.ptr())return;- if (!succeeded || !host->is_open()) {- if (navigable->is_top_level_traversable() && page->displays_tab())- page->view().did_cancel_loading(navigation_id);- navigable->clear_ongoing_navigation();+ if (!succeeded) {+ navigable->did_cancel_navigation(navigation_id);return;}- auto& loader = *navigation->loader;- host->async_populate_navigation(loader.request(), loader.take_result());++ // https://html.spec.whatwg.org/multipage/browsing-the-web.html#attempt-to-populate-the-history-entry's-document+ // 5. Queue a global task on the navigation and traversal task source, given navigable's active window, to run+ // these steps:+ // NB: The page to host the document runs the task.+ host->async_populate_navigation(weak_loader->request(), weak_loader->take_result());};// Wait for the destination RequestServer to acknowledge the import before the host adopts it.if (auto client_id = host->client().request_server_site_bindings().client_id(); client_id.has_value()) {if (auto request_server = RequestServerManager::the().instance_for_client(*client_id)) {- loader.move_response_body_to(*request_server, move(finish_handoff));+ weak_loader->move_response_body_to(*request_server, move(finish_handoff));return true;}}@@ -356,7 +363,7 @@ Optional<CanonicalNavigable&> WebContentPage::population_worker_navigable(Web::Hreturn navigable;auto navigable = traversable().top_level_traversable().find(navigable_id);- if (!navigable.has_value() || !navigable->ongoing_navigation() || navigable->ongoing_navigation()->worker() != this)+ if (!navigable.has_value() || !navigable->uncommitted_navigation() || navigable->uncommitted_navigation()->worker() != this)return {};return *navigable;}@@ -1426,12 +1433,11 @@ bool WebContentPage::populates_a_navigation_to_local_file(ByteString const& pathbool result = false;traversable().for_each_in_inclusive_subtree([&](CanonicalNavigable const& navigable) {- auto const* ongoing_navigation = navigable.ongoing_navigation();- result = ongoing_navigation- && ongoing_navigation->worker() == this- && ongoing_navigation->url.has_value()- && ongoing_navigation->url->scheme() == "file"sv- && ongoing_navigation->url->file_path() == path;+ auto navigation = navigable.uncommitted_navigation();+ result = navigation+ && navigation->worker() == this+ && navigation->url.scheme() == "file"sv+ && navigation->url.file_path() == path;return result ? IterationDecision::Break : IterationDecision::Continue;});return result;@@ -1914,7 +1920,7 @@ void WebContentPage::did_request_navigation_start(Web::HTML::CrossProcessId navi// AD-HOC: The local ongoing-navigation check can run before the UI traversal queue sets its canonical value.// Recheck it here so navigation admission and history traversal remain ordered by the UI process.auto navigation_is_blocked_by_history_traversal = target_navigable- && target_navigable->ongoing_navigation_is_traversal();+ && target_navigable->ongoing_navigation().has<CanonicalNavigable::Traversal>();// The page hosting the navigable's document continues navigate at step 8, for a sourceDocument it hosts or for// one another page hosts, which asked the UI process to route the navigation here.Optional<URL::Origin> initiator_origin;@@ -1958,7 +1964,8 @@ void WebContentPage::did_request_navigation_start(Web::HTML::CrossProcessId navi.url = url,.navigation_id = navigation_id,.sequence_number = sequence_number,- .state = CanonicalNavigation::EvaluatingJavaScriptURL { *this },+ .state = CanonicalNavigation::EvaluatingJavaScriptURL {},+ .page = this,});if (target_navigable->is_top_level_traversable()) {if (displays_tab())@@ -1973,7 +1980,8 @@ void WebContentPage::did_request_navigation_start(Web::HTML::CrossProcessId navi.navigation_id = navigation_id,.retry = move(retry),.sequence_number = sequence_number,- .state = CanonicalNavigation::CheckingIfUnloadingIsCanceled { *this, start_request.release_value() },+ .state = CanonicalNavigation::CheckingIfUnloadingIsCanceled { start_request.release_value() },+ .page = this,});begin_navigation_unload_check(*target_navigable, navigation_id);}@@ -2007,9 +2015,9 @@ void WebContentPage::did_complete_navigation_unload_check(Web::HTML::CrossProcesif (!navigable.has_value())return;- auto* ongoing_navigation = navigable->ongoing_navigation();+ auto* ongoing_navigation = navigable->navigation_with_id(navigation_id);auto* checking = ongoing_navigation ? ongoing_navigation->state.get_pointer<CanonicalNavigation::CheckingIfUnloadingIsCanceled>() : nullptr;- if (!checking || ongoing_navigation->navigation_id != navigation_id || checking->worker.ptr() != this)+ if (!checking || ongoing_navigation->worker() != this)return;auto population_request = Web::HTML::create_navigation_population_request(@@ -2017,7 +2025,7 @@ void WebContentPage::did_complete_navigation_unload_check(Web::HTML::CrossProcesApplication::the().allocate_ui_process_cross_process_id());population_request.target_snapshot_params.sandboxing_flags |= navigable->snapshot_target_snapshot_params().sandboxing_flags;ongoing_navigation->history_entry = MUST(CanonicalSessionHistoryEntry::create_from_descriptor(Web::HTML::create_session_history_entry_descriptor(population_request.history_entry, 0)));- ongoing_navigation->state = CanonicalNavigation::CreatingNavigationParams { *this, NavigationLoader::create(client().is_private(), move(population_request)) };+ ongoing_navigation->state = CanonicalNavigation::CreatingNavigationParams { NavigationLoader::create(client().is_private(), move(population_request)) };async_create_navigation_params(ongoing_navigation->loader()->request());// Requesting navigation params starts the fetch, so a view's top-level population begins its recorded@@ -2037,11 +2045,9 @@ void WebContentPage::did_finish_navigation_params_creation(Web::HTML::CrossProcereturn;}- auto* ongoing_navigation = navigable->ongoing_navigation();- auto* creating = ongoing_navigation && ongoing_navigation->navigation_id == navigation_id- ? ongoing_navigation->state.get_pointer<CanonicalNavigation::CreatingNavigationParams>()- : nullptr;- if (!creating || creating->worker.ptr() != this) {+ auto* ongoing_navigation = navigable->navigation_with_id(navigation_id);+ auto* creating = ongoing_navigation ? ongoing_navigation->state.get_pointer<CanonicalNavigation::CreatingNavigationParams>() : nullptr;+ if (!creating || ongoing_navigation->worker() != this) {if (result.has_value())NavigationLoader::discard(client().is_private(), *result);return;@@ -2055,7 +2061,7 @@ void WebContentPage::did_finish_navigation_params_creation(Web::HTML::CrossProce// Steps 1-4 have produced final navigation params. Keep the pending entry in// sync with redirects before choosing the process that will run step 5.auto loader = move(creating->loader);- ongoing_navigation->state = CanonicalNavigation::AcquiringResponseBody { *this, move(loader) };+ ongoing_navigation->state = CanonicalNavigation::AcquiringResponseBody { move(loader) };auto& acquiring_loader = *ongoing_navigation->loader();acquiring_loader.did_finish_navigation_params_creation(result.release_value());if (ongoing_navigation->history_entry->update_from_descriptor(Web::HTML::create_session_history_entry_descriptor(acquiring_loader.request().history_entry, 0)).is_error()) {@@ -2092,16 +2098,16 @@ void WebContentPage::did_fail_navigation_population(Web::HTML::CrossProcessId na// The failure must name the admitted transaction, and must come from a process that owns part of its// outcome: the population worker (unload check, javascript: evaluation) or the population host.- auto* ongoing_navigation = navigable->ongoing_navigation();+ auto* ongoing_navigation = navigable->navigation_with_id(navigation_id);if (!ongoing_navigation- || ongoing_navigation->navigation_id != navigation_id+ || ongoing_navigation->is_finalizing()|| (ongoing_navigation->worker() != this && ongoing_navigation->host() != this)) {return;}// Only a failed population handoff owns the loader's response body.- if (auto* populating = ongoing_navigation->state.get_pointer<CanonicalNavigation::Populating>(); populating && populating->host.ptr() == this)- populating->loader->reclaim_response_body_after_failed_handoff();+ if (ongoing_navigation->state.has<CanonicalNavigation::Populating>() && ongoing_navigation->host() == this)+ ongoing_navigation->loader()->reclaim_response_body_after_failed_handoff();m_history_recorded_url_for_current_load.clear();navigable->did_cancel_navigation(move(navigation_id));@@ -2201,14 +2207,12 @@ Messages::WebContentClient::DidStartDownloadResponse WebContentPage::did_start_d// received that response may claim it, and only while its population is in flight.bool matches_in_flight_navigation = false;if (auto navigable = population_worker_navigable(navigable_id); navigable.has_value()) {- auto const* ongoing_navigation = navigable->ongoing_navigation();+ auto const* ongoing_navigation = navigation_id.has_value() ? navigable->navigation_with_id(*navigation_id) : nullptr;if (ongoing_navigation- && ongoing_navigation->navigation_id == navigation_id- && !ongoing_navigation->state.has<CanonicalNavigation::AcquiringResponseBody>()- && ongoing_navigation->loader()+ && (ongoing_navigation->state.has<CanonicalNavigation::CreatingNavigationParams>() || ongoing_navigation->state.has<CanonicalNavigation::Populating>())&& ongoing_navigation->loader()->response_body_matches(request_server_client_id, request_server_request_id)) {matches_in_flight_navigation = true;- navigable->did_cancel_navigation(*ongoing_navigation->navigation_id);+ navigable->did_cancel_navigation(*navigation_id);}}if (!matches_in_flight_navigation)diff --git a/Tests/LibWebView/TestApplyHistoryStep.cpp b/Tests/LibWebView/TestApplyHistoryStep.cppindex 8785b398a0c..21848f2b0ca 100644--- a/Tests/LibWebView/TestApplyHistoryStep.cpp+++ b/Tests/LibWebView/TestApplyHistoryStep.cpp@@ -11,6 +11,7 @@#include <LibWebView/ApplyHistoryStep.h>#include <LibWebView/CanonicalBrowsingContext.h>#include <LibWebView/CanonicalNavigable.h>+#include <LibWebView/CanonicalNavigation.h>#include <LibWebView/CanonicalTraversable.h>#include <LibWebView/WebContentClient.h>@@ -28,6 +29,37 @@ static URL::URL parse_url(StringView url)}// Each test entry has a document state of its own, unless a test gives it one.+// A navigation whose steps are checking if unloading is canceled, in no page.+static WebView::CanonicalNavigation navigation_for_testing(Utf16String navigation_id, u64 sequence_number = 0, RefPtr<WebView::CanonicalSessionHistoryEntry> history_entry = {})+{+ return {+ .url = URL::about_blank(),+ .navigation_id = navigation_id,+ .sequence_number = sequence_number,+ .state = WebView::CanonicalNavigation::CheckingIfUnloadingIsCanceled { Web::HTML::NavigationStartRequest {+ .navigable_id = {},+ .url = URL::about_blank(),+ .document_resource = {},+ .request_referrer = Web::Fetch::Infrastructure::RequestReferrer::Client,+ .request_referrer_policy = Web::ReferrerPolicy::ReferrerPolicy::EmptyString,+ .initiator_origin = URL::Origin::create_opaque(),+ .initiator_base_url = {},+ .navigable_target_name = {},+ .source_snapshot_params = Web::HTML::create_navigation_source_snapshot_without_a_source_document(),+ .target_snapshot_params = {},+ .csp_navigation_type = Web::ContentSecurityPolicy::Directives::NavigationType::Other,+ .history_handling = Web::Bindings::NavigationHistoryBehavior::Auto,+ .user_involvement = Web::HTML::UserNavigationInvolvement::None,+ .navigation_id = navigation_id,+ .classic_history_api_state = {},+ .navigation_api_state = {},+ .navigation_api_key = {},+ .navigation_api_id = {},+ } },+ .history_entry = move(history_entry),+ };+}+static u64 s_next_test_document_state_local_id = 1000000;static Web::HTML::SessionHistoryEntryDescriptor entry(i32 step, StringView url)@@ -240,14 +272,14 @@ TEST_CASE(ongoing_traversal_is_owned_by_its_history_operation)navigable.set_ongoing_navigation_to_traversal(first_operation_id());navigable.set_ongoing_navigation_to_traversal(second_operation_id());navigable.clear_ongoing_navigation_traversal(first_operation_id());- EXPECT(navigable.ongoing_navigation_is_traversal());+ EXPECT(navigable.ongoing_navigation().has<WebView::CanonicalNavigable::Traversal>());navigable.clear_ongoing_navigation_traversal(second_operation_id());- EXPECT(!navigable.ongoing_navigation_is_traversal());+ EXPECT(!navigable.ongoing_navigation().has<WebView::CanonicalNavigable::Traversal>());navigable.set_ongoing_navigation_to_traversal(first_operation_id());navigable.clear_ongoing_navigation();- EXPECT(!navigable.ongoing_navigation_is_traversal());+ EXPECT(!navigable.ongoing_navigation().has<WebView::CanonicalNavigable::Traversal>());}TEST_CASE(finalized_replacement_is_selected_from_the_navigables_current_entry)@@ -278,7 +310,7 @@ TEST_CASE(traversal_runs_the_changing_root_job_and_commits_the_target_step)EXPECT(!test.traversable.active_document_is(*target_entry));EXPECT_EQ(test.runner.navigation_api_state_clear_tasks.size(), 1uz);EXPECT_EQ(test.runner.navigation_api_state_clear_tasks[0], root_id());- EXPECT(test.traversable.ongoing_navigation_is_traversal());+ EXPECT(test.traversable.ongoing_navigation().has<WebView::CanonicalNavigable::Traversal>());auto& job = test.runner.changing_jobs[0];EXPECT_EQ(job.job.navigable_id, root_id());EXPECT_EQ(job.job.target_entry->url, parse_url("https://a.example/"sv));@@ -296,7 +328,7 @@ TEST_CASE(traversal_runs_the_changing_root_job_and_commits_the_target_step)EXPECT(test.result == Web::HTML::HistoryStepResult::Applied);EXPECT_EQ(test.current_step(), 0);EXPECT(operation.completed());- EXPECT(!test.traversable.ongoing_navigation_is_traversal());+ EXPECT(!test.traversable.ongoing_navigation().has<WebView::CanonicalNavigable::Traversal>());}TEST_CASE(same_document_traversal_does_not_clear_the_navigation_api_state)@@ -315,7 +347,7 @@ TEST_CASE(same_document_traversal_yields_to_a_navigation_awaiting_admission)test.with_two_same_document_top_level_entries();test.traverse_to_step(0);- EXPECT(!test.traversable.ongoing_navigation_is_traversal());+ EXPECT(!test.traversable.ongoing_navigation().has<WebView::CanonicalNavigable::Traversal>());EXPECT_EQ(test.runner.changing_jobs.size(), 1uz);auto const& job = test.runner.changing_jobs[0].job;EXPECT(job.traversal_yields_to == Web::HTML::TraversalYieldsTo::UnadmittedNavigation);@@ -326,11 +358,11 @@ TEST_CASE(same_document_traversal_names_the_older_navigation_it_cancels){TestTraversable test;test.with_two_same_document_top_level_entries();- test.traversable.set_ongoing_navigation({ .navigation_id = "older"_utf16, .sequence_number = 1 });+ test.traversable.set_ongoing_navigation(navigation_for_testing("older"_utf16, 1));test.traverse_to_step(0);- EXPECT(!test.traversable.ongoing_navigation());- EXPECT(!test.traversable.ongoing_navigation_is_traversal());+ EXPECT(!test.traversable.ongoing_navigation_id().has_value());+ EXPECT(!test.traversable.ongoing_navigation().has<WebView::CanonicalNavigable::Traversal>());EXPECT_EQ(test.runner.changing_jobs.size(), 1uz);auto const& job = test.runner.changing_jobs[0].job;EXPECT(job.traversal_yields_to == Web::HTML::TraversalYieldsTo::UnadmittedNavigation);@@ -341,10 +373,10 @@ TEST_CASE(same_document_traversal_yields_to_a_newer_admitted_navigation){TestTraversable test;test.with_two_same_document_top_level_entries();- test.traversable.set_ongoing_navigation({ .navigation_id = "newer"_utf16, .sequence_number = 3 });+ test.traversable.set_ongoing_navigation(navigation_for_testing("newer"_utf16, 3));test.traverse_to_step(0);- EXPECT(test.traversable.ongoing_navigation());+ EXPECT(test.traversable.ongoing_navigation_id().has_value());EXPECT_EQ(test.runner.changing_jobs.size(), 1uz);auto const& job = test.runner.changing_jobs[0].job;EXPECT(job.traversal_yields_to == Web::HTML::TraversalYieldsTo::AdmittedNavigation);@@ -355,11 +387,11 @@ TEST_CASE(cross_document_traversal_cancels_a_newer_navigation){TestTraversable test;test.with_two_top_level_entries();- test.traversable.set_ongoing_navigation({ .navigation_id = "newer"_utf16, .sequence_number = 3 });+ test.traversable.set_ongoing_navigation(navigation_for_testing("newer"_utf16, 3));test.traverse_to_step(0);- EXPECT(!test.traversable.ongoing_navigation());- EXPECT(test.traversable.ongoing_navigation_is_traversal());+ EXPECT(!test.traversable.ongoing_navigation_id().has_value());+ EXPECT(test.traversable.ongoing_navigation().has<WebView::CanonicalNavigable::Traversal>());EXPECT_EQ(test.runner.changing_jobs.size(), 1uz);auto const& job = test.runner.changing_jobs[0].job;EXPECT(job.traversal_yields_to == Web::HTML::TraversalYieldsTo::Nothing);@@ -503,7 +535,7 @@ TEST_CASE(skipped_changing_job_still_applies_the_history_step)EXPECT(test.result == Web::HTML::HistoryStepResult::Applied);EXPECT_EQ(test.current_step(), 0);- EXPECT(!child.ongoing_navigation_is_traversal());+ EXPECT(!child.ongoing_navigation().has<WebView::CanonicalNavigable::Traversal>());}TEST_CASE(ready_continuations_interleave_with_still_running_changing_jobs)@@ -542,7 +574,7 @@ TEST_CASE(stale_changing_job_completes_without_committing_the_target_step)EXPECT(test.runner.nonchanging_updates.is_empty());EXPECT(test.result == Web::HTML::HistoryStepResult::Applied);EXPECT_EQ(test.current_step(), 1);- EXPECT(!test.traversable.ongoing_navigation_is_traversal());+ EXPECT(!test.traversable.ongoing_navigation().has<WebView::CanonicalNavigable::Traversal>());}TEST_CASE(synchronous_navigation_steps_jump_the_queue_before_continuations)@@ -628,7 +660,7 @@ TEST_CASE(canceled_run_does_not_resume_after_synchronous_navigation)test.operation = nullptr;EXPECT(!test.state.running_nested_apply_history_step);- EXPECT(!test.traversable.ongoing_navigation_is_traversal());+ EXPECT(!test.traversable.ongoing_navigation().has<WebView::CanonicalNavigable::Traversal>());synchronous_steps_signal->resolve({});EXPECT(test.runner.continuations.is_empty());@@ -755,7 +787,7 @@ TEST_CASE(a_paused_traversal_is_abandoned_once_a_jumping_push_removes_its_targetEXPECT(!test.operation->committed_step().has_value());EXPECT_EQ(test.current_step(), 2);EXPECT_EQ(test.history.current_entry()->url, parse_url("https://b.example/pushed"sv));- EXPECT(!test.traversable.ongoing_navigation_is_traversal());+ EXPECT(!test.traversable.ongoing_navigation().has<WebView::CanonicalNavigable::Traversal>());}TEST_CASE(a_paused_push_appends_its_entry_again_once_a_jumping_push_clears_it)diff --git a/Tests/LibWebView/TestCanonicalBrowsingContextGroup.cpp b/Tests/LibWebView/TestCanonicalBrowsingContextGroup.cppindex 0b5b976ed74..892aa05ce60 100644--- a/Tests/LibWebView/TestCanonicalBrowsingContextGroup.cpp+++ b/Tests/LibWebView/TestCanonicalBrowsingContextGroup.cpp@@ -11,10 +11,42 @@#include <LibWebView/CanonicalBrowsingContext.h>#include <LibWebView/CanonicalBrowsingContextGroup.h>#include <LibWebView/CanonicalDocument.h>+#include <LibWebView/CanonicalNavigation.h>#include <LibWebView/CanonicalSessionHistoryEntry.h>#include <LibWebView/CanonicalTraversable.h>#include <LibWebView/CanonicalWindow.h>+// A navigation whose steps are checking if unloading is canceled, in no page.+static WebView::CanonicalNavigation navigation_for_testing(Utf16String navigation_id, u64 sequence_number = 0, RefPtr<WebView::CanonicalSessionHistoryEntry> history_entry = {})+{+ return {+ .url = URL::about_blank(),+ .navigation_id = navigation_id,+ .sequence_number = sequence_number,+ .state = WebView::CanonicalNavigation::CheckingIfUnloadingIsCanceled { Web::HTML::NavigationStartRequest {+ .navigable_id = {},+ .url = URL::about_blank(),+ .document_resource = {},+ .request_referrer = Web::Fetch::Infrastructure::RequestReferrer::Client,+ .request_referrer_policy = Web::ReferrerPolicy::ReferrerPolicy::EmptyString,+ .initiator_origin = URL::Origin::create_opaque(),+ .initiator_base_url = {},+ .navigable_target_name = {},+ .source_snapshot_params = Web::HTML::create_navigation_source_snapshot_without_a_source_document(),+ .target_snapshot_params = {},+ .csp_navigation_type = Web::ContentSecurityPolicy::Directives::NavigationType::Other,+ .history_handling = Web::Bindings::NavigationHistoryBehavior::Auto,+ .user_involvement = Web::HTML::UserNavigationInvolvement::None,+ .navigation_id = navigation_id,+ .classic_history_api_state = {},+ .navigation_api_state = {},+ .navigation_api_key = {},+ .navigation_api_id = {},+ } },+ .history_entry = move(history_entry),+ };+}+static URL::Origin origin_for(StringView url){return URL::Parser::basic_parse(url).value().origin();@@ -145,8 +177,8 @@ TEST_CASE(response_browsing_context_is_activated_only_at_commit)auto* destination_context = &destination_document->browsing_context();auto navigation_id = Utf16String::from_utf8("navigation"sv);auto abandoned_document_state = WebView::CanonicalDocumentState::create({});- traversable.set_ongoing_navigation(WebView::CanonicalNavigation { .navigation_id = navigation_id, .history_entry = WebView::CanonicalSessionHistoryEntry::create(abandoned_document_state) });- traversable.populate_document_for_ongoing_navigation(destination_document);+ traversable.set_ongoing_navigation(navigation_for_testing(navigation_id, 0, WebView::CanonicalSessionHistoryEntry::create(abandoned_document_state)));+ traversable.populate_document_for_navigation(*traversable.uncommitted_navigation(), destination_document);EXPECT_EQ(&traversable.active_browsing_context(), initial_context);EXPECT(initial_group->browsing_context_set().contains(initial_context));@@ -158,8 +190,8 @@ TEST_CASE(response_browsing_context_is_activated_only_at_commit)auto destination_document_state = WebView::CanonicalDocumentState::create({});auto committed_entry = WebView::CanonicalSessionHistoryEntry::create(destination_document_state);- traversable.set_ongoing_navigation(WebView::CanonicalNavigation { .navigation_id = navigation_id, .history_entry = committed_entry });- traversable.populate_document_for_ongoing_navigation(destination_document);+ traversable.set_ongoing_navigation(navigation_for_testing(navigation_id, 0, committed_entry));+ traversable.populate_document_for_navigation(*traversable.uncommitted_navigation(), destination_document);Web::HTML::HostedNavigableState committed_state {.active_document_url = destination_url,.active_document_is_fully_active = true,@@ -171,7 +203,7 @@ TEST_CASE(response_browsing_context_is_activated_only_at_commit)traversable.did_commit_navigation(*committed_entry, move(committed_state), 1, navigation_id, {});EXPECT_EQ(&traversable.active_browsing_context(), destination_context);EXPECT(initial_group->browsing_context_set().is_empty());- EXPECT(!traversable.ongoing_navigation());+ EXPECT(!traversable.ongoing_navigation_id().has_value());}TEST_CASE(child_navigation_under_a_document_that_switched_groups_uses_its_group)@@ -202,8 +234,8 @@ TEST_CASE(child_navigation_under_a_document_that_switched_groups_uses_its_group)// The destination document's frames are created once it is activated.auto navigation_id = Utf16String::from_utf8("navigation"sv);auto destination_document_state = WebView::CanonicalDocumentState::create({});- traversable.set_ongoing_navigation(WebView::CanonicalNavigation { .navigation_id = navigation_id, .history_entry = WebView::CanonicalSessionHistoryEntry::create(destination_document_state) });- traversable.populate_document_for_ongoing_navigation(destination_document);+ traversable.set_ongoing_navigation(navigation_for_testing(navigation_id, 0, WebView::CanonicalSessionHistoryEntry::create(destination_document_state)));+ traversable.populate_document_for_navigation(*traversable.uncommitted_navigation(), destination_document);Web::HTML::HostedNavigableState committed_state {.active_document_url = destination_url,.active_document_is_fully_active = true,@@ -249,16 +281,16 @@ TEST_CASE(clearing_a_navigation_abandons_only_the_document_populated_for_it)auto job_document = make_document();auto job_document_state = WebView::CanonicalDocumentState::create({});traversable.populate_document(job_document_state, job_document);- traversable.set_ongoing_navigation(WebView::CanonicalNavigation { .navigation_id = Utf16String::from_utf8("navigation"sv) });+ traversable.set_ongoing_navigation(navigation_for_testing(Utf16String::from_utf8("navigation"sv)));traversable.clear_ongoing_navigation();EXPECT_EQ(job_document_state->populated_document->document.ptr(), job_document.ptr());// A document populated for a navigation goes with it.auto navigation_id = Utf16String::from_utf8("navigation"sv);auto navigation_document_state = WebView::CanonicalDocumentState::create({});- traversable.set_ongoing_navigation(WebView::CanonicalNavigation { .navigation_id = navigation_id, .history_entry = WebView::CanonicalSessionHistoryEntry::create(navigation_document_state) });+ traversable.set_ongoing_navigation(navigation_for_testing(navigation_id, 0, WebView::CanonicalSessionHistoryEntry::create(navigation_document_state)));auto navigation_document = make_document();- traversable.populate_document_for_ongoing_navigation(navigation_document);+ traversable.populate_document_for_navigation(*traversable.uncommitted_navigation(), navigation_document);EXPECT_EQ(navigation_document_state->populated_document->document.ptr(), navigation_document.ptr());traversable.clear_ongoing_navigation();EXPECT(!navigation_document_state->populated_document.has_value());@@ -271,7 +303,7 @@ TEST_CASE(document_claimed_by_a_history_job_outlives_a_newer_navigation)auto make_document = [] { return WebView::CanonicalBrowsingContext::create_a_new_top_level_browsing_context_and_document({}).document; };traversable.set_active_session_history_entry(WebView::CanonicalSessionHistoryEntry::create(WebView::CanonicalDocumentState::create({}, make_document())));- // The history operation finalizing a navigation took it, and holds the document populated for it as a history job's.+ // A history job populated a document for its entry.auto claimed_navigation_id = Utf16String::from_utf8("claimed"sv);auto claimed_document_state = WebView::CanonicalDocumentState::create({});auto claimed_document = make_document();@@ -279,9 +311,9 @@ TEST_CASE(document_claimed_by_a_history_job_outlives_a_newer_navigation)// A newer navigation starts before the claimed document is activated, and populates its own.auto newer_document_state = WebView::CanonicalDocumentState::create({});- traversable.set_ongoing_navigation(WebView::CanonicalNavigation { .navigation_id = Utf16String::from_utf8("newer"sv), .history_entry = WebView::CanonicalSessionHistoryEntry::create(newer_document_state) });+ traversable.set_ongoing_navigation(navigation_for_testing(Utf16String::from_utf8("newer"sv), 0, WebView::CanonicalSessionHistoryEntry::create(newer_document_state)));auto newer_document = make_document();- traversable.populate_document_for_ongoing_navigation(newer_document);+ traversable.populate_document_for_navigation(*traversable.uncommitted_navigation(), newer_document);EXPECT_EQ(claimed_document_state->populated_document->document.ptr(), claimed_document.ptr());Web::HTML::HostedNavigableState committed_state {@@ -296,7 +328,7 @@ TEST_CASE(document_claimed_by_a_history_job_outlives_a_newer_navigation)EXPECT_EQ(&traversable.active_document(), claimed_document.ptr());EXPECT(!claimed_document_state->populated_document.has_value());EXPECT_EQ(newer_document_state->populated_document->document.ptr(), newer_document.ptr());- EXPECT(traversable.ongoing_navigation());+ EXPECT(traversable.ongoing_navigation_id().has_value());}TEST_CASE(populated_document_replaces_tracked_load_when_document_state_is_reused)@@ -306,7 +338,7 @@ TEST_CASE(populated_document_replaces_tracked_load_when_document_state_is_reusedentry->navigation_api_id = Utf16String::from_utf8("entry"sv);traversable.set_active_session_history_entry(entry);auto navigation_id = Utf16String::from_utf8("reload"sv);- traversable.set_ongoing_navigation(WebView::CanonicalNavigation { .navigation_id = navigation_id });+ traversable.set_ongoing_navigation(navigation_for_testing(navigation_id));traversable.populate_document(entry->document_state, WebView::CanonicalBrowsingContext::create_a_new_top_level_browsing_context_and_document({}).document);auto destination_url = URL::Parser::basic_parse("https://ladybird.org/redirected"sv).release_value();@@ -340,13 +372,13 @@ TEST_CASE(same_document_traversal_commits_only_navigations_admitted_before_it)};// A navigation admitted after the traversal was requested goes on past the traversal's activation.- traversable.set_ongoing_navigation({ .navigation_id = Utf16String::from_utf8("newer"sv), .sequence_number = 2 });+ traversable.set_ongoing_navigation(navigation_for_testing(Utf16String::from_utf8("newer"sv), 2));traversable.did_commit_navigation(*entry, committed_state(), 1, {}, {});- EXPECT(traversable.ongoing_navigation());+ EXPECT(traversable.ongoing_navigation_id().has_value());// One admitted before it does not.traversable.did_commit_navigation(*entry, committed_state(), 3, {}, {});- EXPECT(!traversable.ongoing_navigation());+ EXPECT(!traversable.ongoing_navigation_id().has_value());}TEST_CASE(site_keyed_agent_clusters)diff --git a/Tests/LibWebView/TestRendererOriginClaims.cpp b/Tests/LibWebView/TestRendererOriginClaims.cppindex ce0d0918206..d65d1da8bfd 100644--- a/Tests/LibWebView/TestRendererOriginClaims.cpp+++ b/Tests/LibWebView/TestRendererOriginClaims.cpp@@ -98,8 +98,7 @@ ErrorOr<int> ladybird_main(Main::Arguments arguments).navigation_api_id = {},};stub.did_request_navigation_start(page_id, traversable.id(), Web::NavigationTarget::TopLevel, URL::about_blank(), navigation_id, move(request));- auto const* ongoing_navigation = traversable.ongoing_navigation();- return ongoing_navigation && ongoing_navigation->navigation_id == navigation_id;+ return traversable.navigation_with_id(navigation_id) != nullptr;};// An about:blank document takes its initiator origin, so a victim's would give the renderer a document of its origin.