Modified: trunk/Tools/ChangeLog (220295 => 220296)
--- trunk/Tools/ChangeLog 2017-08-04 21:45:12 UTC (rev 220295)
+++ trunk/Tools/ChangeLog 2017-08-04 21:46:04 UTC (rev 220296)
@@ -1,3 +1,18 @@
+2017-08-04 Tim Horton <[email protected]>
+
+ Add an API test for r220286
+ https://bugs.webkit.org/show_bug.cgi?id=175206
+
+ Reviewed by Simon Fraser.
+
+ * TestWebKitAPI/Tests/WebKit2Cocoa/AnimatedResize.mm:
+ (-[AnimatedResizeWebView _webView:didChangeSafeAreaShouldAffectObscuredInsets:]):
+ (createAnimatedResizeWebView):
+ (TEST):
+ Add a test to ensure that we don't call
+ _webView:didChangeSafeAreaShouldAffectObscuredInsets: during an
+ animated resize.
+
2017-08-04 Stephan Szabo <[email protected]>
[XCode] webkit-patch should run sort-Xcode-project-file
Modified: trunk/Tools/TestWebKitAPI/Tests/WebKit2Cocoa/AnimatedResize.mm (220295 => 220296)
--- trunk/Tools/TestWebKitAPI/Tests/WebKit2Cocoa/AnimatedResize.mm 2017-08-04 21:45:12 UTC (rev 220295)
+++ trunk/Tools/TestWebKitAPI/Tests/WebKit2Cocoa/AnimatedResize.mm 2017-08-04 21:46:04 UTC (rev 220296)
@@ -39,8 +39,9 @@
static bool didLayout;
static bool didEndAnimatedResize;
+static bool didChangeSafeAreaShouldAffectObscuredInsets;
-@interface AnimatedResizeWebView : WKWebView
+@interface AnimatedResizeWebView : WKWebView <WKUIDelegate>
@end
@@ -53,9 +54,14 @@
didEndAnimatedResize = true;
}
+- (void)_webView:(WKWebView *)webView didChangeSafeAreaShouldAffectObscuredInsets:(BOOL)safeAreaShouldAffectObscuredInsets
+{
+ didChangeSafeAreaShouldAffectObscuredInsets = true;
+}
+
@end
-static RetainPtr<WKWebView> createAnimatedResizeWebView()
+static RetainPtr<AnimatedResizeWebView> createAnimatedResizeWebView()
{
RetainPtr<_WKProcessPoolConfiguration> processPoolConfiguration = adoptNS([[_WKProcessPoolConfiguration alloc] init]);
[processPoolConfiguration setIgnoreSynchronousMessagingTimeoutsForTesting:YES];
@@ -64,11 +70,8 @@
RetainPtr<WKWebViewConfiguration> webViewConfiguration = adoptNS([[WKWebViewConfiguration alloc] init]);
[webViewConfiguration setProcessPool:processPool.get()];
- RetainPtr<WKWebView> webView = adoptNS([[AnimatedResizeWebView alloc] initWithFrame:CGRectMake(0, 0, 800, 600) configuration:webViewConfiguration.get()]);
+ RetainPtr<AnimatedResizeWebView> webView = adoptNS([[AnimatedResizeWebView alloc] initWithFrame:CGRectMake(0, 0, 800, 600) configuration:webViewConfiguration.get()]);
- NSURLRequest *request = [NSURLRequest requestWithURL:[[NSBundle mainBundle] URLForResource:@"blinking-div" withExtension:@"html" subdirectory:@"TestWebKitAPI.resources"]];
- [webView loadRequest:request];
-
return webView;
}
@@ -85,6 +88,8 @@
TEST(WebKit2, DISABLED_ResizeWithHiddenContentDoesNotHang)
{
auto webView = createAnimatedResizeWebView();
+ [webView loadRequest:[NSURLRequest requestWithURL:[[NSBundle mainBundle] URLForResource:@"blinking-div" withExtension:@"html" subdirectory:@"TestWebKitAPI.resources"]]];
+
auto navigationDelegate = createFirstVisuallyNonEmptyWatchingNavigationDelegate();
[webView setNavigationDelegate:navigationDelegate.get()];
RetainPtr<UIWindow> window = adoptNS([[UIWindow alloc] initWithFrame:CGRectMake(0, 0, 800, 600)]);
@@ -107,6 +112,8 @@
TEST(WebKit2, AnimatedResizeDoesNotHang)
{
auto webView = createAnimatedResizeWebView();
+ [webView loadRequest:[NSURLRequest requestWithURL:[[NSBundle mainBundle] URLForResource:@"blinking-div" withExtension:@"html" subdirectory:@"TestWebKitAPI.resources"]]];
+
auto navigationDelegate = createFirstVisuallyNonEmptyWatchingNavigationDelegate();
[webView setNavigationDelegate:navigationDelegate.get()];
RetainPtr<UIWindow> window = adoptNS([[UIWindow alloc] initWithFrame:CGRectMake(0, 0, 800, 600)]);
@@ -130,4 +137,51 @@
}
}
+TEST(WebKit2, AnimatedResizeBlocksViewportFitChanges)
+{
+ auto webView = createAnimatedResizeWebView();
+ [webView setUIDelegate:webView.get()];
+
+ // We need to have something loaded before beginning the animated
+ // resize, or it will bail.
+ [webView loadHTMLString:@"<head></head>" baseURL:nil];
+ [webView _test_waitForDidFinishNavigation];
+
+ RetainPtr<UIWindow> window = adoptNS([[UIWindow alloc] initWithFrame:CGRectMake(0, 0, 800, 600)]);
+ [window addSubview:webView.get()];
+ [window setHidden:NO];
+
+ [webView _beginAnimatedResizeWithUpdates:^ {
+ [webView setFrame:CGRectMake(0, 0, [webView frame].size.width + 100, 400)];
+ }];
+
+ // Load a page that will change the state of viewport-fit,
+ // in the middle of the resize.
+ [webView loadHTMLString:@"<head><meta name='viewport' content='viewport-fit=cover' /></head>" baseURL:nil];
+ [webView _test_waitForDidFinishNavigation];
+
+ didChangeSafeAreaShouldAffectObscuredInsets = false;
+
+ // Wait for a commit to come in /after/ loading the viewport-fit=cover
+ // page, and ensure that we didn't call the UIDelegate callback,
+ // because we're still in the resize. Then, end the resize.
+ [webView _doAfterNextPresentationUpdate:^ {
+ EXPECT_FALSE(didChangeSafeAreaShouldAffectObscuredInsets);
+ [webView _endAnimatedResize];
+ }];
+
+ TestWebKitAPI::Util::run(&didEndAnimatedResize);
+ didEndAnimatedResize = false;
+
+ // Wait for one more commit so that we see the viewport-fit state
+ // change actually take place (post-resize), and ensure that it does.
+ __block bool didGetCommitAfterEndAnimatedResize = false;
+ [webView _doAfterNextPresentationUpdate:^ {
+ didGetCommitAfterEndAnimatedResize = true;
+ }];
+ TestWebKitAPI::Util::run(&didGetCommitAfterEndAnimatedResize);
+
+ EXPECT_TRUE(didChangeSafeAreaShouldAffectObscuredInsets);
+}
+
#endif