Bug 187523 - WKWebView.backForwardList.currentItem is incorrect after canceled back/forward navigation
Summary: WKWebView.backForwardList.currentItem is incorrect after canceled back/forwar...
Status: RESOLVED WORKSFORME
Alias: None
Product: WebKit
Classification: Unclassified
Component: Page Loading (show other bugs)
Version: Safari 11
Hardware: iPhone / iPad iOS 11
: P2 Normal
Assignee: Nobody
URL:
Keywords: InRadar
Depends on:
Blocks:
 
Reported: 2018-07-10 09:10 PDT by Danyao Wang
Modified: 2022-02-13 22:08 PST (History)
5 users (show)

See Also:


Attachments
Minimal example to reproduce the bug (71.11 KB, application/zip)
2018-07-10 09:10 PDT, Danyao Wang
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Danyao Wang 2018-07-10 09:10:33 PDT
Created attachment 344701 [details]
Minimal example to reproduce the bug

For back/forward navigation, WebKit's URL and history state are updated before the |webView:decidePolicyForNavigationAction| callback. If the embedder returns WKNavigationActionPolicyCancel, only the URL change is undone, but not the WKWebView.backForwardList.currentItem change.

Steps to reproduce:
1. Navigate to a URL in WKWebView, e.g. https://wikipedia.org
2. Navigate to a second URL: e.g. https://apple.com
3. Go back
4. In |webView:decidePolicyForNavigationAction|, return WKNavigationActionPolicyCancel
5. Observe WKWebView.URL and WKWebView.backForwardList.currentItem.URL in URL KVO

Expected result: both WKWebView.URL and WKWebView.backForwardList.currentItem.URL are https://apple.com
Observed result: WKWebView.URL is https://apple.com. WKWebView.backForwardList.currentItem.URL is https://wikipedia.org.

The attached WKWebView project runs through the above states and logs the URLs to debug log.

The history state is corrected after starting a new navigation. So this may be a discrepancy between the WebProcess and UIProcess.
Comment 1 Ali Juma 2018-07-10 09:46:32 PDT
In reply to Danyao Wang from comment #0)
> So this may be a discrepancy between the WebProcess and UIProcess.

FrameLoader::continueLoadAfterNavigationPolicy has logic (in the !canContinue case) to reset back/forward state. Perhaps something is going wrong with sending that change to the UIProcess.
Comment 2 Radar WebKit Bug Importer 2018-07-10 11:19:30 PDT
<rdar://problem/42032341>
Comment 3 Brent Fulgham 2022-02-13 22:08:02 PST
This bug doesn't seem actionable.