Title: [234809] trunk
Revision
234809
Author
[email protected]
Date
2018-08-13 11:33:30 -0700 (Mon, 13 Aug 2018)

Log Message

[iOS] Dragging a non-editable text selection into a plain text input inserts HTML markup
https://bugs.webkit.org/show_bug.cgi?id=188485
<rdar://problem/43168784>

Reviewed by Tim Horton.

Source/WebCore:

Before r223678, -typeIdentifiersToLoadForRegisteredTypeIdentifiers:, which is responsible for determining which
type identifiers to load upon performing a drop, returned the following when dropping a rich text selection onto
a textarea:

    "public.plain-text",
    "public.html"

After r223678, we now propagate a custom pasteboard data type when dragging, and the same list now looks like:

    "com.apple.WebKit.custom-pasteboard-data",
    "public.html",
    "public.plain-text"

Subsequently, logic in `-_preLoadedDataConformingToType:…` (responsible for mapping a requested type identifier
to data that has been loaded from an item provider) iterates through the aforementioned list of type identifiers
and selects the data of the first type identifier in the list that conforms to the requested type identifier.
However, this list of type identifiers is currently the result of `-[NSSet allObjects]`, which means that the
type identifiers in the list are in no particular order!

As such, this particular use case only worked by accident prior to r223678, and after that change, this latent
bug was surfaced. The patch here makes two adjustments to pasteboard handling on iOS to fix the bug.

Test: DragAndDropTests.NonEditableTextSelectionToTextarea

* platform/ios/PasteboardIOS.mm:
(WebCore::Pasteboard::read):

When reading plain text from the pasteboard, give "public.plain-text" priority over "public.text". This ensures
that we don't end up reading markup as "plain text" when there's already more relevant plain text data present
in the pasteboard.

* platform/ios/WebItemProviderPasteboard.mm:
(-[WebItemProviderPasteboard typeIdentifiersToLoadForRegisteredTypeIdentifiers:]):

Refactor existing logic to enforce a consistent ordering of type identifiers to load. First, we use
NSMutableOrderedSet instead of just an NSMutableSet to store type identifiers we've added. Secondly, move all
logic to insert type identifiers into this set to the end of the method, where we iterate over all of the type
identifiers in order and add each type identifier to the set if needed. This ensures that the order of resulting
types is from highest to lowest fidelity.

(-[WebItemProviderPasteboard doAfterLoadingProvidedContentIntoFileURLs:synchronousTimeout:]):
(-[WebItemProviderPasteboard typeIdentifiersToLoadForRegisteredTypeIdentfiers:]): Deleted.

Fix a typo in the method name.

Tools:

Add a new API test to verify that dropping selected non-editable rich text into a textarea inserts text as
expected, rather than markup.

It's somewhat interesting to note that this particular use case isn't exercised by any existing tests; the
closest test is DragAndDropTests.ContentEditableToTextarea, which drags a rich text selection from a
contenteditable element to a text area. However, due to logic in `DragController::concludeEditDrag` that handles
drag and drop across editable content differently than drag and drop from non-editable to editable content, the
bug that is fixed here doesn't surface in that existing test.

* TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj:
* TestWebKitAPI/Tests/WebKitCocoa/selected-text-and-textarea.html: Added.
* TestWebKitAPI/Tests/ios/DragAndDropTestsIOS.mm:
(TestWebKitAPI::TEST):

Modified Paths

Added Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (234808 => 234809)


