LibWeb: Implement the "check if unloading is canceled" AO

This method is responsible for firing `beforeunload` events.
This commit is contained in:
Tim Ledbetter 2024-10-02 23:56:26 +01:00 committed by Andreas Kling
commit 1fa948f114
Notes: github-actions[bot] 2024-10-05 07:18:28 +00:00
7 changed files with 231 additions and 8 deletions

View file

@ -1369,10 +1369,11 @@ WebIDL::ExceptionOr<void> Navigable::navigate(NavigateParams params)
return;
}
// FIXME: 1. Let unloadPromptCanceled be the result of checking if unloading is user-canceled for navigable's active document's inclusive descendant navigables.
// 1. Let unloadPromptCanceled be the result of checking if unloading is user-canceled for navigable's active document's inclusive descendant navigables.
auto unload_prompt_canceled = traversable_navigable()->check_if_unloading_is_canceled(this->active_document()->inclusive_descendant_navigables());
// FIXME: 2. If unloadPromptCanceled is true, or navigable's ongoing navigation is no longer navigationId, then:
if (!ongoing_navigation().has<String>() || ongoing_navigation().get<String>() != navigation_id) {
// 2. If unloadPromptCanceled is true, or navigable's ongoing navigation is no longer navigationId, then:
if (unload_prompt_canceled != TraversableNavigable::CheckIfUnloadingIsCanceledResult::Continue || !ongoing_navigation().has<String>() || ongoing_navigation().get<String>() != navigation_id) {
// FIXME: 1. Invoke WebDriver BiDi navigation failed with targetBrowsingContext and a new WebDriver BiDi navigation status whose id is navigationId, status is "canceled", and url is url.
// 2. Abort these steps.