Tools/ChangeLog

 12020-04-22 Jer Noble <jer.noble@apple.com>
 2
 3 REGRESSION (r260278): TestWebKitAPI.Fullscreen.Delegate is timing out on macOS bots
 4 https://bugs.webkit.org/show_bug.cgi?id=210676
 5 <rdar://problem/61953702>
 6
 7 Reviewed by NOBODY (OOPS!).
 8
 9 A number of API tests modify the WKWebViewConfiguration after calling -[WKWebView initWithFrame:configuration:], which
 10 could be a source of failures or flakiness. Update these tests to set those configuration values before passing the
 11 configuration to WKWebView.
 12
 13 * TestWebKitAPI/Tests/WebKitCocoa/FullscreenAlert.mm:
 14 (TestWebKitAPI::TEST):
 15 * TestWebKitAPI/Tests/WebKitCocoa/FullscreenDelegate.mm:
 16 (TestWebKitAPI::TEST):
 17 * TestWebKitAPI/Tests/WebKitCocoa/FullscreenLayoutConstraints.mm:
 18 (TestWebKitAPI::TEST):
 19 * TestWebKitAPI/Tests/WebKitCocoa/PictureInPictureDelegate.mm:
 20 (TestWebKitAPI::TEST):
 21 * TestWebKitAPI/Tests/WebKitCocoa/TopContentInset.mm:
 22 (TestWebKitAPI::TEST):
 23
1242020-04-22 Alex Christensen <achristensen@webkit.org>
225
326 Add unit test for resuming downloads

Tools/TestWebKitAPI/Tests/WebKitCocoa/FullscreenAlert.mm

@@static bool isOutOfFullscreen = false;
4141TEST(Fullscreen, Alert)
4242{
4343 auto configuration = adoptNS([[WKWebViewConfiguration alloc] init]);
44  auto webView = adoptNS([[TestWKWebView alloc] initWithFrame:NSMakeRect(0, 0, 100, 100) configuration:configuration.get()]);
4544 [configuration preferences]._fullScreenEnabled = YES;
 45 auto webView = adoptNS([[TestWKWebView alloc] initWithFrame:NSMakeRect(0, 0, 100, 100) configuration:configuration.get()]);
4646
4747 auto checkFullscreen = [&] {
4848 isInFullscreen = [webView _isInFullscreen];

Tools/TestWebKitAPI/Tests/WebKitCocoa/FullscreenDelegate.mm

@@namespace TestWebKitAPI {
8585TEST(Fullscreen, Delegate)
8686{
8787 RetainPtr<WKWebViewConfiguration> configuration = adoptNS([[WKWebViewConfiguration alloc] init]);
88  RetainPtr<WKWebView> webView = adoptNS([[WKWebView alloc] initWithFrame:NSMakeRect(0, 0, 100, 100) configuration:configuration.get()]);
8988 [configuration preferences]._fullScreenEnabled = YES;
 89 RetainPtr<WKWebView> webView = adoptNS([[WKWebView alloc] initWithFrame:NSMakeRect(0, 0, 100, 100) configuration:configuration.get()]);
9090 RetainPtr<FullscreenDelegateMessageHandler> handler = adoptNS([[FullscreenDelegateMessageHandler alloc] init]);
9191 [[configuration userContentController] addScriptMessageHandler:handler.get() name:@"fullscreenChangeHandler"];
9292 [webView _setFullscreenDelegate:handler.get()];

Tools/TestWebKitAPI/Tests/WebKitCocoa/FullscreenLayoutConstraints.mm

@@namespace TestWebKitAPI {
5555TEST(Fullscreen, LayoutConstraints)
5656{
5757 RetainPtr<WKWebViewConfiguration> configuration = adoptNS([[WKWebViewConfiguration alloc] init]);
58  RetainPtr<WKWebView> webView = adoptNS([[WKWebView alloc] initWithFrame:NSMakeRect(0, 0, 100, 100) configuration:configuration.get()]);
5958 [configuration preferences]._fullScreenEnabled = YES;
 59 RetainPtr<WKWebView> webView = adoptNS([[WKWebView alloc] initWithFrame:NSMakeRect(0, 0, 100, 100) configuration:configuration.get()]);
6060 RetainPtr<FullscreenStateChangeMessageHandler> handler = adoptNS([[FullscreenStateChangeMessageHandler alloc] init]);
6161 [[configuration userContentController] addScriptMessageHandler:handler.get() name:@"fullscreenStateChangeHandler"];
6262

Tools/TestWebKitAPI/Tests/WebKitCocoa/PictureInPictureDelegate.mm

@@namespace TestWebKitAPI {
112112TEST(PictureInPicture, WKUIDelegate)
113113{
114114 RetainPtr<WKWebViewConfiguration> configuration = adoptNS([[WKWebViewConfiguration alloc] init]);
115  RetainPtr<WKWebView> webView = adoptNS([[WKWebView alloc] initWithFrame:NSMakeRect(0, 0, 640, 480) configuration:configuration.get()]);
116115 [configuration preferences]._fullScreenEnabled = YES;
117116 [configuration preferences]._allowsPictureInPictureMediaPlayback = YES;
118117 RetainPtr<PictureInPictureUIDelegate> handler = adoptNS([[PictureInPictureUIDelegate alloc] init]);
119118 [[configuration userContentController] addScriptMessageHandler:handler.get() name:@"pictureInPictureChangeHandler"];
 119 RetainPtr<WKWebView> webView = adoptNS([[WKWebView alloc] initWithFrame:NSMakeRect(0, 0, 640, 480) configuration:configuration.get()]);
 120
120121 [webView setUIDelegate:handler.get()];
121122
122123#if HAVE(TOUCH_BAR)

Tools/TestWebKitAPI/Tests/WebKitCocoa/TopContentInset.mm

@@namespace TestWebKitAPI {
5656TEST(TopContentInset, Fullscreen)
5757{
5858 RetainPtr<WKWebViewConfiguration> configuration = adoptNS([[WKWebViewConfiguration alloc] init]);
59  RetainPtr<WKWebView> webView = adoptNS([[WKWebView alloc] initWithFrame:NSMakeRect(0, 0, 100, 100) configuration:configuration.get()]);
60  [webView _setTopContentInset:10];
61  [webView _setAutomaticallyAdjustsContentInsets:NO];
6259 [configuration preferences]._fullScreenEnabled = YES;
6360 RetainPtr<FullscreenChangeMessageHandler> handler = adoptNS([[FullscreenChangeMessageHandler alloc] init]);
6461 [[configuration userContentController] addScriptMessageHandler:handler.get() name:@"fullscreenChangeHandler"];
 62 RetainPtr<WKWebView> webView = adoptNS([[WKWebView alloc] initWithFrame:NSMakeRect(0, 0, 100, 100) configuration:configuration.get()]);
 63 [webView _setTopContentInset:10];
 64 [webView _setAutomaticallyAdjustsContentInsets:NO];
6565
6666 RetainPtr<NSWindow> window = adoptNS([[NSWindow alloc] initWithContentRect:[webView frame] styleMask:NSWindowStyleMaskBorderless backing:NSBackingStoreBuffered defer:NO]);
6767 [[window contentView] addSubview:webView.get()];