Bug 135835 - DragStart dataTransfer.setData clears (almost) all existing data
Summary: DragStart dataTransfer.setData clears (almost) all existing data
Status: NEW
Alias: None
Product: WebKit
Classification: Unclassified
Component: WebKit Misc. (show other bugs)
Version: 528+ (Nightly build)
Hardware: Mac (Intel) OS X 10.9
: P2 Normal
Assignee: Nobody
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2014-08-12 03:17 PDT by web
Modified: 2014-08-12 19:01 PDT (History)
1 user (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description web 2014-08-12 03:17:18 PDT
Calling dataTransfer.setData(type, value) does not just append the data to the existing data, it also clears all existing data the dataTransfer object contained except for a "dyn." type. This breaks dragging e.g. an image with custom data meant for use within a webpage to e.g. Finder.app (as default image data is missing).

Steps to reproduce:

1. Open any page and run the following code in the console:

document.addEventListener('dragstart', function(e) {
	//e.dataTransfer.setData('text/x-test', 'Test')
})
document.addEventListener('dragover', function(e) {
	e.preventDefault()
})
document.addEventListener('drop', function(e) {
	e.preventDefault()
	console.log(e.dataTransfer.types)
})

2. Drag anything and drop on the same web page. Console will output an array with several data types (depending on what was dragged, but generally more than 10).

3. Run the following code in the console:

document.addEventListener('dragstart', function(e) {
	e.dataTransfer.setData('text/x-test', 'Test')
})
document.addEventListener('dragover', function(e) {
	e.preventDefault()
})
document.addEventListener('drop', function(e) {
	e.preventDefault()
	console.log(e.dataTransfer.types)
})

4. Drag anything and drop on the same web page. Console will output an array with two values; "dyn."... and "text/x-test" (it will output these twice unless the page was refreshed).

Expected result:
Output in 4 having the same values as in 2 plus "text/x-test".
As per http://www.whatwg.org/specs/web-apps/current-work/multipage/interaction.html#dom-datatransfer-setdata

Actual result:
Output in 4 having the just "text/x-test" and one more value.