Truly independent web browser
LibWeb+LibWebView+WebContent: Report an unload check with its own result
Shannon Booth35b4407c0816
diff --git a/Libraries/LibWeb/HTML/HistoryExecutor.cpp b/Libraries/LibWeb/HTML/HistoryExecutor.cppindex c031e261cb3..46ed8295b20 100644--- a/Libraries/LibWeb/HTML/HistoryExecutor.cpp+++ b/Libraries/LibWeb/HTML/HistoryExecutor.cpp@@ -218,7 +218,7 @@ void HistoryExecutor::finalize_same_document_navigation(GC::Ref<LocalNavigable>// https://html.spec.whatwg.org/multipage/browsing-the-web.html#checking-if-unloading-is-canceled// NB: The UI process has each page hosting documents to check run this for them. The traversable's host is also given// the target entry, and runs step 4 for the traversable.-void HistoryExecutor::run_ui_beforeunload_check(Vector<CrossProcessId> navigable_ids, Optional<SessionHistoryEntryDescriptor> target_entry_descriptor, Optional<UserNavigationInvolvement> user_involvement_for_navigate_event, UnloadPromptShown unload_prompt_shown, GC::Ref<GC::Function<void(HistoryStepResult, UnloadPromptShown)>> on_complete)+void HistoryExecutor::run_ui_beforeunload_check(Vector<CrossProcessId> navigable_ids, Optional<SessionHistoryEntryDescriptor> target_entry_descriptor, Optional<UserNavigationInvolvement> user_involvement_for_navigate_event, UnloadPromptShown unload_prompt_shown, GC::Ref<GC::Function<void(CheckIfUnloadingIsCanceledResult, UnloadPromptShown)>> on_complete){GC::Ptr<LocalTraversableNavigable> traversable;RefPtr<SessionHistoryEntry> target_entry;@@ -233,21 +233,7 @@ void HistoryExecutor::run_ui_beforeunload_check(Vector<CrossProcessId> navigableif (auto navigable = local_navigable_with_id(navigable_id); navigable && !navigable->has_been_destroyed() && navigable->active_document())navigables.append(*navigable);}- check_if_unloading_is_canceled(move(navigables), traversable, move(target_entry), user_involvement_for_navigate_event, unload_prompt_shown,- GC::create_function(heap(), [on_complete](CheckIfUnloadingIsCanceledResult result, UnloadPromptShown unload_prompt_shown) {- switch (result) {- case CheckIfUnloadingIsCanceledResult::CanceledByBeforeUnload:- on_complete->function()(HistoryStepResult::CanceledByBeforeUnload, unload_prompt_shown);- return;- case CheckIfUnloadingIsCanceledResult::CanceledByNavigate:- on_complete->function()(HistoryStepResult::CanceledByNavigate, unload_prompt_shown);- return;- case CheckIfUnloadingIsCanceledResult::Continue:- on_complete->function()(HistoryStepResult::Applied, unload_prompt_shown);- return;- }- VERIFY_NOT_REACHED();- }));+ check_if_unloading_is_canceled(move(navigables), traversable, move(target_entry), user_involvement_for_navigate_event, unload_prompt_shown, on_complete);}static bool is_same_document_push_or_replace(Optional<Bindings::NavigationType> navigation_type, SessionHistoryEntry const& target_entry, Optional<UniqueNodeID> displayed_document_id)diff --git a/Libraries/LibWeb/HTML/HistoryExecutor.h b/Libraries/LibWeb/HTML/HistoryExecutor.hindex 81a9e9e96c1..c564de04113 100644--- a/Libraries/LibWeb/HTML/HistoryExecutor.h+++ b/Libraries/LibWeb/HTML/HistoryExecutor.h@@ -67,7 +67,7 @@ public:void traverse_the_history_by_delta(int delta, GC::Ptr<DOM::Document> source_document = {});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(HistoryStepResult, UnloadPromptShown)>>);+ 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, UserNavigationInvolvement, Optional<Bindings::NavigationType>, TraversalYieldsTo, Optional<Utf16String> canceled_navigation_id, GC::Ref<OnChangingNavigableHistoryStepJobComplete>, Optional<HistoryNavigationPopulation> = {});bool resume_history_navigation_population(CrossProcessId operation_id, HistoryNavigationPopulation&&);void prepare_ui_changing_navigable_for_unload(CrossProcessId operation_id, CrossProcessId navigable_id, GC::Ref<GC::Function<void()>> on_complete);diff --git a/Libraries/LibWeb/HTML/LocalNavigable.h b/Libraries/LibWeb/HTML/LocalNavigable.hindex a9c8178febd..9b56ce9a32d 100644--- a/Libraries/LibWeb/HTML/LocalNavigable.h+++ b/Libraries/LibWeb/HTML/LocalNavigable.h@@ -739,11 +739,6 @@ bool navigation_must_be_a_replace(URL::URL const& url, DOM::Document const& docubool prepare_to_finalize_a_cross_document_navigation(LocalNavigable&, DOM::Document& pending_document);void finalize_a_cross_document_navigation(GC::Ref<LocalNavigable>, HistoryHandlingBehavior, UserNavigationInvolvement, NonnullRefPtr<SessionHistoryEntry>, GC::Ptr<DOM::Document> pending_document, Utf16String navigation_id, Optional<Utf16String> expected_ongoing_navigation_id, GC::Ref<OnApplyHistoryStepComplete> on_complete);-enum class CheckIfUnloadingIsCanceledResult {- CanceledByBeforeUnload,- CanceledByNavigate,- Continue,-};WEB_API void check_if_unloading_is_canceled(Vector<GC::Root<LocalNavigable>> navigables_that_need_before_unload, GC::Ptr<LocalTraversableNavigable> traversable, RefPtr<SessionHistoryEntry> target_entry, Optional<UserNavigationInvolvement> user_involvement_for_navigate_events, UnloadPromptShown, GC::Ref<GC::Function<void(CheckIfUnloadingIsCanceledResult, UnloadPromptShown)>> callback);WEB_API void check_if_unloading_is_canceled(Vector<GC::Root<LocalNavigable>> navigables_that_need_before_unload, GC::Ref<GC::Function<void(CheckIfUnloadingIsCanceledResult)>> callback);void perform_url_and_history_update_steps(DOM::Document& document, URL::URL new_url, Optional<StorageSerializationRecord> = {}, HistoryHandlingBehavior history_handling = HistoryHandlingBehavior::Replace);diff --git a/Libraries/LibWebCommon/HTML/ApplyHistoryStep.h b/Libraries/LibWebCommon/HTML/ApplyHistoryStep.hindex bc7605beb19..310ac7a7371 100644--- a/Libraries/LibWebCommon/HTML/ApplyHistoryStep.h+++ b/Libraries/LibWebCommon/HTML/ApplyHistoryStep.h@@ -10,6 +10,13 @@namespace Web::HTML {+// https://html.spec.whatwg.org/multipage/browsing-the-web.html#checking-if-unloading-is-canceled+enum class CheckIfUnloadingIsCanceledResult {+ CanceledByBeforeUnload,+ CanceledByNavigate,+ Continue,+};+// https://html.spec.whatwg.org/multipage/browsing-the-web.html#apply-the-history-step// They return "initiator-disallowed", "canceled-by-beforeunload", "canceled-by-navigate", or// "applied".diff --git a/Libraries/LibWebView/ApplyHistoryStep.cpp b/Libraries/LibWebView/ApplyHistoryStep.cppindex 6239f1a2f85..2a2a9f2490e 100644--- a/Libraries/LibWebView/ApplyHistoryStep.cpp+++ b/Libraries/LibWebView/ApplyHistoryStep.cpp@@ -117,14 +117,20 @@ void ApplyHistoryStep::apply_the_history_step()}m_jobs.check_if_unloading_is_canceled(move(navigables_crossing_documents), *target_entry, m_user_involvement,- [this](Web::HTML::HistoryStepResult result) {+ [this](Web::HTML::CheckIfUnloadingIsCanceledResult result) {if (m_completed)return;- if (result != Web::HTML::HistoryStepResult::Applied) {- return_result(result);+ switch (result) {+ case Web::HTML::CheckIfUnloadingIsCanceledResult::CanceledByBeforeUnload:+ return_result(Web::HTML::HistoryStepResult::CanceledByBeforeUnload);+ return;+ case Web::HTML::CheckIfUnloadingIsCanceledResult::CanceledByNavigate:+ return_result(Web::HTML::HistoryStepResult::CanceledByNavigate);+ return;+ case Web::HTML::CheckIfUnloadingIsCanceledResult::Continue:+ get_changing_and_nonchanging_navigables();return;}- get_changing_and_nonchanging_navigables();});}diff --git a/Libraries/LibWebView/ApplyHistoryStep.h b/Libraries/LibWebView/ApplyHistoryStep.hindex 2253ce7c154..81732e4a358 100644--- a/Libraries/LibWebView/ApplyHistoryStep.h+++ b/Libraries/LibWebView/ApplyHistoryStep.h@@ -33,7 +33,7 @@ struct WEBVIEW_API ApplyHistoryStepJobs {// https://html.spec.whatwg.org/multipage/browsing-the-web.html#checking-if-unloading-is-canceled// NB: Given targetStep's target entry, which the traversable's host resolves no further.- Function<void(Vector<Web::HTML::CrossProcessId> navigables_that_need_before_unload, NonnullRefPtr<CanonicalSessionHistoryEntry> target_entry, Web::HTML::UserNavigationInvolvement user_involvement_for_navigate_event, Function<void(Web::HTML::HistoryStepResult)> on_complete)> check_if_unloading_is_canceled;+ Function<void(Vector<Web::HTML::CrossProcessId> navigables_that_need_before_unload, NonnullRefPtr<CanonicalSessionHistoryEntry> target_entry, Web::HTML::UserNavigationInvolvement user_involvement_for_navigate_event, Function<void(Web::HTML::CheckIfUnloadingIsCanceledResult)> on_complete)> check_if_unloading_is_canceled;// NB: This queued work runs in the process hosting the active Window.Function<void(Web::HTML::CrossProcessId navigable_id)> queue_navigation_api_state_clear_task;diff --git a/Libraries/LibWebView/CanonicalTraversable.cpp b/Libraries/LibWebView/CanonicalTraversable.cppindex 387d7bb5154..053837ec90e 100644--- a/Libraries/LibWebView/CanonicalTraversable.cpp+++ b/Libraries/LibWebView/CanonicalTraversable.cpp@@ -1979,11 +1979,11 @@ void CanonicalTraversable::end_history_jobs(CanonicalNavigable const& navigable,ApplyHistoryStepJobs CanonicalTraversable::create_apply_history_step_jobs(HistoryOperation& operation){return {- .check_if_unloading_is_canceled = [this, &operation](Vector<Web::HTML::CrossProcessId> navigables_that_need_before_unload, NonnullRefPtr<CanonicalSessionHistoryEntry> target_entry, Web::HTML::UserNavigationInvolvement user_involvement_for_navigate_event, Function<void(Web::HTML::HistoryStepResult)> on_complete) {+ .check_if_unloading_is_canceled = [this, &operation](Vector<Web::HTML::CrossProcessId> navigables_that_need_before_unload, NonnullRefPtr<CanonicalSessionHistoryEntry> target_entry, Web::HTML::UserNavigationInvolvement user_involvement_for_navigate_event, Function<void(Web::HTML::CheckIfUnloadingIsCanceledResult)> on_complete) {if (operation.finished)return;auto check_id = check_if_unloading_is_canceled(move(navigables_that_need_before_unload), move(target_entry), user_involvement_for_navigate_event, {}, Web::HTML::UnloadPromptShown::No,- [this, operation_id = operation.operation_id, on_complete = move(on_complete)](Web::HTML::HistoryStepResult result, Web::HTML::UnloadPromptShown) {+ [this, operation_id = operation.operation_id, on_complete = move(on_complete)](Web::HTML::CheckIfUnloadingIsCanceledResult result, Web::HTML::UnloadPromptShown) {auto* operation = find_history_operation(operation_id);if (!operation)return;@@ -2841,7 +2841,7 @@ void CanonicalTraversable::abandon_history_operations()// https://html.spec.whatwg.org/multipage/browsing-the-web.html#checking-if-unloading-is-canceled// NB: The steps run in the pages hosting the documents, one page at a time. A skipped endpoint has run its part already.-Optional<Web::HTML::CrossProcessId> CanonicalTraversable::check_if_unloading_is_canceled(Vector<Web::HTML::CrossProcessId> navigables_that_need_before_unload, RefPtr<CanonicalSessionHistoryEntry> target_entry, Optional<Web::HTML::UserNavigationInvolvement> user_involvement_for_navigate_event, RefPtr<WebContentPage> skipped_endpoint, Web::HTML::UnloadPromptShown unload_prompt_shown, Function<void(Web::HTML::HistoryStepResult, Web::HTML::UnloadPromptShown)> on_complete)+Optional<Web::HTML::CrossProcessId> CanonicalTraversable::check_if_unloading_is_canceled(Vector<Web::HTML::CrossProcessId> navigables_that_need_before_unload, RefPtr<CanonicalSessionHistoryEntry> target_entry, Optional<Web::HTML::UserNavigationInvolvement> user_involvement_for_navigate_event, RefPtr<WebContentPage> skipped_endpoint, Web::HTML::UnloadPromptShown unload_prompt_shown, Function<void(Web::HTML::CheckIfUnloadingIsCanceledResult, Web::HTML::UnloadPromptShown)> on_complete){PendingBeforeunloadCheck check;check.target_entry = target_entry;@@ -2884,7 +2884,7 @@ Optional<Web::HTML::CrossProcessId> CanonicalTraversable::check_if_unloading_is_}if (check.groups.is_empty()) {- on_complete(Web::HTML::HistoryStepResult::Applied, unload_prompt_shown);+ on_complete(Web::HTML::CheckIfUnloadingIsCanceledResult::Continue, unload_prompt_shown);return {};}@@ -2922,17 +2922,17 @@ void CanonicalTraversable::dispatch_next_beforeunload_group(Web::HTML::CrossProc// 8. Wait for completedTasks to be totalTasks.// 9. Return finalStatus.auto completed_check = m_pending_beforeunload_checks.take(check_id);- completed_check->on_complete(Web::HTML::HistoryStepResult::Applied, completed_check->unload_prompt_shown);+ completed_check->on_complete(Web::HTML::CheckIfUnloadingIsCanceledResult::Continue, completed_check->unload_prompt_shown);}-void CanonicalTraversable::did_receive_beforeunload_check_result(WebContentPage& source_page, Web::HTML::CrossProcessId check_id, Web::HTML::HistoryStepResult result, Web::HTML::UnloadPromptShown unload_prompt_shown)+void CanonicalTraversable::did_receive_beforeunload_check_result(WebContentPage& source_page, Web::HTML::CrossProcessId check_id, Web::HTML::CheckIfUnloadingIsCanceledResult result, Web::HTML::UnloadPromptShown unload_prompt_shown){if (!source_page.take_owed_reply({ OwedReply::Kind::BeforeunloadCheck, check_id, {} }))return;auto check = m_pending_beforeunload_checks.find(check_id);if (check == m_pending_beforeunload_checks.end())return;- if (result != Web::HTML::HistoryStepResult::Applied) {+ if (result != Web::HTML::CheckIfUnloadingIsCanceledResult::Continue) {auto completed_check = m_pending_beforeunload_checks.take(check_id);completed_check->on_complete(result, unload_prompt_shown);return;diff --git a/Libraries/LibWebView/CanonicalTraversable.h b/Libraries/LibWebView/CanonicalTraversable.hindex 50c9b9d506c..d7aaa3e2359 100644--- a/Libraries/LibWebView/CanonicalTraversable.h+++ b/Libraries/LibWebView/CanonicalTraversable.h@@ -78,10 +78,10 @@ public:RefPtr<WebContentPage> page_hosting(CanonicalNavigable const&) const;void did_receive_history_operation_ready(WebContentPage& source_page, Web::HTML::CrossProcessId operation_id, Web::HistoryOperationReadyResult);- void did_receive_beforeunload_check_result(WebContentPage& source_page, Web::HTML::CrossProcessId check_id, Web::HTML::HistoryStepResult, Web::HTML::UnloadPromptShown);+ void did_receive_beforeunload_check_result(WebContentPage& source_page, Web::HTML::CrossProcessId check_id, Web::HTML::CheckIfUnloadingIsCanceledResult, Web::HTML::UnloadPromptShown);// https://html.spec.whatwg.org/multipage/browsing-the-web.html#checking-if-unloading-is-canceled- Optional<Web::HTML::CrossProcessId> check_if_unloading_is_canceled(Vector<Web::HTML::CrossProcessId> navigables_that_need_before_unload, RefPtr<CanonicalSessionHistoryEntry> target_entry, Optional<Web::HTML::UserNavigationInvolvement> user_involvement_for_navigate_event, RefPtr<WebContentPage> skipped_endpoint, Web::HTML::UnloadPromptShown, Function<void(Web::HTML::HistoryStepResult, Web::HTML::UnloadPromptShown)> on_complete);+ Optional<Web::HTML::CrossProcessId> check_if_unloading_is_canceled(Vector<Web::HTML::CrossProcessId> navigables_that_need_before_unload, RefPtr<CanonicalSessionHistoryEntry> target_entry, Optional<Web::HTML::UserNavigationInvolvement> user_involvement_for_navigate_event, RefPtr<WebContentPage> skipped_endpoint, Web::HTML::UnloadPromptShown, Function<void(Web::HTML::CheckIfUnloadingIsCanceledResult, Web::HTML::UnloadPromptShown)> on_complete);bool is_unloading_document_of(Web::HTML::CrossProcessId navigable_id) const;bool is_handing_navigable_to_another_page(CanonicalNavigable const&) const;void did_receive_changing_navigable_history_job_ready(WebContentPage& source_page, Web::HTML::CrossProcessId operation_id, Web::HTML::CrossProcessId navigable_id, Web::HTML::ChangingNavigableHistoryStepJobDisposition, Web::HTML::UnloadDisplayedDocument);@@ -291,7 +291,7 @@ private:Optional<Web::HTML::UserNavigationInvolvement> user_involvement_for_navigate_event;Vector<BeforeunloadGroup> groups;Web::HTML::UnloadPromptShown unload_prompt_shown { Web::HTML::UnloadPromptShown::No };- Function<void(Web::HTML::HistoryStepResult, Web::HTML::UnloadPromptShown)> on_complete;+ Function<void(Web::HTML::CheckIfUnloadingIsCanceledResult, Web::HTML::UnloadPromptShown)> on_complete;};HashMap<Web::HTML::CrossProcessId, PendingBeforeunloadCheck> m_pending_beforeunload_checks;void dispatch_next_beforeunload_group(Web::HTML::CrossProcessId check_id);diff --git a/Libraries/LibWebView/WebContentPage.cpp b/Libraries/LibWebView/WebContentPage.cppindex 09915d7bc4e..cfe8edca8ed 100644--- a/Libraries/LibWebView/WebContentPage.cpp+++ b/Libraries/LibWebView/WebContentPage.cpp@@ -1641,7 +1641,7 @@ void WebContentPage::history_operation_ready(Web::HTML::CrossProcessId operationtraversable().did_receive_history_operation_ready(*this, operation_id, move(result));}-void WebContentPage::beforeunload_check_result(Web::HTML::CrossProcessId operation_id, Web::HTML::HistoryStepResult result, Web::HTML::UnloadPromptShown unload_prompt_shown)+void WebContentPage::beforeunload_check_result(Web::HTML::CrossProcessId operation_id, Web::HTML::CheckIfUnloadingIsCanceledResult result, Web::HTML::UnloadPromptShown unload_prompt_shown){traversable().did_receive_beforeunload_check_result(*this, operation_id, result, unload_prompt_shown);}@@ -1989,8 +1989,8 @@ void WebContentPage::begin_navigation_unload_check(CanonicalNavigable& target_nareturn IterationDecision::Continue;});(void)target_navigable.top_level_traversable().check_if_unloading_is_canceled(move(inclusive_descendants), {}, {}, *this, Web::HTML::UnloadPromptShown::No,- [page = NonnullRefPtr<WebContentPage>(*this), navigable_id = target_navigable.id(), navigation_id](Web::HTML::HistoryStepResult result, Web::HTML::UnloadPromptShown unload_prompt_shown) {- if (result != Web::HTML::HistoryStepResult::Applied) {+ [page = NonnullRefPtr<WebContentPage>(*this), navigable_id = target_navigable.id(), navigation_id](Web::HTML::CheckIfUnloadingIsCanceledResult result, Web::HTML::UnloadPromptShown unload_prompt_shown) {+ if (result != Web::HTML::CheckIfUnloadingIsCanceledResult::Continue) {// The navigation parked for its population is not coming; the recorded load ends as a failed one.page->async_cancel_navigation_params_creation(navigable_id, navigation_id);if (page->is_open())@@ -2608,7 +2608,7 @@ void WebContentPage::request_unload_check(Web::HTML::CrossProcessId navigable_id{auto navigable = hosted_navigable(navigable_id);if (!navigable.has_value()) {- async_unload_check_result(check_id, Web::HTML::HistoryStepResult::Applied);+ async_unload_check_result(check_id, Web::HTML::CheckIfUnloadingIsCanceledResult::Continue);return;}Vector<Web::HTML::CrossProcessId> inclusive_descendants;@@ -2617,7 +2617,7 @@ void WebContentPage::request_unload_check(Web::HTML::CrossProcessId navigable_idreturn IterationDecision::Continue;});(void)navigable->top_level_traversable().check_if_unloading_is_canceled(move(inclusive_descendants), {}, {}, {}, Web::HTML::UnloadPromptShown::No,- [page = NonnullRefPtr<WebContentPage>(*this), check_id](Web::HTML::HistoryStepResult result, Web::HTML::UnloadPromptShown) {+ [page = NonnullRefPtr<WebContentPage>(*this), check_id](Web::HTML::CheckIfUnloadingIsCanceledResult result, Web::HTML::UnloadPromptShown) {page->async_unload_check_result(check_id, result);});}diff --git a/Libraries/LibWebView/WebContentPage.h b/Libraries/LibWebView/WebContentPage.hindex 40a171c1294..0fe7977707d 100644--- a/Libraries/LibWebView/WebContentPage.h+++ b/Libraries/LibWebView/WebContentPage.h@@ -266,7 +266,7 @@ private:virtual void did_request_key_event_for_testing(Web::KeyEvent event) override;virtual void request_history_operation(Web::HTML::CrossProcessId operation_id, Web::HistoryOperationParameters parameters) override;virtual void history_operation_ready(Web::HTML::CrossProcessId operation_id, Web::HistoryOperationReadyResult result) override;- virtual void beforeunload_check_result(Web::HTML::CrossProcessId operation_id, Web::HTML::HistoryStepResult result, Web::HTML::UnloadPromptShown unload_prompt_shown) override;+ virtual void beforeunload_check_result(Web::HTML::CrossProcessId operation_id, Web::HTML::CheckIfUnloadingIsCanceledResult result, Web::HTML::UnloadPromptShown unload_prompt_shown) override;virtual void changing_navigable_history_job_ready(Web::HTML::CrossProcessId operation_id, Web::HTML::CrossProcessId navigable_id, Web::HTML::ChangingNavigableHistoryStepJobDisposition disposition, Web::HTML::UnloadDisplayedDocument unload_displayed_document) override;virtual void changing_navigable_unload_preparation_complete(Web::HTML::CrossProcessId operation_id, Web::HTML::CrossProcessId navigable_id) override;virtual void descendant_unload_task_complete(Web::HTML::CrossProcessId unload_id, Web::HTML::CrossProcessId navigable_id) override;diff --git a/Services/WebContent/ConnectionFromClient.cpp b/Services/WebContent/ConnectionFromClient.cppindex a3d807ac30b..50cb27ec7d1 100644--- a/Services/WebContent/ConnectionFromClient.cpp+++ b/Services/WebContent/ConnectionFromClient.cpp@@ -559,16 +559,16 @@ void ConnectionFromClient::run_beforeunload_check(Web::PageId page_id, Web::HTML{auto page = this->page(page_id);if (!page.has_value()) {- async_beforeunload_check_result(page_id, check_id, Web::HTML::HistoryStepResult::Applied, unload_prompt_shown);+ async_beforeunload_check_result(page_id, check_id, Web::HTML::CheckIfUnloadingIsCanceledResult::Continue, unload_prompt_shown);return;}- page->page().history_executor().run_ui_beforeunload_check(move(navigable_ids), move(target_entry), user_involvement_for_navigate_event, unload_prompt_shown, GC::create_function(Web::HTML::main_thread_event_loop().heap(), [this, page_id, check_id](Web::HTML::HistoryStepResult result, Web::HTML::UnloadPromptShown unload_prompt_shown) {+ page->page().history_executor().run_ui_beforeunload_check(move(navigable_ids), move(target_entry), user_involvement_for_navigate_event, unload_prompt_shown, GC::create_function(Web::HTML::main_thread_event_loop().heap(), [this, page_id, check_id](Web::HTML::CheckIfUnloadingIsCanceledResult result, Web::HTML::UnloadPromptShown unload_prompt_shown) {async_beforeunload_check_result(page_id, check_id, result, unload_prompt_shown);}));}-void ConnectionFromClient::unload_check_result(Web::PageId page_id, Web::HTML::CrossProcessId check_id, Web::HTML::HistoryStepResult result)+void ConnectionFromClient::unload_check_result(Web::PageId page_id, Web::HTML::CrossProcessId check_id, Web::HTML::CheckIfUnloadingIsCanceledResult result){if (auto page = this->page(page_id); page.has_value())page->did_receive_unload_check_result(check_id, result);diff --git a/Services/WebContent/ConnectionFromClient.h b/Services/WebContent/ConnectionFromClient.hindex c02500da2fa..43bf103fbe9 100644--- a/Services/WebContent/ConnectionFromClient.h+++ b/Services/WebContent/ConnectionFromClient.h@@ -150,7 +150,7 @@ private:virtual void run_descendant_unload_task(Web::PageId page_id, Web::HTML::CrossProcessId unload_id, Web::HTML::CrossProcessId navigable_id, Web::HTML::ChildNavigableDestruction, Web::HTML::StopHostingAfterUnload) override;virtual void continue_child_navigable_destruction(Web::PageId page_id, Web::HTML::CrossProcessId navigable_id) override;virtual void abort_navigable_document(Web::PageId page_id, Web::HTML::CrossProcessId navigable_id) override;- virtual void unload_check_result(Web::PageId page_id, Web::HTML::CrossProcessId check_id, Web::HTML::HistoryStepResult) override;+ virtual void unload_check_result(Web::PageId page_id, Web::HTML::CrossProcessId check_id, Web::HTML::CheckIfUnloadingIsCanceledResult) override;virtual void unfullscreen_navigable_document(Web::PageId page_id, Web::HTML::CrossProcessId navigable_id) override;virtual void fullscreen_navigable_container(Web::PageId page_id, Web::HTML::CrossProcessId navigable_id, Web::HTML::CrossProcessId requesting_navigable_id, Web::Fullscreen::RequestType request_type) override;virtual void container_fullscreen_complete(Web::PageId page_id, Web::HTML::CrossProcessId navigable_id) override;diff --git a/Services/WebContent/PageClient.cpp b/Services/WebContent/PageClient.cppindex d14a92cf841..a7b53b856a4 100644--- a/Services/WebContent/PageClient.cpp+++ b/Services/WebContent/PageClient.cpp@@ -1696,12 +1696,12 @@ void PageClient::page_did_request_unload_check(Web::HTML::CrossProcessId navigabclient().async_request_unload_check(m_id, navigable_id, check_id);}-void PageClient::did_receive_unload_check_result(Web::HTML::CrossProcessId check_id, Web::HTML::HistoryStepResult result)+void PageClient::did_receive_unload_check_result(Web::HTML::CrossProcessId check_id, Web::HTML::CheckIfUnloadingIsCanceledResult result){auto on_complete = m_pending_unload_checks.take(check_id);if (!on_complete.has_value())return;- (*on_complete)->function()(result == Web::HTML::HistoryStepResult::Applied ? Web::HTML::CheckIfUnloadingIsCanceledResult::Continue : Web::HTML::CheckIfUnloadingIsCanceledResult::CanceledByBeforeUnload);+ (*on_complete)->function()(result);}String PageClient::page_did_request_ui_process_session_history_for_testing()diff --git a/Services/WebContent/PageClient.h b/Services/WebContent/PageClient.hindex c6773226409..4bce9cb92e2 100644--- a/Services/WebContent/PageClient.h+++ b/Services/WebContent/PageClient.h@@ -145,7 +145,7 @@ public:void navigate_to_a_fragment(Web::HTML::CrossProcessId navigable_id, URL::URL const&, Web::HTML::HistoryHandlingBehavior, Web::HTML::UserNavigationInvolvement, Utf16String navigation_id);void navigate_to_a_javascript_url(Web::HTML::CrossProcessId navigable_id, URL::URL const&, Web::HTML::HistoryHandlingBehavior, URL::Origin const& initiator_origin, Web::HTML::NavigationSourceSnapshot const&, Web::HTML::UserNavigationInvolvement, Web::ContentSecurityPolicy::Directives::Directive::NavigationType csp_navigation_type, Utf16String navigation_id);void run_navigation_unload_check(Web::HTML::CrossProcessId navigable_id, Utf16String const& navigation_id, Web::HTML::UnloadPromptShown);- void did_receive_unload_check_result(Web::HTML::CrossProcessId check_id, Web::HTML::HistoryStepResult);+ void did_receive_unload_check_result(Web::HTML::CrossProcessId check_id, Web::HTML::CheckIfUnloadingIsCanceledResult);void create_navigation_params(Web::HTML::NavigationPopulationRequest);void navigate_navigable(Web::HTML::CrossProcessId navigable_id, Web::HTML::PreparedNavigationDescriptor);void deliver_posted_message(Web::HTML::CrossProcessId navigable_id, Web::HTML::PostedMessageDescriptor);diff --git a/Services/WebContent/WebContentClient.ipc b/Services/WebContent/WebContentClient.ipcindex d2394b7c8ff..478959a4296 100644--- a/Services/WebContent/WebContentClient.ipc+++ b/Services/WebContent/WebContentClient.ipc@@ -246,7 +246,7 @@ endpoint WebContentClient routed by Web::PageId page_iddid_request_set_system_visibility_state(Web::PageId page_id, Web::HTML::VisibilityState visibility_state) =|request_history_operation(Web::PageId page_id, Web::HTML::CrossProcessId operation_id, Web::HistoryOperationParameters parameters) =|history_operation_ready(Web::PageId page_id, Web::HTML::CrossProcessId operation_id, Web::HistoryOperationReadyResult result) =|- beforeunload_check_result(Web::PageId page_id, Web::HTML::CrossProcessId check_id, Web::HTML::HistoryStepResult result, Web::HTML::UnloadPromptShown unload_prompt_shown) =|+ beforeunload_check_result(Web::PageId page_id, Web::HTML::CrossProcessId check_id, Web::HTML::CheckIfUnloadingIsCanceledResult result, Web::HTML::UnloadPromptShown unload_prompt_shown) =|changing_navigable_history_job_ready(Web::PageId page_id, Web::HTML::CrossProcessId operation_id, Web::HTML::CrossProcessId navigable_id, Web::HTML::ChangingNavigableHistoryStepJobDisposition disposition, Web::HTML::UnloadDisplayedDocument unload_displayed_document) =|changing_navigable_unload_preparation_complete(Web::PageId page_id, Web::HTML::CrossProcessId operation_id, Web::HTML::CrossProcessId navigable_id) =|descendant_unload_task_complete(Web::PageId page_id, Web::HTML::CrossProcessId unload_id, Web::HTML::CrossProcessId navigable_id) =|diff --git a/Services/WebContent/WebContentServer.ipc b/Services/WebContent/WebContentServer.ipcindex ffa8452d38c..5dd360ea96e 100644--- a/Services/WebContent/WebContentServer.ipc+++ b/Services/WebContent/WebContentServer.ipc@@ -300,7 +300,7 @@ endpoint WebContentServer routed by Web::PageId page_iddid_worker_agent_die(Web::HTML::WorkerAgentOwnerToken owner_token) =|request_close(Web::PageId page_id) =|- unload_check_result(Web::PageId page_id, Web::HTML::CrossProcessId check_id, Web::HTML::HistoryStepResult result) =|+ unload_check_result(Web::PageId page_id, Web::HTML::CrossProcessId check_id, Web::HTML::CheckIfUnloadingIsCanceledResult result) =|force_close(Web::PageId page_id) =|exit_fullscreen(Web::PageId page_id) =|diff --git a/Tests/LibWebView/TestApplyHistoryStep.cpp b/Tests/LibWebView/TestApplyHistoryStep.cppindex e20a516ec5a..4be80f5093b 100644--- a/Tests/LibWebView/TestApplyHistoryStep.cpp+++ b/Tests/LibWebView/TestApplyHistoryStep.cpp@@ -69,7 +69,7 @@ public:struct UnloadingCheck {NonnullRefPtr<WebView::CanonicalSessionHistoryEntry> target_entry;Vector<Web::HTML::CrossProcessId> navigables_that_need_before_unload;- Function<void(Web::HTML::HistoryStepResult)> on_complete;+ Function<void(Web::HTML::CheckIfUnloadingIsCanceledResult)> on_complete;};struct ChangingJob {ChangingNavigableHistoryStepJob job;@@ -88,7 +88,7 @@ public:WebView::ApplyHistoryStepJobs jobs(){return {- .check_if_unloading_is_canceled = [this](Vector<Web::HTML::CrossProcessId> navigables_that_need_before_unload, NonnullRefPtr<WebView::CanonicalSessionHistoryEntry> target_entry, Web::HTML::UserNavigationInvolvement, Function<void(Web::HTML::HistoryStepResult)> on_complete) { unloading_checks.append({ move(target_entry), move(navigables_that_need_before_unload), move(on_complete) }); },+ .check_if_unloading_is_canceled = [this](Vector<Web::HTML::CrossProcessId> navigables_that_need_before_unload, NonnullRefPtr<WebView::CanonicalSessionHistoryEntry> target_entry, Web::HTML::UserNavigationInvolvement, Function<void(Web::HTML::CheckIfUnloadingIsCanceledResult)> on_complete) { unloading_checks.append({ move(target_entry), move(navigables_that_need_before_unload), move(on_complete) }); },.queue_navigation_api_state_clear_task = [this](Web::HTML::CrossProcessId navigable_id) { navigation_api_state_clear_tasks.append(navigable_id); },.select_changing_navigable_history_step_job_endpoint = [this](ChangingNavigableHistoryStepJob& job) {selected_changing_job_endpoints.append(job.navigable_id);@@ -381,7 +381,7 @@ TEST_CASE(canceled_unloading_returns_before_any_changing_jobs)EXPECT_EQ(job.target_entry->url, parse_url("https://a.example/"sv));EXPECT_EQ(job.navigables_that_need_before_unload.size(), 1uz);EXPECT_EQ(job.navigables_that_need_before_unload[0], root_id());- job.on_complete(Web::HTML::HistoryStepResult::CanceledByBeforeUnload);+ job.on_complete(Web::HTML::CheckIfUnloadingIsCanceledResult::CanceledByBeforeUnload);EXPECT(test.runner.changing_jobs.is_empty());EXPECT(test.result == Web::HTML::HistoryStepResult::CanceledByBeforeUnload);