layout/generic/test/test_bug288789.html

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/layout/generic/test/test_bug288789.html	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,117 @@
     1.4 +<!DOCTYPE HTML>
     1.5 +<html>
     1.6 +<!--
     1.7 +https://bugzilla.mozilla.org/show_bug.cgi?id=288789
     1.8 +-->
     1.9 +<head>
    1.10 +  <title>Test for Bug 288789</title>
    1.11 +  <script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
    1.12 +  <script type="application/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=288789">Mozilla Bug 288789</a>
    1.17 +<p id="display"></p>
    1.18 +<div id="content">
    1.19 +<textarea id="ta" dir="rtl">
    1.20 +
    1.21 +&#x05d0;a&#x05d1;
    1.22 +
    1.23 +</textarea>
    1.24 +<textarea id="tb">
    1.25 +
    1.26 +abc
    1.27 +
    1.28 +</textarea>
    1.29 +</div>
    1.30 +<pre id="test">
    1.31 +<script class="testbody" type="text/javascript">
    1.32 +
    1.33 +/** Test for Bug 288789 **/
    1.34 +
    1.35 +SimpleTest.waitForExplicitFinish();
    1.36 +
    1.37 +// This seems to be necessary because the selection is not set up properly otherwise
    1.38 +setTimeout(test, 0);
    1.39 +
    1.40 +function test() {
    1.41 +  var textarea = $("ta");
    1.42 +
    1.43 +  function collapse(offset) {
    1.44 +	textarea.selectionStart = offset;
    1.45 +  	textarea.selectionEnd = offset;
    1.46 +  }
    1.47 +
    1.48 +  function testRight(offset) {
    1.49 +    synthesizeKey("VK_RIGHT", {});
    1.50 +    is(textarea.selectionStart, offset, "Right movement broken");
    1.51 +  }
    1.52 +
    1.53 +  function testLeft(offset) {
    1.54 +    synthesizeKey("VK_LEFT", {});
    1.55 +    is(textarea.selectionStart, offset, "Left movement broken");
    1.56 +  }
    1.57 +
    1.58 +  textarea.focus();
    1.59 +  collapse(0);
    1.60 +  ok(true, "Testing forward movement in RTL mode");
    1.61 +  for (var i = 0; i < textarea.textContent.length; ++i) {
    1.62 +    if (i == 0) {
    1.63 +      testRight(i);
    1.64 +    }
    1.65 +    if (textarea.textContent[i] == 'a') {
    1.66 +      testLeft(i);
    1.67 +    } else {
    1.68 +      testLeft(i + 1);
    1.69 +    }
    1.70 +    if (i == textarea.textContent.length - 1) {
    1.71 +      testLeft(i + 1);
    1.72 +    }
    1.73 +  }
    1.74 +  ok(true, "Testing backward movement in RTL mode");
    1.75 +  for (var i = textarea.textContent.length; i > 0; --i) {
    1.76 +    if (i == textarea.textContent.length) {
    1.77 +      testLeft(i);
    1.78 +    }
    1.79 +    if (i > 0 && textarea.textContent[i - 1] == 'a') {
    1.80 +      testRight(i);
    1.81 +    } else {
    1.82 +      testRight(i - 1);
    1.83 +    }
    1.84 +    if (i == 1) {
    1.85 +      testRight(i - 1);
    1.86 +    }
    1.87 +  }
    1.88 +
    1.89 +  textarea = $("tb");
    1.90 +  textarea.focus();
    1.91 +  collapse(0);
    1.92 +  ok(true, "Testing forward movement in LTR mode");
    1.93 +  for (var i = 0; i < textarea.textContent.length; ++i) {
    1.94 +    if (i == 0) {
    1.95 +      testLeft(i);
    1.96 +    }
    1.97 +    testRight(i + 1);
    1.98 +    if (i == textarea.textContent.length - 1) {
    1.99 +      testRight(i + 1);
   1.100 +    }
   1.101 +  }
   1.102 +  ok(true, "Testing backward movement in LTR mode");
   1.103 +  for (var i = textarea.textContent.length; i > 0; --i) {
   1.104 +    if (i == textarea.textContent.length) {
   1.105 +      testRight(i);
   1.106 +    }
   1.107 +    testLeft(i - 1);
   1.108 +    if (i == 1) {
   1.109 +      testLeft(i - 1);
   1.110 +    }
   1.111 +  }
   1.112 +
   1.113 +  SimpleTest.finish();
   1.114 +}
   1.115 +
   1.116 +</script>
   1.117 +</pre>
   1.118 +</body>
   1.119 +</html>
   1.120 +

mercurial