[iOS DnD] Elements in the DOM with the `draggable` attribute should be draggable
[WebKit-https.git] / Tools / TestWebKitAPI / Tests / ios / DataInteractionTests.mm
index 244a2852dd56288e145e3890f9ed1684493a0668..634126c88204f82d7d554274464d379b0a3cbcd4 100644 (file)
@@ -30,6 +30,7 @@
 #import "DataInteractionSimulator.h"
 #import "PlatformUtilities.h"
 #import "TestWKWebView.h"
+#import "UIKitSPI.h"
 #import "WKWebViewConfigurationExtras.h"
 #import <MobileCoreServices/MobileCoreServices.h>
 #import <UIKit/NSItemProvider+UIKitAdditions.h>
@@ -525,6 +526,17 @@ TEST(DataInteractionTests, EnterAndLeaveEvents)
     checkSelectionRectsWithLogging(@[ ], [dataInteractionSimulator finalSelectionRects]);
 }
 
+TEST(DataInteractionTests, CanStartDragOnDivWithDraggableAttribute)
+{
+    auto webView = adoptNS([[TestWKWebView alloc] initWithFrame:CGRectMake(0, 0, 320, 500)]);
+    [webView synchronouslyLoadTestPageNamed:@"custom-draggable-div"];
+
+    auto dataInteractionSimulator = adoptNS([[DataInteractionSimulator alloc] initWithWebView:webView.get()]);
+    [dataInteractionSimulator runFrom:CGPointMake(100, 100) to:CGPointMake(250, 100)];
+
+    EXPECT_GT([dataInteractionSimulator sourceItemProviders].count, 0UL);
+}
+
 TEST(DataInteractionTests, ExternalSourcePlainTextToIFrame)
 {
     auto webView = adoptNS([[TestWKWebView alloc] initWithFrame:CGRectMake(0, 0, 320, 500)]);
@@ -1306,7 +1318,8 @@ TEST(DataInteractionTests, UnresponsivePageDoesNotHangUI)
     [webView evaluateJavaScript:@"while(1);" completionHandler:nil];
 
     // The test passes if we can prepare for data interaction without timing out.
-    [webView _simulatePrepareForDataInteractionSession:nil completion:^() { }];
+    auto dragSession = adoptNS([[MockDragSession alloc] init]);
+    [(id <UIDragInteractionDelegate_ForWebKitOnly>)[webView dragInteractionDelegate] _dragInteraction:[webView dragInteraction] prepareForSession:dragSession.get() completion:^() { }];
 }
 
 TEST(DataInteractionTests, WebItemProviderPasteboardLoading)