layout/generic/test/test_bug288789.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.

     1 <!DOCTYPE HTML>
     2 <html>
     3 <!--
     4 https://bugzilla.mozilla.org/show_bug.cgi?id=288789
     5 -->
     6 <head>
     7   <title>Test for Bug 288789</title>
     8   <script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
     9   <script type="application/javascript" src="/tests/SimpleTest/EventUtils.js"></script>
    10   <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
    11 </head>
    12 <body>
    13 <a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=288789">Mozilla Bug 288789</a>
    14 <p id="display"></p>
    15 <div id="content">
    16 <textarea id="ta" dir="rtl">
    18 &#x05d0;a&#x05d1;
    20 </textarea>
    21 <textarea id="tb">
    23 abc
    25 </textarea>
    26 </div>
    27 <pre id="test">
    28 <script class="testbody" type="text/javascript">
    30 /** Test for Bug 288789 **/
    32 SimpleTest.waitForExplicitFinish();
    34 // This seems to be necessary because the selection is not set up properly otherwise
    35 setTimeout(test, 0);
    37 function test() {
    38   var textarea = $("ta");
    40   function collapse(offset) {
    41 	textarea.selectionStart = offset;
    42   	textarea.selectionEnd = offset;
    43   }
    45   function testRight(offset) {
    46     synthesizeKey("VK_RIGHT", {});
    47     is(textarea.selectionStart, offset, "Right movement broken");
    48   }
    50   function testLeft(offset) {
    51     synthesizeKey("VK_LEFT", {});
    52     is(textarea.selectionStart, offset, "Left movement broken");
    53   }
    55   textarea.focus();
    56   collapse(0);
    57   ok(true, "Testing forward movement in RTL mode");
    58   for (var i = 0; i < textarea.textContent.length; ++i) {
    59     if (i == 0) {
    60       testRight(i);
    61     }
    62     if (textarea.textContent[i] == 'a') {
    63       testLeft(i);
    64     } else {
    65       testLeft(i + 1);
    66     }
    67     if (i == textarea.textContent.length - 1) {
    68       testLeft(i + 1);
    69     }
    70   }
    71   ok(true, "Testing backward movement in RTL mode");
    72   for (var i = textarea.textContent.length; i > 0; --i) {
    73     if (i == textarea.textContent.length) {
    74       testLeft(i);
    75     }
    76     if (i > 0 && textarea.textContent[i - 1] == 'a') {
    77       testRight(i);
    78     } else {
    79       testRight(i - 1);
    80     }
    81     if (i == 1) {
    82       testRight(i - 1);
    83     }
    84   }
    86   textarea = $("tb");
    87   textarea.focus();
    88   collapse(0);
    89   ok(true, "Testing forward movement in LTR mode");
    90   for (var i = 0; i < textarea.textContent.length; ++i) {
    91     if (i == 0) {
    92       testLeft(i);
    93     }
    94     testRight(i + 1);
    95     if (i == textarea.textContent.length - 1) {
    96       testRight(i + 1);
    97     }
    98   }
    99   ok(true, "Testing backward movement in LTR mode");
   100   for (var i = textarea.textContent.length; i > 0; --i) {
   101     if (i == textarea.textContent.length) {
   102       testRight(i);
   103     }
   104     testLeft(i - 1);
   105     if (i == 1) {
   106       testLeft(i - 1);
   107     }
   108   }
   110   SimpleTest.finish();
   111 }
   113 </script>
   114 </pre>
   115 </body>
   116 </html>

mercurial