WebKit Bugzilla
Attachment 360067 Details for
Bug 193805
: WKWebView.goBack should reload if there is a safe browsing warning
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
New Account
|
Log In
Remember
[x]
|
Forgot Password
Login:
[x]
[patch]
Patch
bug-193805-20190124184458.patch (text/plain), 7.93 KB, created by
Alex Christensen
on 2019-01-24 18:44:59 PST
(
hide
)
Description:
Patch
Filename:
MIME Type:
Creator:
Alex Christensen
Created:
2019-01-24 18:44:59 PST
Size:
7.93 KB
patch
obsolete
>Index: Source/WebKit/ChangeLog >=================================================================== >--- Source/WebKit/ChangeLog (revision 240445) >+++ Source/WebKit/ChangeLog (working copy) >@@ -1,3 +1,27 @@ >+2019-01-24 Alex Christensen <achristensen@webkit.org> >+ >+ WKWebView.goBack should reload if there is a safe browsing warning >+ https://bugs.webkit.org/show_bug.cgi?id=193805 >+ <rdar://problem/46908216> >+ >+ Reviewed by NOBODY (OOPS!). >+ >+ If a WKWebView is showing a safe browsing warning and the user clicks a back button >+ in the app which calls WKWebView.goBack, the WKWebView is in a state where it has not navigated yet, >+ so actually going back will appear to the user to go back twice. We can't just do nothing because the >+ app is in a state where it is expecting a navigation to happen. Reloading achieves what the user expects >+ and makes the app work like the app expects. >+ >+ * UIProcess/API/C/WKPage.cpp: >+ (WKPageGoBack): >+ * UIProcess/API/Cocoa/WKWebView.mm: >+ (-[WKWebView goBack]): >+ * UIProcess/PageClient.h: >+ (WebKit::PageClient::hasSafeBrowsingWarning const): >+ * UIProcess/mac/PageClientImplMac.h: >+ * UIProcess/mac/PageClientImplMac.mm: >+ (WebKit::PageClientImpl::hasSafeBrowsingWarning const): >+ > 2019-01-24 John Wilander <wilander@apple.com> > > Add Ad Click Attribution as an internal/experimental feature >Index: Source/WebKit/UIProcess/PageClient.h >=================================================================== >--- Source/WebKit/UIProcess/PageClient.h (revision 240445) >+++ Source/WebKit/UIProcess/PageClient.h (working copy) >@@ -424,6 +424,8 @@ public: > virtual void pinnedStateWillChange() { } > virtual void pinnedStateDidChange() { } > >+ virtual bool hasSafeBrowsingWarning() const { return false; } >+ > #if PLATFORM(MAC) > virtual void didPerformImmediateActionHitTest(const WebHitTestResultData&, bool contentPreventsDefault, API::Object*) = 0; > virtual NSObject *immediateActionAnimationControllerForHitTestResult(RefPtr<API::HitTestResult>, uint64_t, RefPtr<API::Object>) = 0; >Index: Source/WebKit/UIProcess/API/C/WKPage.cpp >=================================================================== >--- Source/WebKit/UIProcess/API/C/WKPage.cpp (revision 240445) >+++ Source/WebKit/UIProcess/API/C/WKPage.cpp (working copy) >@@ -57,6 +57,7 @@ > #include "NativeWebKeyboardEvent.h" > #include "NativeWebWheelEvent.h" > #include "NavigationActionData.h" >+#include "PageClient.h" > #include "PluginInformation.h" > #include "PrintInfo.h" > #include "WKAPICast.h" >@@ -320,7 +321,12 @@ bool WKPageCanGoForward(WKPageRef pageRe > > void WKPageGoBack(WKPageRef pageRef) > { >- toImpl(pageRef)->goBack(); >+ auto& page = *toImpl(pageRef); >+ if (page.pageClient().hasSafeBrowsingWarning()) { >+ WKPageReload(pageRef); >+ return; >+ } >+ page.goBack(); > } > > bool WKPageCanGoBack(WKPageRef pageRef) >Index: Source/WebKit/UIProcess/API/Cocoa/WKWebView.mm >=================================================================== >--- Source/WebKit/UIProcess/API/Cocoa/WKWebView.mm (revision 240445) >+++ Source/WebKit/UIProcess/API/Cocoa/WKWebView.mm (working copy) >@@ -1008,6 +1008,8 @@ - (BOOL)canGoForward > > - (WKNavigation *)goBack > { >+ if (self._safeBrowsingWarning) >+ return [self reload]; > return wrapper(_page->goBack()); > } > >Index: Source/WebKit/UIProcess/mac/PageClientImplMac.h >=================================================================== >--- Source/WebKit/UIProcess/mac/PageClientImplMac.h (revision 240445) >+++ Source/WebKit/UIProcess/mac/PageClientImplMac.h (working copy) >@@ -107,6 +107,7 @@ private: > void showSafeBrowsingWarning(const SafeBrowsingWarning&, CompletionHandler<void(Variant<WebKit::ContinueUnsafeLoad, URL>&&)>&&) override; > void clearSafeBrowsingWarning() override; > void clearSafeBrowsingWarningIfForMainFrameNavigation() override; >+ bool hasSafeBrowsingWarning() const override; > > #if WK_API_ENABLED > bool showShareSheet(const WebCore::ShareDataWithParsedURL&, WTF::CompletionHandler<void(bool)>&&) override; >Index: Source/WebKit/UIProcess/mac/PageClientImplMac.mm >=================================================================== >--- Source/WebKit/UIProcess/mac/PageClientImplMac.mm (revision 240445) >+++ Source/WebKit/UIProcess/mac/PageClientImplMac.mm (working copy) >@@ -496,6 +496,13 @@ void PageClientImpl::showSafeBrowsingWar > m_impl->showSafeBrowsingWarning(warning, WTFMove(completionHandler)); > } > >+bool PageClientImpl::hasSafeBrowsingWarning() const >+{ >+ if (!m_impl) >+ return false; >+ return !!m_impl->safeBrowsingWarning(); >+} >+ > void PageClientImpl::clearSafeBrowsingWarning() > { > m_impl->clearSafeBrowsingWarning(); >Index: Tools/ChangeLog >=================================================================== >--- Tools/ChangeLog (revision 240464) >+++ Tools/ChangeLog (working copy) >@@ -1,3 +1,17 @@ >+2019-01-24 Alex Christensen <achristensen@webkit.org> >+ >+ WKWebView.goBack should reload if there is a safe browsing warning >+ https://bugs.webkit.org/show_bug.cgi?id=193805 >+ <rdar://problem/46908216> >+ >+ Reviewed by NOBODY (OOPS!). >+ >+ * TestWebKitAPI/Tests/WebKitCocoa/SafeBrowsing.mm: >+ (+[Simple3LookupContext sharedLookupContext]): >+ (-[Simple3LookupContext lookUpURL:completionHandler:]): >+ (-[WKWebViewGoBackNavigationDelegate webView:didFinishNavigation:]): >+ (TEST): >+ > 2019-01-24 Fujii Hironori <Hironori.Fujii@sony.com> > > [Win][WebKitTestRunner] Implement EventSenderProxy >Index: Tools/TestWebKitAPI/Tests/WebKitCocoa/SafeBrowsing.mm >=================================================================== >--- Tools/TestWebKitAPI/Tests/WebKitCocoa/SafeBrowsing.mm (revision 240445) >+++ Tools/TestWebKitAPI/Tests/WebKitCocoa/SafeBrowsing.mm (working copy) >@@ -355,6 +355,64 @@ TEST(SafeBrowsing, URLObservation) > } > } > >+@interface Simple3LookupContext : NSObject >+@end >+ >+@implementation Simple3LookupContext >+ >++ (Simple3LookupContext *)sharedLookupContext >+{ >+ static Simple3LookupContext *context = [[Simple3LookupContext alloc] init]; >+ return context; >+} >+ >+- (void)lookUpURL:(NSURL *)URL completionHandler:(void (^)(TestLookupResult *, NSError *))completionHandler >+{ >+ BOOL phishing = NO; >+ if ([URL isEqual:resourceURL(@"simple3")]) >+ phishing = YES; >+ completionHandler([TestLookupResult resultWithResults:@[[TestServiceLookupResult resultWithProvider:@"TestProvider" phishing:phishing malware:NO unwantedSoftware:NO]]], nil); >+} >+ >+@end >+ >+static bool navigationFinished; >+ >+@interface WKWebViewGoBackNavigationDelegate : NSObject <WKNavigationDelegate> >+@end >+ >+@implementation WKWebViewGoBackNavigationDelegate >+ >+- (void)webView:(WKWebView *)webView didFinishNavigation:(null_unspecified WKNavigation *)navigation >+{ >+ navigationFinished = true; >+} >+ >+@end >+ >+TEST(SafeBrowsing, WKWebViewGoBack) >+{ >+ ClassMethodSwizzler swizzler(objc_getClass("SSBLookupContext"), @selector(sharedLookupContext), [Simple3LookupContext methodForSelector:@selector(sharedLookupContext)]); >+ >+ auto delegate = adoptNS([WKWebViewGoBackNavigationDelegate new]); >+ auto webView = adoptNS([WKWebView new]); >+ [webView setNavigationDelegate:delegate.get()]; >+ [webView loadRequest:[NSURLRequest requestWithURL:resourceURL(@"simple")]]; >+ TestWebKitAPI::Util::run(&navigationFinished); >+ >+ navigationFinished = false; >+ [webView loadRequest:[NSURLRequest requestWithURL:resourceURL(@"simple2")]]; >+ TestWebKitAPI::Util::run(&navigationFinished); >+ >+ navigationFinished = false; >+ [webView loadRequest:[NSURLRequest requestWithURL:resourceURL(@"simple3")]]; >+ while (![webView _safeBrowsingWarning]) >+ TestWebKitAPI::Util::spinRunLoop(); >+ [webView goBack]; >+ TestWebKitAPI::Util::run(&navigationFinished); >+ EXPECT_TRUE([[webView URL] isEqual:resourceURL(@"simple2")]); >+} >+ > @interface NullLookupContext : NSObject > @end > @implementation NullLookupContext
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Flags:
ggaren
:
review+
Actions:
View
|
Formatted Diff
|
Diff
Attachments on
bug 193805
: 360067