--- trunk/Source/WebCore/ChangeLog	2018-08-13 18:19:03 UTC (rev 234808)
+++ trunk/Source/WebCore/ChangeLog	2018-08-13 18:33:30 UTC (rev 234809)
@@ -1,3 +1,56 @@
+2018-08-13  Wenson Hsieh  <[email protected]>
+
+        [iOS] Dragging a non-editable text selection into a plain text input inserts HTML markup
+        https://bugs.webkit.org/show_bug.cgi?id=188485
+        <rdar://problem/43168784>
+
+        Reviewed by Tim Horton.
+
+        Before r223678, -typeIdentifiersToLoadForRegisteredTypeIdentifiers:, which is responsible for determining which
+        type identifiers to load upon performing a drop, returned the following when dropping a rich text selection onto
+        a textarea:
+
+            "public.plain-text",
+            "public.html"
+
+        After r223678, we now propagate a custom pasteboard data type when dragging, and the same list now looks like:
+
+            "com.apple.WebKit.custom-pasteboard-data",
+            "public.html",
+            "public.plain-text"
+
+        Subsequently, logic in `-_preLoadedDataConformingToType:…` (responsible for mapping a requested type identifier
+        to data that has been loaded from an item provider) iterates through the aforementioned list of type identifiers
+        and selects the data of the first type identifier in the list that conforms to the requested type identifier.
+        However, this list of type identifiers is currently the result of `-[NSSet allObjects]`, which means that the
+        type identifiers in the list are in no particular order!
+
+        As such, this particular use case only worked by accident prior to r223678, and after that change, this latent
+        bug was surfaced. The patch here makes two adjustments to pasteboard handling on iOS to fix the bug.
+
+        Test: DragAndDropTests.NonEditableTextSelectionToTextarea
+
+        * platform/ios/PasteboardIOS.mm:
+        (WebCore::Pasteboard::read):
+
+        When reading plain text from the pasteboard, give "public.plain-text" priority over "public.text". This ensures
+        that we don't end up reading markup as "plain text" when there's already more relevant plain text data present
+        in the pasteboard.
+
+        * platform/ios/WebItemProviderPasteboard.mm:
+        (-[WebItemProviderPasteboard typeIdentifiersToLoadForRegisteredTypeIdentifiers:]):
+
+        Refactor existing logic to enforce a consistent ordering of type identifiers to load. First, we use
+        NSMutableOrderedSet instead of just an NSMutableSet to store type identifiers we've added. Secondly, move all
+        logic to insert type identifiers into this set to the end of the method, where we iterate over all of the type
+        identifiers in order and add each type identifier to the set if needed. This ensures that the order of resulting
+        types is from highest to lowest fidelity.
+
+        (-[WebItemProviderPasteboard doAfterLoadingProvidedContentIntoFileURLs:synchronousTimeout:]):
+        (-[WebItemProviderPasteboard typeIdentifiersToLoadForRegisteredTypeIdentfiers:]): Deleted.
+
+        Fix a typo in the method name.
+
 2018-08-13  Alex Christensen  <[email protected]>
 
         Use a 1-byte enum class for TextDirection

Modified: trunk/Source/WebCore/platform/ios/PasteboardIOS.mm (234808 => 234809)


--- trunk/Source/WebCore/platform/ios/PasteboardIOS.mm	2018-08-13 18:19:03 UTC (rev 234808)
+++ trunk/Source/WebCore/platform/ios/PasteboardIOS.mm	2018-08-13 18:33:30 UTC (rev 234809)
@@ -148,14 +148,14 @@
 {
     PasteboardStrategy& strategy = *platformStrategies()->pasteboardStrategy();
     text.text = strategy.readStringFromPasteboard(0, kUTTypeURL, m_pasteboardName);
-    if (!text.text.isNull() && !text.text.isEmpty()) {
+    if (!text.text.isEmpty()) {
         text.isURL = true;
         return;
     }
 
-    text.text = strategy.readStringFromPasteboard(0, kUTTypeText, m_pasteboardName);
+    text.text = strategy.readStringFromPasteboard(0, kUTTypePlainText, m_pasteboardName);
     if (text.text.isEmpty())
-        text.text = strategy.readStringFromPasteboard(0, kUTTypePlainText, m_pasteboardName);
+        text.text = strategy.readStringFromPasteboard(0, kUTTypeText, m_pasteboardName);
 
     text.isURL = false;
 }

Modified: trunk/Source/WebCore/platform/ios/WebItemProviderPasteboard.mm (234808 => 234809)


--- trunk/Source/WebCore/platform/ios/WebItemProviderPasteboard.mm	2018-08-13 18:19:03 UTC (rev 234808)
+++ trunk/Source/WebCore/platform/ios/WebItemProviderPasteboard.mm	2018-08-13 18:33:30 UTC (rev 234809)
@@ -685,13 +685,14 @@
     return [fileManager linkItemAtURL:url toURL:destination error:nil] ? destination : nil;
 }
 
