test_bug240933.html (2045B)
1 <!DOCTYPE HTML> 2 <html> 3 <!-- 4 https://bugzilla.mozilla.org/show_bug.cgi?id=240933 5 --> 6 7 <head> 8 <title>Test for Bug 240933</title> 9 <script src="/tests/SimpleTest/SimpleTest.js"></script> 10 <script src="/tests/SimpleTest/EventUtils.js"></script> 11 <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/> 12 </head> 13 14 <body> 15 <a target="_blank" 16 href="https://bugzilla.mozilla.org/show_bug.cgi?id=240933"> 17 Mozilla Bug 240933 18 </a> 19 <p id="display"></p> 20 <div id="content" style="display: none"> 21 </div> 22 23 <pre id="test"> 24 <script type="application/javascript"> 25 26 /** Test for Bug 240933 */ 27 28 SimpleTest.waitForExplicitFinish(); 29 30 SimpleTest.waitForFocus(function() { 31 var t = document.getElementById("t"); 32 synthesizeMouse(t, t.clientWidth / 2, 5, {}, window); 33 is(t.selectionStart, 3, "The selection should be set before the newline"); 34 is(t.selectionEnd, 3, "The selection should be set before the newline"); 35 36 t = document.getElementById("ta"); 37 t.focus(); 38 t.selectionStart = t.selectionEnd = t.value.length; 39 var val = t.value; 40 synthesizeKey("KEY_Enter"); 41 is(t.value, val + "\n", "Pressing enter right after focusing the textarea should work"); 42 43 t = document.getElementById("tb"); 44 t.focus(); 45 synthesizeKey("KEY_Enter"); 46 is(t.value, "\n", "Pressing enter for the first time should work"); 47 synthesizeKey("KEY_Enter"); 48 is(t.value, "\n\n", "Pressing enter for the second time should work"); 49 synthesizeKey("KEY_Backspace"); 50 is(t.value, "\n", "Pressing backspace for the first time should work"); 51 synthesizeKey("KEY_Backspace"); 52 is(t.value, "", "Pressing backspace for the second time should work"); 53 SimpleTest.finish(); 54 }); 55 56 </script> 57 </pre> 58 59 <textarea id="t" rows="10" cols="10">abc 60 </textarea> 61 <textarea id="ta" rows="10" cols="10"> 62 test 63 64 </textarea> 65 <textarea id="tb" rows="10" cols="10"></textarea> 66 67 </body> 68 </html>