Branch: refs/heads/main
  Home:   https://github.com/WebKit/WebKit
  Commit: d56ef888827c41123460b958d32e1a135a81cd3f
      
https://github.com/WebKit/WebKit/commit/d56ef888827c41123460b958d32e1a135a81cd3f
  Author: Chris Dumez <[email protected]>
  Date:   2026-03-24 (Tue, 24 Mar 2026)

  Changed paths:
    M 
LayoutTests/imported/w3c/web-platform-tests/navigation-api/navigate-event/navigate-anchor-same-url-expected.txt
    M Source/WebCore/html/HTMLAnchorElement.cpp
    M Source/WebCore/loader/FrameLoader.cpp

  Log Message:
  -----------
  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
rdar://169999046

Reviewed by Basuke Suzuki and Rupin Mittal.

When clicking an <a> element whose href matches the current document URL,
NavigateEvent.navigationType should be "replace" per the spec's
"navigate-convert-to-replace" step [1]. WebKit was returning "push" due
to two issues:

1. HTMLAnchorElement::handleClick() hardcoded NavigationHistoryBehavior::Push,
   bypassing the auto-resolution logic in FrameLoader that detects same-URL
   navigations and converts them to Replace.

2. The auto-resolution logic in FrameLoader also checked
   `document->readyState() != Complete`, which is unrelated to the spec's
   navigate-convert-to-replace step and is already handled at the call sites
   (e.g. Location.cpp).

Fix by changing HTMLAnchorElement to pass NavigationHistoryBehavior::Auto, and
simplifying the FrameLoader auto-resolution to match the spec: only convert
Auto to Replace when the URL equals the document URL and origins match.

[1] 
https://html.spec.whatwg.org/multipage/browsing-the-web.html#navigate-convert-to-replace

No new tests, covered by the following rebaselined test:
- 
imported/w3c/web-platform-tests/navigation-api/navigate-event/navigate-anchor-same-url.html

* 
LayoutTests/imported/w3c/web-platform-tests/navigation-api/navigate-event/navigate-anchor-same-url-expected.txt:
* Source/WebCore/html/HTMLAnchorElement.cpp:
(WebCore::HTMLAnchorElement::handleClick):
* Source/WebCore/loader/FrameLoader.cpp:
(WebCore::FrameLoader::loadURL):

Canonical link: https://commits.webkit.org/309871@main



To unsubscribe from these emails, change your notification settings at 
https://github.com/WebKit/WebKit/settings/notifications

Reply via email to