Repository navigation
Description
What is the issue with the HTML Standard?
For the following HTML:
<!DOCTYPE html>
<meta charset="utf-8">
<title>same-URL address bar: push or replace?</title>
<dl>
<dt>Loads of this URL in this tab</dt><dd id="loads"></dd>
<dt>history.length</dt><dd id="len"></dd>
<dt>performance navigation type</dt><dd id="ptype"></dd>
<dt>navigation.activation.navigationType</dt><dd id="atype"></dd>
</dl>
<p><a id="link" href="?other">go to the “other” page</a></p>
<script>
const key = "same-url-loads:" + location.search;
sessionStorage[key] = Number(sessionStorage[key] || 0) + 1;
document.getElementById("loads").textContent = sessionStorage[key];
document.getElementById("len").textContent = history.length;
document.getElementById("ptype").textContent = performance.getEntriesByType("navigation")[0]?.type ?? "n/a";
document.getElementById("atype").textContent = window.navigation?.activation?.navigationType ?? "n/a";
if (location.search === "?other") {
const link = document.getElementById("link");
link.href = location.pathname;
link.textContent = "go back to the main page";
}
</script>When the same URL hosting the URL is reentered into the URL bar and navigated to:
- Firefox will not increase history.length, but navigation type will be a "push"
- Safari does the same as Firefox above
- Chromium will also not increase history.length and navigation type will change to "replace"
The spec matches no engine behaviour above.
Per https://html.spec.whatwg.org/#navigate, since userInvolvement is "browser UI" initiatorOriginSnapshot is an opaque origin, so step 13.1 of keeps history handling as "push" because of the origin check. But that should also result in history.length growing.
Since history handling is push but history.length is not growing in Firefox/Webkit, I think Chromium behavior is most coherent here. I think the following spec change IIUC aligns with that behaviour:
diff --git a/source b/source
index 3e75cc95..9a63c7f7 100644
--- a/source
+++ b/source
@@ -107935,10 +107935,11 @@ <h5>Beginning navigation</h5>
<ol>
<li><p>If <var>url</var> <span data-x="concept-url-equals">equals</span>
<var>navigable</var>'s <span data-x="nav-document">active document</span>'s <span
- data-x="concept-document-url">URL</span>, and <var>initiatorOriginSnapshot</var> is <span>same
- origin</span> with <var>navigable</var>'s <span data-x="nav-document">active document</span>'s
- <span data-x="concept-document-origin">origin</span>, then set <var>historyHandling</var> to
- "<code data-x="NavigationHistoryBehavior-replace">replace</code>".</p></li>
+ data-x="concept-document-url">URL</span>, and either <var>sourceDocument</var> is null or
+ <var>initiatorOriginSnapshot</var> is <span>same origin</span> with <var>navigable</var>'s <span
+ data-x="nav-document">active document</span>'s <span
+ data-x="concept-document-origin">origin</span>, then set <var>historyHandling</var> to "<code
+ data-x="NavigationHistoryBehavior-replace">replace</code>".</p></li>
<li><p>Otherwise, set <var>historyHandling</var> to "<code
data-x="NavigationHistoryBehavior-push">push</code>".</p></li>I also tried testing same URL navigation over webdriver. While webdriver integration with HTML spec needs a little work at the moment (github.com/w3c/webdriver-bidi/issues/858 - github.com/w3c/webdriver-bidi/issues/371), but under the assumption that webdriver navigations are modelled like browser UI user activation, all browsers also seem to be aligned on webdriver same URL navigations not increasing history.length either.
Does the above change sound reasonable?
Activity
annevk commentedon Aug 21, 2026
cc @beidson @farre @jakearchibald
jakearchibald commentedon Aug 21, 2026
Yeah, Chrome's behaviour seems right here. Or, at least, using "push" but not increasing the history length seems odd.
shannonbooth commentedon Aug 23, 2026
Cool, I have raised: #12824. Not sure if there is any other way of testing this than webdriver though it does show same behaviour as browser UI here.
Use replace history handling for same-URL browser UI navigations