008.html (1623B)
1 <!doctype html> 2 <html> 3 <head> 4 <title>Dropzone should not affect the dropEffect if dragover is cancelled</title> 5 <style type="text/css"> 6 div:first-child { 7 height: 100px; 8 width: 100px; 9 background: orange; 10 display: inline-block; 11 } 12 div:first-child + div { 13 height: 100px; 14 width: 100px; 15 background: blue; 16 display: inline-block; 17 } 18 </style> 19 <script type="text/javascript"> 20 window.onload = function () { 21 var drag = document.getElementsByTagName('div')[0]; 22 drag.ondragstart = function (e) { 23 e.dataTransfer.setData('text','hello'); 24 e.dataTransfer.effectAllowed = 'all'; 25 }; 26 var drop = document.getElementsByTagName('div')[1], dragenter, dragover; 27 drop.ondragenter = function (e) { 28 dragenter = e.dataTransfer.dropEffect; 29 e.preventDefault(); 30 }; 31 drop.ondragover = function (e) { 32 dragover = e.dataTransfer.dropEffect; 33 e.preventDefault(); 34 }; 35 drop.ondrop = function (e) { 36 var sequence = ([dragenter,dragover,e.dataTransfer.dropEffect]).join('=>') 37 var desiredsequence = (['copy','copy','copy']).join('=>') 38 if( sequence == desiredsequence ) { 39 document.getElementsByTagName('div')[2].innerHTML = 'PASS'; 40 } else { 41 document.getElementsByTagName('div')[2].innerHTML = 'FAIL, got:<br>'+sequence+'<br>instead of:<br>'+desiredsequence; 42 } 43 }; 44 }; 45 </script> 46 </head> 47 <body> 48 49 <div draggable="true"></div> 50 <div dropzone="link string:text/plain"></div> 51 <div> </div> 52 <p>Drag the orange square onto the blue square and release it.</p> 53 <noscript><p>Enable JavaScript and reload</p></noscript> 54 55 </body> 56 </html>