From dc9861174b52a941b98b02b04231d77d94203628 Mon Sep 17 00:00:00 2001 From: Shannon Booth Date: Sun, 13 Oct 2024 15:03:40 +1300 Subject: [PATCH] LibWeb: Fire traversable event during "apply the history step" These steps were recently clarified by Andrew in: https://github.com/whatwg/html/commit/12b0d582 --- .../LibWeb/HTML/TraversableNavigable.cpp | 21 ++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) diff --git a/Userland/Libraries/LibWeb/HTML/TraversableNavigable.cpp b/Userland/Libraries/LibWeb/HTML/TraversableNavigable.cpp index 21fd28a53c5..4ca0f5818a0 100644 --- a/Userland/Libraries/LibWeb/HTML/TraversableNavigable.cpp +++ b/Userland/Libraries/LibWeb/HTML/TraversableNavigable.cpp @@ -560,9 +560,24 @@ TraversableNavigable::HistoryStepResult TraversableNavigable::apply_the_history_ // 6. Let oldOrigin be targetEntry's document state's origin. auto old_origin = target_entry->document_state()->origin(); - // FIXME: 7. If navigable is not traversable, and targetEntry is not navigable's current session history entry, - // and oldOrigin is the same as navigable's current session history entry's document state's origin, - // then fire a traverse navigate event given targetEntry and userInvolvementForNavigateEvents. + // 7. If all of the following are true: + // * navigable is not traversable; + // * targetEntry is not navigable's current session history entry; and + // * oldOrigin is the same as navigable's current session history entry's document state's origin, + // then: + if (!navigable->is_traversable() + && target_entry != navigable->current_session_history_entry() + && old_origin == navigable->current_session_history_entry()->document_state()->origin()) { + + // 1. Assert: userInvolvementForNavigateEvents is not null. + VERIFY(user_involvement_for_navigate_events.has_value()); + + // 2. Let navigation be navigable's active window's navigation API. + auto navigation = active_window()->navigation(); + + // 3. Fire a traverse navigate event at navigation given targetEntry and userInvolvementForNavigateEvents. + navigation->fire_a_traverse_navigate_event(*target_entry, *user_involvement_for_navigate_events); + } auto after_document_populated = [old_origin, changing_navigable_continuation, &changing_navigable_continuations, &vm, &navigable](bool populated_cloned_target_she, JS::NonnullGCPtr target_entry) mutable { changing_navigable_continuation->populated_target_entry = target_entry;