summaryrefslogtreecommitdiffstats
path: root/testing/web-platform/tests/html/editing/dnd/target-origin/011-manual.html
blob: d68e03ad49b291d1e79934018db982e4fddce647 (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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
<!doctype html>
<html>
  <head>
    <title>allowTargetOrigin should only block dragenter, dragover, dragleave and drop events</title>
    <style type="text/css">
div { height: 100px; width: 100px; background: orange; margin: 0; padding: 0; float: left; }
div + div { background: blue; }
    </style>
    <script type="text/javascript">
window.onload = function () {
  var orange = document.getElementsByTagName('div')[0], evtdone = {}, fails = [];
  orange.ondragstart = function (e) {
    evtdone[e.type] = true;
    e.dataTransfer.effectAllowed = 'copy';
    e.dataTransfer.setData('text','dummy text');
    try {
      e.dataTransfer.allowTargetOrigin('http://example.com');
    } catch(e) {
      fails[fails.length] = 'allowTargetOrigin threw an error: '+e;
    }
  };
  orange.ondragenter = orange.ondragover = orange.ondrop = function (e) {
    e.preventDefault();
    evtdone[e.type] = true;
  };
  orange.ondrag = orange.ondragleave = function (e) {
    evtdone[e.type] = true;
  };
  orange.ondragend = function (e) {
    evtdone[e.type] = true;
    if( !evtdone.dragstart ) {
      fails[fails.length] = 'dragstart did not fire - how did that happen?';
    }
    if( !evtdone.drag ) {
      fails[fails.length] = 'drag did not fire';
    }
    if( !evtdone.dragend ) {
      fails[fails.length] = 'dragend did not fire - OK, who broke the testcase?';
    }
    if( evtdone.dragenter ) {
      fails[fails.length] = 'dragenter fired';
    }
    if( evtdone.dragover ) {
      fails[fails.length] = 'dragover fired';
    }
    if( evtdone.dragleave ) {
      fails[fails.length] = 'dragleave fired';
    }
    if( evtdone.drop ) {
      fails[fails.length] = 'drop fired';
    }
    document.getElementsByTagName('p')[0].innerHTML = fails.length ? ( 'FAIL:<br>' + fails.join('<br>') ) : 'PASS';
  };
};
    </script>
  </head>
  <body>
    <p>Drag the orange square over the blue square then back to the orange square, then release it. Fail if this text does not change.</p>
    <div draggable="true"></div>
    <div></div>
    <noscript><p>Enable JavaScript and reload</p></noscript>
  </body>
</html>