Fix and re-enable data interaction unit tests
authorwenson_hsieh@apple.com <wenson_hsieh@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sat, 29 Apr 2017 00:44:13 +0000 (00:44 +0000)
committerwenson_hsieh@apple.com <wenson_hsieh@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sat, 29 Apr 2017 00:44:13 +0000 (00:44 +0000)
https://bugs.webkit.org/show_bug.cgi?id=171446
<rdar://problem/31820646>

Reviewed by Tim Horton.

Source/WebCore:

Three small tweaks to get all data interaction tests passing again (changes detailed below).
Fixes a failing unit test: DataInteractionTests.RespectsExternalSourceFidelityRankings.

* page/mac/DragControllerMac.mm:

When dropping in a plain text editable area, don't consider kUTTypeText to be a UTI supported by the destination.
This is because doing so would cause rich text UTIs, such as kUTTypeHTML, to match, so that the plain text area
would report HTML as a preferred UTI type to load when dropping rich content over it. What we want to check for
conformance here is really kUTTypePlainText.

(WebCore::DragController::updatePreferredTypeIdentifiersForDragHandlingMethod):
* platform/Pasteboard.h:
* platform/ios/PasteboardIOS.mm:

The default Pasteboard constructor no longer makes a sync call to the UI process to get the change count.
Instead, we introduce a new constructor that takes and sets the change count. This default constructor was used
from three places: Pasteboard::createForCopyAndPaste, Pasteboard::createPrivate and StaticPasteboard::create.

The first two call sites have been refactored to first fetch the change count from the UI process and then pass
it in to the constructor.

(WebCore::changeCountForPasteboard):
(WebCore::Pasteboard::Pasteboard):
(WebCore::Pasteboard::createForCopyAndPaste):
(WebCore::Pasteboard::createPrivate):
(WebCore::Pasteboard::readString):
(WebCore::Pasteboard::types):
* platform/mac/DragDataMac.mm:
(WebCore::typeIsAppropriateForSupportedTypes):
(WebCore::DragData::updatePreferredTypeIdentifiers):

Remove the two-pass heuristic. Instead, we should follow this policy: "select the highest fidelity UTI that
conforms to one of the destination's supported types".

* platform/mac/PasteboardMac.mm:
(WebCore::Pasteboard::Pasteboard):

Tools:

Enables all DataInteractionTests, and adjusts file upload tests to no longer write to a temporary file before
registering with the UIItemProvider, and instead just register data directly via
-registerDataRepresentationForTypeIdentifier:visibility:loadHandler:.

* TestWebKitAPI/Tests/ios/DataInteractionTests.mm:
(TestWebKitAPI::TEST):
(temporaryURLForDataInteractionFileLoad): Deleted.
(cleanUpDataInteractionTemporaryPath): Deleted.
(-[UIItemProvider registerFileRepresentationForTypeIdentifier:withData:filename:]): Deleted.
* TestWebKitAPI/ios/DataInteractionSimulator.h:
* TestWebKitAPI/ios/DataInteractionSimulator.mm:

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@215962 268f45cc-cd09-0410-ab3c-d52691b4dbfc

Source/WebCore/ChangeLog
Source/WebCore/page/mac/DragControllerMac.mm
Source/WebCore/platform/Pasteboard.h
Source/WebCore/platform/ios/PasteboardIOS.mm
Source/WebCore/platform/mac/DragDataMac.mm
Tools/ChangeLog
Tools/TestWebKitAPI/Tests/ios/DataInteractionTests.mm
Tools/TestWebKitAPI/ios/DataInteractionSimulator.h
Tools/TestWebKitAPI/ios/DataInteractionSimulator.mm

