| <!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>Foo | <i> bar</i></div>', |
| selection => { |
| selection.document.execCommand('insertText', false, 'x'); |
| selection.document.execCommand('insertText', false, 'x'); |
| selection.document.execCommand('insertText', false, 'x'); |
| }, |
| '<div contenteditable>Foo xxx|<i>bar</i></div>'), |
| 'Collapse spaces'); |
| |
| test(() => assert_selection( |
| '<div contenteditable>Foo <i> bar</i>\n\n|baz</div>', |
| selection => { |
| selection.document.execCommand('insertText', false, 'x'); |
| selection.document.execCommand('insertText', false, 'x'); |
| selection.document.execCommand('insertText', false, 'x'); |
| }, |
| '<div contenteditable>Foo <i> bar</i>\u{00A0}xxx|baz</div>'), |
| 'Replace newlines into nbsp'); |
| |
| test(() => assert_selection( |
| '<div contenteditable>foo|bar</div>', |
| selection => { |
| selection.document.execCommand('insertLineBreak'); |
| selection.document.execCommand('insertLineBreak'); |
| }, |
| '<div contenteditable>foo<br><br>|bar</div>'), |
| 'Insert BRs'); |
| </script> |