Show error if web process never connects
This commit is contained in:
@@ -282,6 +282,30 @@ class BrowserViewController: UIViewController, WKNavigationDelegate, WKUIDelegat
|
||||
func webView(_ webView: WKWebView, didStartProvisionalNavigation navigation: WKNavigation!) {
|
||||
loadError = nil
|
||||
|
||||
// Check to make sure we have connected to the web content process
|
||||
if !tab.bridge.webContentProcessConnected {
|
||||
// This means we started loading a page but the web content process hasn't loaded, which means
|
||||
// scripts are not getting blocked.
|
||||
|
||||
// If you're ad-hoc signing this, you'll need to disable library validation:
|
||||
// sudo defaults write /Library/Preferences/com.apple.security.libraryvalidation DisableLibraryValidation -bool YES
|
||||
|
||||
DispatchQueue.main.async { [unowned self] in
|
||||
// Stop loading now
|
||||
webView.stopLoading()
|
||||
|
||||
// Show an alert
|
||||
let alert = UIAlertController(title: "Web Process Not Loaded",
|
||||
message: "The web content process never contacted the host application",
|
||||
preferredStyle: .alert)
|
||||
alert.addAction(UIAlertAction(title: "OK", style: .default, handler: { _ in
|
||||
alert.dismiss(animated: true, completion: nil)
|
||||
}))
|
||||
|
||||
present(alert, animated: true, completion: nil)
|
||||
}
|
||||
}
|
||||
|
||||
// Reset tracking this
|
||||
tab.allowedScriptOrigins.removeAll()
|
||||
tab.blockedScriptOrigins.removeAll()
|
||||
|
||||
Reference in New Issue
Block a user