index a3368f9..0cc4895 100644 (file)
@@ -1,3 +1,48 @@
+2017-04-28  Wenson Hsieh  <wenson_hsieh@apple.com>
+
+        Fix and re-enable data interaction unit tests
+        https://bugs.webkit.org/show_bug.cgi?id=171446
+        <rdar://problem/31820646>
+
+        Reviewed by Tim Horton.
+
+        Three small tweaks to get all data interaction tests passing again (changes detailed below).
+        Fixes a failing unit test: DataInteractionTests.RespectsExternalSourceFidelityRankings.
+
+        * page/mac/DragControllerMac.mm:
+
+        When dropping in a plain text editable area, don't consider kUTTypeText to be a UTI supported by the destination.
+        This is because doing so would cause rich text UTIs, such as kUTTypeHTML, to match, so that the plain text area
+        would report HTML as a preferred UTI type to load when dropping rich content over it. What we want to check for
+        conformance here is really kUTTypePlainText.
+
+        (WebCore::DragController::updatePreferredTypeIdentifiersForDragHandlingMethod):
+        * platform/Pasteboard.h:
+        * platform/ios/PasteboardIOS.mm:
+
+        The default Pasteboard constructor no longer makes a sync call to the UI process to get the change count.
+        Instead, we introduce a new constructor that takes and sets the change count. This default constructor was used
+        from three places: Pasteboard::createForCopyAndPaste, Pasteboard::createPrivate and StaticPasteboard::create.
+
+        The first two call sites have been refactored to first fetch the change count from the UI process and then pass
+        it in to the constructor.
+
+        (WebCore::changeCountForPasteboard):
+        (WebCore::Pasteboard::Pasteboard):
+        (WebCore::Pasteboard::createForCopyAndPaste):
+        (WebCore::Pasteboard::createPrivate):
+        (WebCore::Pasteboard::readString):
+        (WebCore::Pasteboard::types):
+        * platform/mac/DragDataMac.mm:
+        (WebCore::typeIsAppropriateForSupportedTypes):
+        (WebCore::DragData::updatePreferredTypeIdentifiers):
+
+        Remove the two-pass heuristic. Instead, we should follow this policy: "select the highest fidelity UTI that
+        conforms to one of the destination's supported types".
+
+        * platform/mac/PasteboardMac.mm:
+        (WebCore::Pasteboard::Pasteboard):
+
 2017-04-28  Dean Jackson  <dino@apple.com>
 
         App crashing: Dispatch queue: com.apple.root.user-interactive-qos / vBoxConvolve / WebCore::FEGaussianBlur::platformApplySoftware()
