LibWeb/HTML: Implement NavigationTransition committed promise

This commit is contained in:
Sam Atkins 2025-12-04 16:21:03 +00:00
parent 945c4ca5b3
commit 4fb28539a9
Notes: github-actions[bot] 2025-12-05 09:21:16 +00:00
4 changed files with 27 additions and 9 deletions

View file

@ -806,7 +806,8 @@ void Navigation::abort_a_navigate_event(GC::Ref<NavigateEvent> event, GC::Ref<We
if (!m_transition)
return;
// FIXME: 8. Reject navigation's transition's committed promise with error.
// 8. Reject navigation's transition's committed promise with error.
WebIDL::reject_promise(realm(), m_transition->committed(), reason);
// 9. Reject navigation's transition's finished promise with reason.
WebIDL::reject_promise(realm(), m_transition->finished(), reason);
@ -1127,13 +1128,17 @@ bool Navigation::inner_navigate_event_firing_algorithm(
// navigation type: navigationType
// from entry: fromNHE
// destination: event's destination
// FIXME: committed promise: a new promise created in navigation's relevant realm
// committed promise: a new promise created in navigation's relevant realm
// finished promise: a new promise created in navigation's relevant realm
m_transition = NavigationTransition::create(realm, navigation_type, *from_nhe, event->destination(), WebIDL::create_promise(realm));
m_transition = NavigationTransition::create(realm, navigation_type, *from_nhe, event->destination(), WebIDL::create_promise(realm), WebIDL::create_promise(realm));
// 5. Mark as handled navigation's transition's finished promise.
WebIDL::mark_promise_as_handled(*m_transition->finished());
// AD-HOC: The current spec has changed significantly from what we implement here, but marks the committed
// promise as handled at the equivalent place.
WebIDL::mark_promise_as_handled(*m_transition->committed());
// 6. If navigationType is "traverse", then set navigation's suppress normal scroll restoration during ongoing navigation to true.
// NOTE: If event's scroll behavior was set to "after-transition", then scroll restoration will happen as part of finishing
// the relevant NavigateEvent. Otherwise, there will be no scroll restoration. That is, no navigation which is intercepted