Skip to content
This repository has been archived by the owner on May 10, 2024. It is now read-only.

Commit

Permalink
Block synthetic clicks. Also do not allow the error alert to show abo…
Browse files Browse the repository at this point in the history
…ve the suppression alert in Z-Order.
  • Loading branch information
Brandon-T committed Nov 29, 2023
1 parent e069a88 commit ca17b89
Showing 1 changed file with 8 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -420,10 +420,16 @@ extension BrowserViewController: WKNavigationDelegate {
// Do not allow opening external URLs from child tabs
return await withCheckedContinuation { continuation in
handleExternalURL(requestURL, tab: tab, navigationAction: navigationAction) { [weak tab] shouldOpen in

let isSyntheticClick = navigationAction.responds(to: Selector(("_syntheticClickType"))) && navigationAction.value(forKey: "syntheticClickType") as? Int == 0

// Do not show error message for JS navigated links or redirect
// as it's not the result of a user action.
if !shouldOpen, navigationAction.navigationType == .linkActivated {
if self.presentedViewController == nil && tab?.isExternalAppAlertPresented == false && tab?.isExternalAppAlertSuppressed == false {
if !shouldOpen, navigationAction.navigationType == .linkActivated && !isSyntheticClick {
if self.presentedViewController == nil &&
self.presentingViewController == nil &&
tab?.isExternalAppAlertPresented == false &&
tab?.isExternalAppAlertSuppressed == false {
let alert = UIAlertController(title: Strings.unableToOpenURLErrorTitle, message: Strings.unableToOpenURLError, preferredStyle: .alert)
alert.addAction(UIAlertAction(title: Strings.OKString, style: .default, handler: nil))
self.present(alert, animated: true) {
Expand Down

0 comments on commit ca17b89

Please sign in to comment.