index 41cc882..2473a43 100644 (file)
@@ -113,8 +113,7 @@ void DragController::updatePreferredTypeIdentifiersForDragHandlingMethod(DragHan
         break;
     case DragHandlingMethod::EditPlainText:
         supportedTypes.append(kUTTypeURL);
-        supportedTypes.append(kUTTypeText);
-        supportedTypes.append(kUTTypeUTF8PlainText);
+        supportedTypes.append(kUTTypePlainText);
         break;
     case DragHandlingMethod::EditRichText:
         for (NSString *type in Pasteboard::supportedPasteboardTypes())
index 429e1af..8c213d9 100644 (file)
@@ -197,6 +197,8 @@ public:
 #endif
 
 #if PLATFORM(IOS)
+    explicit Pasteboard(long changeCount);
+
     static NSArray* supportedPasteboardTypes();
     static String resourceMIMEType(const NSString *mimeType);
 #endif
index 7d4254f..3d8d74c 100644 (file)
 
 namespace WebCore {
 
+static long changeCountForPasteboard(const String& pasteboardName = { })
+{
+    return platformStrategies()->pasteboardStrategy()->changeCount(pasteboardName);
+}
+
 // FIXME: Does this need to be declared in the header file?
 WEBCORE_EXPORT NSString *WebArchivePboardType = @"Apple Web Archive pasteboard type";
 
@@ -86,7 +91,12 @@ PasteboardImage::~PasteboardImage()
 }
 
 Pasteboard::Pasteboard()
-    : m_changeCount(platformStrategies()->pasteboardStrategy()->changeCount(m_pasteboardName))
+    : m_changeCount(0)
+{
+}
+
+Pasteboard::Pasteboard(long changeCount)
+    : m_changeCount(changeCount)
 {
 }
 
@@ -96,12 +106,12 @@ void Pasteboard::writeMarkup(const String&)
 
 std::unique_ptr<Pasteboard> Pasteboard::createForCopyAndPaste()
 {
-    return std::make_unique<Pasteboard>();
+    return std::make_unique<Pasteboard>(changeCountForPasteboard());
 }
 
 std::unique_ptr<Pasteboard> Pasteboard::createPrivate()
 {
-    return std::make_unique<Pasteboard>();
+    return std::make_unique<Pasteboard>(changeCountForPasteboard());
 }
 
 void Pasteboard::write(const PasteboardWebContent& content)
@@ -352,7 +362,7 @@ String Pasteboard::readString(const String& type)
 
     // Enforce changeCount ourselves for security. We check after reading instead of before to be
     // sure it doesn't change between our testing the change count and accessing the data.
-    if (cocoaValue && m_changeCount == platformStrategies()->pasteboardStrategy()->changeCount(m_pasteboardName))
+    if (cocoaValue && m_changeCount == changeCountForPasteboard(m_pasteboardName))
         return cocoaValue;
 
     return String();
@@ -393,7 +403,7 @@ Vector<String> Pasteboard::types()
 
     // Enforce changeCount ourselves for security. We check after reading instead of before to be
     // sure it doesn't change between our testing the change count and accessing the data.
-    if (m_changeCount != platformStrategies()->pasteboardStrategy()->changeCount(m_pasteboardName))
+    if (m_changeCount != changeCountForPasteboard(m_pasteboardName))
         return Vector<String>();
 
     ListHashSet<String> result;
index 8b30cb3..a49e134 100644 (file)
@@ -294,13 +294,18 @@ String DragData::asURL(FilenameConversionPolicy, String* title) const
 
 #if ENABLE(DATA_INTERACTION)
 
-void DragData::updatePreferredTypeIdentifiers(const Vector<String>& supportedTypesVector) const
+static bool typeIsAppropriateForSupportedTypes(const String& type, const Vector<String>& supportedTypes)
 {
-    NSMutableSet *supportedTypes = [NSMutableSet setWithCapacity:supportedTypesVector.size()];
-    for (auto& supportedType : supportedTypesVector)
-        [supportedTypes addObject:supportedType];
+    CFStringRef cfType = type.createCFString().autorelease();
+    for (auto supportedType : supportedTypes) {
+        if (UTTypeConformsTo(cfType, supportedType.createCFString().get()))
+            return true;
+    }
+    return false;
+}
 
-    // Match UIItemProvider behavior by performing two-pass UTI matching.
+void DragData::updatePreferredTypeIdentifiers(const Vector<String>& supportedTypes) const
+{
     Vector<String> bestTypeIdentifiers;
     auto& strategy = *platformStrategies()->pasteboardStrategy();
     uint64_t itemCount = strategy.getPasteboardItemsCount(m_pasteboardName);
@@ -309,26 +314,12 @@ void DragData::updatePreferredTypeIdentifiers(const Vector<String>& supportedTyp
         strategy.getTypesByFidelityForItemAtIndex(typeIdentifiers, itemIndex, m_pasteboardName);
 
         String bestTypeIdentifier = emptyString();
-        // In the first pass, look for the highest fidelity UTI that exactly matches one of the supported UTIs.
         for (auto& type : typeIdentifiers) {
-            if ([supportedTypes containsObject:(NSString *)type]) {
-                bestTypeIdentifier = type;
-                break;
-            }
-        }
+            if (!typeIsAppropriateForSupportedTypes(type, supportedTypes))
+                continue;
 
-        // In the second pass, look for the highest fidelity UTI that conforms to one of the supported UTIs.
-        if (bestTypeIdentifier.isEmpty()) {
-            for (auto& type : typeIdentifiers) {
-                for (NSString *supportedType in supportedTypes) {
-                    if (UTTypeConformsTo(type.createCFString().autorelease(), (CFStringRef)supportedType)) {
-                        bestTypeIdentifier = type;
-                        break;
-                    }
-                }
-                if (!bestTypeIdentifier.isEmpty())
-                    break;
-            }
+            bestTypeIdentifier = type;
+            break;
         }
         bestTypeIdentifiers.append(bestTypeIdentifier);
     }
index c613c40..d259eb7 100644 (file)
@@ -1,3 +1,23 @@
+2017-04-28  Wenson Hsieh  <wenson_hsieh@apple.com>
+
+        Fix and re-enable data interaction unit tests
+        https://bugs.webkit.org/show_bug.cgi?id=171446
+        <rdar://problem/31820646>
+
+        Reviewed by Tim Horton.
+
+        Enables all DataInteractionTests, and adjusts file upload tests to no longer write to a temporary file before
+        registering with the UIItemProvider, and instead just register data directly via
+        -registerDataRepresentationForTypeIdentifier:visibility:loadHandler:.
+
+        * TestWebKitAPI/Tests/ios/DataInteractionTests.mm:
+        (TestWebKitAPI::TEST):
+        (temporaryURLForDataInteractionFileLoad): Deleted.
+        (cleanUpDataInteractionTemporaryPath): Deleted.
+        (-[UIItemProvider registerFileRepresentationForTypeIdentifier:withData:filename:]): Deleted.
+        * TestWebKitAPI/ios/DataInteractionSimulator.h:
+        * TestWebKitAPI/ios/DataInteractionSimulator.mm:
+
 2017-04-28  Brady Eidson  <beidson@apple.com>
 
         Teach the DatabaseProcess to be fully SessionID aware
index fe5131e..304873c 100644 (file)
@@ -25,7 +25,7 @@
 
 #include "config.h"
 
-#if 0
+#if ENABLE(DATA_INTERACTION)
 
 #import "DataInteractionSimulator.h"
 #import "PlatformUtilities.h"
@@ -48,38 +48,8 @@ static UIImage *testIconImage()
     return [UIImage imageNamed:@"TestWebKitAPI.resources/icon.png"];
 }
 
-static NSURL *temporaryURLForDataInteractionFileLoad(NSString *temporaryFileName)
-{
-    NSString *temporaryDirectoryPath = [NSTemporaryDirectory() stringByAppendingPathComponent:@"data-interaction"];
-    if (![[NSFileManager defaultManager] fileExistsAtPath:temporaryDirectoryPath])
-        [[NSFileManager defaultManager] createDirectoryAtPath:temporaryDirectoryPath withIntermediateDirectories:YES attributes:nil error:nil];
-    return [NSURL fileURLWithPath:[temporaryDirectoryPath stringByAppendingPathComponent:temporaryFileName]];
-}
-
-static void cleanUpDataInteractionTemporaryPath()
-{
-    NSArray *temporaryDirectoryContents = [[NSFileManager defaultManager] contentsOfDirectoryAtURL:[NSURL fileURLWithPath:NSTemporaryDirectory()] includingPropertiesForKeys:nil options:0 error:nil];
-    for (NSURL *url in temporaryDirectoryContents) {
-        if ([url.lastPathComponent rangeOfString:@"data-interaction"].location != NSNotFound)
-            [[NSFileManager defaultManager] removeItemAtURL:url error:nil];
-    }
-}
-
 @implementation UIItemProvider (DataInteractionTests)
 
-- (void)registerFileRepresentationForTypeIdentifier:(NSString *)typeIdentifier withData:(NSData *)data filename:(NSString *)filename
-{
-    RetainPtr<NSData> retainedData = data;
-    RetainPtr<NSURL> retainedTemporaryURL = temporaryURLForDataInteractionFileLoad(filename);
-    [self registerFileRepresentationForTypeIdentifier:typeIdentifier fileOptions:0 visibility:NSItemProviderRepresentationVisibilityAll loadHandler: [retainedData, retainedTemporaryURL] (FileLoadCompletionBlock block) -> NSProgress * {
-        [retainedData writeToFile:[retainedTemporaryURL path] atomically:YES];
-        dispatch_async(dispatch_get_main_queue(), [retainedTemporaryURL, capturedBlock = makeBlockPtr(block)] {
-            capturedBlock(retainedTemporaryURL.get(), NO, nil);
-        });
-        return nil;
-    }];
-}
-
 - (void)registerDataRepresentationForTypeIdentifier:(NSString *)typeIdentifier withData:(NSData *)data
 {
     RetainPtr<NSData> retainedData = data;
@@ -342,14 +312,13 @@ TEST(DataInteractionTests, ExternalSourceJSONToFileInput)
 
     RetainPtr<UIItemProvider> simulatedJSONItemProvider = adoptNS([[UIItemProvider alloc] init]);
     NSData *jsonData = [@"{ \"foo\": \"bar\",  \"bar\": \"baz\" }" dataUsingEncoding:NSUTF8StringEncoding];
-    [simulatedJSONItemProvider registerFileRepresentationForTypeIdentifier:(NSString *)kUTTypeJSON withData:jsonData filename:@"data.json"];
+    [simulatedJSONItemProvider registerDataRepresentationForTypeIdentifier:(NSString *)kUTTypeJSON withData:jsonData];
 
     RetainPtr<DataInteractionSimulator> dataInteractionSimulator = adoptNS([[DataInteractionSimulator alloc] initWithWebView:webView.get()]);
     [dataInteractionSimulator setExternalItemProviders:@[ simulatedJSONItemProvider.get() ]];
     [dataInteractionSimulator runFrom:CGPointMake(200, 100) to:CGPointMake(100, 100)];
 
     EXPECT_WK_STREQ("application/json", [webView stringByEvaluatingJavaScript:@"output.value"]);
-    cleanUpDataInteractionTemporaryPath();
 }
 
 TEST(DataInteractionTests, ExternalSourceImageToFileInput)
@@ -359,7 +328,7 @@ TEST(DataInteractionTests, ExternalSourceImageToFileInput)
 
     RetainPtr<UIItemProvider> simulatedImageItemProvider = adoptNS([[UIItemProvider alloc] init]);
     NSData *imageData = UIImageJPEGRepresentation(testIconImage(), 0.5);
-    [simulatedImageItemProvider registerFileRepresentationForTypeIdentifier:(NSString *)kUTTypeJPEG withData:imageData filename:@"image.png"];
+    [simulatedImageItemProvider registerDataRepresentationForTypeIdentifier:(NSString *)kUTTypeJPEG withData:imageData];
 
     RetainPtr<DataInteractionSimulator> dataInteractionSimulator = adoptNS([[DataInteractionSimulator alloc] initWithWebView:webView.get()]);
     [dataInteractionSimulator setExternalItemProviders:@[ simulatedImageItemProvider.get() ]];
@@ -367,8 +336,6 @@ TEST(DataInteractionTests, ExternalSourceImageToFileInput)
 
     NSString *outputValue = [webView stringByEvaluatingJavaScript:@"output.value"];
     EXPECT_WK_STREQ("image/jpeg", outputValue.UTF8String);
-
-    cleanUpDataInteractionTemporaryPath();
 }
 
 TEST(DataInteractionTests, ExternalSourceHTMLToUploadArea)
