Fix same-url navigate

Same-URL navigate should always cause a reload. The code that currently prevents
a navigate on fragment change is too loose and treats identical URLs as being
a fragment change..but for it to be considered a fragment change, the fragment
actually has to change.

This improves some WPT compat where tests do:

<iframe></iframe>  <--- loads "about:blank"

<script>
document.querySelector('iframe').src = "about:blank"; <--- should load it again
</script>
This commit is contained in:
Karl Seguin
2026-04-27 09:27:30 +08:00
parent e1e9a0d78c
commit a2f21ff463
2 changed files with 17 additions and 2 deletions

View File

@@ -720,7 +720,10 @@ fn scheduleNavigationWithArena(originator: *Frame, arena: Allocator, request_url
};
const session = target._session;
if (!opts.force and URL.eqlDocument(target.url, resolved_url)) {
// Short-circuit only true fragment-only navigations (same path/query, different
// fragment). Identical URLs fall through and trigger a real reload.
const is_fragment_navigation = !std.mem.eql(u8, target.url, resolved_url) and URL.eqlDocument(target.url, resolved_url);
if (!opts.force and is_fragment_navigation) {
target.url = try target.arena.dupeZ(u8, resolved_url);
target.window._location = try Location.init(target.url, target);
if (target.parent == null) {

View File

@@ -151,8 +151,20 @@
}
</script>
<iframe id=f7></iframe>
<script id=onloadorder type=module>
{
const state = await testing.async();
$('#f7').onload = state.resolve;
$('#f7').src = "about:blank";
await state.done(() => {
testing.expectEqual(true, true);
});
}
</script>
<script id=count>
testing.onload(() => {
testing.expectEqual(9, window.length);
testing.expectEqual(10, window.length);
});
</script>