Re-enable safe browsing in WKWebView
authorcommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 5 Jun 2019 21:24:45 +0000 (21:24 +0000)
committercommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 5 Jun 2019 21:24:45 +0000 (21:24 +0000)
https://bugs.webkit.org/show_bug.cgi?id=196161
<rdar://problem/49171413>

Patch by Alex Christensen <achristensen@webkit.org> on 2019-06-05
Reviewed by Ryosuke Niwa.

Source/WebKit:

This is mostly just reverting r241728.

* Shared/WebPreferences.yaml:
* UIProcess/API/Cocoa/WKPreferences.h:
* UIProcess/API/Cocoa/WKPreferences.mm:
(-[WKPreferences setSafeBrowsingEnabled:]):
(-[WKPreferences isSafeBrowsingEnabled]):

Tools:

* TestWebKitAPI/Tests/WebKitCocoa/ProcessSwapOnNavigation.mm:
* TestWebKitAPI/Tests/WebKitCocoa/SafeBrowsing.mm:
(TEST):
(safeBrowsingView):

LayoutTests:

* platform/mac-wk2/http/tests/navigation/keyboard-events-during-provisional-navigation-expected.txt:

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

LayoutTests/ChangeLog
LayoutTests/platform/mac-wk2/http/tests/navigation/keyboard-events-during-provisional-navigation-expected.txt
Source/WebKit/ChangeLog
Source/WebKit/Shared/WebPreferences.yaml
Source/WebKit/UIProcess/API/Cocoa/WKPreferences.h
Source/WebKit/UIProcess/API/Cocoa/WKPreferences.mm
Tools/ChangeLog
Tools/TestWebKitAPI/Tests/WebKitCocoa/ProcessSwapOnNavigation.mm
Tools/TestWebKitAPI/Tests/WebKitCocoa/SafeBrowsing.mm

index e8d0993..d8b7ac7 100644 (file)
@@ -1 +1,11 @@
+2019-06-05  Alex Christensen  <achristensen@webkit.org>
+
+        Re-enable safe browsing in WKWebView
+        https://bugs.webkit.org/show_bug.cgi?id=196161
+        <rdar://problem/49171413>
+
+        Reviewed by Ryosuke Niwa.
+
+        * platform/mac-wk2/http/tests/navigation/keyboard-events-during-provisional-navigation-expected.txt:
+
 == Rolled over to ChangeLog-2019-06-05 ==
index bf62ccd..f256843 100644 (file)
@@ -10,6 +10,8 @@ CONSOLE MESSAGE: line 52: Inserting text "c".
 CONSOLE MESSAGE: line 55: Pasting text "d".
 CONSOLE MESSAGE: line 58: Input element value after text input events: "".
 CONSOLE MESSAGE: line 20: Pressing "z" with access key modifiers should navigate to resources/keyboard-events-after-navigation.html.
+CONSOLE MESSAGE: line 18: keydownevent dispatched (isTrusted: true).
+CONSOLE MESSAGE: line 18: keyupevent dispatched (isTrusted: true).
 CONSOLE MESSAGE: line 6: Finished navigating to resources/keyboard-events-after-navigation.html.
 CONSOLE MESSAGE: line 7: Trusted events should be logged and the input element should have the value "acd".
 CONSOLE MESSAGE: line 34: Dispatching untrusted keypress event.
index 97c2eab..9359981 100644 (file)
@@ -1,5 +1,21 @@
 2019-06-05  Alex Christensen  <achristensen@webkit.org>
 
+        Re-enable safe browsing in WKWebView
+        https://bugs.webkit.org/show_bug.cgi?id=196161
+        <rdar://problem/49171413>
+
+        Reviewed by Ryosuke Niwa.
+
+        This is mostly just reverting r241728.
+
+        * Shared/WebPreferences.yaml:
+        * UIProcess/API/Cocoa/WKPreferences.h:
+        * UIProcess/API/Cocoa/WKPreferences.mm:
+        (-[WKPreferences setSafeBrowsingEnabled:]):
+        (-[WKPreferences isSafeBrowsingEnabled]):
+
+2019-06-05  Alex Christensen  <achristensen@webkit.org>
+
         Progress towards resurrecting Mac CMake build
         https://bugs.webkit.org/show_bug.cgi?id=197132
 
index 75436a8..5ec408b 100644 (file)
@@ -82,7 +82,7 @@ XSSAuditorEnabled:
 
 SafeBrowsingEnabled:
   type: bool
-  defaultValue: false
+  defaultValue: true
   webcoreBinding: none
 
 PrivateBrowsingEnabled:
index 640940a..d9e7ae7 100644 (file)
@@ -51,6 +51,13 @@ WK_CLASS_AVAILABLE(macos(10.10), ios(8.0))
  */
 @property (nonatomic) BOOL javaScriptCanOpenWindowsAutomatically;
 
