1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/layout/generic/test/test_bug904810.html Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,110 @@ 1.4 +<!DOCTYPE HTML> 1.5 +<html> 1.6 +<!-- 1.7 +https://bugzilla.mozilla.org/show_bug.cgi?id=904810 1.8 +--> 1.9 +<head> 1.10 + <title>Test for Bug 904810</title> 1.11 + <script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script> 1.12 + <script type="text/javascript" src="/tests/SimpleTest/EventUtils.js"></script> 1.13 + <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/> 1.14 +</head> 1.15 +<body> 1.16 +<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=904810">Mozilla Bug 904810</a> 1.17 +<p id="display"> 1.18 +<textarea dir="ltr" id="textarea904810"> 1.19 +first line 1.20 +second line 1.21 +third line 1.22 +</textarea></p> 1.23 +<div id="content" style="display: none"> 1.24 + 1.25 +</div> 1.26 +<pre id="test"> 1.27 +<script type="application/javascript"> 1.28 + 1.29 +/** Test for Bug 904810 **/ 1.30 + 1.31 +SimpleTest.waitForExplicitFinish(); 1.32 +SimpleTest.waitForFocus(function test() { 1.33 + function shiftLeft(i) { 1.34 + for ( ; i > 0; --i) 1.35 + synthesizeKey("VK_LEFT", {shiftKey:true}); 1.36 + } 1.37 + 1.38 + function shiftRight(i) { 1.39 + for ( ; i > 0; --i) 1.40 + synthesizeKey("VK_RIGHT", {shiftKey:true}); 1.41 + } 1.42 + 1.43 + const isWindows = /WINNT/.test(SpecialPowers.OS); 1.44 + 1.45 + var textarea = document.getElementById('textarea904810'); 1.46 + textarea.focus(); 1.47 + 1.48 + // Testing VK_DOWN with forward selection 1.49 + textarea.selectionStart = 1; 1.50 + textarea.selectionEnd = 1; 1.51 + shiftRight(7); 1.52 + synthesizeKey("VK_DOWN", {}); 1.53 + if (isWindows) { 1.54 + is(textarea.selectionStart, 19, "caret moved to next line below selection end"); 1.55 + is(textarea.selectionEnd, 19, "caret moved to next line below selection end"); 1.56 + } else { 1.57 + is(textarea.selectionStart, 8, "caret moved to visual end of selection"); 1.58 + is(textarea.selectionEnd, 8, "caret moved to visual end of selection"); 1.59 + } 1.60 + 1.61 + // Testing VK_DOWN with backward selection 1.62 + textarea.selectionStart = 8; 1.63 + textarea.selectionEnd = 8; 1.64 + shiftLeft(7); 1.65 + synthesizeKey("VK_DOWN", {}); 1.66 + if (isWindows) { 1.67 + is(textarea.selectionStart, 12, "caret moved to next line below selection start"); 1.68 + is(textarea.selectionEnd, 12, "caret moved to next line below selection start"); 1.69 + } else { 1.70 + is(textarea.selectionStart, 8, "caret moved to visual end of selection"); 1.71 + is(textarea.selectionEnd, 8, "caret moved to visual end of selection"); 1.72 + } 1.73 + 1.74 + // Testing VK_UP with forward selection 1.75 + textarea.selectionStart = 12; 1.76 + textarea.selectionEnd = 12; 1.77 + shiftRight(7); 1.78 + synthesizeKey("VK_UP", {}); 1.79 + var result = textarea.selectionEnd 1.80 + if (isWindows) { 1.81 + is(textarea.selectionStart, 8, "caret moved to previous line above selection end"); 1.82 + is(textarea.selectionEnd, 8, "caret moved to previous line above selection end"); 1.83 + } else { 1.84 + is(textarea.selectionStart, 12, "caret moved to visual start of selection"); 1.85 + is(textarea.selectionEnd, 12, "caret moved to visual start of selection"); 1.86 + } 1.87 + 1.88 + // Testing VK_UP with backward selection 1.89 + textarea.selectionStart = 19; 1.90 + textarea.selectionEnd = 19; 1.91 + shiftLeft(7); 1.92 + synthesizeKey("VK_UP", {}); 1.93 + var result = textarea.selectionEnd 1.94 + if (isWindows) { 1.95 + is(textarea.selectionStart, 1, "caret moved to previous line above selection start"); 1.96 + is(textarea.selectionEnd, 1, "caret moved to previous line above selection start"); 1.97 + } else { 1.98 + is(textarea.selectionStart, 12, "caret moved to visual start of selection"); 1.99 + is(textarea.selectionEnd, 12, "caret moved to visual start of selection"); 1.100 + } 1.101 + 1.102 + 1.103 + 1.104 + SimpleTest.finish(); 1.105 +}); 1.106 + 1.107 + 1.108 + 1.109 + 1.110 +</script> 1.111 +</pre> 1.112 +</body> 1.113 +</html>