-- (NSArray<NSString *> *)typeIdentifiersToLoadForRegisteredTypeIdentfiers:(NSArray<NSString *> *)registeredTypeIdentifiers
+- (NSArray<NSString *> *)typeIdentifiersToLoadForRegisteredTypeIdentifiers:(NSArray<NSString *> *)registeredTypeIdentifiers
 {
-    NSMutableSet *typesToLoad = [NSMutableSet set];
+    auto typesToLoad = adoptNS([[NSMutableOrderedSet alloc] init]);
+    NSString *highestFidelitySupportedType = nil;
     NSString *highestFidelityContentType = nil;
 
     BOOL containsFlatRTFD = [registeredTypeIdentifiers containsObject:(NSString *)kUTTypeFlatRTFD];
-    // First, we want to either load the highest fidelity supported type or the highest fidelity generic content type.
+    // First, search for the highest fidelity supported type or the highest fidelity generic content type.
     for (NSString *registeredTypeIdentifier in registeredTypeIdentifiers) {
         if (containsFlatRTFD && [registeredTypeIdentifier isEqualToString:(NSString *)kUTTypeRTFD]) {
             // In the case where attachments are enabled and we're accepting all types of content using attachment
@@ -703,34 +704,27 @@
             continue;
         }
 
-        if (typeConformsToTypes(registeredTypeIdentifier, _supportedTypeIdentifiers.get())) {
-            [typesToLoad addObject:registeredTypeIdentifier];
-            break;
-        }
+        if (!highestFidelitySupportedType && typeConformsToTypes(registeredTypeIdentifier, _supportedTypeIdentifiers.get()))
+            highestFidelitySupportedType = registeredTypeIdentifier;
 
         if (!highestFidelityContentType && UTTypeConformsTo((CFStringRef)registeredTypeIdentifier, kUTTypeContent))
             highestFidelityContentType = registeredTypeIdentifier;
     }
-    if (!typesToLoad.count && highestFidelityContentType)
-        [typesToLoad addObject:highestFidelityContentType];
 
     // For compatibility with DataTransfer APIs, additionally load web-exposed types. Since this is the only chance to
     // fault in any data at all, we need to load up front any information that the page may ask for later down the line.
     NSString *customPasteboardDataUTI = @(PasteboardCustomData::cocoaType());
     for (NSString *registeredTypeIdentifier in registeredTypeIdentifiers) {
-        if ([typesToLoad containsObject:registeredTypeIdentifier])
-            continue;
-        if ([registeredTypeIdentifier isEqualToString:customPasteboardDataUTI])
-            [typesToLoad addObject:customPasteboardDataUTI];
-        if (UTTypeConformsTo((CFStringRef)registeredTypeIdentifier, kUTTypeURL))
-            [typesToLoad addObject:(NSString *)kUTTypeURL];
-        if (UTTypeConformsTo((CFStringRef)registeredTypeIdentifier, kUTTypeHTML))
-            [typesToLoad addObject:(NSString *)kUTTypeHTML];
-        if (UTTypeConformsTo((CFStringRef)registeredTypeIdentifier, kUTTypePlainText))
-            [typesToLoad addObject:(NSString *)kUTTypePlainText];
+        if ([registeredTypeIdentifier isEqualToString:highestFidelityContentType]
+            || [registeredTypeIdentifier isEqualToString:highestFidelitySupportedType]
+            || [registeredTypeIdentifier isEqualToString:customPasteboardDataUTI]
+            || UTTypeConformsTo((CFStringRef)registeredTypeIdentifier, kUTTypeURL)
+            || UTTypeConformsTo((CFStringRef)registeredTypeIdentifier, kUTTypeHTML)
+            || UTTypeConformsTo((CFStringRef)registeredTypeIdentifier, kUTTypePlainText))
+            [typesToLoad addObject:registeredTypeIdentifier];
     }
 
-    return typesToLoad.allObjects;
+    return [typesToLoad array];
 }
 
 - (void)doAfterLoadingProvidedContentIntoFileURLs:(WebItemProviderFileLoadBlock)action
