<!doctype html>
<script src="../../resources/testharness.js"></script>
<script src="../../resources/testharnessreport.js"></script>
<script src="../assert_selection.js"></script>
<script>
function mouseMoveTo(selection, element) {
const mouseX = selection.document.offsetLeft + element.offsetLeft + element.offsetWidth / 2;
const mouseY = selection.document.offsetTop + element.offsetTop + element.offsetHeight / 2;
eventSender.mouseMoveTo(mouseX, mouseY);
}
test(() => {
assert_not_equals(window.testRunner, 'This test requires clipboard access.');
assert_selection(
[
'<div contenteditable id="src">',
'^foo <span contenteditable="false">bar</span> baz|',
'</div>',
'<div contenteditable id="dest"></div>'
].join(''),
selection => {
mouseMoveTo(selection, selection.document.getElementById('src'));
eventSender.mouseDown();
eventSender.leapForward(500);
mouseMoveTo(selection, selection.document.getElementById('dest'));
eventSender.mouseUp();
},
[
'<div contenteditable id="src"></div>',
'<div contenteditable id="dest">',
'^foo\u00A0<span contenteditable="false">bar</span>\u00A0baz|',
'</div>'
].join('')
);
}, 'Dropping content with mixed editability does not change editability');
test(() => {
assert_not_equals(window.testRunner, 'This test requires clipboard access.');
assert_selection(
[
'<div contenteditable id="src">',
'^foo <span contenteditable="false">bar</span> baz|',
'</div>',
'<div contenteditable id="dest"></div>'
].join(''),
selection => {
selection.document.execCommand('copy');
selection.document.getElementById('dest').focus();
selection.document.execCommand('paste');
},
[
'<div contenteditable id="src">',
'foo <span contenteditable="false">bar</span> baz',
'</div>',
'<div contenteditable id="dest">',
'foo\u00A0<span contenteditable="false">bar</span>\u00A0baz|',
'</div>'
].join('')
);
}, 'Pasting content with mixed editability does not change editability');
</script>