Skip to content

Commit b1bab91

Browse files
Fix and re-enable data interaction unit tests
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: http://svn.webkit.org/repository/webkit/trunk@215962 268f45cc-cd09-0410-ab3c-d52691b4dbfc
1 parent fc7924d commit b1bab91

File tree

9 files changed

+110
-84
lines changed

9 files changed

+110
-84
lines changed

Source/WebCore/ChangeLog

+45
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,48 @@
1+
2017-04-28 Wenson Hsieh <[email protected]>
2+
3+
Fix and re-enable data interaction unit tests
4+
https://bugs.webkit.org/show_bug.cgi?id=171446
5+
<rdar://problem/31820646>
6+
7+
Reviewed by Tim Horton.
8+
9+
Three small tweaks to get all data interaction tests passing again (changes detailed below).
10+
Fixes a failing unit test: DataInteractionTests.RespectsExternalSourceFidelityRankings.
11+
12+
* page/mac/DragControllerMac.mm:
13+
14+
When dropping in a plain text editable area, don't consider kUTTypeText to be a UTI supported by the destination.
15+
This is because doing so would cause rich text UTIs, such as kUTTypeHTML, to match, so that the plain text area
16+
would report HTML as a preferred UTI type to load when dropping rich content over it. What we want to check for
17+
conformance here is really kUTTypePlainText.
18+
19+
(WebCore::DragController::updatePreferredTypeIdentifiersForDragHandlingMethod):
20+
* platform/Pasteboard.h:
21+
* platform/ios/PasteboardIOS.mm:
22+
23+
The default Pasteboard constructor no longer makes a sync call to the UI process to get the change count.
24+
Instead, we introduce a new constructor that takes and sets the change count. This default constructor was used
25+
from three places: Pasteboard::createForCopyAndPaste, Pasteboard::createPrivate and StaticPasteboard::create.
26+
27+
The first two call sites have been refactored to first fetch the change count from the UI process and then pass
28+
it in to the constructor.
29+
30+
(WebCore::changeCountForPasteboard):
31+
(WebCore::Pasteboard::Pasteboard):
32+
(WebCore::Pasteboard::createForCopyAndPaste):
33+
(WebCore::Pasteboard::createPrivate):
34+
(WebCore::Pasteboard::readString):
35+
(WebCore::Pasteboard::types):
36+
* platform/mac/DragDataMac.mm:
37+
(WebCore::typeIsAppropriateForSupportedTypes):
38+
(WebCore::DragData::updatePreferredTypeIdentifiers):
39+
40+
Remove the two-pass heuristic. Instead, we should follow this policy: "select the highest fidelity UTI that
41+
conforms to one of the destination's supported types".
42+
43+
* platform/mac/PasteboardMac.mm:
44+
(WebCore::Pasteboard::Pasteboard):
45+
146
2017-04-28 Dean Jackson <[email protected]>
247

348
App crashing: Dispatch queue: com.apple.root.user-interactive-qos / vBoxConvolve / WebCore::FEGaussianBlur::platformApplySoftware()

Source/WebCore/page/mac/DragControllerMac.mm

+1-2
Original file line numberDiff line numberDiff line change
@@ -113,8 +113,7 @@
113113
break;
114114
case DragHandlingMethod::EditPlainText:
115115
supportedTypes.append(kUTTypeURL);
116-
supportedTypes.append(kUTTypeText);
117-
supportedTypes.append(kUTTypeUTF8PlainText);
116+
supportedTypes.append(kUTTypePlainText);
118117
break;
119118
case DragHandlingMethod::EditRichText:
120119
for (NSString *type in Pasteboard::supportedPasteboardTypes())

Source/WebCore/platform/Pasteboard.h

