| <!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>', |
| '|<table><tr><td>foo</td></tr></table>', |
| '</div>', |
| ].join(''), |
| 'insertParagraph', |
| [ |
| '<div contenteditable>', |
| '<br>', |
| '|<table><tbody><tr><td>foo</td></tr></tbody></table>', |
| '</div>', |
| ].join('')), |
| 'Insert BR before table'); |
| |
| test(() => assert_selection( |
| [ |
| '<div contenteditable>', |
| '<table><tr><td>foo</td></tr></table>', |
| '|bar', |
| '</div>', |
| ].join(''), |
| 'insertParagraph', |
| [ |
| '<div contenteditable>', |
| '<table><tbody><tr><td>foo</td></tr></tbody></table>', |
| '<br>', |
| '<div>|bar</div>', |
| '</div>', |
| ].join('')), |
| 'Insert BR and enclose with DIV'); |
| |
| test(() => assert_selection( |
| [ |
| '<div contenteditable>', |
| 'foo|<hr>bar', |
| '</div>', |
| ].join(''), |
| 'insertParagraph', |
| [ |
| '<div contenteditable>', |
| 'foo', |
| '<div>|<br><hr>bar</div>', |
| '</div>', |
| ].join('')), |
| 'Insert BR before HR'); |
| |
| test(() => assert_selection( |
| [ |
| '<div contenteditable>', |
| 'foo<hr>|bar', |
| '</div>', |
| ].join(''), |
| selection => { |
| // Set selection to afterNode(HR) |
| selection.modify('move', 'backward', 'character'); |
| selection.document.execCommand('insertParagraph'); |
| }, |
| [ |
| '<div contenteditable>', |
| 'foo<hr>|<br>bar', |
| '</div>', |
| ].join('')), |
| 'Insert BR after HR'); |
| |
| test(() => assert_selection( |
| [ |
| '<div contenteditable>', |
| '<a href="http://example.com">|example</a>', |
| '</div>', |
| ].join(''), |
| 'insertParagraph', |
| [ |
| '<div contenteditable>', |
| '<div><br></div>', |
| '<a href="http://example.com">|example</a>', |
| '</div>', |
| ].join('')), |
| 'Insert DIV+BR before A'); |
| </script> |