Unreviewed, rolling out r243956.
authorcommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 8 Apr 2019 02:58:26 +0000 (02:58 +0000)
committercommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 8 Apr 2019 02:58:26 +0000 (02:58 +0000)
https://bugs.webkit.org/show_bug.cgi?id=196688

Broke API Test SafeBrowsing.WKWebViewGoBackIFrame (Requested
by aakashjain on #webkit).

Reverted changeset:

"Clicking "Go Back" from a safe browsing warning from an
iframe should navigate the WKWebView back to the previous
page"
https://bugs.webkit.org/show_bug.cgi?id=196665
https://trac.webkit.org/changeset/243956

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

Source/WebKit/ChangeLog
Source/WebKit/UIProcess/API/Cocoa/WKWebView.mm
Source/WebKit/UIProcess/Cocoa/WebViewImpl.mm
Tools/ChangeLog
Tools/TestWebKitAPI/Tests/WebKitCocoa/SafeBrowsing.mm

index d90513b..3bde10f 100644 (file)
@@ -1,3 +1,19 @@
+2019-04-07  Commit Queue  <commit-queue@webkit.org>
+
+        Unreviewed, rolling out r243956.
+        https://bugs.webkit.org/show_bug.cgi?id=196688
+
+        Broke API Test SafeBrowsing.WKWebViewGoBackIFrame (Requested
+        by aakashjain on #webkit).
+
+        Reverted changeset:
+
+        "Clicking "Go Back" from a safe browsing warning from an
+        iframe should navigate the WKWebView back to the previous
+        page"
+        https://bugs.webkit.org/show_bug.cgi?id=196665
+        https://trac.webkit.org/changeset/243956
+
 2019-04-07  Geoffrey Garen  <ggaren@apple.com>
 
         Remove stray byte added by r241131
index 9779496..d8411d3 100644 (file)
@@ -1355,19 +1355,12 @@ static _WKSelectionAttributes selectionAttributes(const WebKit::EditorState& edi
         auto strongSelf = weakSelf.get();
         if (!strongSelf)
             return;
-        bool navigatesFrame = WTF::switchOn(result,
+        bool navigatesMainFrame = WTF::switchOn(result,
             [] (WebKit::ContinueUnsafeLoad continueUnsafeLoad) { return continueUnsafeLoad == WebKit::ContinueUnsafeLoad::Yes; },
             [] (const URL&) { return true; }
         );
-        bool forMainFrameNavigation = [strongSelf->_safeBrowsingWarning forMainFrameNavigation];
-        if (navigatesFrame && forMainFrameNavigation) {
-            // The safe browsing warning will be hidden once the next page is shown.
+        if (navigatesMainFrame && [strongSelf->_safeBrowsingWarning forMainFrameNavigation])
             return;
-        }
-        if (!navigatesFrame && strongSelf->_safeBrowsingWarning && !forMainFrameNavigation) {
-            [strongSelf goBack];
-            return;
-        }
         [std::exchange(strongSelf->_safeBrowsingWarning, nullptr) removeFromSuperview];
     }]);
     [self addSubview:_safeBrowsingWarning.get()];
index 4c9014a..1bd83b7 100644 (file)
@@ -1587,19 +1587,12 @@ void WebViewImpl::showSafeBrowsingWarning(const SafeBrowsingWarning& warning, Co
         completionHandler(WTFMove(result));
         if (!weakThis)
             return;
-        bool navigatesFrame = WTF::switchOn(result,
+        bool navigatesMainFrame = WTF::switchOn(result,
             [] (ContinueUnsafeLoad continueUnsafeLoad) { return continueUnsafeLoad == ContinueUnsafeLoad::Yes; },
             [] (const URL&) { return true; }
         );
-        bool forMainFrameNavigation = [weakThis->m_safeBrowsingWarning forMainFrameNavigation];
-        if (navigatesFrame && forMainFrameNavigation) {
-            // The safe browsing warning will be hidden once the next page is shown.
+        if (navigatesMainFrame && [weakThis->m_safeBrowsingWarning forMainFrameNavigation])
             return;
-        }
-        if (!navigatesFrame && weakThis->m_safeBrowsingWarning && !forMainFrameNavigation) {
-            weakThis->m_page->goBack();
-            return;
-        }
         [std::exchange(weakThis->m_safeBrowsingWarning, nullptr) removeFromSuperview];
     }]);
     [m_view addSubview:m_safeBrowsingWarning.get()];
