<?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>282609</bug_id>
          
          <creation_ts>2024-11-05 09:00:02 -0800</creation_ts>
          <short_desc>[Navigation] navigation-history-entry/entries-after-blob-navigation.html is failing</short_desc>
          <delta_ts>2024-12-09 08:24:09 -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>Page Loading</component>
          <version>WebKit Nightly Build</version>
          <rep_platform>Unspecified</rep_platform>
          <op_sys>Unspecified</op_sys>
          <bug_status>RESOLVED</bug_status>
          <resolution>FIXED</resolution>
          
          <see_also>https://github.com/web-platform-tests/wpt/pull/49553</see_also>
          <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="Rob Buis">rbuis</reporter>
          <assigned_to name="Chris Dumez">cdumez</assigned_to>
          <cc>beidson</cc>
    
    <cc>cdumez</cc>
    
    <cc>webkit-bug-importer</cc>
          

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>2072818</commentid>
    <comment_count>0</comment_count>
    <who name="Rob Buis">rbuis</who>
    <bug_when>2024-11-05 09:00:02 -0800</bug_when>
    <thetext>Fix blob: navigation related timeout.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>2072819</commentid>
    <comment_count>1</comment_count>
    <who name="Rob Buis">rbuis</who>
    <bug_when>2024-11-05 09:01:24 -0800</bug_when>
    <thetext>navigation-history-entry/entries-after-blob-navigation.html times out.

The support for blob: seems to be good in WebKit, so it may be a problem similar to webkit.org/b/282601.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>2074528</commentid>
    <comment_count>2</comment_count>
    <who name="Radar WebKit Bug Importer">webkit-bug-importer</who>
    <bug_when>2024-11-12 09:00:17 -0800</bug_when>
    <thetext>&lt;rdar://problem/139725684&gt;</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>2079451</commentid>
    <comment_count>3</comment_count>
    <who name="Chris Dumez">cdumez</who>
    <bug_when>2024-12-05 12:41:25 -0800</bug_when>
    <thetext>The test times out because the Blob created by the test is not recognized as html so we try to download it instead of rendering it.
Updating the test to use:
```
i.src = URL.createObjectURL(new Blob([&quot;&lt;body&gt;&lt;/body&gt;&quot;], { type: &quot;text/html&quot; }));
```

instead of
```
i.src = URL.createObjectURL(new Blob([&quot;&lt;body&gt;&lt;/body&gt;&quot;]));
```

makes it run.

However, the test still fails later:
```
--- /Volumes/Work/WebKit/OpenSource/WebKitBuild/Debug/layout-test-results/imported/w3c/web-platform-tests/navigation-api/navigation-history-entry/entries-after-blob-navigation-expected.txt
+++ /Volumes/Work/WebKit/OpenSource/WebKitBuild/Debug/layout-test-results/imported/w3c/web-platform-tests/navigation-api/navigation-history-entry/entries-after-blob-navigation-actual.txt
@@ -1,6 +1,4 @@
 
 
-Harness Error (TIMEOUT), message = null
+FAIL entries() after navigation to a blob: URL assert_not_equals: got disallowed value &quot;a971b867-1f08-47e2-ab20-932e9615c1ea&quot;
 
-TIMEOUT entries() after navigation to a blob: URL Test timed out
-
```</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>2079453</commentid>
    <comment_count>4</comment_count>
    <who name="Chris Dumez">cdumez</who>
    <bug_when>2024-12-05 12:56:53 -0800</bug_when>
    <thetext>Fixing the WPT test in https://github.com/web-platform-tests/wpt/pull/49553 but we still need to investigate the TEXT failure once the timeout is addressed.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>2079487</commentid>
    <comment_count>5</comment_count>
    <who name="Chris Dumez">cdumez</who>
    <bug_when>2024-12-05 15:01:17 -0800</bug_when>
    <thetext>I did some debugging and the remaining issue is not related to blobs. The issue is that `i.src = URL.createObjectURL(new Blob([&quot;&lt;body&gt;&lt;/body&gt;&quot;], { type: &quot;text/html&quot; }));` is called synchronously inside the top frame&apos;s load event. As a result, we re-use the same HistoryItem for the navigation. If this was called inside a setTimeout(0), the test would pass.

As far as I know, it is pretty standard behavior to lock the back/forward list if the navigation is triggered from inside the load event. I have to look more into it to see if and why we differ with other browsers here.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>2079497</commentid>
    <comment_count>6</comment_count>
    <who name="Chris Dumez">cdumez</who>
    <bug_when>2024-12-05 15:48:46 -0800</bug_when>
    <thetext>I think this is the relevant spec:
https://html.spec.whatwg.org/#navigate-an-iframe-or-frame

Step 2:
&gt; If element&apos;s content navigable&apos;s active document is not completely loaded, then set historyHandling to &quot;replace&quot;.

Since we&apos;re inside the load event handler, WebKit treats the document as not completely loaded and decides to replace the HistoryItem, whereas the test expects 2 separate history items.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>2079501</commentid>
    <comment_count>7</comment_count>
    <who name="Chris Dumez">cdumez</who>
    <bug_when>2024-12-05 15:54:53 -0800</bug_when>
    <thetext>Interestingly, I think we don&apos;t match the HTML spec here. 

It says that the document is &quot;completely loaded&quot; if its &quot;completely loaded time&quot; is set.

As per https://html.spec.whatwg.org/#completely-finish-loading, the &quot;completely loaded time&quot; should get set *right before* firing the load event. I guess ideally we&apos;d match the spec. This is a large change though.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>2079512</commentid>
    <comment_count>8</comment_count>
    <who name="Chris Dumez">cdumez</who>
    <bug_when>2024-12-05 16:10:58 -0800</bug_when>
    <thetext>It is this check in `NavigationScheduler::scheduleLocationChange()` that is causing this:
```
if (lockBackForwardList == LockBackForwardList::No)
    lockBackForwardList = mustLockBackForwardList(m_frame);
```

The caller here says NOT to lock the back/forward list. However, lockBackForwardList gets overwritten here.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>2079521</commentid>
    <comment_count>9</comment_count>
    <who name="Chris Dumez">cdumez</who>
    <bug_when>2024-12-05 16:22:24 -0800</bug_when>
    <thetext>Pull request: https://github.com/WebKit/WebKit/pull/37514</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>2080201</commentid>
    <comment_count>10</comment_count>
    <who name="EWS">ews-feeder</who>
    <bug_when>2024-12-09 08:24:07 -0800</bug_when>
    <thetext>Committed 287549@main (f183cbdda713): &lt;https://commits.webkit.org/287549@main&gt;

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

    </bug>

</bugzilla>