Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Be explicit when performing developer redirects #884

Merged
merged 4 commits into from
Jul 17, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 3 additions & 5 deletions Sources/Navigation/DistributedNavigationDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -308,7 +308,6 @@ extension DistributedNavigationDelegate: WKNavigationDelegate {
// MARK: Policy making

@MainActor
// swiftlint:disable:next cyclomatic_complexity
public func webView(_ webView: WKWebView, decidePolicyFor wkNavigationAction: WKNavigationAction, preferences wkPreferences: WKWebpagePreferences, decisionHandler: @escaping (WKNavigationActionPolicy, WKWebpagePreferences) -> Void) {

// new navigation or an ongoing navigation (for a server-redirect)?
Expand Down Expand Up @@ -400,10 +399,9 @@ extension DistributedNavigationDelegate: WKNavigationDelegate {
let navigator = webView.navigator(distributedNavigationDelegate: self, redirectedNavigation: mainFrameNavigation, expectedNavigations: expectedNavigationsPtr)
redirect(navigator)
}
// ignore already started Navigations (they will receive didFail)
if mainFrameNavigation?.isCurrent != true {
didCancelNavigationAction(navigationAction, withRedirectNavigations: expectedNavigations)
}
// Already started Navigations will also receive didFail
// In case navigation has not started yet, use the below callback to handle it.
didCancelNavigationAction(navigationAction, withRedirectNavigations: expectedNavigations)

case .download:
self.willStartDownload(with: navigationAction, in: webView)
Expand Down
Loading