Truly independent web browser
LibWebView: Traverse to the nearest step in navigation API traversals
Andreas Kling6145dcbaf6c4
diff --git a/Libraries/LibWebView/CanonicalTraversable.cpp b/Libraries/LibWebView/CanonicalTraversable.cppindex 0ae78fa94e3..542a4d83b4f 100644--- a/Libraries/LibWebView/CanonicalTraversable.cpp+++ b/Libraries/LibWebView/CanonicalTraversable.cpp@@ -2198,9 +2198,23 @@ void CanonicalTraversable::perform_a_navigation_api_traversal_at_queue_position(return;}+ // INTEROP: targetSHE stays navigable's current entry for every step until navigable's next entry. When going+ // back, traverse to the nearest of those steps instead of targetSHE's step, so that other navigables+ // are not traversed along with it.+ auto target_step = target_entry->step;+ if (target_step < m_session_history.current_step()) {+ for (auto step : m_session_history.used_steps()) {+ if (step >= m_session_history.current_step())+ break;+ auto const* entry_at_step = m_session_history.get_the_target_history_entry(*navigable, step);+ if (entry_at_step && entry_at_step->identity() == target_entry->identity())+ target_step = step;+ }+ }+// 12.4. Let result be the result of applying the traverse history step targetSHE's step to traversable, given// sourceSnapshotParams, navigable, and "none".- apply_the_traverse_history_step(operation, target_entry->step, request.source_snapshot_params, request.navigable_id, Web::HTML::UserNavigationInvolvement::None);+ apply_the_traverse_history_step(operation, target_step, request.source_snapshot_params, request.navigable_id, Web::HTML::UserNavigationInvolvement::None);// Steps 12.5-12.6 are handled in Navigation's relevant realm when the requesting process learns the result.}diff --git a/Tests/LibWeb/Text/expected/wpt-import/navigation-api/navigation-methods/back-forward-multiple-frames.txt b/Tests/LibWeb/Text/expected/wpt-import/navigation-api/navigation-methods/back-forward-multiple-frames.txtindex 34ec42c7054..fe68c85c37c 100644--- a/Tests/LibWeb/Text/expected/wpt-import/navigation-api/navigation-methods/back-forward-multiple-frames.txt+++ b/Tests/LibWeb/Text/expected/wpt-import/navigation-api/navigation-methods/back-forward-multiple-frames.txt@@ -2,5 +2,5 @@ Harness status: OKFound 1 tests-1 Fail-Fail navigation.back() and navigation.forward() can navigate multiple frames\ No newline at end of file+1 Pass+Pass navigation.back() and navigation.forward() can navigate multiple frames\ No newline at end of filediff --git a/Tests/LibWeb/Text/expected/wpt-import/navigation-api/navigation-methods/disambigaute-back.txt b/Tests/LibWeb/Text/expected/wpt-import/navigation-api/navigation-methods/disambigaute-back.txtindex b1d71a67f57..80a5fbb8b05 100644--- a/Tests/LibWeb/Text/expected/wpt-import/navigation-api/navigation-methods/disambigaute-back.txt+++ b/Tests/LibWeb/Text/expected/wpt-import/navigation-api/navigation-methods/disambigaute-back.txt@@ -2,5 +2,5 @@ Harness status: OKFound 1 tests-1 Fail-Fail navigation.back() goes to the nearest back entry\ No newline at end of file+1 Pass+Pass navigation.back() goes to the nearest back entry\ No newline at end of filediff --git a/Tests/LibWeb/Text/expected/wpt-import/navigation-api/navigation-methods/disambigaute-forward.txt b/Tests/LibWeb/Text/expected/wpt-import/navigation-api/navigation-methods/disambigaute-forward.txtindex 52cd680ff0a..47d6c265e33 100644--- a/Tests/LibWeb/Text/expected/wpt-import/navigation-api/navigation-methods/disambigaute-forward.txt+++ b/Tests/LibWeb/Text/expected/wpt-import/navigation-api/navigation-methods/disambigaute-forward.txt@@ -2,5 +2,5 @@ Harness status: OKFound 1 tests-1 Fail-Fail navigation.forward() goes to the nearest forward entry\ No newline at end of file+1 Pass+Pass navigation.forward() goes to the nearest forward entry\ No newline at end of filediff --git a/Tests/LibWeb/Text/expected/wpt-import/navigation-api/navigation-methods/disambigaute-traverseTo-back-multiple.txt b/Tests/LibWeb/Text/expected/wpt-import/navigation-api/navigation-methods/disambigaute-traverseTo-back-multiple.txtindex 858f53b7239..218510ed38d 100644--- a/Tests/LibWeb/Text/expected/wpt-import/navigation-api/navigation-methods/disambigaute-traverseTo-back-multiple.txt+++ b/Tests/LibWeb/Text/expected/wpt-import/navigation-api/navigation-methods/disambigaute-traverseTo-back-multiple.txt@@ -2,5 +2,5 @@ Harness status: OKFound 1 tests-1 Fail-Fail navigation.traverseTo() goes to the nearest entry when going back\ No newline at end of file+1 Pass+Pass navigation.traverseTo() goes to the nearest entry when going back\ No newline at end of filediff --git a/Tests/LibWeb/Text/expected/wpt-import/navigation-api/navigation-methods/disambigaute-traverseTo-forward-multiple.txt b/Tests/LibWeb/Text/expected/wpt-import/navigation-api/navigation-methods/disambigaute-traverseTo-forward-multiple.txtindex 65cbe41f499..7f40e82676c 100644--- a/Tests/LibWeb/Text/expected/wpt-import/navigation-api/navigation-methods/disambigaute-traverseTo-forward-multiple.txt+++ b/Tests/LibWeb/Text/expected/wpt-import/navigation-api/navigation-methods/disambigaute-traverseTo-forward-multiple.txt@@ -2,5 +2,5 @@ Harness status: OKFound 1 tests-1 Fail-Fail navigation.traverseTo() goes to the nearest entry when going forward\ No newline at end of file+1 Pass+Pass navigation.traverseTo() goes to the nearest entry when going forward\ No newline at end of file