Skip to content

Instantly share code, notes, and snippets.

@Infocatcher
Created February 28, 2013 15:38
Show Gist options
  • Save Infocatcher/5057618 to your computer and use it in GitHub Desktop.
Save Infocatcher/5057618 to your computer and use it in GitHub Desktop.
Drag-and-drop test for Gecko-based applications (Firefox & Co)
function dndTest(e) {
var dt = e.dataTransfer;
setTimeout(function() {
var types = dt.types;
var c = dt.mozItemCount;
var r = [];
for(var i = 0, li = types.length; i < li; ++i) {
var type = types.item(i);
r.push(i + ": " + type);
for(var j = 0; j < c; ++j) {
var data = dt.mozGetDataAt(type, j);
if(data)
r.push(" " + j + ": " + data);
}
}
Components.classes["@mozilla.org/consoleservice;1"]
.getService(Components.interfaces.nsIConsoleService)
.logStringMessage("DND test:\n" + r.join("\n"));
}, 0);
}
addEventListener("dragstart", dndTest, true);
setTimeout(function() {
removeEventListener("dragstart", dndTest, true);
}, 15e3);
@Infocatcher
Copy link
Author

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment