<!doctype html>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="/resources/testdriver.js"></script>
<script src="/resources/testdriver-vendor.js"></script>
<script src="/resources/testdriver-actions.js"></script>
<script src="../resources/test-helper.js"></script>
<head>
<title>dataURL image drag and drop between iframes</title>
<style type="text/css">
iframe
  {width:160px;
  height:160px;
  border-style:none;}
</style>
</head>
<body>
<p><iframe src="helper-drag-me-data-url-image.xhtml">XHTML with image</iframe></p>
<p>Drag circle above to the box below. It should be copied to the box once you drop it there.</p>
<p><iframe src="helper-drop-image-here.xhtml" id="iframe-2">XHTML with image</iframe></p>
<script>
async function test() {
  await new Promise(loaded => window.addEventListener("load", loaded));
  const iframe = document.querySelector('iframe');
  const iframeTwo = document.getElementById('iframe-2');
  const innerDoc = iframeTwo.contentDocument || iframeTwo.contentWindow.document;
  const div = innerDoc.querySelector('div');
  function onDropCallBack(event) {
    const innerDoc1 = iframe.contentDocument || iframe.contentWindow.document;
    const img = innerDoc1.querySelector('img');
    assert_equals(img.src, event.dataTransfer.getData('text/uri-list').replace(/\r\n$/,''));
    return true;
  }
  dragDropTest(iframe, div, onDropCallBack, 'Dragging a dataURL image within an iframe to another iframe should copy it there', iframeTwo);
}
test();
</script>
</body>
</html>