+/*! @abstract A Boolean value indicating whether warnings should be
+ shown for suspected fraudulent content such as phishing or malware.
+ @discussion The default value is YES. This feature is currently available
+ in the following region: China.
+ */
+@property (nonatomic, getter=isFraudulentWebsiteWarningEnabled) BOOL fraudulentWebsiteWarningEnabled WK_API_AVAILABLE(macos(WK_MAC_TBA), ios(WK_IOS_TBA));
+
 #if !TARGET_OS_IPHONE
 /*!
  @property tabFocusesLinks
index df0b002..e06f47e 100644 (file)
@@ -122,6 +122,16 @@ ALLOW_DEPRECATED_DECLARATIONS_END
     _preferences->setJavaScriptEnabled(javaScriptEnabled);
 }
 
+- (void)setFraudulentWebsiteWarningEnabled:(BOOL)enabled
+{
+    _preferences->setSafeBrowsingEnabled(enabled);
+}
+
+- (BOOL)isFraudulentWebsiteWarningEnabled
+{
+    return _preferences->safeBrowsingEnabled();
+}
+
 - (BOOL)javaScriptCanOpenWindowsAutomatically
 {
     return _preferences->javaScriptCanOpenWindowsAutomatically();
index e8d0993..112b0eb 100644 (file)
@@ -1 +1,14 @@
+2019-06-05  Alex Christensen  <achristensen@webkit.org>
+
+        Re-enable safe browsing in WKWebView
+        https://bugs.webkit.org/show_bug.cgi?id=196161
+        <rdar://problem/49171413>
+
+        Reviewed by Ryosuke Niwa.
+
+        * TestWebKitAPI/Tests/WebKitCocoa/ProcessSwapOnNavigation.mm:
+        * TestWebKitAPI/Tests/WebKitCocoa/SafeBrowsing.mm:
+        (TEST):
+        (safeBrowsingView):
+
 == Rolled over to ChangeLog-2019-06-05 ==
index e4c1809..8004c82 100644 (file)
@@ -606,7 +606,7 @@ TEST(ProcessSwap, KillWebContentProcessAfterServerRedirectPolicyDecision)
     auto navigationDelegate = adoptNS([[PSONNavigationDelegate alloc] init]);
     [webView setNavigationDelegate:navigationDelegate.get()];
 
-    [webView configuration].preferences._safeBrowsingEnabled = NO;
+    [webView configuration].preferences.fraudulentWebsiteWarningEnabled = NO;
 
     NSURLRequest *request = [NSURLRequest requestWithURL:[NSURL URLWithString:@"pson://www.webkit.org/main1.html"]];
     [webView loadRequest:request];
@@ -1696,7 +1696,7 @@ TEST(ProcessSwap, TerminateProcessRightAfterSwap)
     auto delegate = adoptNS([[PSONNavigationDelegate alloc] init]);
     [webView setNavigationDelegate:delegate.get()];
 
-    [webView configuration].preferences._safeBrowsingEnabled = NO;
+    [webView configuration].preferences.fraudulentWebsiteWarningEnabled = NO;
 
     NSURLRequest *request = [NSURLRequest requestWithURL:[NSURL URLWithString:@"pson://www.webkit.org/main.html"]];
     [webView loadRequest:request];
@@ -2245,7 +2245,7 @@ static void runQuickBackForwardNavigationTest(ShouldEnablePSON shouldEnablePSON)
     auto delegate = adoptNS([[PSONNavigationDelegate alloc] init]);
     [webView setNavigationDelegate:delegate.get()];
 
-    [webView configuration].preferences._safeBrowsingEnabled = NO;
+    [webView configuration].preferences.fraudulentWebsiteWarningEnabled = NO;
 
     NSURLRequest *request = [NSURLRequest requestWithURL:[NSURL URLWithString:@"pson://www.webkit.org/main1.html"]];
     [webView loadRequest:request];
@@ -3046,7 +3046,7 @@ TEST(ProcessSwap, NavigateCrossSiteBeforePageLoadEnd)
     auto delegate = adoptNS([[PSONNavigationDelegate alloc] init]);
     [webView setNavigationDelegate:delegate.get()];
 
-    [webView configuration].preferences._safeBrowsingEnabled = NO;
+    [webView configuration].preferences.fraudulentWebsiteWarningEnabled = NO;
 
     failed = false;
     NSURLRequest *request = [NSURLRequest requestWithURL:[NSURL URLWithString:@"pson://www.webkit.org/main.html"]];
@@ -3074,7 +3074,7 @@ TEST(ProcessSwap, DoSameSiteNavigationAfterCrossSiteProvisionalLoadStarted)
     auto delegate = adoptNS([[PSONNavigationDelegate alloc] init]);
     [webView setNavigationDelegate:delegate.get()];
 
-    [webView configuration].preferences._safeBrowsingEnabled = NO;
+    [webView configuration].preferences.fraudulentWebsiteWarningEnabled = NO;
 
     NSURLRequest *request = [NSURLRequest requestWithURL:[NSURL URLWithString:@"pson://www.webkit.org/main1.html"]];
     [webView loadRequest:request];
@@ -4453,7 +4453,7 @@ TEST(ProcessSwap, ClosePageAfterCrossSiteProvisionalLoad)
     auto navigationDelegate = adoptNS([[PSONNavigationDelegate alloc] init]);
     [webView setNavigationDelegate:navigationDelegate.get()];
 
-    [webView configuration].preferences._safeBrowsingEnabled = NO;
+    [webView configuration].preferences.fraudulentWebsiteWarningEnabled = NO;
 
     [webView loadRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:@"pson://www.webkit.org/main.html"]]];
     TestWebKitAPI::Util::run(&done);
@@ -4511,7 +4511,7 @@ TEST(ProcessSwap, LoadingStateAfterPolicyDecision)
     auto navigationDelegate = adoptNS([[PSONNavigationDelegate alloc] init]);
     [webView setNavigationDelegate:navigationDelegate.get()];
 
-    [webView configuration].preferences._safeBrowsingEnabled = NO;
+    [webView configuration].preferences.fraudulentWebsiteWarningEnabled = NO;
 
     [webView loadRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:@"pson://www.webkit.org/main.html"]]];
     TestWebKitAPI::Util::run(&done);
index 7315f49..017c84a 100644 (file)
@@ -170,17 +170,17 @@ TEST(SafeBrowsing, Preference)
     };
 
     auto webView = adoptNS([WKWebView new]);
-    EXPECT_FALSE([webView configuration].preferences._safeBrowsingEnabled);
-    [webView configuration].preferences._safeBrowsingEnabled = YES;
+    EXPECT_TRUE([webView configuration].preferences.fraudulentWebsiteWarningEnabled);
+    [webView configuration].preferences.fraudulentWebsiteWarningEnabled = YES;
     [webView setNavigationDelegate:delegate.get()];
-    [webView configuration].preferences._safeBrowsingEnabled = YES;
+    [webView configuration].preferences.fraudulentWebsiteWarningEnabled = YES;
     [webView loadRequest:[NSURLRequest requestWithURL:resourceURL(@"simple")]];
     while (![webView _safeBrowsingWarning])
         TestWebKitAPI::Util::spinRunLoop();
-    [webView configuration].preferences._safeBrowsingEnabled = NO;
+    [webView configuration].preferences.fraudulentWebsiteWarningEnabled = NO;
     [webView loadRequest:[NSURLRequest requestWithURL:resourceURL(@"simple2")]];
     TestWebKitAPI::Util::run(&done);
-    EXPECT_FALSE([webView configuration].preferences._safeBrowsingEnabled);
+    EXPECT_FALSE([webView configuration].preferences.fraudulentWebsiteWarningEnabled);
     EXPECT_FALSE([webView _safeBrowsingWarning]);
 }
 
@@ -190,7 +190,7 @@ static RetainPtr<WKWebView> safeBrowsingView()
 
     static auto delegate = adoptNS([SafeBrowsingNavigationDelegate new]);
     auto webView = adoptNS([WKWebView new]);
-    [webView configuration].preferences._safeBrowsingEnabled = YES;
+    [webView configuration].preferences.fraudulentWebsiteWarningEnabled = YES;
     [webView setNavigationDelegate:delegate.get()];
     [webView setUIDelegate:delegate.get()];
     [webView loadRequest:[NSURLRequest requestWithURL:resourceURL(@"simple")]];
@@ -319,7 +319,7 @@ TEST(SafeBrowsing, URLObservation)
 
     auto webViewWithWarning = [&] () -> RetainPtr<WKWebView> {
         auto webView = adoptNS([WKWebView new]);
-        [webView configuration].preferences._safeBrowsingEnabled = YES;
+        [webView configuration].preferences.fraudulentWebsiteWarningEnabled = YES;
         [webView addObserver:observer.get() forKeyPath:@"URL" options:NSKeyValueObservingOptionNew context:nil];
 
         [webView loadHTMLString:@"meaningful content to be drawn" baseURL:simpleURL.get()];
@@ -415,7 +415,7 @@ TEST(SafeBrowsing, WKWebViewGoBack)
     
     auto delegate = adoptNS([WKWebViewGoBackNavigationDelegate new]);
     auto webView = adoptNS([WKWebView new]);
-    [webView configuration].preferences._safeBrowsingEnabled = YES;
+    [webView configuration].preferences.fraudulentWebsiteWarningEnabled = YES;
     [webView setNavigationDelegate:delegate.get()];
     [webView loadRequest:[NSURLRequest requestWithURL:resourceURL(@"simple")]];
     TestWebKitAPI::Util::run(&navigationFinished);