<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<!DOCTYPE bugzilla SYSTEM "https://bugs.webkit.org/page.cgi?id=bugzilla.dtd">

<bugzilla version="5.0.4.1"
          urlbase="https://bugs.webkit.org/"
          
          maintainer="admin@webkit.org"
>

    <bug>
          <bug_id>282622</bug_id>
          
          <creation_ts>2024-11-05 10:46:40 -0800</creation_ts>
          <short_desc>[Navigation] Cross document push navigations don&apos;t prune correctly</short_desc>
          <delta_ts>2024-12-09 08:22:42 -0800</delta_ts>
          <reporter_accessible>1</reporter_accessible>
          <cclist_accessible>1</cclist_accessible>
          <classification_id>1</classification_id>
          <classification>Unclassified</classification>
          <product>WebKit</product>
          <component>WebCore Misc.</component>
          <version>WebKit Nightly Build</version>
          <rep_platform>Unspecified</rep_platform>
          <op_sys>Unspecified</op_sys>
          <bug_status>RESOLVED</bug_status>
          <resolution>FIXED</resolution>
          
          
          <bug_file_loc></bug_file_loc>
          <status_whiteboard></status_whiteboard>
          <keywords>InRadar</keywords>
          <priority>P2</priority>
          <bug_severity>Normal</bug_severity>
          <target_milestone>---</target_milestone>
          
          <blocked>258384</blocked>
          <everconfirmed>1</everconfirmed>
          <reporter name="Patrick Griffis">pgriffis</reporter>
          <assigned_to name="Chris Dumez">cdumez</assigned_to>
          <cc>webkit-bug-importer</cc>
          

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>2072875</commentid>
    <comment_count>0</comment_count>
    <who name="Patrick Griffis">pgriffis</who>
    <bug_when>2024-11-05 10:46:40 -0800</bug_when>
    <thetext>This is test navigation-api/navigation-history-entry/entries-after-cross-document-forward-pruning.html

This is resolved by fixing this fixme: https://github.com/WebKit/WebKit/blob/ac9f0488c548bf6c6bc855059c6b3b27929b1b81/Source/WebCore/page/Navigation.cpp#L141

A diff such as this would be the starting point:

diff --git a/Source/WebCore/page/Navigation.cpp b/Source/WebCore/page/Navigation.cpp
index cf5725257363..c0753548cfb2 100644
--- a/Source/WebCore/page/Navigation.cpp
+++ b/Source/WebCore/page/Navigation.cpp
@@ -138,7 +138,7 @@ void Navigation::initializeForNewWindow(std::optional&lt;NavigationNavigationType&gt;
 
             // FIXME: This should handle Push, however somewhere before here the currentEntry of previousNavigation was updated
             // to the new navigation so we get duplicate entries.
-            if (navigationType != NavigationNavigationType::Push) {
+            if (true) {
                 if (navigationType == NavigationNavigationType::Traverse) {
                     m_currentEntryIndex = getEntryIndexOfHistoryItem(m_entries, *currentItem);
                     if (m_currentEntryIndex) {
@@ -151,6 +151,11 @@ void Navigation::initializeForNewWindow(std::optional&lt;NavigationNavigationType&gt;
                 } else {
                     Ref previousEntry = m_entries[*previousNavigation-&gt;m_currentEntryIndex];
 
+                    if (navigationType == NavigationNavigationType::Push) {
+                        m_entries.resize(*previousNavigation-&gt;m_currentEntryIndex + 1); // Prune forward entries.
+                        m_entries.append(NavigationHistoryEntry::create(protectedScriptExecutionContext().get(), *currentItem)); // fixme
+                    }
+
                     if (navigationType == NavigationNavigationType::Replace)
                         m_entries[*previousNavigation-&gt;m_currentEntryIndex] = NavigationHistoryEntry::create(protectedScriptExecutionContext().get(), *currentItem);</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>2074557</commentid>
    <comment_count>1</comment_count>
    <who name="Radar WebKit Bug Importer">webkit-bug-importer</who>
    <bug_when>2024-11-12 10:47:14 -0800</bug_when>
    <thetext>&lt;rdar://problem/139734080&gt;</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>2079441</commentid>
    <comment_count>2</comment_count>
    <who name="Chris Dumez">cdumez</who>
    <bug_when>2024-12-05 11:35:09 -0800</bug_when>
    <thetext>Pull request: https://github.com/WebKit/WebKit/pull/37500</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>2080200</commentid>
    <comment_count>3</comment_count>
    <who name="EWS">ews-feeder</who>
    <bug_when>2024-12-09 08:22:40 -0800</bug_when>
    <thetext>Committed 287548@main (e08f45aa8902): &lt;https://commits.webkit.org/287548@main&gt;

Reviewed commits have been landed. Closing PR #37500 and removing active labels.</thetext>
  </long_desc>
      
      

    </bug>

</bugzilla>