@@ -378,7 +345,7 @@ TEST(DataInteractionTests, ExternalSourceHTMLToUploadArea)
 
     RetainPtr<UIItemProvider> simulatedHTMLItemProvider = adoptNS([[UIItemProvider alloc] init]);
     NSData *htmlData = [@"<body contenteditable></body>" dataUsingEncoding:NSUTF8StringEncoding];
-    [simulatedHTMLItemProvider registerFileRepresentationForTypeIdentifier:(NSString *)kUTTypeHTML withData:htmlData filename:@"index.html"];
+    [simulatedHTMLItemProvider registerDataRepresentationForTypeIdentifier:(NSString *)kUTTypeHTML withData:htmlData];
 
     RetainPtr<DataInteractionSimulator> dataInteractionSimulator = adoptNS([[DataInteractionSimulator alloc] initWithWebView:webView.get()]);
     [dataInteractionSimulator setExternalItemProviders:@[ simulatedHTMLItemProvider.get() ]];
@@ -386,8 +353,6 @@ TEST(DataInteractionTests, ExternalSourceHTMLToUploadArea)
 
     NSString *outputValue = [webView stringByEvaluatingJavaScript:@"output.value"];
     EXPECT_WK_STREQ("text/html", outputValue.UTF8String);
-
-    cleanUpDataInteractionTemporaryPath();
 }
 
 TEST(DataInteractionTests, ExternalSourceImageAndHTMLToSingleFileInput)
