Skip to content

Commit

Permalink
Revert "Bugfix FXIOS-10214 Fix Javascript alert callback" (#22640)
Browse files Browse the repository at this point in the history
Revert "Bugfix FXIOS-10214 Fix Javascript alert callback (#22392)"

This reverts commit 88a299d.
  • Loading branch information
OrlaM authored Oct 18, 2024
1 parent 00c05a5 commit 7c4c7f4
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 10 deletions.
5 changes: 1 addition & 4 deletions firefox-ios/Client/Frontend/Browser/BrowserPrompts.swift
Original file line number Diff line number Diff line change
Expand Up @@ -40,16 +40,13 @@ protocol JSAlertInfo {
struct MessageAlert: JSAlertInfo {
let message: String
let frame: WKFrameInfo
let completionHandler: (() -> Void)?

func alertController() -> JSPromptAlertController {
let alertController = JSPromptAlertController(
title: titleForJavaScriptPanelInitiatedByFrame(frame),
message: message,
preferredStyle: .alert)
alertController.addAction(UIAlertAction(title: .OKString, style: .default) { _ in
completionHandler?()
})
alertController.addAction(UIAlertAction(title: .OKString, style: .default))
alertController.alertInfo = self
return alertController
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,14 +57,14 @@ extension BrowserViewController: WKUIDelegate {
initiatedByFrame frame: WKFrameInfo,
completionHandler: @escaping () -> Void
) {
let messageAlert = MessageAlert(message: message, frame: frame, completionHandler: {
completionHandler()
self.logger.log("Javascript message alert was completed.", level: .info, category: .webview)
})
let messageAlert = MessageAlert(message: message, frame: frame)
if shouldDisplayJSAlertForWebView(webView) {
logger.log("Javascript message alert will be presented.", level: .info, category: .webview)

present(messageAlert.alertController(), animated: true)
present(messageAlert.alertController(), animated: true) {
completionHandler()
self.logger.log("Javascript message alert was completed.", level: .info, category: .webview)
}
} else if let promptingTab = tabManager[webView] {
logger.log("Javascript message alert is queued.", level: .info, category: .webview)

Expand Down Expand Up @@ -964,7 +964,7 @@ private extension BrowserViewController {

func shouldDisplayJSAlertForWebView(_ webView: WKWebView) -> Bool {
// Only display a JS Alert if we are selected and there isn't anything being shown
return (tabManager.selectedTab == nil ? false : tabManager.selectedTab!.webView == webView)
return ((tabManager.selectedTab == nil ? false : tabManager.selectedTab!.webView == webView))
&& (self.presentedViewController == nil)
}

Expand Down

0 comments on commit 7c4c7f4

Please sign in to comment.