| OLD | NEW |
| 1 <html> | 1 <!doctype html> |
| 2 <script src="../../resources/testharness.js"></script> |
| 3 <script src="../../resources/testharnessreport.js"></script> |
| 4 <script src="../assert_selection.js"></script> |
| 5 <script> |
| 6 test(() => assert_selection( |
| 7 '<div contenteditable>|hello</div>', |
| 8 'insertText c', |
| 9 '<div contenteditable>c|hello</div>'), |
| 10 'insert text into DIV with some text'); |
| 2 | 11 |
| 3 <head> | 12 test(() => assert_selection( |
| 4 <script> | 13 '<div contenteditable>|</div>', |
| 5 if (window.testRunner) | 14 'insertText c', |
| 6 testRunner.dumpEditingCallbacks(); | 15 '<div contenteditable>c|</div>'), |
| 16 'insert text into completely empty DIV'); |
| 17 |
| 18 test(() => assert_selection( |
| 19 '<div contenteditable>|\n</div>', |
| 20 'insertText c', |
| 21 '<div contenteditable>c|\n</div>'), |
| 22 'insert text into DIV with collapsable whitespace'); |
| 23 |
| 24 test(() => assert_selection( |
| 25 '<div contenteditable style="min-height: 20px">|<p></p></div>', |
| 26 'insertText c', |
| 27 '<div contenteditable style="min-height: 20px">c|<p></p></div>'), |
| 28 'insert text into DIV with empty P'); |
| 29 |
| 30 test(() => assert_selection( |
| 31 '<div contenteditable style="min-height: 20px">|\n<p></p>\n</div>', |
| 32 'insertText c', |
| 33 '<div contenteditable style="min-height: 20px">c|\n<p></p>\n</div>'), |
| 34 'insert text into DIV with empty P with collapsable whitespace'); |
| 7 </script> | 35 </script> |
| 8 | |
| 9 <script> | |
| 10 </script> | |
| 11 </head> | |
| 12 <style> | |
| 13 div { | |
| 14 border: 1px dotted blue; | |
| 15 min-height: 20px; | |
| 16 width: 90%; | |
| 17 } | |
| 18 </style> | |
| 19 | |
| 20 <script> | |
| 21 function foo() { | |
| 22 var selection = window.getSelection(); | |
| 23 var bar = 1; | |
| 24 var divs = document.getElementsByTagName("div"); | |
| 25 for (var i = 0; divs[i]; i++) { | |
| 26 selection.collapse(divs[i], 0); | |
| 27 document.execCommand("InsertText", false, 'c'); | |
| 28 } | |
| 29 } | |
| 30 </script> | |
| 31 <body onload="foo()"> | |
| 32 | |
| 33 <p>This tests the ability to start editing in blocks that are visible, but have
little or no content. Each of the divs below should be able to accept a caret.<
/p> | |
| 34 | |
| 35 <p>This div contains some text.</p> | |
| 36 <div contentEditable="true"> | |
| 37 hello | |
| 38 </div> | |
| 39 | |
| 40 <p>This div is completely empty.</p> | |
| 41 <div contentEditable="true"></div> | |
| 42 | |
| 43 <p>This div contains some collapsable whitespace (a '\n').</p> | |
| 44 <div contentEditable="true"> | |
| 45 </div> | |
| 46 | |
| 47 <p>This div contains a self-closing p tag.</p> | |
| 48 <div contentEditable="true"><p /></div> | |
| 49 | |
| 50 <p>This div contains a self-closing p tag and some collapsable whitespace (two '
\n's before and after the self closing p.</p> | |
| 51 <div contentEditable="true"> | |
| 52 <p /> | |
| 53 </div> | |
| 54 | |
| 55 </body> | |
| 56 </html> | |
| OLD | NEW |