Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 <!doctype HTML> | |
| 2 <script src="../../resources/testharness.js"></script> | |
| 3 <script src="../../resources/testharnessreport.js"></script> | |
| 4 <style> | |
| 5 #textarea, #plaintext, #richedit { | |
| 6 font-family: 'Courier', monospace; | |
| 7 width: 10ch; | |
| 8 } | |
| 9 #plaintext, #richedit { | |
| 10 border: 1px solid black; | |
| 11 white-space: pre-wrap; | |
| 12 } | |
| 13 </style> | |
| 14 <textarea id="textarea">12345 67</textarea> | |
| 15 <div id="plaintext" contenteditable="plaintext-only">12345 67</div> | |
| 16 <div id="richedit" contenteditable>12345 67</div> | |
| 17 <script> | |
| 18 (function () { | |
| 19 if (!window.eventSender) { | |
|
yosin_UTC9
2017/01/06 01:22:22
Good pattern!
| |
| 20 test(function () { | |
| 21 assert_unreached(); | |
| 22 }, 'This test requires eventSender'); | |
| 23 return; | |
| 24 } | |
| 25 | |
| 26 test(function () { | |
| 27 let textarea = document.getElementById('textarea'); | |
| 28 textarea.focus(); | |
| 29 textarea.setSelectionRange(10, 10); | |
| 30 eventSender.keyDown(' '); | |
| 31 assert_equals(textarea.value, '12345 \n 67', 'Line break should be inser ted automatically'); | |
| 32 }, 'Typing space at the start of wrapped line in textarea'); | |
| 33 | |
| 34 test(function () { | |
| 35 let editor = document.getElementById('plaintext'); | |
| 36 let textNode = editor.firstChild; | |
| 37 window.getSelection().setBaseAndExtent(textNode, 10, textNode, 10); | |
| 38 eventSender.keyDown(' '); | |
| 39 assert_equals(editor.textContent, '12345 \n 67', 'Line break should be i nserted automatically'); | |
| 40 }, 'Typing space at the start of wrapped line in plaintext-only'); | |
| 41 | |
| 42 test(function () { | |
| 43 let editor = document.getElementById('richedit'); | |
| 44 let textNode = editor.firstChild; | |
| 45 window.getSelection().setBaseAndExtent(textNode, 10, textNode, 10); | |
| 46 eventSender.keyDown(' '); | |
| 47 assert_equals(editor.textContent, '12345 67', 'Line break should NOT be inserted automatically'); | |
| 48 }, 'Typing space at the start of wrapped line in contenteditable'); | |
| 49 })(); | |
| 50 </script> | |
| OLD | NEW |