Wed, 31 Dec 2014 06:09:35 +0100
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=288789 |
michael@0 | 5 | --> |
michael@0 | 6 | <head> |
michael@0 | 7 | <title>Test for Bug 288789</title> |
michael@0 | 8 | <script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script> |
michael@0 | 9 | <script type="application/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=288789">Mozilla Bug 288789</a> |
michael@0 | 14 | <p id="display"></p> |
michael@0 | 15 | <div id="content"> |
michael@0 | 16 | <textarea id="ta" dir="rtl"> |
michael@0 | 17 | |
michael@0 | 18 | אaב |
michael@0 | 19 | |
michael@0 | 20 | </textarea> |
michael@0 | 21 | <textarea id="tb"> |
michael@0 | 22 | |
michael@0 | 23 | abc |
michael@0 | 24 | |
michael@0 | 25 | </textarea> |
michael@0 | 26 | </div> |
michael@0 | 27 | <pre id="test"> |
michael@0 | 28 | <script class="testbody" type="text/javascript"> |
michael@0 | 29 | |
michael@0 | 30 | /** Test for Bug 288789 **/ |
michael@0 | 31 | |
michael@0 | 32 | SimpleTest.waitForExplicitFinish(); |
michael@0 | 33 | |
michael@0 | 34 | // This seems to be necessary because the selection is not set up properly otherwise |
michael@0 | 35 | setTimeout(test, 0); |
michael@0 | 36 | |
michael@0 | 37 | function test() { |
michael@0 | 38 | var textarea = $("ta"); |
michael@0 | 39 | |
michael@0 | 40 | function collapse(offset) { |
michael@0 | 41 | textarea.selectionStart = offset; |
michael@0 | 42 | textarea.selectionEnd = offset; |
michael@0 | 43 | } |
michael@0 | 44 | |
michael@0 | 45 | function testRight(offset) { |
michael@0 | 46 | synthesizeKey("VK_RIGHT", {}); |
michael@0 | 47 | is(textarea.selectionStart, offset, "Right movement broken"); |
michael@0 | 48 | } |
michael@0 | 49 | |
michael@0 | 50 | function testLeft(offset) { |
michael@0 | 51 | synthesizeKey("VK_LEFT", {}); |
michael@0 | 52 | is(textarea.selectionStart, offset, "Left movement broken"); |
michael@0 | 53 | } |
michael@0 | 54 | |
michael@0 | 55 | textarea.focus(); |
michael@0 | 56 | collapse(0); |
michael@0 | 57 | ok(true, "Testing forward movement in RTL mode"); |
michael@0 | 58 | for (var i = 0; i < textarea.textContent.length; ++i) { |
michael@0 | 59 | if (i == 0) { |
michael@0 | 60 | testRight(i); |
michael@0 | 61 | } |
michael@0 | 62 | if (textarea.textContent[i] == 'a') { |
michael@0 | 63 | testLeft(i); |
michael@0 | 64 | } else { |
michael@0 | 65 | testLeft(i + 1); |
michael@0 | 66 | } |
michael@0 | 67 | if (i == textarea.textContent.length - 1) { |
michael@0 | 68 | testLeft(i + 1); |
michael@0 | 69 | } |
michael@0 | 70 | } |
michael@0 | 71 | ok(true, "Testing backward movement in RTL mode"); |
michael@0 | 72 | for (var i = textarea.textContent.length; i > 0; --i) { |
michael@0 | 73 | if (i == textarea.textContent.length) { |
michael@0 | 74 | testLeft(i); |
michael@0 | 75 | } |
michael@0 | 76 | if (i > 0 && textarea.textContent[i - 1] == 'a') { |
michael@0 | 77 | testRight(i); |
michael@0 | 78 | } else { |
michael@0 | 79 | testRight(i - 1); |
michael@0 | 80 | } |
michael@0 | 81 | if (i == 1) { |
michael@0 | 82 | testRight(i - 1); |
michael@0 | 83 | } |
michael@0 | 84 | } |
michael@0 | 85 | |
michael@0 | 86 | textarea = $("tb"); |
michael@0 | 87 | textarea.focus(); |
michael@0 | 88 | collapse(0); |
michael@0 | 89 | ok(true, "Testing forward movement in LTR mode"); |
michael@0 | 90 | for (var i = 0; i < textarea.textContent.length; ++i) { |
michael@0 | 91 | if (i == 0) { |
michael@0 | 92 | testLeft(i); |
michael@0 | 93 | } |
michael@0 | 94 | testRight(i + 1); |
michael@0 | 95 | if (i == textarea.textContent.length - 1) { |
michael@0 | 96 | testRight(i + 1); |
michael@0 | 97 | } |
michael@0 | 98 | } |
michael@0 | 99 | ok(true, "Testing backward movement in LTR mode"); |
michael@0 | 100 | for (var i = textarea.textContent.length; i > 0; --i) { |
michael@0 | 101 | if (i == textarea.textContent.length) { |
michael@0 | 102 | testRight(i); |
michael@0 | 103 | } |
michael@0 | 104 | testLeft(i - 1); |
michael@0 | 105 | if (i == 1) { |
michael@0 | 106 | testLeft(i - 1); |
michael@0 | 107 | } |
michael@0 | 108 | } |
michael@0 | 109 | |
michael@0 | 110 | SimpleTest.finish(); |
michael@0 | 111 | } |
michael@0 | 112 | |
michael@0 | 113 | </script> |
michael@0 | 114 | </pre> |
michael@0 | 115 | </body> |
michael@0 | 116 | </html> |
michael@0 | 117 |