layout/generic/test/test_bug904810.html

Wed, 31 Dec 2014 06:09:35 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 06:09:35 +0100
changeset 0
6474c204b198
permissions
-rw-r--r--

Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.

michael@0 1 <!DOCTYPE HTML>
michael@0 2 <html>
michael@0 3 <!--
michael@0 4 https://bugzilla.mozilla.org/show_bug.cgi?id=904810
michael@0 5 -->
michael@0 6 <head>
michael@0 7 <title>Test for Bug 904810</title>
michael@0 8 <script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
michael@0 9 <script type="text/javascript" src="/tests/SimpleTest/EventUtils.js"></script>
michael@0 10 <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
michael@0 11 </head>
michael@0 12 <body>
michael@0 13 <a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=904810">Mozilla Bug 904810</a>
michael@0 14 <p id="display">
michael@0 15 <textarea dir="ltr" id="textarea904810">
michael@0 16 first line
michael@0 17 second line
michael@0 18 third line
michael@0 19 </textarea></p>
michael@0 20 <div id="content" style="display: none">
michael@0 21
michael@0 22 </div>
michael@0 23 <pre id="test">
michael@0 24 <script type="application/javascript">
michael@0 25
michael@0 26 /** Test for Bug 904810 **/
michael@0 27
michael@0 28 SimpleTest.waitForExplicitFinish();
michael@0 29 SimpleTest.waitForFocus(function test() {
michael@0 30 function shiftLeft(i) {
michael@0 31 for ( ; i > 0; --i)
michael@0 32 synthesizeKey("VK_LEFT", {shiftKey:true});
michael@0 33 }
michael@0 34
michael@0 35 function shiftRight(i) {
michael@0 36 for ( ; i > 0; --i)
michael@0 37 synthesizeKey("VK_RIGHT", {shiftKey:true});
michael@0 38 }
michael@0 39
michael@0 40 const isWindows = /WINNT/.test(SpecialPowers.OS);
michael@0 41
michael@0 42 var textarea = document.getElementById('textarea904810');
michael@0 43 textarea.focus();
michael@0 44
michael@0 45 // Testing VK_DOWN with forward selection
michael@0 46 textarea.selectionStart = 1;
michael@0 47 textarea.selectionEnd = 1;
michael@0 48 shiftRight(7);
michael@0 49 synthesizeKey("VK_DOWN", {});
michael@0 50 if (isWindows) {
michael@0 51 is(textarea.selectionStart, 19, "caret moved to next line below selection end");
michael@0 52 is(textarea.selectionEnd, 19, "caret moved to next line below selection end");
michael@0 53 } else {
michael@0 54 is(textarea.selectionStart, 8, "caret moved to visual end of selection");
michael@0 55 is(textarea.selectionEnd, 8, "caret moved to visual end of selection");
michael@0 56 }
michael@0 57
michael@0 58 // Testing VK_DOWN with backward selection
michael@0 59 textarea.selectionStart = 8;
michael@0 60 textarea.selectionEnd = 8;
michael@0 61 shiftLeft(7);
michael@0 62 synthesizeKey("VK_DOWN", {});
michael@0 63 if (isWindows) {
michael@0 64 is(textarea.selectionStart, 12, "caret moved to next line below selection start");
michael@0 65 is(textarea.selectionEnd, 12, "caret moved to next line below selection start");
michael@0 66 } else {
michael@0 67 is(textarea.selectionStart, 8, "caret moved to visual end of selection");
michael@0 68 is(textarea.selectionEnd, 8, "caret moved to visual end of selection");
michael@0 69 }
michael@0 70
michael@0 71 // Testing VK_UP with forward selection
michael@0 72 textarea.selectionStart = 12;
michael@0 73 textarea.selectionEnd = 12;
michael@0 74 shiftRight(7);
michael@0 75 synthesizeKey("VK_UP", {});
michael@0 76 var result = textarea.selectionEnd
michael@0 77 if (isWindows) {
michael@0 78 is(textarea.selectionStart, 8, "caret moved to previous line above selection end");
michael@0 79 is(textarea.selectionEnd, 8, "caret moved to previous line above selection end");
michael@0 80 } else {
michael@0 81 is(textarea.selectionStart, 12, "caret moved to visual start of selection");
michael@0 82 is(textarea.selectionEnd, 12, "caret moved to visual start of selection");
michael@0 83 }
michael@0 84
michael@0 85 // Testing VK_UP with backward selection
michael@0 86 textarea.selectionStart = 19;
michael@0 87 textarea.selectionEnd = 19;
michael@0 88 shiftLeft(7);
michael@0 89 synthesizeKey("VK_UP", {});
michael@0 90 var result = textarea.selectionEnd
michael@0 91 if (isWindows) {
michael@0 92 is(textarea.selectionStart, 1, "caret moved to previous line above selection start");
michael@0 93 is(textarea.selectionEnd, 1, "caret moved to previous line above selection start");
michael@0 94 } else {
michael@0 95 is(textarea.selectionStart, 12, "caret moved to visual start of selection");
michael@0 96 is(textarea.selectionEnd, 12, "caret moved to visual start of selection");
michael@0 97 }
michael@0 98
michael@0 99
michael@0 100
michael@0 101 SimpleTest.finish();
michael@0 102 });
michael@0 103
michael@0 104
michael@0 105
michael@0 106
michael@0 107 </script>
michael@0 108 </pre>
michael@0 109 </body>
michael@0 110 </html>

mercurial