Branch: refs/heads/main
Home: https://github.com/WebKit/WebKit
Commit: 27ade177851927fba50877e7ec47b8a996dfdb5d
https://github.com/WebKit/WebKit/commit/27ade177851927fba50877e7ec47b8a996dfdb5d
Author: Basuke Suzuki <[email protected]>
Date: 2026-03-15 (Sun, 15 Mar 2026)
Changed paths:
M
LayoutTests/imported/w3c/web-platform-tests/html/browsers/browsing-the-web/history-traversal/srcdoc/consecutive-srcdoc-expected.txt
M Source/WebCore/loader/FrameLoader.cpp
M Tools/TestWebKitAPI/Tests/WebKitCocoa/LoadDataWithNilMIMEType.mm
Log Message:
-----------
WKWebView loadHTMLString:baseURL: is a no-op on second call when baseURL
contains a fragment
https://bugs.webkit.org/show_bug.cgi?id=309923
rdar://168589818
Reviewed by Brady Eidson.
Calling `[WKWebView loadHTMLString:baseURL:]` (or
`loadData:MIMEType:characterEncodingName:baseURL:`)
with a baseURL containing a fragment identifier (e.g.,
`http://example.test/#test`)
works on the first call but silently fails on subsequent calls with the same
baseURL. No `WKNavigationDelegate` methods are called and the new HTML content
is never loaded.
The root cause is in `FrameLoader::loadWithDocumentLoader()`. After the first
load, the document URL becomes the baseURL (including fragment). On the second
call, `shouldPerformFragmentNavigation()` compares the current document URL
with the new URL, and since they match when ignoring fragments, it treats the
load as a same-document fragment navigation. This causes an early return that
skips loading the substitute data containing the new HTML.
The fix adds a check to skip the fragment navigation optimization when the
`DocumentLoader` carries substitute data, since substitute data always
represents
an explicit new document load regardless of URL similarity.
Updated the expected result for consecutive-srcdoc.html because this change
exposed a pre-existing issue where srcdoc content is not properly restored
during history navigation. That issue is outside the scope of this fix.
Test: Tools/TestWebKitAPI/Tests/WebKitCocoa/LoadDataWithNilMIMEType.mm
*
LayoutTests/imported/w3c/web-platform-tests/html/browsers/browsing-the-web/history-traversal/srcdoc/consecutive-srcdoc-expected.txt:
* Source/WebCore/loader/FrameLoader.cpp:
(WebCore::FrameLoader::loadWithDocumentLoader):
* Tools/TestWebKitAPI/Tests/WebKitCocoa/LoadDataWithNilMIMEType.mm:
(TEST(WebKit, LoadHTMLStringWithFragmentInBaseURL)):
Canonical link: https://commits.webkit.org/309290@main
To unsubscribe from these emails, change your notification settings at
https://github.com/WebKit/WebKit/settings/notifications