Merge Chromium + Blink git repositories
[chromium-blink-merge.git] / third_party / WebKit / LayoutTests / fast / events / moving-text-should-fire-drop-and-dragend-events.html
blob50a83380137152d38e19ed754c47f4d4c6fd6720
1 <!DOCTYPE html>
2 <html>
3 <body>
4 <p>This tests dragging text within the same contenteditable element. To manually test, move the target below to the destination.
5 You should see dragstart, drop, and dragend in the log.</p>
6 <div contenteditable><span>Drag_and_drop_this_target to here, the_destination.</span></div>
7 <pre id="log">
8 Log:
9 </pre>
10 <script>
12 var log = document.getElementById('log');
13 var div = document.querySelector('div');
14 var eventLogs = [];
16 function logEvent(event) {
17 eventLogs.push(event.type);
18 log.innerText += event.type + '\n';
21 div.addEventListener('dragstart', logEvent, false);
22 div.addEventListener('dragend', logEvent, false);
23 div.addEventListener('drop', logEvent, false);
25 if (window.eventSender) {
26 testRunner.dumpAsText();
28 div.focus();
29 getSelection().collapse(div, 0);
30 getSelection().modify('extend', 'forward', 'word');
32 var y = div.offsetTop + div.offsetHeight / 2;
33 eventSender.dragMode = true;
34 eventSender.mouseMoveTo(div.offsetLeft + div.firstChild.offsetWidth / 5, y);
35 eventSender.mouseDown();
36 eventSender.leapForward(500);
37 eventSender.mouseMoveTo(div.offsetLeft + div.firstChild.offsetWidth * 4 / 5, y);
38 eventSender.mouseUp();
40 div.style.display = 'none'; // The resultant text will be different depending on font metrics so hide it.
42 log.innerHTML += '\n' + (eventLogs.join('') == ['dragstart', 'drop', 'dragend'].join('') ? 'PASS' : 'FAIL');
45 </script>
46 </body>
47 </html>