@@ -749,7 +743,7 @@
     BOOL foundAnyDataToLoad = NO;
     RetainPtr<WebItemProviderPasteboard> protectedSelf = self;
     for (NSItemProvider *itemProvider in _itemProviders.get()) {
-        NSArray<NSString *> *typeIdentifiersToLoad = [protectedSelf typeIdentifiersToLoadForRegisteredTypeIdentfiers:itemProvider.registeredTypeIdentifiers];
+        NSArray<NSString *> *typeIdentifiersToLoad = [protectedSelf typeIdentifiersToLoadForRegisteredTypeIdentifiers:itemProvider.registeredTypeIdentifiers];
         foundAnyDataToLoad |= typeIdentifiersToLoad.count;
         [loadResults addObject:[WebItemProviderLoadResult loadResultWithItemProvider:itemProvider typesToLoad:typeIdentifiersToLoad]];
     }

Modified: trunk/Tools/ChangeLog (234808 => 234809)


--- trunk/Tools/ChangeLog	2018-08-13 18:19:03 UTC (rev 234808)
+++ trunk/Tools/ChangeLog	2018-08-13 18:33:30 UTC (rev 234809)
@@ -1,3 +1,25 @@
+2018-08-13  Wenson Hsieh  <[email protected]>
+
+        [iOS] Dragging a non-editable text selection into a plain text input inserts HTML markup
+        https://bugs.webkit.org/show_bug.cgi?id=188485
+        <rdar://problem/43168784>
+
+        Reviewed by Tim Horton.
+
+        Add a new API test to verify that dropping selected non-editable rich text into a textarea inserts text as
+        expected, rather than markup.
+
+        It's somewhat interesting to note that this particular use case isn't exercised by any existing tests; the
+        closest test is DragAndDropTests.ContentEditableToTextarea, which drags a rich text selection from a
+        contenteditable element to a text area. However, due to logic in `DragController::concludeEditDrag` that handles
+        drag and drop across editable content differently than drag and drop from non-editable to editable content, the
+        bug that is fixed here doesn't surface in that existing test.
+
+        * TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj:
+        * TestWebKitAPI/Tests/WebKitCocoa/selected-text-and-textarea.html: Added.
+        * TestWebKitAPI/Tests/ios/DragAndDropTestsIOS.mm:
+        (TestWebKitAPI::TEST):
+
 2018-08-13  Alex Christensen  <[email protected]>
 
         Use a 1-byte enum class for TextDirection

Modified: trunk/Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj (234808 => 234809)


--- trunk/Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj	2018-08-13 18:19:03 UTC (rev 234808)
+++ trunk/Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj	2018-08-13 18:33:30 UTC (rev 234809)
@@ -839,6 +839,7 @@
 		F4D5E4E81F0C5D38008C1A49 /* dragstart-clear-selection.html in Copy Resources */ = {isa = PBXBuildFile; fileRef = F4D5E4E71F0C5D27008C1A49 /* dragstart-clear-selection.html */; };
 		F4D65DA81F5E4704009D8C27 /* selected-text-image-link-and-editable.html in Copy Resources */ = {isa = PBXBuildFile; fileRef = F4D65DA71F5E46C0009D8C27 /* selected-text-image-link-and-editable.html */; };
 		F4DEF6ED1E9B4DB60048EF61 /* image-in-link-and-input.html in Copy Resources */ = {isa = PBXBuildFile; fileRef = F4DEF6EC1E9B4D950048EF61 /* image-in-link-and-input.html */; };
+		F4E0A296211FC5FB00AF7C7F /* selected-text-and-textarea.html in Copy Resources */ = {isa = PBXBuildFile; fileRef = F4E0A295211FC5A300AF7C7F /* selected-text-and-textarea.html */; };
 		F4E3D80820F70BB9007B58C5 /* significant-text-milestone-article.html in Copy Resources */ = {isa = PBXBuildFile; fileRef = F4E3D80720F708E4007B58C5 /* significant-text-milestone-article.html */; };
 		F4F137921D9B683E002BEC57 /* large-video-test-now-playing.html in Copy Resources */ = {isa = PBXBuildFile; fileRef = F4F137911D9B6832002BEC57 /* large-video-test-now-playing.html */; };
 		F4F405BC1D4C0D1C007A9707 /* full-size-autoplaying-video-with-audio.html in Copy Resources */ = {isa = PBXBuildFile; fileRef = F4F405BA1D4C0CF8007A9707 /* full-size-autoplaying-video-with-audio.html */; };
