blob: fcbcb5c4b61357f4566727c157846bb8bf7742df [file] [log] [blame]
<!doctype html>
<script src="../../../resources/testharness.js"></script>
<script src="../../../resources/testharnessreport.js"></script>
<p>This tests dragging a selected table by mousing down on the
contents of one of its cells. It should be in the red bordered area.</p>
<div id="root">
<div id="source" style="border: 1px solid blue;" contenteditable="true"><table border="1"><tr><td id="cell">foo</td></tr></table></div>
<div id="destination" style="border: 1px solid red;" contenteditable="true"><br></div>
</div>
<div id="log"></div>
<script>
test(function() {
if (!window.testRunner)
return;
var cell = document.getElementById('cell');
var source = document.getElementById('source');
source.focus();
document.execCommand('selectAll');
var x, y;
x = cell.offsetParent.offsetLeft + cell.offsetLeft + cell.offsetWidth / 2;
y = cell.offsetParent.offsetTop + cell.offsetTop + cell.offsetHeight / 2;
eventSender.mouseMoveTo(x, y);
eventSender.mouseDown();
eventSender.leapForward(1000);
var destination = document.getElementById('destination');
x = destination.offsetParent.offsetLeft + destination.offsetLeft + destination.offsetWidth / 2;
y = destination.offsetParent.offsetTop + destination.offsetTop + destination.offsetHeight / 2;
eventSender.mouseMoveTo(x, y);
eventSender.mouseUp();
var selection = window.getSelection();
// Note: |cell| is copied by drag-and-drop
cell = document.getElementById('cell');
assert_equals(selection.anchorNode, destination, 'anchorNode');
assert_equals(selection.anchorOffset, 0, 'anchorOffset');
assert_equals(selection.focusNode, cell.firstChild, 'focusNode');
assert_equals(selection.focusOffset, 3, 'focusOffset');
});
</script>
</body>
</html>