index 46cabe7..fd654a7 100644 (file)
@@ -1,3 +1,19 @@
+2019-04-07  Commit Queue  <commit-queue@webkit.org>
+
+        Unreviewed, rolling out r243956.
+        https://bugs.webkit.org/show_bug.cgi?id=196688
+
+        Broke API Test SafeBrowsing.WKWebViewGoBackIFrame (Requested
+        by aakashjain on #webkit).
+
+        Reverted changeset:
+
+        "Clicking "Go Back" from a safe browsing warning from an
+        iframe should navigate the WKWebView back to the previous
+        page"
+        https://bugs.webkit.org/show_bug.cgi?id=196665
+        https://trac.webkit.org/changeset/243956
+
 2019-04-06  Ryosuke Niwa  <rniwa@webkit.org>
 
         Added tests for WeakHashSet::computesEmpty and WeakHashSet::computeSize
index ad9222e..a730d0d 100644 (file)
@@ -220,15 +220,12 @@ static void checkTitleAndClick(UIButton *button, const char* expectedTitle)
 }
 #endif
 
-template<typename ViewType> void goBack(ViewType *view, bool mainFrame = true)
+template<typename ViewType> void goBack(ViewType *view)
 {
     WKWebView *webView = (WKWebView *)view.superview;
     auto box = view.subviews.firstObject;
     checkTitleAndClick(box.subviews[3], "Go Back");
-    if (mainFrame)
-        EXPECT_EQ([webView _safeBrowsingWarning], nil);
-    else
-        EXPECT_NE([webView _safeBrowsingWarning], nil);
+    EXPECT_EQ([webView _safeBrowsingWarning], nil);
 }
 
 TEST(SafeBrowsing, GoBack)
@@ -371,23 +368,21 @@ TEST(SafeBrowsing, URLObservation)
     }
 }
 
-static RetainPtr<NSString> phishingResourceName;
-
-@interface SimpleLookupContext : NSObject
+@interface Simple3LookupContext : NSObject
 @end
 
-@implementation SimpleLookupContext
+@implementation Simple3LookupContext
 
-+ (SimpleLookupContext *)sharedLookupContext
++ (Simple3LookupContext *)sharedLookupContext
 {
-    static SimpleLookupContext *context = [[SimpleLookupContext alloc] init];
+    static Simple3LookupContext *context = [[Simple3LookupContext alloc] init];
     return context;
 }
 
 - (void)lookUpURL:(NSURL *)URL completionHandler:(void (^)(TestLookupResult *, NSError *))completionHandler
 {
     BOOL phishing = NO;
-    if ([URL isEqual:resourceURL(phishingResourceName.get())])
+    if ([URL isEqual:resourceURL(@"simple3")])
         phishing = YES;
     completionHandler([TestLookupResult resultWithResults:@[[TestServiceLookupResult resultWithProvider:@"TestProvider" phishing:phishing malware:NO unwantedSoftware:NO]]], nil);
 }
@@ -410,8 +405,7 @@ static bool navigationFinished;
 
 TEST(SafeBrowsing, WKWebViewGoBack)
 {
-    phishingResourceName = @"simple3";
-    ClassMethodSwizzler swizzler(objc_getClass("SSBLookupContext"), @selector(sharedLookupContext), [SimpleLookupContext methodForSelector:@selector(sharedLookupContext)]);
+    ClassMethodSwizzler swizzler(objc_getClass("SSBLookupContext"), @selector(sharedLookupContext), [Simple3LookupContext methodForSelector:@selector(sharedLookupContext)]);
     
     auto delegate = adoptNS([WKWebViewGoBackNavigationDelegate new]);
     auto webView = adoptNS([WKWebView new]);
@@ -433,27 +427,6 @@ TEST(SafeBrowsing, WKWebViewGoBack)
     EXPECT_TRUE([[webView URL] isEqual:resourceURL(@"simple2")]);
 }
 
-TEST(SafeBrowsing, WKWebViewGoBackIFrame)
-{
-    phishingResourceName = @"simple";
-    ClassMethodSwizzler swizzler(objc_getClass("SSBLookupContext"), @selector(sharedLookupContext), [SimpleLookupContext methodForSelector:@selector(sharedLookupContext)]);
-    
-    auto delegate = adoptNS([WKWebViewGoBackNavigationDelegate new]);
-    auto webView = adoptNS([WKWebView new]);
-    [webView configuration].preferences._safeBrowsingEnabled = YES;
-    [webView setNavigationDelegate:delegate.get()];
-    [webView loadRequest:[NSURLRequest requestWithURL:resourceURL(@"simple2")]];
-    TestWebKitAPI::Util::run(&navigationFinished);
-    
-    [webView loadRequest:[NSURLRequest requestWithURL:resourceURL(@"simple-iframe")]];
-    while (![webView _safeBrowsingWarning])
-        TestWebKitAPI::Util::spinRunLoop();
-    navigationFinished = false;
-    goBack([webView _safeBrowsingWarning], false);
-    TestWebKitAPI::Util::run(&navigationFinished);
-    EXPECT_TRUE([[webView URL] isEqual:resourceURL(@"simple2")]);
-}
-
 @interface NullLookupContext : NSObject
 @end
 @implementation NullLookupContext