summaryrefslogtreecommitdiffstats
path: root/testing/web-platform/tests/html/editing/dnd/images/cross-domain/001-manual.xhtml
blob: f06463341073596c295cb83a03e6572816a5f897 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
<?xml version="1.0" encoding="utf-8"?>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Cross-domain image data must not populate the dataTransfer</title>
<script src="../../resources/crossorigin.sub.js"></script>
<style type="text/css">
div {
  width:105px;
  min-height:105px;
  text-align:center;
  margin-top:20px;
  padding:10px;
  border:solid thin navy;
}
</style>
</head>
<body>
<p><img id="image" draggable="true" alt="" width="100" height="100" /></p>
<p>Drag the navy square above to the box below.</p>
<div></div>
<script><![CDATA[

document.getElementsByTagName("img")[0].src = crossOriginUrl("www", "../../resources/100x100-navy.png");

window.onload = function() {
  var image = document.getElementsByTagName('img')[0], div = document.getElementsByTagName('div')[0], failed = [];
  div.ondragover = div.ondragenter = function(e) {
    e.preventDefault();
    e.dataTransfer.dropEffect = 'copy';
  };
  div.ondrop = image.ondragstart = function(e) {
    if( e.type == 'dragstart' ) {
      e.dataTransfer.setData('Text', 'dummy text');
      e.dataTransfer.dropEffect = 'copy';
    }
    for( var i = 0; i < e.dataTransfer.types.length; i++ ) {
      if( e.dataTransfer.types[i].match(/image\//) ) {
        failed[failed.length] = e.dataTransfer.types[i];
      }
    }
    if( e.type == 'drop' ) {
       e.preventDefault();
      document.getElementsByTagName('p')[1].innerHTML = failed.length ? ( 'FAIL (found ' + failed.join() + ')' ) : 'PASS';
    }
  };
};
]]></script>
</body>
</html>