@@ -921,9 +922,6 @@
 			dstPath = TestWebKitAPI.resources;
 			dstSubfolderSpec = 7;
 			files = (
-				CD57779C211CE91F001B371E /* audio-with-web-audio.html in Copy Resources */,
-				CD57779D211CE91F001B371E /* video-with-audio-and-web-audio.html in Copy Resources */,
-				CD577799211CE0E4001B371E /* web-audio-only.html in Copy Resources */,
 				1A9E52C913E65EF4006917F5 /* 18-characters.html in Copy Resources */,
 				379028B914FAC24C007E6B43 /* acceptsFirstMouse.html in Copy Resources */,
 				1C2B81871C8925A000A5529F /* Ahem.ttf in Copy Resources */,
@@ -940,6 +938,7 @@
 				7C9ED98B17A19F4B00E4DC33 /* attributedStringStrikethrough.html in Copy Resources */,
 				37137E4B21124D01002BEEA4 /* AttrStyle.html in Copy Resources */,
 				CD9E292E1C90C33F000BB800 /* audio-only.html in Copy Resources */,
+				CD57779C211CE91F001B371E /* audio-with-web-audio.html in Copy Resources */,
 				76E182DF154767E600F1FADD /* auto-submitting-form.html in Copy Resources */,
 				F41AB99F1EF4696B0083FA08 /* autofocus-contenteditable.html in Copy Resources */,
 				93CFA8671CEB9E38000565A8 /* autofocused-text-input.html in Copy Resources */,
@@ -1138,6 +1137,7 @@
 				A12DDC001E8373E700CF6CAE /* rendered-image-excluding-overflow.html in Copy Resources */,
 				F46849C01EEF5EF300B937FE /* rich-and-plain-text.html in Copy Resources */,
 				0F5651F91FCE513500310FBC /* scroll-to-anchor.html in Copy Resources */,
+				F4E0A296211FC5FB00AF7C7F /* selected-text-and-textarea.html in Copy Resources */,
 				F4D65DA81F5E4704009D8C27 /* selected-text-image-link-and-editable.html in Copy Resources */,
 				7A66BDB81EAF18D500CCC924 /* set-long-title.html in Copy Resources */,
 				CE6E81A420A933D500E2C80F /* set-timeout-function.html in Copy Resources */,
@@ -1172,6 +1172,7 @@
 				F41AB9AA1EF4696B0083FA08 /* textarea-to-input.html in Copy Resources */,
 				F4451C761EB8FD890020C5DA /* two-paragraph-contenteditable.html in Copy Resources */,
 				C540F784152E5A9A00A40C8C /* verboseMarkup.html in Copy Resources */,
+				CD57779D211CE91F001B371E /* video-with-audio-and-web-audio.html in Copy Resources */,
 				CDC8E4941BC6F10800594FEC /* video-with-audio.html in Copy Resources */,
 				CDC8E4951BC6F10800594FEC /* video-with-audio.mp4 in Copy Resources */,
 				CD321B041E3A85FA00EB21C8 /* video-with-muted-audio-and-webaudio.html in Copy Resources */,
@@ -1180,6 +1181,7 @@
 				CDC8E4961BC6F10800594FEC /* video-without-audio.html in Copy Resources */,
 				CDC8E4971BC6F10800594FEC /* video-without-audio.mp4 in Copy Resources */,
 				07CD32F82065B72B0064A4BE /* video.html in Copy Resources */,
+				CD577799211CE0E4001B371E /* web-audio-only.html in Copy Resources */,
 				1C2B81861C89259D00A5529F /* webfont.html in Copy Resources */,
 				51714EB41CF8C78C004723C4 /* WebProcessKillIDBCleanup-1.html in Copy Resources */,
 				51714EB51CF8C78C004723C4 /* WebProcessKillIDBCleanup-2.html in Copy Resources */,
@@ -2074,6 +2076,7 @@
 		F4D5E4E71F0C5D27008C1A49 /* dragstart-clear-selection.html */ = {isa = PBXFileReference; lastKnownFileType = text.html; path = "dragstart-clear-selection.html"; sourceTree = "<group>"; };
 		F4D65DA71F5E46C0009D8C27 /* selected-text-image-link-and-editable.html */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.html; path = "selected-text-image-link-and-editable.html"; sourceTree = "<group>"; };
 		F4DEF6EC1E9B4D950048EF61 /* image-in-link-and-input.html */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.html; path = "image-in-link-and-input.html"; sourceTree = "<group>"; };
