accessible/tests/mochitest/text/test_lineboundary.html

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/accessible/tests/mochitest/text/test_lineboundary.html	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,223 @@
     1.4 +<!DOCTYPE html>
     1.5 +<html>
     1.6 +<head>
     1.7 +  <title>Line boundary getText* functions tests</title>
     1.8 +  <link rel="stylesheet" type="text/css" href="chrome://mochikit/content/tests/SimpleTest/test.css" />
     1.9 +
    1.10 +  <script type="application/javascript"
    1.11 +          src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
    1.12 +  <script type="application/javascript"
    1.13 +          src="../common.js"></script>
    1.14 +  <script type="application/javascript"
    1.15 +          src="../text.js"></script>
    1.16 +  <script type="application/javascript">
    1.17 +    function doTest()
    1.18 +    {
    1.19 +      //////////////////////////////////////////////////////////////////////////
    1.20 +      // __h__e__l__l__o__ __m__y__ __f__r__i__e__n__d__
    1.21 +      //  0  1  2  3  4  5  6  7  8  9 10 11 12 13 14 15
    1.22 +
    1.23 +      var IDs = [ "input", "div", "editable", "textarea",
    1.24 +                  getNode("ta", getNode("ta_cntr").contentDocument) ];
    1.25 +
    1.26 +      testTextBeforeOffset(IDs, BOUNDARY_LINE_START,
    1.27 +                           [ [ 0, 15, "", 0, 0 ] ]);
    1.28 +      testTextBeforeOffset(IDs, BOUNDARY_LINE_END,
    1.29 +                           [ [ 0, 15, "", 0, 0 ] ]);
    1.30 +
    1.31 +      testTextAtOffset(IDs, BOUNDARY_LINE_START,
    1.32 +                       [ [ 0, 15, "hello my friend", 0, 15 ] ]);
    1.33 +      testTextAtOffset(IDs, BOUNDARY_LINE_END,
    1.34 +                       [ [ 0, 15, "hello my friend", 0, 15 ] ]);
    1.35 +
    1.36 +      testTextAfterOffset(IDs, BOUNDARY_LINE_START,
    1.37 +                          [ [ 0, 15, "", 15, 15 ] ]);
    1.38 +      testTextAfterOffset(IDs, BOUNDARY_LINE_END,
    1.39 +                          [ [ 0, 15, "", 15, 15 ] ]);
    1.40 +
    1.41 +      //////////////////////////////////////////////////////////////////////////
    1.42 +      // __o__n__e__w__o__r__d__\n
    1.43 +      //  0  1  2  3  4  5  6  7
    1.44 +      // __\n
    1.45 +      //  8
    1.46 +      // __t__w__o__ __w__o__r__d__s__\n
    1.47 +      //  9 10 11 12 13 14 15 16 17 18
    1.48 +
    1.49 +      IDs = [ "ml_div", "ml_divbr", "ml_editable", "ml_editablebr", "ml_textarea"];
    1.50 +
    1.51 +      testTextBeforeOffset(IDs, BOUNDARY_LINE_START,
    1.52 +                           [ [ 0, 7, "", 0, 0 ],
    1.53 +                             [ 8, 8, "oneword\n", 0, 8 ],
    1.54 +                             [ 9, 18, "\n", 8, 9 ],
    1.55 +                             [ 19, 19, "two words\n", 9, 19 ]]);
    1.56 +
    1.57 +      testTextBeforeOffset(IDs, BOUNDARY_LINE_END,
    1.58 +                          [ [ 0, 7, "", 0, 0 ],
    1.59 +                            [ 8, 8, "oneword", 0, 7 ],
    1.60 +                            [ 9, 18, "\n", 7, 8 ],
    1.61 +                            [ 19, 19, "\ntwo words", 8, 18 ]]);
    1.62 +
    1.63 +      testTextAtOffset(IDs, BOUNDARY_LINE_START,
    1.64 +                       [ [ 0, 7, "oneword\n", 0, 8 ],
    1.65 +                         [ 8, 8, "\n", 8, 9 ],
    1.66 +                         [ 9, 18, "two words\n", 9, 19 ],
    1.67 +                         [ 19, 19, "", 19, 19 ]]);
    1.68 +      testTextAtOffset(IDs, BOUNDARY_LINE_END,
    1.69 +                       [ [ 0, 7, "oneword", 0, 7 ],
    1.70 +                         [ 8, 8, "\n", 7, 8 ],
    1.71 +                         [ 9, 18, "\ntwo words", 8, 18 ],
    1.72 +                         [ 19, 19, "\n", 18, 19 ]]);
    1.73 +
    1.74 +      testTextAfterOffset(IDs, BOUNDARY_LINE_START,
    1.75 +                          [ [ 0, 7, "\n", 8, 9 ],
    1.76 +                            [ 8, 8, "two words\n", 9, 19 ],
    1.77 +                            [ 9, 19, "", 19, 19 ]]);
    1.78 +      testTextAfterOffset(IDs, BOUNDARY_LINE_END,
    1.79 +                          [ [ 0, 7, "\n", 7, 8 ],
    1.80 +                            [ 8, 8, "\ntwo words", 8, 18 ],
    1.81 +                            [ 9, 18, "\n", 18, 19 ],
    1.82 +                            [ 19, 19, "", 19, 19 ]]);
    1.83 +
    1.84 +      //////////////////////////////////////////////////////////////////////////
    1.85 +      // a * b (* is embedded char for link)
    1.86 +      testTextBeforeOffset([ getAccessible("ht_1").firstChild ], BOUNDARY_LINE_START,
    1.87 +                           [ [ 0, 5, "", 0, 0 ] ]);
    1.88 +
    1.89 +      testTextBeforeOffset([ getAccessible("ht_1").firstChild ], BOUNDARY_LINE_END,
    1.90 +                           [ [ 0, 5, "", 0, 0 ] ]);
    1.91 +
    1.92 +      testTextAtOffset([ getAccessible("ht_1").firstChild ], BOUNDARY_LINE_START,
    1.93 +                       [ [ 0, 5, "a " + kEmbedChar + " c", 0, 5 ] ]);
    1.94 +
    1.95 +      testTextAtOffset([ getAccessible("ht_1").firstChild ], BOUNDARY_LINE_END,
    1.96 +                       [ [ 0, 5, "a " + kEmbedChar + " c", 0, 5 ] ]);
    1.97 +
    1.98 +      testTextAfterOffset([ getAccessible("ht_1").firstChild ], BOUNDARY_LINE_START,
    1.99 +                          [ [ 0, 5, "", 5, 5 ] ]);
   1.100 +
   1.101 +      testTextAfterOffset([ getAccessible("ht_1").firstChild ], BOUNDARY_LINE_END,
   1.102 +                          [ [ 0, 5, "", 5, 5 ] ]);
   1.103 +
   1.104 +      //////////////////////////////////////////////////////////////////////////
   1.105 +      // foo<br> and foo<br><br>
   1.106 +
   1.107 +      testTextAtOffset([ getAccessible("ht_2").firstChild.firstChild ],
   1.108 +                       BOUNDARY_LINE_START,
   1.109 +                       [ [ 0, 3, "foo", 0, 3 ] ]);
   1.110 +      testTextAtOffset([ getAccessible("ht_3").firstChild.firstChild ],
   1.111 +                       BOUNDARY_LINE_START,
   1.112 +                       [ [ 0, 3, "foo\n", 0, 4 ], [ 4, 4, "", 4, 4 ] ]);
   1.113 +
   1.114 +      //////////////////////////////////////////////////////////////////////////
   1.115 +      // 'Hello world ' (\n is rendered as space)
   1.116 +
   1.117 +      testTextAtOffset([ "ht_4" ], BOUNDARY_LINE_START,
   1.118 +                       [ [ 0, 12, "Hello world ", 0, 12 ] ]);
   1.119 +
   1.120 +      //////////////////////////////////////////////////////////////////////////
   1.121 +      // list items
   1.122 +
   1.123 +      testTextAtOffset([ "li1" ], BOUNDARY_LINE_START,
   1.124 +                       [ [ 0, 5, kDiscBulletChar + "Item", 0, 5 ] ]);
   1.125 +      testTextAtOffset([ "li2" ], BOUNDARY_LINE_START,
   1.126 +                       [ [ 0, 1, kDiscBulletChar, 0, 1 ] ]);
   1.127 +      testTextAtOffset([ "li3" ], BOUNDARY_LINE_START,
   1.128 +                       [ [ 0, 7, kDiscBulletChar + "a long ", 0, 8 ],
   1.129 +                         [ 8, 11, "and ", 8, 12 ] ]);
   1.130 +      testTextAtOffset([ "li4" ], BOUNDARY_LINE_START,
   1.131 +                       [ [ 0, 6, kDiscBulletChar + "a " + kEmbedChar + " c", 0, 6 ] ]);
   1.132 +      testTextAtOffset([ "ul1" ], BOUNDARY_LINE_START,
   1.133 +                       [ [ 0, 0, kEmbedChar, 0, 1 ],
   1.134 +                         [ 1, 1, kEmbedChar, 1, 2 ],
   1.135 +                         [ 2, 2, kEmbedChar, 2, 3 ],
   1.136 +                         [ 3, 4, kEmbedChar, 3, 4 ] ]);
   1.137 +
   1.138 +      //////////////////////////////////////////////////////////////////////////
   1.139 +      // Nested hypertexts
   1.140 +
   1.141 +      testTextAtOffset(["ht_5" ], BOUNDARY_LINE_START,
   1.142 +                       [ [ 0, 0, kEmbedChar, 0, 1 ] ]);
   1.143 +
   1.144 +      SimpleTest.finish();
   1.145 +    }
   1.146 +
   1.147 +    SimpleTest.waitForExplicitFinish();
   1.148 +    addA11yLoadEvent(doTest);
   1.149 +  </script>
   1.150 +</head>
   1.151 +<body>
   1.152 +
   1.153 +  <a target="_blank"
   1.154 +     title="getTextAtOffset for word boundaries: beginning of a new life"
   1.155 +     href="https://bugzilla.mozilla.org/show_bug.cgi?id=853340">
   1.156 +    Bug 853340
   1.157 +  </a>
   1.158 +  <a target="_blank"
   1.159 +     title="getTextBeforeOffset for word boundaries: evolving"
   1.160 +     href="https://bugzilla.mozilla.org/show_bug.cgi?id=855732">
   1.161 +    Bug 855732
   1.162 +  </a>
   1.163 +  <a target="_blank"
   1.164 +     title=" getTextAfterOffset for line boundary on new rails"
   1.165 +     href="https://bugzilla.mozilla.org/show_bug.cgi?id=882292">
   1.166 +    Bug 882292
   1.167 +  </a>
   1.168 +  <a target="_blank"
   1.169 +     title="getTextAtOffset broken for last object when closing tag is preceded by newline char"
   1.170 +     href="https://bugzilla.mozilla.org/show_bug.cgi?id=947170">
   1.171 +    Bug 947170
   1.172 +  </a>
   1.173 +
   1.174 +  <p id="display"></p>
   1.175 +  <div id="content" style="display: none"></div>
   1.176 +  <pre id="test">
   1.177 +  </pre>
   1.178 +
   1.179 +  <input id="input" value="hello my friend"/>
   1.180 +  <div id="div">hello my friend</div>
   1.181 +  <div id="editable" contenteditable="true">hello my friend</div>
   1.182 +  <textarea id="textarea">hello my friend</textarea>
   1.183 +  <iframe id="ta_cntr"
   1.184 +          src="data:text/html,<html><body><textarea id='ta'>hello my friend</textarea></body></html>"></iframe>
   1.185 +
   1.186 +  <pre>
   1.187 +    <div id="ml_div" style="border-style:outset;">oneword
   1.188 +
   1.189 +two words
   1.190 +</div>
   1.191 +  <div id="ml_divbr" style="border-style:outset;">oneword<br/><br/>two words<br/><br/></div>
   1.192 +  <div id="ml_editable" style="border-style:outset;" contenteditable="true">oneword
   1.193 +
   1.194 +two words
   1.195 +</div>
   1.196 +  <div id="ml_editablebr" contenteditable="true" style="border-style:outset;">oneword<br/><br/>two words<br/><br/></div>
   1.197 +  <textarea id="ml_textarea" cols="300">oneword
   1.198 +
   1.199 +two words
   1.200 +</textarea>
   1.201 +  </pre>
   1.202 +
   1.203 +  <iframe id="ht_1" src="data:text/html,<html><body>a <a href=''>b</a> c</body></html>"></iframe>
   1.204 +
   1.205 +  <iframe id="ht_2" src="data:text/html,<div contentEditable='true'>foo<br/></div>"></iframe>
   1.206 +  <iframe id="ht_3" src="data:text/html,<div contentEditable='true'>foo<br/><br/></div>"></iframe>
   1.207 +
   1.208 +  <p id="ht_4">Hello world
   1.209 +</p>
   1.210 +
   1.211 +  <ul id="ul1">
   1.212 +    <li id="li1">Item</li>
   1.213 +    <li id="li2"></li>
   1.214 +    <li id="li3" style="width:10ex; font-family:monospace; font-size:10pt;">a long and winding road that lead me to your door</li>
   1.215 +    <li id="li4">a <a href=''>b</a> c</li>
   1.216 +  </ul>
   1.217 +
   1.218 +  <div id="ht_5">
   1.219 +    <div>
   1.220 +      <p>sectiounus</p>
   1.221 +      <p>seciofarus</p>
   1.222 +    </div>
   1.223 +  </div>
   1.224 +
   1.225 +</body>
   1.226 +</html>

mercurial