@@ -397,11 +362,11 @@ TEST(DataInteractionTests, ExternalSourceImageAndHTMLToSingleFileInput)
 
     RetainPtr<UIItemProvider> simulatedImageItemProvider = adoptNS([[UIItemProvider alloc] init]);
     NSData *imageData = UIImageJPEGRepresentation(testIconImage(), 0.5);
-    [simulatedImageItemProvider registerFileRepresentationForTypeIdentifier:(NSString *)kUTTypeJPEG withData:imageData filename:@"image.png"];
+    [simulatedImageItemProvider registerDataRepresentationForTypeIdentifier:(NSString *)kUTTypeJPEG withData:imageData];
 
     RetainPtr<UIItemProvider> simulatedHTMLItemProvider = adoptNS([[UIItemProvider alloc] init]);
     NSData *htmlData = [@"<body contenteditable></body>" dataUsingEncoding:NSUTF8StringEncoding];
-    [simulatedHTMLItemProvider registerFileRepresentationForTypeIdentifier:(NSString *)kUTTypeHTML withData:htmlData filename:@"index.html"];
+    [simulatedHTMLItemProvider registerDataRepresentationForTypeIdentifier:(NSString *)kUTTypeHTML withData:htmlData];
 
     RetainPtr<DataInteractionSimulator> dataInteractionSimulator = adoptNS([[DataInteractionSimulator alloc] initWithWebView:webView.get()]);
     [dataInteractionSimulator setExternalItemProviders:@[ simulatedHTMLItemProvider.get(), simulatedImageItemProvider.get() ]];
