Bug 178016 - DataTransfer.items does not contain items for custom types supplied via add or setData
Summary: DataTransfer.items does not contain items for custom types supplied via add o...
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: HTML Editing (show other bugs)
Version: WebKit Nightly Build
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Wenson Hsieh
URL:
Keywords: InRadar
Depends on:
Blocks:
 
Reported: 2017-10-06 10:24 PDT by Wenson Hsieh
Modified: 2017-10-08 17:37 PDT (History)
10 users (show)

See Also:


Attachments
Patch (22.06 KB, patch)
2017-10-07 19:43 PDT, Wenson Hsieh
darin: review+
Details | Formatted Diff | Diff
Wait for EWS (25.22 KB, patch)
2017-10-08 01:25 PDT, Wenson Hsieh
buildbot: commit-queue-
Details | Formatted Diff | Diff
Archive of layout-test-results from ews102 for mac-elcapitan (1.29 MB, application/zip)
2017-10-08 13:28 PDT, Build Bot
no flags Details
Fix test expectation (26.03 KB, patch)
2017-10-08 13:47 PDT, Wenson Hsieh
no flags Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
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>