015-manual.html (2295B)
1 <!doctype html> 2 <html> 3 <head> 4 <title>Using dataTransfer in new thread</title> 5 <style type="text/css"> 6 blockquote { height: 100px; width: 100px; background: orange; margin: 0; padding: 0; float: left; } 7 blockquote + blockquote { background: blue; } 8 blockquote + blockquote + blockquote { background: fuchsia; } 9 blockquote + div { clear: left; } 10 </style> 11 <script type="text/javascript" src="/resources/testharness.js"></script> 12 <script type="text/javascript" src="/resources/testharnessreport.js"></script> 13 <script type="text/javascript"> 14 setup(function () {},{explicit_done:true,explicit_timeout:true}); 15 window.onload = function () { 16 17 var orange = document.getElementsByTagName('blockquote')[0], 18 blue = document.getElementsByTagName('blockquote')[1], 19 fuchsia = document.getElementsByTagName('blockquote')[2], 20 evtdone = {}; 21 22 orange.ondragstart = function (e) { 23 e.dataTransfer.effectAllowed = 'copy'; 24 e.dataTransfer.setData('text','dragstart real data'); 25 var dataTransfer = e.dataTransfer; 26 setTimeout(function () { 27 test(function () { 28 assert_equals( dataTransfer.getData('text'), '', 'step 1' ); 29 dataTransfer.setData('text','new thread after dragstart'); 30 assert_equals( dataTransfer.getData('text'), '', 'step 2' ); 31 },'dragstart data store should be protected after new thread starts'); 32 },0); 33 }; 34 35 fuchsia.ondragenter = fuchsia.ondragover = function (e) { 36 e.preventDefault(); 37 }; 38 39 fuchsia.ondrop = function (e) { 40 e.preventDefault(); 41 var dataTransfer = e.dataTransfer; 42 setTimeout(function () { 43 test(function () { 44 assert_equals( dataTransfer.getData('text'), '', 'step 1' ); 45 dataTransfer.setData('text','new thread after dragstart'); 46 assert_equals( dataTransfer.getData('text'), '', 'step 2' ); 47 },'drop data store should be protected after new thread starts'); 48 done(); 49 },0); 50 }; 51 52 }; 53 </script> 54 </head> 55 <body> 56 <p>Drag the orange square over the blue square then the fuchsia square, then release it.</p> 57 <blockquote draggable="true"></blockquote> 58 <blockquote></blockquote> 59 <blockquote></blockquote> 60 <div id="log"></div> 61 <noscript><p>Enable JavaScript and reload</p></noscript> 62 </body> 63 </html>