chromium/third_party/blink/web_tests/editing/style/preserve-selection-direction.html

<!DOCTYPE html>
<script src="../../resources/testharness.js"></script>
<script src="../../resources/testharnessreport.js"></script>
<script src="../assert_selection.js"></script>
<script>
selection_test(
    ['<div contenteditable>Thi^s is |some sample text</div>'],
    selection => {
        selection.document.execCommand('foreColor', false, 'green');
    },
    ['<div contenteditable>Thi<font color="#008000">^s is |</font>some sample text</div>'],
    'Preserve forward selection direction  - Anchor offset must be smaller than focus offset.');

selection_test(
  ['<div contenteditable>Thi|s is ^some sample text</div>'],
  selection => {
     selection.document.execCommand('foreColor', false, 'green');
  },
  ['<div contenteditable>Thi<font color="#008000">|s is ^</font>some sample text</div>'],
  'Preserve backward selection direction  - Anchor offset must be bigger than focus offset.');
</script>