+2
Original file line numberDiff line numberDiff line change
@@ -197,6 +197,8 @@ class Pasteboard {
197197
#endif
198198

199199
#if PLATFORM(IOS)
200+
explicit Pasteboard(long changeCount);
201+
200202
static NSArray* supportedPasteboardTypes();
201203
static String resourceMIMEType(const NSString *mimeType);
202204
#endif

Source/WebCore/platform/ios/PasteboardIOS.mm

+15-5
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,11 @@ - (BOOL)containsAttachments;
6464

6565
namespace WebCore {
6666

67+
static long changeCountForPasteboard(const String& pasteboardName = { })
68+
{
69+
return platformStrategies()->pasteboardStrategy()->changeCount(pasteboardName);
70+
}
71+
6772
// FIXME: Does this need to be declared in the header file?
6873
WEBCORE_EXPORT NSString *WebArchivePboardType = @"Apple Web Archive pasteboard type";
6974

@@ -86,7 +91,12 @@ - (BOOL)containsAttachments;
8691
}
8792

8893
Pasteboard::Pasteboard()
89-
: m_changeCount(platformStrategies()->pasteboardStrategy()->changeCount(m_pasteboardName))
94+
: m_changeCount(0)
95+
{
96+
}
97+
98+
Pasteboard::Pasteboard(long changeCount)
99+
: m_changeCount(changeCount)
90100
{
91101
}
92102

@@ -96,12 +106,12 @@ - (BOOL)containsAttachments;
96106

97107
std::unique_ptr<Pasteboard> Pasteboard::createForCopyAndPaste()
98108
{
99-
return std::make_unique<Pasteboard>();
109+
return std::make_unique<Pasteboard>(changeCountForPasteboard());
100110
}
101111

102112
std::unique_ptr<Pasteboard> Pasteboard::createPrivate()
103113
{
104-
return std::make_unique<Pasteboard>();
114+
return std::make_unique<Pasteboard>(changeCountForPasteboard());
105115
}
106116

107117
void Pasteboard::write(const PasteboardWebContent& content)
@@ -352,7 +362,7 @@ static String utiTypeFromCocoaType(NSString *type)
352362

353363
// Enforce changeCount ourselves for security. We check after reading instead of before to be
354364
// sure it doesn't change between our testing the change count and accessing the data.
355-
if (cocoaValue && m_changeCount == platformStrategies()->pasteboardStrategy()->changeCount(m_pasteboardName))
365+
if (cocoaValue && m_changeCount == changeCountForPasteboard(m_pasteboardName))
356366
return cocoaValue;
357367

358368
return String();
@@ -393,7 +403,7 @@ static void addHTMLClipboardTypesForCocoaType(ListHashSet<String>& resultTypes,
393403

394404
// Enforce changeCount ourselves for security. We check after reading instead of before to be
395405
// sure it doesn't change between our testing the change count and accessing the data.
396-
if (m_changeCount != platformStrategies()->pasteboardStrategy()->changeCount(m_pasteboardName))
406+
if (m_changeCount != changeCountForPasteboard(m_pasteboardName))
397407
return Vector<String>();
398408

399409
ListHashSet<String> result;

Source/WebCore/platform/mac/DragDataMac.mm

+14-23
Original file line numberDiff line numberDiff line change
@@ -294,13 +294,18 @@ static inline String tiffPasteboardType()
294294

295295
#if ENABLE(DATA_INTERACTION)
296296

297-
void DragData::updatePreferredTypeIdentifiers(const Vector<String>& supportedTypesVector) const
297+
static bool typeIsAppropriateForSupportedTypes(const String& type, const Vector<String>& supportedTypes)
298298
{
299-
NSMutableSet *supportedTypes = [NSMutableSet setWithCapacity:supportedTypesVector.size()];
300-
for (auto& supportedType : supportedTypesVector)
301-
[supportedTypes addObject:supportedType];
299+
CFStringRef cfType = type.createCFString().autorelease();
300+
for (auto supportedType : supportedTypes) {
301+
if (UTTypeConformsTo(cfType, supportedType.createCFString().get()))
302+
return true;
303+
}
304+
return false;
305+
}
302306

303-
// Match UIItemProvider behavior by performing two-pass UTI matching.
307+
void DragData::updatePreferredTypeIdentifiers(const Vector<String>& supportedTypes) const
308+
{
304309
Vector<String> bestTypeIdentifiers;
305310
auto& strategy = *platformStrategies()->pasteboardStrategy();
306311
uint64_t itemCount = strategy.getPasteboardItemsCount(m_pasteboardName);
@@ -309,26 +314,12 @@ static inline String tiffPasteboardType()
309314
strategy.getTypesByFidelityForItemAtIndex(typeIdentifiers, itemIndex, m_pasteboardName);
310315

311316
String bestTypeIdentifier = emptyString();
312-
// In the first pass, look for the highest fidelity UTI that exactly matches one of the supported UTIs.
313317
for (auto& type : typeIdentifiers) {
314-
if ([supportedTypes containsObject:(NSString *)type]) {
315-
bestTypeIdentifier = type;
316-
break;
317-
}
318-
}
318+
if (!typeIsAppropriateForSupportedTypes(type, supportedTypes))
319+
continue;
319320

320-
// In the second pass, look for the highest fidelity UTI that conforms to one of the supported UTIs.
321-
if (bestTypeIdentifier.isEmpty()) {
322-
for (auto& type : typeIdentifiers) {
323-
for (NSString *supportedType in supportedTypes) {
324-
if (UTTypeConformsTo(type.createCFString().autorelease(), (CFStringRef)supportedType)) {
325-
bestTypeIdentifier = type;
326-
break;
327-
}
328-
}
329-
if (!bestTypeIdentifier.isEmpty())
330-
break;
331-
}
321+
bestTypeIdentifier = type;
322+
break;
332323
}
333324
bestTypeIdentifiers.append(bestTypeIdentifier);
334325
}

Tools/ChangeLog

+20
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,23 @@
1+
2017-04-28 Wenson Hsieh <[email protected]>
2+
3+
Fix and re-enable data interaction unit tests
4+
https://bugs.webkit.org/show_bug.cgi?id=171446
5+
<rdar://problem/31820646>
6+
7+
Reviewed by Tim Horton.
8+
9+
Enables all DataInteractionTests, and adjusts file upload tests to no longer write to a temporary file before
10+
registering with the UIItemProvider, and instead just register data directly via
11+
-registerDataRepresentationForTypeIdentifier:visibility:loadHandler:.
12+
13+
* TestWebKitAPI/Tests/ios/DataInteractionTests.mm:
14+
(TestWebKitAPI::TEST):
15+
(temporaryURLForDataInteractionFileLoad): Deleted.
16+
(cleanUpDataInteractionTemporaryPath): Deleted.
17+
(-[UIItemProvider registerFileRepresentationForTypeIdentifier:withData:filename:]): Deleted.
18+
* TestWebKitAPI/ios/DataInteractionSimulator.h:
19+
* TestWebKitAPI/ios/DataInteractionSimulator.mm:
20+
121
2017-04-28 Brady Eidson <[email protected]>
222

323
Teach the DatabaseProcess to be fully SessionID aware

Tools/TestWebKitAPI/Tests/ios/DataInteractionTests.mm

+11-52
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525

2626
#include "config.h"
2727

28-
#if 0
28+
#if ENABLE(DATA_INTERACTION)
2929

3030
#import "DataInteractionSimulator.h"
3131
#import "PlatformUtilities.h"
@@ -48,38 +48,8 @@
4848
return [UIImage imageNamed:@"TestWebKitAPI.resources/icon.png"];
4949
}
5050

51-
static NSURL *temporaryURLForDataInteractionFileLoad(NSString *temporaryFileName)
52-
{
53-
NSString *temporaryDirectoryPath = [NSTemporaryDirectory() stringByAppendingPathComponent:@"data-interaction"];
54-
if (![[NSFileManager defaultManager] fileExistsAtPath:temporaryDirectoryPath])
55-
[[NSFileManager defaultManager] createDirectoryAtPath:temporaryDirectoryPath withIntermediateDirectories:YES attributes:nil error:nil];
56-
return [NSURL fileURLWithPath:[temporaryDirectoryPath stringByAppendingPathComponent:temporaryFileName]];
57-
}
58-
59-
static void cleanUpDataInteractionTemporaryPath()
60-
{
61-
NSArray *temporaryDirectoryContents = [[NSFileManager defaultManager] contentsOfDirectoryAtURL:[NSURL fileURLWithPath:NSTemporaryDirectory()] includingPropertiesForKeys:nil options:0 error:nil];
62-
for (NSURL *url in temporaryDirectoryContents) {
63-
if ([url.lastPathComponent rangeOfString:@"data-interaction"].location != NSNotFound)
64-
[[NSFileManager defaultManager] removeItemAtURL:url error:nil];
65-
}
66-
}
67-
6851
@implementation UIItemProvider (DataInteractionTests)
6952

70-
- (void)registerFileRepresentationForTypeIdentifier:(NSString *)typeIdentifier withData:(NSData *)data filename:(NSString *)filename
71-
{
72-
RetainPtr<NSData> retainedData = data;
73-
RetainPtr<NSURL> retainedTemporaryURL = temporaryURLForDataInteractionFileLoad(filename);
74-
[self registerFileRepresentationForTypeIdentifier:typeIdentifier fileOptions:0 visibility:NSItemProviderRepresentationVisibilityAll loadHandler: [retainedData, retainedTemporaryURL] (FileLoadCompletionBlock block) -> NSProgress * {
75-
[retainedData writeToFile:[retainedTemporaryURL path] atomically:YES];
76-
dispatch_async(dispatch_get_main_queue(), [retainedTemporaryURL, capturedBlock = makeBlockPtr(block)] {
77-
capturedBlock(retainedTemporaryURL.get(), NO, nil);
78-
});
79-
return nil;
80-
}];
81-
}
82-
8353
- (void)registerDataRepresentationForTypeIdentifier:(NSString *)typeIdentifier withData:(NSData *)data
8454
{
8555
RetainPtr<NSData> retainedData = data;
@@ -342,14 +312,13 @@ static void checkTypeIdentifierPrecedesOtherTypeIdentifier(DataInteractionSimula
342312

343313
RetainPtr<UIItemProvider> simulatedJSONItemProvider = adoptNS([[UIItemProvider alloc] init]);
344314
NSData *jsonData = [@"{ \"foo\": \"bar\", \"bar\": \"baz\" }" dataUsingEncoding:NSUTF8StringEncoding];
345-
[simulatedJSONItemProvider registerFileRepresentationForTypeIdentifier:(NSString *)kUTTypeJSON withData:jsonData filename:@"data.json"];
315+
[simulatedJSONItemProvider registerDataRepresentationForTypeIdentifier:(NSString *)kUTTypeJSON withData:jsonData];
346316

347317
RetainPtr<DataInteractionSimulator> dataInteractionSimulator = adoptNS([[DataInteractionSimulator alloc] initWithWebView:webView.get()]);
348318
[dataInteractionSimulator setExternalItemProviders:@[ simulatedJSONItemProvider.get() ]];
349319
[dataInteractionSimulator runFrom:CGPointMake(200, 100) to:CGPointMake(100, 100)];
350320

351321
EXPECT_WK_STREQ("application/json", [webView stringByEvaluatingJavaScript:@"output.value"]);
352-
cleanUpDataInteractionTemporaryPath();
353322
}
354323

355324
TEST(DataInteractionTests, ExternalSourceImageToFileInput)
@@ -359,16 +328,14 @@ static void checkTypeIdentifierPrecedesOtherTypeIdentifier(DataInteractionSimula
359328

360329
RetainPtr<UIItemProvider> simulatedImageItemProvider = adoptNS([[UIItemProvider alloc] init]);
361330
NSData *imageData = UIImageJPEGRepresentation(testIconImage(), 0.5);
362-
[simulatedImageItemProvider registerFileRepresentationForTypeIdentifier:(NSString *)kUTTypeJPEG withData:imageData filename:@"image.png"];
331+
[simulatedImageItemProvider registerDataRepresentationForTypeIdentifier:(NSString *)kUTTypeJPEG withData:imageData];
363332

364333
RetainPtr<DataInteractionSimulator> dataInteractionSimulator = adoptNS([[DataInteractionSimulator alloc] initWithWebView:webView.get()]);
365334
[dataInteractionSimulator setExternalItemProviders:@[ simulatedImageItemProvider.get() ]];
366335
[dataInteractionSimulator runFrom:CGPointMake(200, 100) to:CGPointMake(100, 100)];
367336

368337
NSString *outputValue = [webView stringByEvaluatingJavaScript:@"output.value"];
369338
EXPECT_WK_STREQ("image/jpeg", outputValue.UTF8String);
370-
371-
cleanUpDataInteractionTemporaryPath();
372339
}
373340

374341
TEST(DataInteractionTests, ExternalSourceHTMLToUploadArea)
@@ -378,16 +345,14 @@ static void checkTypeIdentifierPrecedesOtherTypeIdentifier(DataInteractionSimula
378345

379346
RetainPtr<UIItemProvider> simulatedHTMLItemProvider = adoptNS([[UIItemProvider alloc] init]);
380347
NSData *htmlData = [@"<body contenteditable></body>" dataUsingEncoding:NSUTF8StringEncoding];
381-
[simulatedHTMLItemProvider registerFileRepresentationForTypeIdentifier:(NSString *)kUTTypeHTML withData:htmlData filename:@"index.html"];
348+
[simulatedHTMLItemProvider registerDataRepresentationForTypeIdentifier:(NSString *)kUTTypeHTML withData:htmlData];
382349

383350
RetainPtr<DataInteractionSimulator> dataInteractionSimulator = adoptNS([[DataInteractionSimulator alloc] initWithWebView:webView.get()]);
384351
[dataInteractionSimulator setExternalItemProviders:@[ simulatedHTMLItemProvider.get() ]];
385352
[dataInteractionSimulator runFrom:CGPointMake(200, 300) to:CGPointMake(100, 300)];
386353

387354
NSString *outputValue = [webView stringByEvaluatingJavaScript:@"output.value"];
388355
EXPECT_WK_STREQ("text/html", outputValue.UTF8String);
389-
390-
cleanUpDataInteractionTemporaryPath();
391356
}
392357

393358
TEST(DataInteractionTests, ExternalSourceImageAndHTMLToSingleFileInput)
@@ -397,20 +362,18 @@ static void checkTypeIdentifierPrecedesOtherTypeIdentifier(DataInteractionSimula
397362

398363
RetainPtr<UIItemProvider> simulatedImageItemProvider = adoptNS([[UIItemProvider alloc] init]);
399364
NSData *imageData = UIImageJPEGRepresentation(testIconImage(), 0.5);
400-
[simulatedImageItemProvider registerFileRepresentationForTypeIdentifier:(NSString *)kUTTypeJPEG withData:imageData filename:@"image.png"];
365+
[simulatedImageItemProvider registerDataRepresentationForTypeIdentifier:(NSString *)kUTTypeJPEG withData:imageData];
401366

402367
RetainPtr<UIItemProvider> simulatedHTMLItemProvider = adoptNS([[UIItemProvider alloc] init]);
403368
NSData *htmlData = [@"<body contenteditable></body>" dataUsingEncoding:NSUTF8StringEncoding];
404-
[simulatedHTMLItemProvider registerFileRepresentationForTypeIdentifier:(NSString *)kUTTypeHTML withData:htmlData filename:@"index.html"];
369+
[simulatedHTMLItemProvider registerDataRepresentationForTypeIdentifier:(NSString *)kUTTypeHTML withData:htmlData];
405370

406371
RetainPtr<DataInteractionSimulator> dataInteractionSimulator = adoptNS([[DataInteractionSimulator alloc] initWithWebView:webView.get()]);
407372
[dataInteractionSimulator setExternalItemProviders:@[ simulatedHTMLItemProvider.get(), simulatedImageItemProvider.get() ]];
408373
[dataInteractionSimulator runFrom:CGPointMake(200, 100) to:CGPointMake(100, 100)];
409374

410375
NSString *outputValue = [webView stringByEvaluatingJavaScript:@"output.value"];
411376
EXPECT_WK_STREQ("", outputValue.UTF8String);
412-
413-
cleanUpDataInteractionTemporaryPath();
414377
}
415378

416379
TEST(DataInteractionTests, ExternalSourceImageAndHTMLToMultipleFileInput)
@@ -421,20 +384,18 @@ static void checkTypeIdentifierPrecedesOtherTypeIdentifier(DataInteractionSimula
421384

422385
RetainPtr<UIItemProvider> simulatedImageItemProvider = adoptNS([[UIItemProvider alloc] init]);
423386
NSData *imageData = UIImageJPEGRepresentation(testIconImage(), 0.5);
424-
[simulatedImageItemProvider registerFileRepresentationForTypeIdentifier:(NSString *)kUTTypeJPEG withData:imageData filename:@"image.png"];
387+
[simulatedImageItemProvider registerDataRepresentationForTypeIdentifier:(NSString *)kUTTypeJPEG withData:imageData];
425388

426389
RetainPtr<UIItemProvider> simulatedHTMLItemProvider = adoptNS([[UIItemProvider alloc] init]);
427390
NSData *htmlData = [@"<body contenteditable></body>" dataUsingEncoding:NSUTF8StringEncoding];
428-
[simulatedHTMLItemProvider registerFileRepresentationForTypeIdentifier:(NSString *)kUTTypeHTML withData:htmlData filename:@"index.html"];
391+
[simulatedHTMLItemProvider registerDataRepresentationForTypeIdentifier:(NSString *)kUTTypeHTML withData:htmlData];
429392

430393
RetainPtr<DataInteractionSimulator> dataInteractionSimulator = adoptNS([[DataInteractionSimulator alloc] initWithWebView:webView.get()]);
431394
[dataInteractionSimulator setExternalItemProviders:@[ simulatedHTMLItemProvider.get(), simulatedImageItemProvider.get() ]];
432395
[dataInteractionSimulator runFrom:CGPointMake(200, 100) to:CGPointMake(100, 100)];
433396

434397
NSString *outputValue = [webView stringByEvaluatingJavaScript:@"output.value"];
435398
EXPECT_WK_STREQ("image/jpeg, text/html", outputValue.UTF8String);
436-
437-
cleanUpDataInteractionTemporaryPath();
438399
}
439400

440401
TEST(DataInteractionTests, ExternalSourceImageAndHTMLToUploadArea)
@@ -444,24 +405,22 @@ static void checkTypeIdentifierPrecedesOtherTypeIdentifier(DataInteractionSimula
444405

445406
RetainPtr<UIItemProvider> simulatedImageItemProvider = adoptNS([[UIItemProvider alloc] init]);
446407
NSData *imageData = UIImageJPEGRepresentation(testIconImage(), 0.5);
447-
[simulatedImageItemProvider registerFileRepresentationForTypeIdentifier:(NSString *)kUTTypeJPEG withData:imageData filename:@"image.png"];
408+
[simulatedImageItemProvider registerDataRepresentationForTypeIdentifier:(NSString *)kUTTypeJPEG withData:imageData];
448409

449410
RetainPtr<UIItemProvider> firstSimulatedHTMLItemProvider = adoptNS([[UIItemProvider alloc] init]);
450411
NSData *firstHTMLData = [@"<body contenteditable></body>" dataUsingEncoding:NSUTF8StringEncoding];
451-
[firstSimulatedHTMLItemProvider registerFileRepresentationForTypeIdentifier:(NSString *)kUTTypeHTML withData:firstHTMLData filename:@"index.html"];
412+
[firstSimulatedHTMLItemProvider registerDataRepresentationForTypeIdentifier:(NSString *)kUTTypeHTML withData:firstHTMLData];
452413

453414
RetainPtr<UIItemProvider> secondSimulatedHTMLItemProvider = adoptNS([[UIItemProvider alloc] init]);
454415
NSData *secondHTMLData = [@"<html><body>hello world</body></html>" dataUsingEncoding:NSUTF8StringEncoding];
455-
[secondSimulatedHTMLItemProvider registerFileRepresentationForTypeIdentifier:(NSString *)kUTTypeHTML withData:secondHTMLData filename:@"index.html"];
416+
[secondSimulatedHTMLItemProvider registerDataRepresentationForTypeIdentifier:(NSString *)kUTTypeHTML withData:secondHTMLData];
456417

457418
RetainPtr<DataInteractionSimulator> dataInteractionSimulator = adoptNS([[DataInteractionSimulator alloc] initWithWebView:webView.get()]);
458419
[dataInteractionSimulator setExternalItemProviders:@[ simulatedImageItemProvider.get(), firstSimulatedHTMLItemProvider.get(), secondSimulatedHTMLItemProvider.get() ]];
459420
[dataInteractionSimulator runFrom:CGPointMake(200, 300) to:CGPointMake(100, 300)];
460421

461422
NSString *outputValue = [webView stringByEvaluatingJavaScript:@"output.value"];
462423
EXPECT_WK_STREQ("image/jpeg, text/html, text/html", outputValue.UTF8String);
463-
464-
cleanUpDataInteractionTemporaryPath();
465424
}
466425

467426
TEST(DataInteractionTests, RespectsExternalSourceFidelityRankings)

Tools/TestWebKitAPI/ios/DataInteractionSimulator.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
* THE POSSIBILITY OF SUCH DAMAGE.
2424
*/
2525

26-
#if 0
26+
#if ENABLE(DATA_INTERACTION)
2727

2828
#import "TestWKWebView.h"
2929
#import <UIKit/UIItemProvider.h>

0 commit comments

Comments
 (0)