accessible/tests/mochitest/text/test_gettext.html

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/accessible/tests/mochitest/text/test_gettext.html	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,112 @@
     1.4 +<!DOCTYPE html>
     1.5 +<html>
     1.6 +<head>
     1.7 +  <title>Get text between offsets tests</title>
     1.8 +  <link rel="stylesheet" type="text/css"
     1.9 +        href="chrome://mochikit/content/tests/SimpleTest/test.css" />
    1.10 +
    1.11 +  <script type="application/javascript"
    1.12 +          src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
    1.13 +  <script type="application/javascript"
    1.14 +          src="../common.js"></script>
    1.15 +  <script type="application/javascript"
    1.16 +          src="../text.js"></script>
    1.17 +
    1.18 +  <script type="application/javascript">
    1.19 +    function doTest()
    1.20 +    {
    1.21 +      //////////////////////////////////////////////////////////////////////////
    1.22 +      //
    1.23 +      // __h__e__l__l__o__ __m__y__ __f__r__i__e__n__d__
    1.24 +      //  0  1  2  3  4  5  6  7  8  9 10 11 12 13 14 15
    1.25 +
    1.26 +      var IDs = [ "i1", "d1", "e1", "t1" ];
    1.27 +
    1.28 +      testCharacterCount(IDs, 15);
    1.29 +
    1.30 +      testText(IDs, 0, 1, "h");
    1.31 +      testText(IDs, 1, 3, "el");
    1.32 +      testText(IDs, 14, 15, "d");
    1.33 +      testText(IDs, 0, 15, "hello my friend");
    1.34 +      testText(IDs, 0, -1, "hello my friend");
    1.35 +
    1.36 +      //////////////////////////////////////////////////////////////////////////
    1.37 +      //
    1.38 +      // __B__r__a__v__e__ __S__i__r__ __ __R__o__b__i__n__ __ __ __r__a__n
    1.39 +      //  0  1  2  3  4  5  6  7  8  9 10 11 12 13 14 15 16 17 18 19 20 21
    1.40 +
    1.41 +      IDs = [ "i2", "dpre2", "epre2", "t2" ];
    1.42 +
    1.43 +      testCharacterCount(IDs, 22);
    1.44 +
    1.45 +      testText(IDs, 0, 1, "B");
    1.46 +      testText(IDs, 5, 6, " ");
    1.47 +      testText(IDs, 9, 11, "  ");
    1.48 +      testText(IDs, 16, 19, "   ");
    1.49 +      testText(IDs, 0, 22, "Brave Sir  Robin   ran");
    1.50 +      testText(IDs, 0, -1, "Brave Sir  Robin   ran");
    1.51 +
    1.52 +      testCharacterCount(["d2", "e2"], 19);
    1.53 +      testText(["d2", "e2"], 0, 19, "Brave Sir Robin ran");
    1.54 +
    1.55 +      //////////////////////////////////////////////////////////////////////////
    1.56 +      //
    1.57 +      // __o__n__e__w__o__r__d__\n
    1.58 +      //  0  1  2  3  4  5  6  7
    1.59 +      // __\n
    1.60 +      //  8
    1.61 +      // __t__w__o__ __w__o__r__d__s__\n
    1.62 +      //  9 10 11 12 13 14 15 16 17 18
    1.63 +
    1.64 +      var IDs = ["d3", "dbr3", "e3", "ebr3", "t3"];
    1.65 +
    1.66 +      testCharacterCount(IDs, 19);
    1.67 +
    1.68 +      testText(IDs, 0, 19, "oneword\n\ntwo words\n");
    1.69 +      testText(IDs, 0, -1, "oneword\n\ntwo words\n");
    1.70 +
    1.71 +      SimpleTest.finish();
    1.72 +    }
    1.73 +
    1.74 +    SimpleTest.waitForExplicitFinish();
    1.75 +    addA11yLoadEvent(doTest);
    1.76 +  </script>
    1.77 +</head>
    1.78 +<body>
    1.79 +
    1.80 +  <p id="display"></p>
    1.81 +  <div id="content" style="display: none"></div>
    1.82 +  <pre id="test">
    1.83 +  </pre>
    1.84 +
    1.85 +  <input id="i1" value="hello my friend"/>
    1.86 +  <div id="d1">hello my friend</div>
    1.87 +  <div id="e1" contenteditable="true">hello my friend</div>
    1.88 +  <textarea id="t1">hello my friend</textarea>
    1.89 +
    1.90 +  <input id="i2" value="Brave Sir  Robin   ran"/>
    1.91 +  <pre><div id="dpre2">Brave Sir  Robin   ran</div></pre>
    1.92 +  <pre><div id="epre2" contenteditable="true">Brave Sir  Robin   ran</div></pre>
    1.93 +  <textarea id="t2" cols="300">Brave Sir  Robin   ran</textarea>
    1.94 +  <div id="d2">Brave Sir  Robin   ran</div>
    1.95 +  <div id="e2" contenteditable="true">Brave Sir  Robin   ran</div>
    1.96 +
    1.97 +  <pre>
    1.98 +  <div id="d3">oneword
    1.99 +
   1.100 +two words
   1.101 +</div>
   1.102 +  <div id="dbr3">oneword<br/><br/>two words<br/><br/></div>
   1.103 +  <div id="e3" contenteditable="true">oneword
   1.104 +
   1.105 +two words
   1.106 +</div>
   1.107 +  <div id="ebr3" contenteditable="true">oneword<br/><br/>two words<br/><br/></div>
   1.108 +  <textarea id="t3" cols="300">oneword
   1.109 +
   1.110 +two words
   1.111 +</textarea>
   1.112 +  </pre>
   1.113 +
   1.114 +</body>
   1.115 +</html>

mercurial