chromium/third_party/blink/web_tests/editing/style/toggle-style-bold-italic.html

<!doctype html>
<script src="../../resources/testharness.js"></script>
<script src="../../resources/testharnessreport.js"></script>
<script src="../assert_selection.js"></script>
<script>
test(() => assert_selection(
    [
      '<div contenteditable>^',
      '   <div>abc def</div>',
      '   <p>ghi jkl|</p>',
      '</div>',
    ].join('\n'),
    'bold',
    [
      '<div contenteditable>',
      '   <div><b>^abc def</b></div>',
      '   <p><b>ghi jkl|</b></p>',
      '</div>',
    ].join('\n')),
    'bold');

test(() => assert_selection(
    [
      '<div contenteditable>^',
      '   <div>abc def</div>',
      '   <p>ghi jkl|</p>',
      '</div>',
    ].join('\n'),
    selection => {
      selection.document.execCommand('bold');
      selection.document.execCommand('italic');
    },
    [
      '<div contenteditable>',
      '   <div><b><i>^abc def</i></b></div>',
      '   <p><b><i>ghi jkl|</i></b></p>',
      '</div>',
    ].join('\n')),
    'bold+italic');

test(() => assert_selection(
    [
      '<div contenteditable>^',
      '   <div>abc def</div>',
      '   <p>ghi jkl|</p>',
      '</div>',
    ].join('\n'),
    selection => {
      selection.document.execCommand('bold');
      selection.document.execCommand('italic');
      selection.document.execCommand('bold');
    },
    [
      '<div contenteditable>',
      '   <div><i style>^abc def</i></div>',
      '   <p><i style>ghi jkl|</i></p>',
      '</div>',
    ].join('\n')),
    'bold+italic+bold');

test(() => assert_selection(
    [
        '<div contenteditable>^',
        '   <div>abc def</div>',
        '   <p>ghi jkl|</p>',
        '</div>',
    ].join('\n'),
    selection => {
        selection.document.execCommand('bold');
        selection.document.execCommand('italic');
        selection.document.execCommand('bold');
        selection.document.execCommand('italic');
    },
    [
        '<div contenteditable>',
        '   <div>^abc def</div>',
        '   <p>ghi jkl|</p>',
        '</div>',
    ].join('\n')),
    'bold+italic+bold+italic');
</script>