<!doctype html>
<script src="../../resources/testharness.js"></script>
<script src="../../resources/testharnessreport.js"></script>
<script src="../assert_selection.js"></script>
<script>
const bidiCaretAffinityEnabled =
window.internals && internals.runtimeFlags.bidiCaretAffinityEnabled;
selection_test(
[
'<div contenteditable id="target" style="direction: rtl">',
'abc',
'</div>',
],
selection => {
if (!window.eventSender)
throw 'This test requires eventSender.';
const target = selection.document.getElementById('target');
eventSender.mouseMoveTo(
selection.computeLeft(target) + 3,
selection.computeLeft(target) + 3);
eventSender.mouseDown();
eventSender.mouseUp();
},
[
'<div contenteditable id="target" style="direction: rtl">',
bidiCaretAffinityEnabled ? '|abc' : 'abc|',
'</div>',
], 'Click left');
selection_test(
[
'<div contenteditable id="target" style="direction: rtl">',
'abc',
'</div>',
],
selection => {
if (!window.eventSender)
throw 'This test requires eventSender.';
const target = selection.document.getElementById('target');
eventSender.mouseMoveTo(
selection.computeLeft(target) + target.offsetWidth - 3,
selection.computeLeft(target) + 3);
eventSender.mouseDown();
eventSender.mouseUp();
},
[
'<div contenteditable id="target" style="direction: rtl">',
bidiCaretAffinityEnabled ? 'abc|' : '|abc',
'</div>',
], 'Click right');
</script>