+		F4E0A295211FC5A300AF7C7F /* selected-text-and-textarea.html */ = {isa = PBXFileReference; lastKnownFileType = text.html; path = "selected-text-and-textarea.html"; sourceTree = "<group>"; };
 		F4E3D80720F708E4007B58C5 /* significant-text-milestone-article.html */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.html; path = "significant-text-milestone-article.html"; sourceTree = "<group>"; };
 		F4F137911D9B6832002BEC57 /* large-video-test-now-playing.html */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.html; path = "large-video-test-now-playing.html"; sourceTree = "<group>"; };
 		F4F405BA1D4C0CF8007A9707 /* full-size-autoplaying-video-with-audio.html */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.html; path = "full-size-autoplaying-video-with-audio.html"; sourceTree = "<group>"; };
@@ -2587,6 +2590,7 @@
 				5C9E59401D3EB1DE00E3C62E /* ApplicationCache.db-wal */,
 				F4856CA21E6498A8009D7EE7 /* attachment-element.html */,
 				3760C4F221124BD000233ACC /* AttrStyle.html */,
+				CD57779A211CE6B7001B371E /* audio-with-web-audio.html */,
 				F41AB9981EF4692C0083FA08 /* autofocus-contenteditable.html */,
 				93CFA8661CEB9DE1000565A8 /* autofocused-text-input.html */,
 				2E14A5281D3FE8B80010F35B /* autoplaying-video-with-audio.html */,
@@ -2708,6 +2712,7 @@
 				F41AB99A1EF4692C0083FA08 /* prevent-start.html */,
 				A12DDBFF1E8373C100CF6CAE /* rendered-image-excluding-overflow.html */,
 				F46849BF1EEF5EDC00B937FE /* rich-and-plain-text.html */,
+				F4E0A295211FC5A300AF7C7F /* selected-text-and-textarea.html */,
 				F4D65DA71F5E46C0009D8C27 /* selected-text-image-link-and-editable.html */,
 				F4E3D80720F708E4007B58C5 /* significant-text-milestone-article.html */,
 				F4FC077620F0108100CA043C /* significant-text-milestone.html */,
@@ -2724,13 +2729,12 @@
 				F44C7A0420FAAE320014478C /* text-with-deferred-script.html */,
 				F41AB9951EF4692C0083FA08 /* textarea-to-input.html */,
 				F4451C751EB8FD7C0020C5DA /* two-paragraph-contenteditable.html */,
+				CD57779B211CE6CE001B371E /* video-with-audio-and-web-audio.html */,
+				CD577798211CDE8F001B371E /* web-audio-only.html */,
 				51714EB21CF8C761004723C4 /* WebProcessKillIDBCleanup-1.html */,
 				51714EB31CF8C761004723C4 /* WebProcessKillIDBCleanup-2.html */,
 				5120C83B1E674E350025B250 /* WebsiteDataStoreCustomPaths.html */,
 				2E131C171D83A97E001BA36C /* wide-autoplaying-video-with-audio.html */,
-				CD577798211CDE8F001B371E /* web-audio-only.html */,
-				CD57779A211CE6B7001B371E /* audio-with-web-audio.html */,
-				CD57779B211CE6CE001B371E /* video-with-audio-and-web-audio.html */,
 			);
 			name = Resources;
 			sourceTree = "<group>";
