chromium/third_party/blink/web_tests/editing/spelling/marker_preservation_with_focus_change.html

<!DOCTYPE html>
<script src="../../resources/testharness.js"></script>
<script src="../../resources/testharnessreport.js"></script>
<script src="../assert_selection.js"></script>
<script src="spellcheck_test.js"></script>

<script>
const steps = [];

steps.push(
    () => spellcheck_test(
        [
          '<textarea id="textarea"></textarea>',
          '<input>',
          '<textarea id="aux"></textarea>'
        ].join(''),
        document => {
          const textarea = document.getElementById('textarea');
          const input = document.querySelector('input');
          textarea.focus();
          document.execCommand('insertText', false, 'zz.');
          input.focus();
          document.execCommand('insertText', false, 'zz. ');
        },
        [
          '<textarea id="textarea">#zz#.</textarea>',
          '<input value="#zz#. ">',
          '<textarea id="aux"></textarea>'
        ].join(''),
        {
          title: 'TEXTAREA and INPUT have markers after typing.',
          callback: sample => steps.shift()(sample)
        }));

steps.push(
    sample => spellcheck_test(
        sample,
        document => document.getElementById('aux').focus(),
        [
          '<textarea id="textarea">#zz#.</textarea>',
          '<input value="zz. ">',
          '<textarea id="aux"></textarea>'
        ].join(''),
        {
          title: 'Focusing TEXTAREA removes markers from INPUT.',
          callback: sample => steps.shift()(sample)
        }));

steps.push(
    sample => spellcheck_test(
        sample,
        document => document.querySelector('input').focus(),
        [
          '<textarea id="textarea">#zz#.</textarea>',
          '<input value="#zz#. ">',
          '<textarea id="aux"></textarea>'
        ].join(''),
        'Focusing INPUT preserves markers in TEXTAREA.'));

steps.shift()();
</script>