WebKit Bugzilla
New
Browse
Search+
Log In
×
Sign in with GitHub
or
Remember my login
Create Account
·
Forgot Password
Forgotten password account recovery
RESOLVED FIXED
306802
NavigateEvent#navigationType should be "replace" when navigating to a URL that matches the active document's URL
https://bugs.webkit.org/show_bug.cgi?id=306802
Summary
NavigateEvent#navigationType should be "replace" when navigating to a URL tha...
Dom Christie
Reported
2026-02-02 13:59:18 PST
In section 7.4.2.2, the [spec](
https://html.spec.whatwg.org/multipage/browsing-the-web.html#navigate-convert-to-replace
) states:
> If url equals navigable's active document's URL, and initiatorOriginSnapshot is same origin with navigable's active document's origin, then set historyHandling to "replace".
When tapping a link to a url that matches the current location, the NavigateEvent#navigationType property is "push" rather than "replace". This differs to the Chrome and Firefox implementation, which returns "replace".
Attachments
rendering in safari, firefox, chrome
(269.21 KB, image/png)
2026-02-02 19:40 PST
,
Karl Dubost
no flags
Details
testcase
(2.70 KB, text/html)
2026-02-02 19:41 PST
,
Karl Dubost
no flags
Details
View All
Add attachment
proposed patch, testcase, etc.
Karl Dubost
Comment 1
2026-02-02 19:40:37 PST
Created
attachment 478220
[details]
rendering in safari, firefox, chrome Confirmed.
Karl Dubost
Comment 2
2026-02-02 19:41:22 PST
Created
attachment 478221
[details]
testcase PASS Firefox/Chrome FAIL Safari (STP235)
Karl Dubost
Comment 3
2026-02-02 22:27:58 PST
The spec says:
https://url.spec.whatwg.org/#concept-url-equals
============= 4.6. URL equivalence To determine whether a URL A equals URL B, with an optional boolean exclude fragments (default false), run these steps: 1. Let serializedA be the result of serializing A, with exclude fragment set to exclude fragments. 2. Let serializedB be the result of serializing B, with exclude fragment set to exclude fragments. 3. Return true if serializedA is serializedB; otherwise false. ============= which means that foo.html#blah should be equivalent to foo.html and vice versa. So when we go back to the spec, it says:
https://html.spec.whatwg.org/multipage/browsing-the-web.html#navigate-convert-to-replace
============== 12. If historyHandling is "auto", then: 1. If url equals navigable's active document's URL, and initiatorOriginSnapshot is same origin with navigable's active document's origin, then set historyHandling to "replace". 2. Otherwise, set historyHandling to "push". ============== The current code is:
https://searchfox.org/wubkat/rev/efbda44f77fdac3adc639a9427ab93943f2b17b9/Source/WebCore/loader/FrameLoader.cpp#1613-1623
```cpp bool isSameOrigin = frameLoadRequest.protectedRequesterSecurityOrigin()->isSameOriginDomain(document->protectedSecurityOrigin().get()); if (!isReload(newLoadType)) { if (historyHandling == NavigationHistoryBehavior::Auto) { if ((document->url() == newURL || document->readyState() != Document::ReadyState::Complete) && isSameOrigin) historyHandling = NavigationHistoryBehavior::Replace; else historyHandling = NavigationHistoryBehavior::Push; } if (newURL.protocolIsJavaScript() || (documentLoader() && documentLoader()->isInitialAboutBlank())) historyHandling = NavigationHistoryBehavior::Replace; } ``` are document->url() and newURL comparing the same URLs? For example, this should be equal? document.url() "
https://example.com/page#section1
" newURL "
https://example.com/page
" What about the opposite? This is covered by
https://wpt.fyi/results/navigation-api/navigate-event/navigate-anchor-same-url.html
Karl Dubost
Comment 4
2026-02-02 22:29:32 PST
The test
http://wpt.live/navigation-api/navigate-event/navigate-anchor-same-url.html
seems to be looping in STP 235.
Radar WebKit Bug Importer
Comment 5
2026-02-09 14:00:13 PST
<
rdar://problem/169999046
>
Chris Dumez
Comment 6
2026-03-23 22:10:52 PDT
Pull request:
https://github.com/WebKit/WebKit/pull/61221
EWS
Comment 7
2026-03-24 15:51:35 PDT
Committed
309871@main
(d56ef888827c): <
https://commits.webkit.org/309871@main
> Reviewed commits have been landed. Closing PR #61221 and removing active labels.
Note
You need to
log in
before you can comment on or make changes to this bug.
Top of Page
Format For Printing
XML
Clone This Bug