test_bug600570.html (2405B)
1 <!DOCTYPE HTML> 2 <html> 3 <!-- 4 https://bugzilla.mozilla.org/show_bug.cgi?id=600570 5 --> 6 <head> 7 <title>Test for Bug 600570</title> 8 <script src="/tests/SimpleTest/SimpleTest.js"></script> 9 <script src="/tests/SimpleTest/EventUtils.js"></script> 10 <script src="/tests/SimpleTest/WindowSnapshot.js"></script> 11 <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/> 12 <style> 13 textarea { border-color: white; } 14 </style> 15 </head> 16 <body> 17 <a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=600570">Mozilla Bug 600570</a> 18 <p id="display"></p> 19 <div id="content"> 20 <textarea spellcheck="false"> 21 aaa 22 [bbb]</textarea> 23 </div> 24 <pre id="test"> 25 <script type="application/javascript"> 26 27 /** Test for Bug 600570 */ 28 29 SimpleTest.waitForExplicitFinish(); 30 SimpleTest.waitForFocus(function() { 31 var t = document.querySelector("textarea"); 32 t.value = "[aaa\nbbb]"; 33 t.focus(); 34 synthesizeKey("A", {accelKey: true}); 35 36 SimpleTest.executeSoon(function() { 37 t.getBoundingClientRect(); // flush layout 38 var afterSetValue = snapshotWindow(window); 39 40 t.value = t.defaultValue; 41 42 t.selectionStart = 0; 43 t.selectionEnd = 4; 44 SimpleTest.waitForClipboard("aaa\n", 45 function() { 46 synthesizeKey("X", {accelKey: true}); 47 }, 48 function() { 49 t.addEventListener("input", function() { 50 setTimeout(function() { // Avoid the assertion in bug 649797 51 is(t.value, "[aaa\nbbb]", "The value of the textarea should be correct"); 52 synthesizeKey("A", {accelKey: true}); 53 is(t.selectionStart, 0, "Select all should set the selection start to the beginning of textarea"); 54 is(t.selectionEnd, 9, "Select all should set the selection end to the end of textarea"); 55 56 var afterPaste = snapshotWindow(window); 57 58 var res = compareSnapshots(afterSetValue, afterPaste, true); 59 var msg = "Pasting and setting the value directly should result in the same rendering"; 60 if (!res[0]) { 61 msg += "\nRESULT:\n" + res[2] + "\nREFERENCE:\n" + res[1]; 62 } 63 ok(res[0], msg); 64 65 SimpleTest.finish(); 66 }, 0); 67 }, {once: true}); 68 synthesizeKey("KEY_ArrowRight"); 69 synthesizeKey("V", {accelKey: true}); 70 }, 71 function() { 72 SimpleTest.finish(); 73 } 74 ); 75 }); 76 }); 77 78 </script> 79 </pre> 80 </body> 81 </html>