006.html (1846B)
1 <!doctype html> 2 <script src="/resources/testharness.js"></script> 3 <script src="/resources/testharnessreport.js"></script> 4 <script src="/resources/testdriver.js"></script> 5 <script src="/resources/testdriver-vendor.js"></script> 6 <script src="/resources/testdriver-actions.js"></script> 7 <script src="../resources/test-helper.js"></script> 8 <head> 9 <title>dataURL image drag and drop from iframe</title> 10 <style type="text/css"> 11 div[ondragenter] { 12 width: 105px; 13 min-height: 105px; 14 text-align: center; 15 margin-top: 20px; 16 padding: 10px; 17 border: solid thin navy; 18 } 19 20 iframe { 21 width: 150px; 22 height: 150px; 23 border-style: none; 24 } 25 </style> 26 <script> 27 function addImage(event) { 28 var c = document.createElement('img'); 29 c.setAttribute('src', event.dataTransfer.getData('text/uri-list').replace(/\r\n$/, '')); 30 document.querySelector('div').appendChild(c); 31 } 32 </script> 33 </head> 34 <body> 35 <p><iframe src="helper-drag-me-data-url-image.xhtml">XHTML with image</iframe></p> 36 <p>Drag circle above to the box below. It should be copied to the box once you drop it there.</p> 37 <div ondragenter="event.preventDefault()" ondragover="return false" ondrop="addImage(event)"></div> 38 <script> 39 async function test() { 40 await new Promise(loaded => window.addEventListener("load", loaded)); 41 const iframe = document.querySelector('iframe'); 42 const div = document.querySelector('div'); 43 44 function onDropCallBack(event) { 45 const img = document.querySelector('img'); 46 assert_equals(frames[0].document.querySelector('img').src, img.src); 47 return true; 48 } 49 dragDropTest(iframe, div, onDropCallBack, 50 'Dragging a dataURL image from an iframe to a div should copy it there'); 51 } 52 test(); 53 </script> 54 </body> 55 </html>