Bug 178016

Summary: DataTransfer.items does not contain items for custom types supplied via add or setData
Product: WebKit Reporter: Wenson Hsieh <wenson_hsieh>
Component: HTML EditingAssignee: Wenson Hsieh <wenson_hsieh>
Status: RESOLVED FIXED    
Severity: Normal CC: buildbot, cdumez, commit-queue, darin, dbates, esprehn+autocc, kangil.han, rniwa, webkit-bug-importer, wenson_hsieh
Priority: P2 Keywords: InRadar
Version: WebKit Nightly Build   
Hardware: Unspecified   
OS: Unspecified   
Attachments:
Description Flags
Patch
darin: review+
Wait for EWS
buildbot: commit-queue-
Archive of layout-test-results from ews102 for mac-elcapitan
none
Fix test expectation none

Description Wenson Hsieh 2017-10-06 10:24:46 PDT
DataTransfer.items does not contain items for custom types supplied via add or setData. This is not a major issue if there are no files in the DataTransfer, since the page can use DataTransfer.types and DataTransfer.getData to retrieve custom type data. But if there are files, we'll report only ["Files"] for DataTransfer.types, and not expose custom data in the DataTransferItemList.

This behavior diverges from both Chrome (61.0) and FireFox (56.0).
Comment 1 Wenson Hsieh 2017-10-07 19:43:00 PDT
Created attachment 323115 [details]
Patch
Comment 2 Darin Adler 2017-10-07 23:45:28 PDT
Comment on attachment 323115 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=323115&action=review

> Source/WebCore/dom/DataTransfer.cpp:145
> +    auto lowercaseType = type.stripWhiteSpace().convertToASCIILowercase();

It is probably not right to use stringWhiteSpace here; that function uses the Unicode definition of whitespace, not the one that we’d normally use in HTML. Instead we would normally use stripLeadingAndTrailingHTMLSpaces.

> Source/WebCore/dom/DataTransfer.cpp:146
> +    if (Settings::customPasteboardDataEnabled() && !Pasteboard::isSafeTypeForDOMToReadAndWrite(lowercaseType))

It would be nice to have a named function for this test that we do in three different places in this patch.
Comment 3 Wenson Hsieh 2017-10-08 01:25:43 PDT
Comment on attachment 323115 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=323115&action=review

>> Source/WebCore/dom/DataTransfer.cpp:145
>> +    auto lowercaseType = type.stripWhiteSpace().convertToASCIILowercase();
> 
> It is probably not right to use stringWhiteSpace here; that function uses the Unicode definition of whitespace, not the one that we’d normally use in HTML. Instead we would normally use stripLeadingAndTrailingHTMLSpaces.

Fixed. I also adjusted normalizeTypes() to do the same.

>> Source/WebCore/dom/DataTransfer.cpp:146
>> +    if (Settings::customPasteboardDataEnabled() && !Pasteboard::isSafeTypeForDOMToReadAndWrite(lowercaseType))
> 
> It would be nice to have a named function for this test that we do in three different places in this patch.

Sounds good!
Comment 4 Wenson Hsieh 2017-10-08 01:25:59 PDT
Created attachment 323128 [details]
Wait for EWS
Comment 5 Build Bot 2017-10-08 13:28:03 PDT
Comment on attachment 323128 [details]
Wait for EWS

Attachment 323128 [details] did not pass mac-ews (mac):
Output: http://webkit-queues.webkit.org/results/4794263

New failing tests:
editing/pasteboard/data-transfer-get-data-non-normalized-types.html
Comment 6 Build Bot 2017-10-08 13:28:04 PDT
Created attachment 323138 [details]
Archive of layout-test-results from ews102 for mac-elcapitan

The attached test failures were seen while running run-webkit-tests on the mac-ews.
Bot: ews102  Port: mac-elcapitan  Platform: Mac OS X 10.11.6
Comment 7 Wenson Hsieh 2017-10-08 13:47:22 PDT
Created attachment 323139 [details]
Fix test expectation
Comment 8 WebKit Commit Bot 2017-10-08 14:58:32 PDT
Comment on attachment 323139 [details]
Fix test expectation

Clearing flags on attachment: 323139

Committed r223034: <http://trac.webkit.org/changeset/223034>
Comment 9 Radar WebKit Bug Importer 2017-10-08 17:37:24 PDT
<rdar://problem/34877586>