@@ -409,8 +374,6 @@ TEST(DataInteractionTests, ExternalSourceImageAndHTMLToSingleFileInput)
 
     NSString *outputValue = [webView stringByEvaluatingJavaScript:@"output.value"];
     EXPECT_WK_STREQ("", outputValue.UTF8String);
-
-    cleanUpDataInteractionTemporaryPath();
 }
 
 TEST(DataInteractionTests, ExternalSourceImageAndHTMLToMultipleFileInput)
@@ -421,11 +384,11 @@ TEST(DataInteractionTests, ExternalSourceImageAndHTMLToMultipleFileInput)
 
     RetainPtr<UIItemProvider> simulatedImageItemProvider = adoptNS([[UIItemProvider alloc] init]);
     NSData *imageData = UIImageJPEGRepresentation(testIconImage(), 0.5);
-    [simulatedImageItemProvider registerFileRepresentationForTypeIdentifier:(NSString *)kUTTypeJPEG withData:imageData filename:@"image.png"];
+    [simulatedImageItemProvider registerDataRepresentationForTypeIdentifier:(NSString *)kUTTypeJPEG withData:imageData];
 
     RetainPtr<UIItemProvider> simulatedHTMLItemProvider = adoptNS([[UIItemProvider alloc] init]);
     NSData *htmlData = [@"<body contenteditable></body>" dataUsingEncoding:NSUTF8StringEncoding];
-    [simulatedHTMLItemProvider registerFileRepresentationForTypeIdentifier:(NSString *)kUTTypeHTML withData:htmlData filename:@"index.html"];
+    [simulatedHTMLItemProvider registerDataRepresentationForTypeIdentifier:(NSString *)kUTTypeHTML withData:htmlData];
 
     RetainPtr<DataInteractionSimulator> dataInteractionSimulator = adoptNS([[DataInteractionSimulator alloc] initWithWebView:webView.get()]);
     [dataInteractionSimulator setExternalItemProviders:@[ simulatedHTMLItemProvider.get(), simulatedImageItemProvider.get() ]];
