Skip to content

Commit

Permalink
LibWeb/HTML: Halt navigation if navigate event returns false
Browse files Browse the repository at this point in the history
  • Loading branch information
AtkinsSJ committed Jan 7, 2025
1 parent 9377952 commit d468856
Showing 1 changed file with 19 additions and 8 deletions.
27 changes: 19 additions & 8 deletions Libraries/LibWeb/HTML/Navigable.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1430,14 +1430,25 @@ WebIDL::ExceptionOr<void> Navigable::navigate(NavigateParams params)
// otherwise, StructuredSerializeForStorage(undefined).
auto navigation_api_state_for_firing = navigation_api_state.value_or(MUST(structured_serialize_for_storage(vm, JS::js_undefined())));

// FIXME: 4. Let continue be the result of firing a push/replace/reload navigate event at navigation
// with navigationType set to historyHandling, isSameDocument set to false, userInvolvement set to userInvolvement,
// formDataEntryList set to entryListForFiring, destinationURL set to url, and navigationAPIState set to navigationAPIStateForFiring.
(void)navigation;
(void)entry_list_for_firing;
(void)navigation_api_state_for_firing;

// FIXME: 5. If continue is false, then return.
// 4. Let continue be the result of firing a push/replace/reload navigate event at navigation
// with navigationType set to historyHandling, isSameDocument set to false, userInvolvement set to userInvolvement,
// formDataEntryList set to entryListForFiring, destinationURL set to url, and navigationAPIState set to navigationAPIStateForFiring.
auto navigation_type = [](Bindings::NavigationHistoryBehavior history_handling) {
switch (history_handling) {
case Bindings::NavigationHistoryBehavior::Push:
return Bindings::NavigationType::Push;
case Bindings::NavigationHistoryBehavior::Replace:
return Bindings::NavigationType::Replace;
case Bindings::NavigationHistoryBehavior::Auto:
default:
VERIFY_NOT_REACHED();
}
}(history_handling);
auto continue_ = navigation->fire_a_push_replace_reload_navigate_event(navigation_type, url, false, user_involvement, entry_list_for_firing, navigation_api_state_for_firing);

// 5. If continue is false, then return.
if (!continue_)
return {};
}

// AD-HOC: Tell the UI that we started loading.
Expand Down

0 comments on commit d468856

Please sign in to comment.