Merge Chromium + Blink git repositories
[chromium-blink-merge.git] / third_party / WebKit / LayoutTests / fast / events / setDragImage-with-detached-node.html
blob921949ddfd6c442a8de8c57d21a768057f9a8e4d
1 <!DOCTYPE html>
2 <script src="../../resources/js-test.js"></script>
3 <script>
4 var dragEndExpected = true;
6 window.onload = function()
8 var dragger = document.getElementById('dragMe');
9 dragger.addEventListener('dragstart', dragStart);
10 dragger.addEventListener('drag', dragging);
11 dragger.addEventListener('dragend', dragEnd);
12 if (!window.testRunner)
13 return;
15 var x = dragger.offsetLeft + dragger.offsetWidth / 2;
16 var y = dragger.offsetTop + dragger.offsetHeight / 2;
18 eventSender.mouseMoveTo(x, y);
19 eventSender.mouseDown();
20 eventSender.leapForward(100);
21 eventSender.mouseMoveTo(x + 100, y + 100);
22 eventSender.mouseUp();
25 function dragStart(e)
27 if (window.testRunner)
28 dragEndExpected = false;
29 debug('Started drag.');
30 var emptyDiv = document.createElement('div');
31 e.dataTransfer.setDragImage(emptyDiv, 0, 0);
34 function dragging()
36 dragEndExpected = true;
39 function dragEnd()
41 if (!dragEndExpected)
42 testFailed('Not expecting drag end!');
43 else
44 testPassed('Ended drag.');
46 </script>
47 <style>
48 html, body {
49 height: 100%;
50 margin: 0;
53 #dragMe {
54 border: 1px solid black;
56 </style>
57 <body>
58 <p>Test that calling setDragImage() with a detached node doesn't immediately abort the drag. This test can be manually run by dragging the 'Drag Me' div around and then ending the drag.
59 <div id="dragMe" draggable="true">Drag Me</div>
60 <div id="console"></div>
61 </body>