Title: [277508] trunk/Tools
Revision
277508
Author
j...@apple.com
Date
2021-05-14 15:18:06 -0700 (Fri, 14 May 2021)

Log Message

TestWebKitAPI.Fullscreen.WKViewDelegate is timing out
https://bugs.webkit.org/show_bug.cgi?id=223282
rdar://75495585

Reviewed by Jer Noble.

* TestWebKitAPI/Tests/WebKitCocoa/FullscreenDelegate.mm:
(TestWebKitAPI::TEST): Use WkView/NSWindow directly instead of using a
PlatformWebView. A PlatformWebView uses an OffscreenWindow which is a
NSWindow placed with a -10000 offset. This configuration appears to fail
to go into full screen in automation.

Modified Paths

Diff

Modified: trunk/Tools/ChangeLog (277507 => 277508)


--- trunk/Tools/ChangeLog	2021-05-14 22:02:15 UTC (rev 277507)
+++ trunk/Tools/ChangeLog	2021-05-14 22:18:06 UTC (rev 277508)
@@ -1,3 +1,17 @@
+2021-05-14  Jean-Yves Avenard  <j...@apple.com>
+
+        TestWebKitAPI.Fullscreen.WKViewDelegate is timing out
+        https://bugs.webkit.org/show_bug.cgi?id=223282
+        rdar://75495585
+
+        Reviewed by Jer Noble.
+
+        * TestWebKitAPI/Tests/WebKitCocoa/FullscreenDelegate.mm:
+        (TestWebKitAPI::TEST): Use WkView/NSWindow directly instead of using a
+        PlatformWebView. A PlatformWebView uses an OffscreenWindow which is a
+        NSWindow placed with a -10000 offset. This configuration appears to fail
+        to go into full screen in automation.
+
 2021-05-14  Sam Weinig  <wei...@apple.com>
 
         REGRESSION(r277313): [ Debug ] 2 TestWebKitAPI.IPCTestingAPI (API-Tests) are constant timeouts

Modified: trunk/Tools/TestWebKitAPI/Tests/WebKitCocoa/FullscreenDelegate.mm (277507 => 277508)


--- trunk/Tools/TestWebKitAPI/Tests/WebKitCocoa/FullscreenDelegate.mm	2021-05-14 22:02:15 UTC (rev 277507)
+++ trunk/Tools/TestWebKitAPI/Tests/WebKitCocoa/FullscreenDelegate.mm	2021-05-14 22:18:06 UTC (rev 277508)
@@ -28,10 +28,10 @@
 #if PLATFORM(MAC)
 
 #import "PlatformUtilities.h"
-#import "PlatformWebView.h"
 #import <WebKit/WKPagePrivateMac.h>
 #import <WebKit/WKPreferencesPrivate.h>
 #import <WebKit/WKView.h>
+#import <WebKit/WKViewPrivate.h>
 #import <WebKit/WKWebViewConfigurationPrivate.h>
 #import <WebKit/WKWebViewPrivate.h>
 #import <WebKit/_WKFullscreenDelegate.h>
@@ -114,8 +114,7 @@
     ASSERT_FALSE([webView _isInFullscreen]);
 }
 
-// FIXME: Re-enable this test once webkit.org/b/223282 is resolved
-TEST(Fullscreen, DISABLED_WKViewDelegate)
+TEST(Fullscreen, WKViewDelegate)
 {
     WKRetainPtr<WKContextRef> context = adoptWK(WKContextCreateWithConfiguration(nullptr));
     WKRetainPtr<WKPageGroupRef> pageGroup = adoptWK(WKPageGroupCreateWithIdentifier(Util::toWK("FullscreenDelegate").get()));
@@ -122,10 +121,20 @@
     WKPreferencesRef preferences = WKPageGroupGetPreferences(pageGroup.get());
     WKPreferencesSetFullScreenEnabled(preferences, true);
 
-    PlatformWebView webView(context.get(), pageGroup.get());
+    WKRetainPtr<WKPageConfigurationRef> configuration = adoptWK(WKPageConfigurationCreate());
+    WKPageConfigurationSetContext(configuration.get(), context.get());
+    WKPageConfigurationSetPageGroup(configuration.get(), pageGroup.get());
 
+    NSRect rect = NSMakeRect(0, 0, 800, 600);
+    auto webView = adoptNS([[WKView alloc] initWithFrame:rect configurationRef:configuration.get()]);
+    [webView setWindowOcclusionDetectionEnabled:NO];
+
+    auto window = adoptNS([[NSWindow alloc] initWithContentRect:rect styleMask:NSWindowStyleMaskBorderless backing:NSBackingStoreBuffered defer:NO]);
+    [[window contentView] addSubview:webView.get()];
+    [window makeKeyAndOrderFront:nil];
+
     RetainPtr<FullscreenDelegateMessageHandler> handler = adoptNS([[FullscreenDelegateMessageHandler alloc] init]);
-    WKPageSetFullscreenDelegate(webView.page(), handler.get());
+    WKPageSetFullscreenDelegate([webView pageRef], handler.get());
 
     WKPageNavigationClientV0 loaderClient;
     memset(&loaderClient, 0 , sizeof(loaderClient));
@@ -132,19 +141,21 @@
 
     loaderClient.base.version = 0;
     loaderClient.didFinishNavigation = didFinishNavigation;
-    WKPageSetPageNavigationClient(webView.page(), &loaderClient.base);
+    WKPageSetPageNavigationClient([webView pageRef], &loaderClient.base);
 
     receivedLoadedMessage = false;
     WKRetainPtr<WKURLRef> url = "" "html"));
-    WKPageLoadURL(webView.page(), url.get());
+    WKPageLoadURL([webView pageRef], url.get());
 
     TestWebKitAPI::Util::run(&receivedLoadedMessage);
 
-    webView.simulateButtonClick(kWKEventMouseButtonLeftButton, 5, 5, 0);
+    NSEvent *event = [NSEvent mouseEventWithType:NSEventTypeLeftMouseDown location:NSMakePoint(5, 5) modifierFlags:0 timestamp:0 windowNumber:window.get().windowNumber context:0 eventNumber:0 clickCount:0 pressure:0];
+
+    [webView mouseDown:event];
     TestWebKitAPI::Util::run(&receivedWillEnterFullscreenMessage);
     TestWebKitAPI::Util::run(&receivedDidEnterFullscreenMessage);
 
-    webView.simulateButtonClick(kWKEventMouseButtonLeftButton, 5, 5, 0);
+    [webView mouseDown:event];
     TestWebKitAPI::Util::run(&receivedWillExitFullscreenMessage);
     TestWebKitAPI::Util::run(&receivedDidExitFullscreenMessage);
 }
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to