Show error if web process never connects

This commit is contained in:
James Magahern
2020-09-22 12:30:09 -07:00
parent d081a1c3f8
commit 2cdee87e8a
3 changed files with 28 additions and 0 deletions

View File

@@ -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()