REGRESSION(234640) Loading stalls in environments without SafariSafeBrowsing framework
authorachristensen@apple.com <achristensen@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 9 Aug 2018 22:37:52 +0000 (22:37 +0000)
committerachristensen@apple.com <achristensen@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 9 Aug 2018 22:37:52 +0000 (22:37 +0000)
https://bugs.webkit.org/show_bug.cgi?id=188453
<rdar://problem/43102553>

Source/WebKit:

Reviewed by Chris Dumez.

* UIProcess/Cocoa/WebPageProxyCocoa.mm:
(WebKit::WebPageProxy::beginSafeBrowsingCheck):

Tools:

Reviewed by Chris Dumez

* TestWebKitAPI/Tests/WebKitCocoa/SafeBrowsing.mm:
(TEST):
(+[NullLookupContext sharedLookupContext]):
(TestWebKitAPI::TEST): Deleted.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@234739 268f45cc-cd09-0410-ab3c-d52691b4dbfc

Source/WebKit/ChangeLog
Source/WebKit/UIProcess/Cocoa/WebPageProxyCocoa.mm
Tools/ChangeLog
Tools/TestWebKitAPI/Tests/WebKitCocoa/SafeBrowsing.mm

index f303b13..7f3caca 100644 (file)
@@ -1,5 +1,16 @@
 2018-08-09  Alex Christensen  <achristensen@webkit.org>
 
+        REGRESSION(234640) Loading stalls in environments without SafariSafeBrowsing framework
+        https://bugs.webkit.org/show_bug.cgi?id=188453
+        <rdar://problem/43102553>
+
+        Reviewed by Chris Dumez.
+
+        * UIProcess/Cocoa/WebPageProxyCocoa.mm:
+        (WebKit::WebPageProxy::beginSafeBrowsingCheck):
+
+2018-08-09  Alex Christensen  <achristensen@webkit.org>
+
         WKURLSchemeHandler crashes when sent errors with sync XHR
         https://bugs.webkit.org/show_bug.cgi?id=188358
 
index 7705c36..847a587 100644 (file)
@@ -74,7 +74,10 @@ void WebPageProxy::loadRecentSearches(const String& name, Vector<WebCore::Recent
 void WebPageProxy::beginSafeBrowsingCheck(const URL& url, WebFramePolicyListenerProxy& listener)
 {
 #if HAVE(SAFE_BROWSING)
-    [[SSBLookupContext sharedLookupContext] lookUpURL:url completionHandler:BlockPtr<void(SSBLookupResult *, NSError *)>::fromCallable([listener = makeRef(listener)] (SSBLookupResult *result, NSError *error) mutable {
+    SSBLookupContext *context = [SSBLookupContext sharedLookupContext];
+    if (!context)
+        return listener.didReceiveSafeBrowsingResults({ });
+    [context lookUpURL:url completionHandler:BlockPtr<void(SSBLookupResult *, NSError *)>::fromCallable([listener = makeRef(listener)] (SSBLookupResult *result, NSError *error) mutable {
         RunLoop::main().dispatch([listener = WTFMove(listener), result = retainPtr(result), error = retainPtr(error)] {
             if (error) {
                 listener->didReceiveSafeBrowsingResults({ });
index 169ad6a..c1f88dd 100644 (file)
@@ -1,5 +1,18 @@
 2018-08-09  Alex Christensen  <achristensen@webkit.org>
 
+        REGRESSION(234640) Loading stalls in environments without SafariSafeBrowsing framework
+        https://bugs.webkit.org/show_bug.cgi?id=188453
+        <rdar://problem/43102553>
+
+        Reviewed by Chris Dumez
+
+        * TestWebKitAPI/Tests/WebKitCocoa/SafeBrowsing.mm:
+        (TEST):
+        (+[NullLookupContext sharedLookupContext]):
+        (TestWebKitAPI::TEST): Deleted.
+
+2018-08-09  Alex Christensen  <achristensen@webkit.org>
+
         WKURLSchemeHandler crashes when sent errors with sync XHR
         https://bugs.webkit.org/show_bug.cgi?id=188358
 
index 6387a52..20a59b8 100644 (file)
@@ -29,6 +29,7 @@
 
 #import "ClassMethodSwizzler.h"
 #import "PlatformUtilities.h"
+#import "TestWKWebView.h"
 #import <WebKit/WKNavigationDelegate.h>
 #import <WebKit/WKWebViewPrivate.h>
 #import <wtf/RetainPtr.h>
@@ -143,11 +144,9 @@ static bool done;
 
 @end
 
-namespace TestWebKitAPI {
-
 TEST(WebKit, SafeBrowsing)
 {
-    ClassMethodSwizzler swizzler(objc_getClass("SSBLookupContext"), @selector(sharedLookupContext), [TestLookupContext methodForSelector:@selector(sharedLookupContext)]);
+    TestWebKitAPI::ClassMethodSwizzler swizzler(objc_getClass("SSBLookupContext"), @selector(sharedLookupContext), [TestLookupContext methodForSelector:@selector(sharedLookupContext)]);
 
     auto navigationDelegate = adoptNS([[SafeBrowsingNavigationDelegate alloc] init]);
     auto webView = adoptNS([[WKWebView alloc] init]);
@@ -158,7 +157,21 @@ TEST(WebKit, SafeBrowsing)
 
     TestWebKitAPI::Util::run(&done);
 }
-    
-} // namespace TestWebKitAPI
+
+@interface NullLookupContext : NSObject
+@end
+@implementation NullLookupContext
++ (NullLookupContext *)sharedLookupContext
+{
+    return nil;
+}
+@end
+
+TEST(WebKit, NoSafeBrowsing)
+{
+    TestWebKitAPI::ClassMethodSwizzler swizzler(objc_getClass("SSBLookupContext"), @selector(sharedLookupContext), [NullLookupContext methodForSelector:@selector(sharedLookupContext)]);
+    auto webView = adoptNS([[TestWKWebView alloc] initWithFrame:CGRectMake(0, 0, 800, 600)]);
+    [webView synchronouslyLoadTestPageNamed:@"simple"];
+}
 
 #endif // WK_API_ENABLED