Bug 135835

Summary: DragStart dataTransfer.setData clears (almost) all existing data
Product: WebKit Reporter: web
Component: WebKit Misc.Assignee: Nobody <webkit-unassigned>
Status: NEW ---    
Severity: Normal CC: ap
Priority: P2    
Version: 528+ (Nightly build)   
Hardware: Mac (Intel)   
OS: OS X 10.9   

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.