Changeset 240490 in webkit
- Timestamp:
- Jan 25, 2019, 11:42:27 AM (6 years ago)
- Location:
- trunk
- Files:
-
- 8 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebKit/ChangeLog
r240485 r240490 1 2019-01-25 Alex Christensen <achristensen@webkit.org> 2 3 WKWebView.goBack should reload if there is a safe browsing warning 4 https://bugs.webkit.org/show_bug.cgi?id=193805 5 <rdar://problem/46908216> 6 7 Reviewed by Geoff Garen. 8 9 If a WKWebView is showing a safe browsing warning and the user clicks a back button 10 in the app which calls WKWebView.goBack, the WKWebView is in a state where it has not navigated yet, 11 so actually going back will appear to the user to go back twice. We can't just do nothing because the 12 app is in a state where it is expecting a navigation to happen. Reloading achieves what the user expects 13 and makes the app work like the app expects. 14 15 * UIProcess/API/C/WKPage.cpp: 16 (WKPageGoBack): 17 * UIProcess/API/Cocoa/WKWebView.mm: 18 (-[WKWebView goBack]): 19 * UIProcess/PageClient.h: 20 (WebKit::PageClient::hasSafeBrowsingWarning const): 21 * UIProcess/mac/PageClientImplMac.h: 22 * UIProcess/mac/PageClientImplMac.mm: 23 (WebKit::PageClientImpl::hasSafeBrowsingWarning const): 24 1 25 2019-01-25 Chris Dumez <cdumez@apple.com> 2 26 -
trunk/Source/WebKit/UIProcess/API/C/WKPage.cpp
r240100 r240490 58 58 #include "NativeWebWheelEvent.h" 59 59 #include "NavigationActionData.h" 60 #include "PageClient.h" 60 61 #include "PluginInformation.h" 61 62 #include "PrintInfo.h" … … 321 322 void WKPageGoBack(WKPageRef pageRef) 322 323 { 323 toImpl(pageRef)->goBack(); 324 auto& page = *toImpl(pageRef); 325 if (page.pageClient().hasSafeBrowsingWarning()) { 326 WKPageReload(pageRef); 327 return; 328 } 329 page.goBack(); 324 330 } 325 331 -
trunk/Source/WebKit/UIProcess/API/Cocoa/WKWebView.mm
r240466 r240490 1009 1009 - (WKNavigation *)goBack 1010 1010 { 1011 if (self._safeBrowsingWarning) 1012 return [self reload]; 1011 1013 return wrapper(_page->goBack()); 1012 1014 } -
trunk/Source/WebKit/UIProcess/PageClient.h
r240199 r240490 425 425 virtual void pinnedStateDidChange() { } 426 426 427 virtual bool hasSafeBrowsingWarning() const { return false; } 428 427 429 #if PLATFORM(MAC) 428 430 virtual void didPerformImmediateActionHitTest(const WebHitTestResultData&, bool contentPreventsDefault, API::Object*) = 0; -
trunk/Source/WebKit/UIProcess/mac/PageClientImplMac.h
r240046 r240490 108 108 void clearSafeBrowsingWarning() override; 109 109 void clearSafeBrowsingWarningIfForMainFrameNavigation() override; 110 bool hasSafeBrowsingWarning() const override; 110 111 111 112 #if WK_API_ENABLED -
trunk/Source/WebKit/UIProcess/mac/PageClientImplMac.mm
r240046 r240490 497 497 } 498 498 499 bool PageClientImpl::hasSafeBrowsingWarning() const 500 { 501 if (!m_impl) 502 return false; 503 return !!m_impl->safeBrowsingWarning(); 504 } 505 499 506 void PageClientImpl::clearSafeBrowsingWarning() 500 507 { -
trunk/Tools/ChangeLog
r240485 r240490 1 2019-01-25 Alex Christensen <achristensen@webkit.org> 2 3 WKWebView.goBack should reload if there is a safe browsing warning 4 https://bugs.webkit.org/show_bug.cgi?id=193805 5 <rdar://problem/46908216> 6 7 Reviewed by Geoff Garen. 8 9 * TestWebKitAPI/Tests/WebKitCocoa/SafeBrowsing.mm: 10 (+[Simple3LookupContext sharedLookupContext]): 11 (-[Simple3LookupContext lookUpURL:completionHandler:]): 12 (-[WKWebViewGoBackNavigationDelegate webView:didFinishNavigation:]): 13 (TEST): 14 1 15 2019-01-25 Chris Dumez <cdumez@apple.com> 2 16 -
trunk/Tools/TestWebKitAPI/Tests/WebKitCocoa/SafeBrowsing.mm
r239408 r240490 356 356 } 357 357 358 @interface Simple3LookupContext : NSObject 359 @end 360 361 @implementation Simple3LookupContext 362 363 + (Simple3LookupContext *)sharedLookupContext 364 { 365 static Simple3LookupContext *context = [[Simple3LookupContext alloc] init]; 366 return context; 367 } 368 369 - (void)lookUpURL:(NSURL *)URL completionHandler:(void (^)(TestLookupResult *, NSError *))completionHandler 370 { 371 BOOL phishing = NO; 372 if ([URL isEqual:resourceURL(@"simple3")]) 373 phishing = YES; 374 completionHandler([TestLookupResult resultWithResults:@[[TestServiceLookupResult resultWithProvider:@"TestProvider" phishing:phishing malware:NO unwantedSoftware:NO]]], nil); 375 } 376 377 @end 378 379 static bool navigationFinished; 380 381 @interface WKWebViewGoBackNavigationDelegate : NSObject <WKNavigationDelegate> 382 @end 383 384 @implementation WKWebViewGoBackNavigationDelegate 385 386 - (void)webView:(WKWebView *)webView didFinishNavigation:(null_unspecified WKNavigation *)navigation 387 { 388 navigationFinished = true; 389 } 390 391 @end 392 393 TEST(SafeBrowsing, WKWebViewGoBack) 394 { 395 ClassMethodSwizzler swizzler(objc_getClass("SSBLookupContext"), @selector(sharedLookupContext), [Simple3LookupContext methodForSelector:@selector(sharedLookupContext)]); 396 397 auto delegate = adoptNS([WKWebViewGoBackNavigationDelegate new]); 398 auto webView = adoptNS([WKWebView new]); 399 [webView setNavigationDelegate:delegate.get()]; 400 [webView loadRequest:[NSURLRequest requestWithURL:resourceURL(@"simple")]]; 401 TestWebKitAPI::Util::run(&navigationFinished); 402 403 navigationFinished = false; 404 [webView loadRequest:[NSURLRequest requestWithURL:resourceURL(@"simple2")]]; 405 TestWebKitAPI::Util::run(&navigationFinished); 406 407 navigationFinished = false; 408 [webView loadRequest:[NSURLRequest requestWithURL:resourceURL(@"simple3")]]; 409 while (![webView _safeBrowsingWarning]) 410 TestWebKitAPI::Util::spinRunLoop(); 411 [webView goBack]; 412 TestWebKitAPI::Util::run(&navigationFinished); 413 EXPECT_TRUE([[webView URL] isEqual:resourceURL(@"simple2")]); 414 } 415 358 416 @interface NullLookupContext : NSObject 359 417 @end
Note:
See TracChangeset
for help on using the changeset viewer.