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!) {
|
func webView(_ webView: WKWebView, didStartProvisionalNavigation navigation: WKNavigation!) {
|
||||||
loadError = nil
|
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
|
// Reset tracking this
|
||||||
tab.allowedScriptOrigins.removeAll()
|
tab.allowedScriptOrigins.removeAll()
|
||||||
tab.blockedScriptOrigins.removeAll()
|
tab.blockedScriptOrigins.removeAll()
|
||||||
|
|||||||
@@ -32,6 +32,8 @@ NS_ASSUME_NONNULL_BEGIN
|
|||||||
@property (nonatomic, assign) BOOL allowAllScripts; // default is NO
|
@property (nonatomic, assign) BOOL allowAllScripts; // default is NO
|
||||||
@property (nonatomic, assign) BOOL darkModeEnabled;
|
@property (nonatomic, assign) BOOL darkModeEnabled;
|
||||||
|
|
||||||
|
@property (nonatomic, readonly) BOOL webContentProcessConnected;
|
||||||
|
|
||||||
- (void)policyDataSourceDidChange;
|
- (void)policyDataSourceDidChange;
|
||||||
- (void)tearDown;
|
- (void)tearDown;
|
||||||
|
|
||||||
|
|||||||
@@ -105,6 +105,8 @@
|
|||||||
- (void)webProcessDidConnect
|
- (void)webProcessDidConnect
|
||||||
{
|
{
|
||||||
NSLog(@"SBRProcessBundleBridge: did connect. Saying hello, syncing allowlist");
|
NSLog(@"SBRProcessBundleBridge: did connect. Saying hello, syncing allowlist");
|
||||||
|
_webContentProcessConnected = YES;
|
||||||
|
|
||||||
[_webProcessProxy hello];
|
[_webProcessProxy hello];
|
||||||
[self policyDataSourceDidChange];
|
[self policyDataSourceDidChange];
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user