@@ -433,8 +396,6 @@ TEST(DataInteractionTests, ExternalSourceImageAndHTMLToMultipleFileInput)
 
     NSString *outputValue = [webView stringByEvaluatingJavaScript:@"output.value"];
     EXPECT_WK_STREQ("image/jpeg, text/html", outputValue.UTF8String);
-
-    cleanUpDataInteractionTemporaryPath();
 }
 
 TEST(DataInteractionTests, ExternalSourceImageAndHTMLToUploadArea)
@@ -444,15 +405,15 @@ TEST(DataInteractionTests, ExternalSourceImageAndHTMLToUploadArea)
 
     RetainPtr<UIItemProvider> simulatedImageItemProvider = adoptNS([[UIItemProvider alloc] init]);
     NSData *imageData = UIImageJPEGRepresentation(testIconImage(), 0.5);
-    [simulatedImageItemProvider registerFileRepresentationForTypeIdentifier:(NSString *)kUTTypeJPEG withData:imageData filename:@"image.png"];
+    [simulatedImageItemProvider registerDataRepresentationForTypeIdentifier:(NSString *)kUTTypeJPEG withData:imageData];
 
     RetainPtr<UIItemProvider> firstSimulatedHTMLItemProvider = adoptNS([[UIItemProvider alloc] init]);
     NSData *firstHTMLData = [@"<body contenteditable></body>" dataUsingEncoding:NSUTF8StringEncoding];
-    [firstSimulatedHTMLItemProvider registerFileRepresentationForTypeIdentifier:(NSString *)kUTTypeHTML withData:firstHTMLData filename:@"index.html"];
+    [firstSimulatedHTMLItemProvider registerDataRepresentationForTypeIdentifier:(NSString *)kUTTypeHTML withData:firstHTMLData];
 
     RetainPtr<UIItemProvider> secondSimulatedHTMLItemProvider = adoptNS([[UIItemProvider alloc] init]);
     NSData *secondHTMLData = [@"<html><body>hello world</body></html>" dataUsingEncoding:NSUTF8StringEncoding];
-    [secondSimulatedHTMLItemProvider registerFileRepresentationForTypeIdentifier:(NSString *)kUTTypeHTML withData:secondHTMLData filename:@"index.html"];
+    [secondSimulatedHTMLItemProvider registerDataRepresentationForTypeIdentifier:(NSString *)kUTTypeHTML withData:secondHTMLData];
 
     RetainPtr<DataInteractionSimulator> dataInteractionSimulator = adoptNS([[DataInteractionSimulator alloc] initWithWebView:webView.get()]);
     [dataInteractionSimulator setExternalItemProviders:@[ simulatedImageItemProvider.get(), firstSimulatedHTMLItemProvider.get(), secondSimulatedHTMLItemProvider.get() ]];
@@ -460,8 +421,6 @@ TEST(DataInteractionTests, ExternalSourceImageAndHTMLToUploadArea)
 
     NSString *outputValue = [webView stringByEvaluatingJavaScript:@"output.value"];
     EXPECT_WK_STREQ("image/jpeg, text/html, text/html", outputValue.UTF8String);
-
-    cleanUpDataInteractionTemporaryPath();
 }
 
 TEST(DataInteractionTests, RespectsExternalSourceFidelityRankings)
index 6bbe066..3436ec4 100644 (file)
@@ -23,7 +23,7 @@
  * THE POSSIBILITY OF SUCH DAMAGE.
  */
 
-#if 0
+#if ENABLE(DATA_INTERACTION)
 
 #import "TestWKWebView.h"
 #import <UIKit/UIItemProvider.h>
index 0266cdd..16c6537 100644 (file)
@@ -26,7 +26,7 @@
 #include "config.h"
 #include "DataInteractionSimulator.h"
 
-#if 0
+#if ENABLE(DATA_INTERACTION)
 
 #import "InstanceMethodSwizzler.h"
 #import "PlatformUtilities.h"