005.html (1807B)
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>Drag and drop to iframe: dropping block element onto canvas</title> 10 <style type="text/css"> 11 div { 12 width: 20px; 13 height: 20px; 14 background-color: green; 15 } 16 17 iframe { 18 width: 200px; 19 height: 200px; 20 border-style: none; 21 } 22 </style> 23 <script type="application/ecmascript"> 24 function start(event) { 25 event.dataTransfer.effectAllowed = 'copy'; 26 event.dataTransfer.setData('text/plain', 'green'); 27 } 28 </script> 29 </head> 30 <body> 31 <div draggable="true" ondragstart="start(event)"></div> 32 <p>Drag green box above to the gray canvas below. Canvas should turn green when you drop green box on it.</p> 33 <p><iframe src="helper-drop-here-canvas.xhtml">Canvas</iframe></p> 34 <script> 35 async function test() { 36 await new Promise(loaded => window.addEventListener("load", loaded)); 37 const canvas = frames[0].document.querySelector('canvas'); 38 39 function onDropCallBack(event) { 40 let style = window.getComputedStyle(canvas); 41 let currentColor = "rgba(0, 0, 0, 0)"; 42 assert_equals(style.getPropertyValue("background-color"), currentColor); 43 return true; 44 } 45 46 const div = document.querySelector('div'); 47 const iframe = document.querySelector('iframe'); 48 dragDropTest(div, canvas, onDropCallBack, 49 'Dragging the div to the bottom iframe should turn it green', /*dragIframe=*/ null, iframe); 50 } 51 test(); 52 </script> 53 </body> 54 </html>