<!DOCTYPE html>
<html>
<head>
<script>
function onDrop(evt) {
document.body.innerHTML = 'PASS';
if (!evt.dataTransfer.types) return;
for (var i = 0, type; type = evt.dataTransfer.types[i]; i++) {
clip = evt.dataTransfer.getData(type);
if (typeof clip == 'string' && clip.indexOf('FAIL') != -1)
document.body.innerHTML = 'FAIL';
}
evt.preventDefault();
testRunner.notifyDone();
}
function runTest() {
testRunner.dumpAsText();
testRunner.waitUntilDone();
var d = document.getElementById('drag');
var o = document.getElementById('drop');
eventSender.mouseMoveTo(d.offsetLeft + d.offsetWidth / 2, d.offsetTop + d.offsetHeight / 2);
eventSender.mouseDown();
eventSender.leapForward(100);
eventSender.mouseMoveTo(o.offsetLeft + o.offsetWidth / 2, o.offsetTop + o.offsetHeight / 2);
eventSender.mouseUp();
}
window.onload = function() {
var d = document.getElementById('drag');
var r = document.createRange();
r.selectNode(d);
getSelection().removeAllRanges();
getSelection().addRange(r);
document.getElementById('drop').addEventListener('drop', onDrop, true);
window.addEventListener('dragover', function(x) { x.preventDefault() }, true);
window.addEventListener('dragstart', function(x) { window.focus() }, true);
if (window.testRunner)
runTest();
}
</script>
</head>
<body>
Dragging this iframe onto a drop target should not expose its contents.
<div id="drag" style="-webkit-user-drag: element ">
→
<iframe src="resources/file-for-drag-and-drop-subframe-dataTransfer.html"></iframe>
←
</div>
<input id="drop">
</body>
</html>