| <!doctype html> |
| <script src="../../resources/testharness.js"></script> |
| <script src="../../resources/testharnessreport.js"></script> |
| <script src="../assert_selection.js"></script> |
| <div id="log"></div> |
| <script> |
| test(() => { |
| assert_selection( |
| '<div contenteditable>|0123456789</div>', |
| 'createLink abc', |
| '<div contenteditable><a href="abc">^abc|</a>0123456789</div>', |
| 'Anchor text is an URI'); |
| |
| assert_selection( |
| '<div contenteditable>^0123456789|</div>', |
| 'createLink abc', |
| '<div contenteditable><a href="abc">^0123456789|</a></div>', |
| 'Fully select the line'); |
| |
| assert_selection( |
| '<div contenteditable>012^345|6789</div>', |
| 'createLink abc', |
| '<div contenteditable>012<a href="abc">^345|</a>6789</div>', |
| 'Partially select the line'); |
| |
| assert_selection( |
| '<div contenteditable><a href="abc">012^345|6789</a></div>', |
| 'createLink xyz', |
| '<div contenteditable><a href="abc">012</a><a href="xyz">^345|</a><a href="abc">6789</a></div>', |
| 'Partially select the link'); |
| |
| assert_selection( |
| '<div contenteditable>^012<ul><li>item1</li><li>item2</li></ul>345|</div>', |
| 'createLink abc', |
| '<div contenteditable><a href="abc">^012</a><ul><li><a href="abc">item1</a></li><li><a href="abc">item2</a></li></ul><a href="abc">345|</a></div>', |
| 'Selection whole list'); |
| |
| assert_selection( |
| '<div contenteditable>^foo <img src="../resources/abe.png"> bar|</div>', |
| 'createLink abc', |
| '<div contenteditable><a href="abc">^foo <img src="../resources/abe.png"> bar|</a></div>', |
| 'Line contains an image'); |
| |
| assert_selection( |
| '<div contenteditable>^012<table><tr><td>item1</td><td>item2</td></tr></table>345|</div>', |
| 'createLink abc', |
| '<div contenteditable><a href="abc">^012</a><table><tbody><tr><td><a href="abc">item1</a></td><td><a href="abc">item2</a></td></tr></tbody></table><a href="abc">345|</a></div>', |
| 'Selection whole table'); |
| |
| }); |
| </script> |