@@ -3748,7 +3752,6 @@
 				CD78E11D1DB7EA660014A2DE /* FullscreenDelegate.mm in Sources */,
 				7C83E0BD1D0A650C00FEBCF3 /* FullscreenTopContentInset.mm in Sources */,
 				CDBFCC451A9FF45300A7B691 /* FullscreenZoomInitialFrame.mm in Sources */,
-				CD227E44211A4D5D00D285AF /* PreferredAudioBufferSize.mm in Sources */,
 				83DB79691EF63B3C00BFA5E5 /* Function.cpp in Sources */,
 				7CCE7EF81A411AE600447C4C /* Geolocation.cpp in Sources */,
 				631EFFF61E7B5E8D00D2EBB8 /* Geolocation.mm in Sources */,
@@ -3867,6 +3870,7 @@
 				7CCE7EA71A411A1300447C4C /* PlatformWebViewMac.mm in Sources */,
 				83BAEE8D1EF4625500DDE894 /* PluginLoadClientPolicies.mm in Sources */,
 				7CCE7F261A411AF600447C4C /* Preferences.mm in Sources */,
+				CD227E44211A4D5D00D285AF /* PreferredAudioBufferSize.mm in Sources */,
 				7C1AF7951E8DCBAB002645B9 /* PrepareForMoveToWindow.mm in Sources */,
 				7CCE7F0B1A411AE600447C4C /* PreventEmptyUserAgent.cpp in Sources */,
 				7CCE7F2C1A411B1000447C4C /* PreventImageLoadWithAutoResizing.mm in Sources */,

Added: trunk/Tools/TestWebKitAPI/Tests/WebKitCocoa/selected-text-and-textarea.html (0 => 234809)


--- trunk/Tools/TestWebKitAPI/Tests/WebKitCocoa/selected-text-and-textarea.html	                        (rev 0)
+++ trunk/Tools/TestWebKitAPI/Tests/WebKitCocoa/selected-text-and-textarea.html	2018-08-13 18:33:30 UTC (rev 234809)
@@ -0,0 +1,29 @@
+<head>
+<meta name="viewport" content="width=device-width">
+<style>
+body {
+    width: 100%;
+    height: 100%;
+    margin: 0;
+}
+
+#source, #destination {
+    width: 100%;
+    height: 200px;
+    font-size: 200px;
+    white-space: nowrap;
+}
+
+#destination {
+    border: black 1px solid;
+}
+</style>
+</head>
+<body>
+<div id="source">Hello world</div>
+<textarea id="destination"></textarea>
+<script>
+let text = source.childNodes[0];
+getSelection().setBaseAndExtent(text, 0, text, text.data.length);
+</script>
+</body>

Modified: trunk/Tools/TestWebKitAPI/Tests/ios/DragAndDropTestsIOS.mm (234808 => 234809)


--- trunk/Tools/TestWebKitAPI/Tests/ios/DragAndDropTestsIOS.mm	2018-08-13 18:19:03 UTC (rev 234808)
+++ trunk/Tools/TestWebKitAPI/Tests/ios/DragAndDropTestsIOS.mm	2018-08-13 18:33:30 UTC (rev 234809)
@@ -376,6 +376,17 @@
     checkRichTextTypePrecedesPlainTextType(simulator.get());
 }
 
+TEST(DragAndDropTests, NonEditableTextSelectionToTextarea)
+{
+    auto webView = adoptNS([[TestWKWebView alloc] initWithFrame:CGRectMake(0, 0, 320, 500)]);
+    auto simulator = adoptNS([[DragAndDropSimulator alloc] initWithWebView:webView.get()]);
+
+    [webView synchronouslyLoadTestPageNamed:@"selected-text-and-textarea"];
+    [simulator runFrom:CGPointMake(160, 100) to:CGPointMake(160, 300)];
+
+    EXPECT_WK_STREQ("Hello world", [webView stringByEvaluatingJavaScript:@"destination.value"]);
+}
+
 TEST(DragAndDropTests, ContentEditableMoveParagraphs)
 {
     auto webView = adoptNS([[TestWKWebView alloc] initWithFrame:CGRectMake(0, 0, 320, 500)]);
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to