| OLD | NEW |
| 1 <!DOCTYPE html> | 1 <!doctype html> |
| 2 <html> | 2 <script src="../../resources/testharness.js"></script> |
| 3 <body> | 3 <script src="../../resources/testharnessreport.js"></script> |
| 4 <p id="description">This tests dragging and dropping a URL. The content before a
nd after the drag and drop should match.</p> | 4 <script src="../assert_selection.js"></script> |
| 5 <div contenteditable><a href="http://webkit.org/" title="some title" target="_bl
ank" style="color:orange">drag me</a></div> | |
| 6 <p>to the box blow:</p> | |
| 7 <div id="destination" contenteditable ondrop="setTimeout(dump, 0);" style="borde
r: solid 2px blue; padding: 5px;"><br></div> | |
| 8 <script src="../../resources/dump-as-markup.js"></script> | |
| 9 <script> | 5 <script> |
| 10 | 6 function computePoint(selection, target) { |
| 11 Markup.waitUntilDone(); | 7 const x = selection.document.offsetLeft + target.offsetLeft + |
| 12 | 8 target.offsetWidth / 2; |
| 13 Markup.description(document.getElementById('description').textContent); | 9 const y = selection.document.offsetTop + target.offsetTop + |
| 14 | 10 target.offsetHeight / 2; |
| 15 var target = document.getElementsByTagName("a")[0]; | 11 return {x, y}; |
| 16 getSelection().selectAllChildren(target); | |
| 17 Markup.dump(target.parentNode, 'before'); | |
| 18 | |
| 19 function dump() { | |
| 20 Markup.dump('destination', 'after'); | |
| 21 Markup.notifyDone(); | |
| 22 } | 12 } |
| 23 | 13 |
| 24 if (window.eventSender) { | 14 test(() => { |
| 25 var x = target.offsetLeft + target.offsetWidth / 2; | 15 if (!window.eventSender) { |
| 26 var y = target.offsetTop + target.offsetHeight / 2; | 16 assert_unreached('This test requires eventSender.'); |
| 27 eventSender.mouseMoveTo(x, y); | 17 return; |
| 28 eventSender.mouseDown(); | 18 } |
| 29 | 19 |
| 30 var destination = document.getElementById("destination"); | 20 assert_selection( |
| 31 eventSender.leapForward(300); | 21 [ |
| 32 eventSender.mouseMoveTo(destination.offsetLeft + 10, destination.offsetTop +
destination.offsetHeight / 2); | 22 '<div contenteditable>', |
| 33 eventSender.mouseUp(); | 23 '<a href="http://dev.chromium.org/"', |
| 24 ' title="some title" style="color:orange">^drag me|</a>', |
| 25 '</div>', |
| 26 '<p>to the box blow:</p>', |
| 27 '<div contenteditable id="drop"><br></div>', |
| 28 ].join(''), |
| 29 selection => { |
| 30 const source = selection.document.querySelector('a'); |
| 31 const sourcePoint = computePoint(selection, source); |
| 32 eventSender.mouseMoveTo(sourcePoint.x, sourcePoint.y); |
| 33 eventSender.mouseDown(); |
| 34 | 34 |
| 35 setTimeout(function () { destination.innerHTML = 'FAIL'; dump(); }, 100); | 35 const drop = selection.document.getElementById('drop'); |
| 36 } | 36 const dropPoint = computePoint(selection, drop); |
| 37 | 37 eventSender.leapForward(300); |
| 38 eventSender.mouseMoveTo(dropPoint.x, dropPoint.y); |
| 39 eventSender.mouseUp(); |
| 40 }, |
| 41 [ |
| 42 '<div contenteditable></div>', |
| 43 '<p>to the box blow:</p>', |
| 44 '<div contenteditable id="drop">', |
| 45 '<a href="http://dev.chromium.org/"', |
| 46 ' style="color: orange;" title="some title">^drag me|</a>', |
| 47 '</div>', |
| 48 ].join('')); |
| 49 }, 'Drag-and-Drop should keep attributes of A'); |
| 38 </script> | 50 </script> |
| 39 </body> | |
| 40 </html> | |
| OLD | NEW |