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>
12 var log
= document
.getElementById('log');
13 var div
= document
.querySelector('div');
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();
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');