Changeset 244089 in webkit
- Timestamp:
- Apr 9, 2019, 12:07:55 PM (7 years ago)
- Location:
- trunk
- Files:
-
- 5 edited
-
Source/WebKit/ChangeLog (modified) (1 diff)
-
Source/WebKit/UIProcess/API/Cocoa/WKWebView.mm (modified) (1 diff)
-
Source/WebKit/UIProcess/Cocoa/WebViewImpl.mm (modified) (1 diff)
-
Tools/ChangeLog (modified) (1 diff)
-
Tools/TestWebKitAPI/Tests/WebKitCocoa/SafeBrowsing.mm (modified) (5 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebKit/ChangeLog
r244086 r244089 1 2019-04-09 Alex Christensen <achristensen@webkit.org> 2 3 Clicking "Go Back" from a safe browsing warning from an iframe should navigate the WKWebView back to the previous page 4 https://bugs.webkit.org/show_bug.cgi?id=196665 5 <rdar://45115669> 6 7 Reviewed by Geoff Garen. 8 9 It is insufficient to just not navigate the subframe. We must leave the page that contained it. 10 11 * UIProcess/API/Cocoa/WKWebView.mm: 12 (-[WKWebView _showSafeBrowsingWarning:completionHandler:]): 13 * UIProcess/Cocoa/WebViewImpl.mm: 14 (WebKit::WebViewImpl::showSafeBrowsingWarning): 15 1 16 2019-04-09 John Wilander <wilander@apple.com> 2 17 -
trunk/Source/WebKit/UIProcess/API/Cocoa/WKWebView.mm
r243969 r244089 1356 1356 if (!strongSelf) 1357 1357 return; 1358 bool navigates MainFrame = WTF::switchOn(result,1358 bool navigatesFrame = WTF::switchOn(result, 1359 1359 [] (WebKit::ContinueUnsafeLoad continueUnsafeLoad) { return continueUnsafeLoad == WebKit::ContinueUnsafeLoad::Yes; }, 1360 1360 [] (const URL&) { return true; } 1361 1361 ); 1362 if (navigatesMainFrame && [strongSelf->_safeBrowsingWarning forMainFrameNavigation]) 1362 bool forMainFrameNavigation = [strongSelf->_safeBrowsingWarning forMainFrameNavigation]; 1363 if (navigatesFrame && forMainFrameNavigation) { 1364 // The safe browsing warning will be hidden once the next page is shown. 1363 1365 return; 1366 } 1367 if (!navigatesFrame && strongSelf->_safeBrowsingWarning && !forMainFrameNavigation) { 1368 strongSelf->_page->goBack(); 1369 return; 1370 } 1364 1371 [std::exchange(strongSelf->_safeBrowsingWarning, nullptr) removeFromSuperview]; 1365 1372 }]); -
trunk/Source/WebKit/UIProcess/Cocoa/WebViewImpl.mm
r243969 r244089 1588 1588 if (!weakThis) 1589 1589 return; 1590 bool navigates MainFrame = WTF::switchOn(result,1590 bool navigatesFrame = WTF::switchOn(result, 1591 1591 [] (ContinueUnsafeLoad continueUnsafeLoad) { return continueUnsafeLoad == ContinueUnsafeLoad::Yes; }, 1592 1592 [] (const URL&) { return true; } 1593 1593 ); 1594 if (navigatesMainFrame && [weakThis->m_safeBrowsingWarning forMainFrameNavigation]) 1594 bool forMainFrameNavigation = [weakThis->m_safeBrowsingWarning forMainFrameNavigation]; 1595 if (navigatesFrame && forMainFrameNavigation) { 1596 // The safe browsing warning will be hidden once the next page is shown. 1595 1597 return; 1598 } 1599 if (!navigatesFrame && weakThis->m_safeBrowsingWarning && !forMainFrameNavigation) { 1600 weakThis->m_page->goBack(); 1601 return; 1602 } 1596 1603 [std::exchange(weakThis->m_safeBrowsingWarning, nullptr) removeFromSuperview]; 1597 1604 }]); -
trunk/Tools/ChangeLog
r244086 r244089 1 2019-04-09 Alex Christensen <achristensen@webkit.org> 2 3 Clicking "Go Back" from a safe browsing warning from an iframe should navigate the WKWebView back to the previous page 4 https://bugs.webkit.org/show_bug.cgi?id=196665 5 <rdar://45115669> 6 7 Reviewed by Geoff Garen. 8 9 * TestWebKitAPI/Tests/WebKitCocoa/SafeBrowsing.mm: 10 (goBack): 11 (+[SimpleLookupContext sharedLookupContext]): 12 (-[SimpleLookupContext lookUpURL:completionHandler:]): 13 (TEST): 14 (+[Simple3LookupContext sharedLookupContext]): Deleted. 15 (-[Simple3LookupContext lookUpURL:completionHandler:]): Deleted. 16 1 17 2019-04-09 John Wilander <wilander@apple.com> 2 18 -
trunk/Tools/TestWebKitAPI/Tests/WebKitCocoa/SafeBrowsing.mm
r243969 r244089 221 221 #endif 222 222 223 template<typename ViewType> void goBack(ViewType *view )223 template<typename ViewType> void goBack(ViewType *view, bool mainFrame = true) 224 224 { 225 225 WKWebView *webView = (WKWebView *)view.superview; 226 226 auto box = view.subviews.firstObject; 227 227 checkTitleAndClick(box.subviews[3], "Go Back"); 228 EXPECT_EQ([webView _safeBrowsingWarning], nil); 228 if (mainFrame) 229 EXPECT_EQ([webView _safeBrowsingWarning], nil); 230 else 231 EXPECT_NE([webView _safeBrowsingWarning], nil); 229 232 } 230 233 … … 369 372 } 370 373 371 @interface Simple3LookupContext : NSObject 372 @end 373 374 @implementation Simple3LookupContext 375 376 + (Simple3LookupContext *)sharedLookupContext 377 { 378 static Simple3LookupContext *context = [[Simple3LookupContext alloc] init]; 374 static RetainPtr<NSString> phishingResourceName; 375 376 @interface SimpleLookupContext : NSObject 377 @end 378 379 @implementation SimpleLookupContext 380 381 + (SimpleLookupContext *)sharedLookupContext 382 { 383 static SimpleLookupContext *context = [[SimpleLookupContext alloc] init]; 379 384 return context; 380 385 } … … 383 388 { 384 389 BOOL phishing = NO; 385 if ([URL isEqual:resourceURL( @"simple3")])390 if ([URL isEqual:resourceURL(phishingResourceName.get())]) 386 391 phishing = YES; 387 392 completionHandler([TestLookupResult resultWithResults:@[[TestServiceLookupResult resultWithProvider:@"TestProvider" phishing:phishing malware:NO unwantedSoftware:NO]]], nil); … … 406 411 TEST(SafeBrowsing, WKWebViewGoBack) 407 412 { 408 ClassMethodSwizzler swizzler(objc_getClass("SSBLookupContext"), @selector(sharedLookupContext), [Simple3LookupContext methodForSelector:@selector(sharedLookupContext)]); 413 phishingResourceName = @"simple3"; 414 ClassMethodSwizzler swizzler(objc_getClass("SSBLookupContext"), @selector(sharedLookupContext), [SimpleLookupContext methodForSelector:@selector(sharedLookupContext)]); 409 415 410 416 auto delegate = adoptNS([WKWebViewGoBackNavigationDelegate new]); … … 428 434 } 429 435 436 TEST(SafeBrowsing, WKWebViewGoBackIFrame) 437 { 438 phishingResourceName = @"simple"; 439 ClassMethodSwizzler swizzler(objc_getClass("SSBLookupContext"), @selector(sharedLookupContext), [SimpleLookupContext methodForSelector:@selector(sharedLookupContext)]); 440 441 auto delegate = adoptNS([WKWebViewGoBackNavigationDelegate new]); 442 auto webView = adoptNS([WKWebView new]); 443 [webView configuration].preferences._safeBrowsingEnabled = YES; 444 [webView setNavigationDelegate:delegate.get()]; 445 [webView loadRequest:[NSURLRequest requestWithURL:resourceURL(@"simple2")]]; 446 TestWebKitAPI::Util::run(&navigationFinished); 447 448 [webView loadRequest:[NSURLRequest requestWithURL:resourceURL(@"simple-iframe")]]; 449 while (![webView _safeBrowsingWarning]) 450 TestWebKitAPI::Util::spinRunLoop(); 451 #if !PLATFORM(MAC) 452 [[webView _safeBrowsingWarning] didMoveToWindow]; 453 #endif 454 navigationFinished = false; 455 goBack([webView _safeBrowsingWarning], false); 456 TestWebKitAPI::Util::run(&navigationFinished); 457 EXPECT_TRUE([[webView URL] isEqual:resourceURL(@"simple2")]); 458 } 459 430 460 @interface NullLookupContext : NSObject 431 461 @end
Note:
See TracChangeset
for help on using the changeset viewer.