accessible/tests/mochitest/text/test_wordboundary.html

Tue, 06 Jan 2015 21:39:09 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Tue, 06 Jan 2015 21:39:09 +0100
branch
TOR_BUG_9701
changeset 8
97036ab72558
permissions
-rw-r--r--

Conditionally force memory storage according to privacy.thirdparty.isolate;
This solves Tor bug #9701, complying with disk avoidance documented in
https://www.torproject.org/projects/torbrowser/design/#disk-avoidance.

michael@0 1 <!DOCTYPE html>
michael@0 2 <html>
michael@0 3 <head>
michael@0 4 <title>Word boundary text tests</title>
michael@0 5 <link rel="stylesheet" type="text/css"
michael@0 6 href="chrome://mochikit/content/tests/SimpleTest/test.css" />
michael@0 7
michael@0 8 <script type="application/javascript"
michael@0 9 src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
michael@0 10 <script type="application/javascript"
michael@0 11 src="../common.js"></script>
michael@0 12 <script type="application/javascript"
michael@0 13 src="../text.js"></script>
michael@0 14
michael@0 15 <script type="application/javascript">
michael@0 16 function doTest()
michael@0 17 {
michael@0 18 // "hello"
michael@0 19 // __h__e__l__l__o__
michael@0 20 // 0 1 2 3 4 5
michael@0 21 var ids = [ "i1", "d1", "e1", "t1" ];
michael@0 22 testTextBeforeOffset(ids, BOUNDARY_WORD_START,
michael@0 23 [ [ 0, 5, "", 0, 0 ] ]);
michael@0 24 testTextBeforeOffset(ids, BOUNDARY_WORD_END,
michael@0 25 [ [ 0, 5, "", 0, 0 ] ]);
michael@0 26
michael@0 27 testTextAtOffset(ids, BOUNDARY_WORD_START,
michael@0 28 [ [ 0, 5, "hello", 0, 5 ] ]);
michael@0 29 testTextAtOffset(ids, BOUNDARY_WORD_END,
michael@0 30 [ [ 0, 5, "hello", 0, 5 ] ]);
michael@0 31
michael@0 32 testTextAfterOffset(ids, BOUNDARY_WORD_START,
michael@0 33 [ [ 0, 5, "", 5, 5 ] ]);
michael@0 34 testTextAfterOffset(ids, BOUNDARY_WORD_END,
michael@0 35 [ [ 0, 5, "", 5, 5 ] ]);
michael@0 36
michael@0 37 // "hello "
michael@0 38 // __h__e__l__l__o__ __
michael@0 39 // 0 1 2 3 4 5 6
michael@0 40 var ids = [ "i2", "d2", "e2", "t2" ];
michael@0 41 testTextBeforeOffset(ids, BOUNDARY_WORD_START,
michael@0 42 [ [ 0, 6, "", 0, 0 ] ]);
michael@0 43 testTextBeforeOffset(ids, BOUNDARY_WORD_END,
michael@0 44 [ [ 0, 5, "", 0, 0 ],
michael@0 45 [ 6, 6, "hello", 0, 5,
michael@0 46 [ [6, "e2", kTodo, kOk, kTodo ] ]
michael@0 47 ]
michael@0 48 ]);
michael@0 49
michael@0 50 testTextAtOffset(ids, BOUNDARY_WORD_START,
michael@0 51 [ [ 0, 6, "hello ", 0, 6 ] ]);
michael@0 52 testTextAtOffset(ids, BOUNDARY_WORD_END,
michael@0 53 [ [ 0, 4, "hello", 0, 5 ],
michael@0 54 [ 5, 6, " ", 5, 6,
michael@0 55 [ [ 5, "e2", kTodo, kTodo, kOk ],
michael@0 56 [ 6, "e2", kTodo, kTodo, kOk ] ]
michael@0 57 ]
michael@0 58 ]);
michael@0 59
michael@0 60 testTextAfterOffset(ids, BOUNDARY_WORD_START,
michael@0 61 [ [ 0, 6, "", 6, 6 ] ]);
michael@0 62 testTextAfterOffset(ids, BOUNDARY_WORD_END,
michael@0 63 [ [ 0, 5, " ", 5, 6,
michael@0 64 [ [ 5, "e2", kTodo, kTodo, kOk ] ]
michael@0 65 ],
michael@0 66 [ 6, 6, "", 6, 6 ]
michael@0 67 ]);
michael@0 68
michael@0 69 // "hello all"
michael@0 70 // __h__e__l__l__o__ __a__l__l__
michael@0 71 // 0 1 2 3 4 5 6 7 8 9
michael@0 72 ids = [ "i6", "d6", "e6", "t6" ];
michael@0 73 testTextBeforeOffset(ids, BOUNDARY_WORD_START,
michael@0 74 [ [ 0, 5, "", 0, 0 ],
michael@0 75 [ 6, 9, "hello ", 0, 6 ]]);
michael@0 76 testTextBeforeOffset(ids, BOUNDARY_WORD_END,
michael@0 77 [ [ 0, 5, "", 0, 0 ],
michael@0 78 [ 6, 9, "hello", 0, 5 ] ]);
michael@0 79
michael@0 80 testTextAtOffset(ids, BOUNDARY_WORD_START,
michael@0 81 [ [ 0, 5, "hello ", 0, 6 ],
michael@0 82 [ 6, 9, "all", 6, 9 ] ]);
michael@0 83 testTextAtOffset(ids, BOUNDARY_WORD_END,
michael@0 84 [ [ 0, 4, "hello", 0, 5 ],
michael@0 85 [ 5, 9, " all", 5, 9 ] ]);
michael@0 86
michael@0 87 testTextAfterOffset(ids, BOUNDARY_WORD_START,
michael@0 88 [ [ 0, 5, "all", 6, 9 ],
michael@0 89 [ 6, 9, "", 9, 9 ] ]);
michael@0 90 testTextAfterOffset(ids, BOUNDARY_WORD_END,
michael@0 91 [ [ 0, 5, " all", 5, 9 ],
michael@0 92 [ 6, 9, "", 9, 9 ] ]);
michael@0 93
michael@0 94 // "hello my friend"
michael@0 95 // __h__e__l__l__o__ __m__y__ __f__r__i__e__n__d__
michael@0 96 // 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
michael@0 97 ids = [ "i7", "d7", "e7", "t7" ];
michael@0 98 testTextBeforeOffset(ids, BOUNDARY_WORD_START,
michael@0 99 [ [ 0, 5, "", 0, 0 ],
michael@0 100 [ 6, 8, "hello ", 0, 6 ],
michael@0 101 [ 9, 15, "my ", 6, 9 ] ]);
michael@0 102 testTextBeforeOffset(ids, BOUNDARY_WORD_END,
michael@0 103 [ [ 0, 5, "", 0, 0 ],
michael@0 104 [ 6, 8, "hello", 0, 5 ],
michael@0 105 [ 9, 15, " my", 5, 8 ] ]);
michael@0 106
michael@0 107 testTextAtOffset(ids, BOUNDARY_WORD_START,
michael@0 108 [ [ 0, 5, "hello ", 0, 6 ],
michael@0 109 [ 6, 8, "my ", 6, 9 ],
michael@0 110 [ 9, 15, "friend", 9, 15] ]);
michael@0 111 testTextAtOffset(ids, BOUNDARY_WORD_END,
michael@0 112 [ [ 0, 4, "hello", 0, 5 ],
michael@0 113 [ 5, 7, " my", 5, 8 ],
michael@0 114 [ 8, 15, " friend", 8, 15] ]);
michael@0 115
michael@0 116 testTextAfterOffset(ids, BOUNDARY_WORD_START,
michael@0 117 [ [ 0, 5, "my ", 6, 9 ],
michael@0 118 [ 6, 8, "friend", 9, 15 ],
michael@0 119 [ 9, 15, "", 15, 15 ] ]);
michael@0 120 testTextAfterOffset(ids, BOUNDARY_WORD_END,
michael@0 121 [ [ 0, 5, " my", 5, 8 ],
michael@0 122 [ 6, 8, " friend", 8, 15 ],
michael@0 123 [ 9, 15, "", 15, 15 ] ]);
michael@0 124
michael@0 125 // "Brave Sir Robin ran"
michael@0 126 // __B__r__a__v__e__ __S__i__r__ __ __R__o__b__i__n__ __ __ __r__a__n__
michael@0 127 // 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22
michael@0 128 ids = [ "i8", "d8", "e8", "t8" ];
michael@0 129 testTextBeforeOffset(ids, BOUNDARY_WORD_START,
michael@0 130 [ [ 0, 5, "", 0, 0 ],
michael@0 131 [ 6, 10, "Brave ", 0, 6 ],
michael@0 132 [ 11, 18, "Sir ", 6, 11 ],
michael@0 133 [ 19, 22, "Robin ", 11, 19 ] ]);
michael@0 134 testTextBeforeOffset(ids, BOUNDARY_WORD_END,
michael@0 135 [ [ 0, 5, "", 0, 0 ],
michael@0 136 [ 6, 9, "Brave", 0, 5 ],
michael@0 137 [ 10, 16, " Sir", 5, 9 ],
michael@0 138 [ 17, 22, " Robin", 9, 16 ] ]);
michael@0 139
michael@0 140 testTextAtOffset(ids, BOUNDARY_WORD_START,
michael@0 141 [ [ 0, 5, "Brave ", 0, 6 ],
michael@0 142 [ 6, 10, "Sir ", 6, 11 ],
michael@0 143 [ 11, 18, "Robin ", 11, 19 ],
michael@0 144 [ 19, 22, "ran", 19, 22 ] ]);
michael@0 145 testTextAtOffset(ids, BOUNDARY_WORD_END,
michael@0 146 [ [ 0, 4, "Brave", 0, 5 ],
michael@0 147 [ 5, 8, " Sir", 5, 9 ],
michael@0 148 [ 9, 15, " Robin", 9, 16 ],
michael@0 149 [ 16, 22, " ran", 16, 22 ] ]);
michael@0 150
michael@0 151 testTextAfterOffset(ids, BOUNDARY_WORD_START,
michael@0 152 [ [ 0, 5, "Sir ", 6, 11 ],
michael@0 153 [ 6, 10, "Robin ", 11, 19 ],
michael@0 154 [ 11, 18, "ran", 19, 22 ],
michael@0 155 [ 19, 22, "", 22, 22 ] ]);
michael@0 156 testTextAfterOffset(ids, BOUNDARY_WORD_END,
michael@0 157 [ [ 0, 5, " Sir", 5, 9 ],
michael@0 158 [ 6, 9, " Robin", 9, 16 ],
michael@0 159 [ 10, 16, " ran", 16, 22 ],
michael@0 160 [ 17, 22, "", 22, 22 ] ]);
michael@0 161
michael@0 162 // 'oneword
michael@0 163 // '
michael@0 164 // 'two words
michael@0 165 // '
michael@0 166 // __o__n__e__w__o__r__d__\n
michael@0 167 // 0 1 2 3 4 5 6 7
michael@0 168 // __\n
michael@0 169 // 8
michael@0 170 // __t__w__o__ __w__o__r__d__s__\n__
michael@0 171 // 9 10 11 12 13 14 15 16 17 18 19
michael@0 172
michael@0 173 ids = ["ml_div1", "ml_divbr1", "ml_ediv1", "ml_edivbr1", "ml_t1"];
michael@0 174 testTextBeforeOffset(ids, BOUNDARY_WORD_START,
michael@0 175 [ [ 0, 8, "", 0, 0 ],
michael@0 176 [ 9, 12, "oneword\n\n", 0, 9 ],
michael@0 177 [ 13, 19, "two ", 9, 13 ] ]);
michael@0 178 testTextBeforeOffset(ids, BOUNDARY_WORD_END,
michael@0 179 [ [ 0, 7, "", 0, 0 ],
michael@0 180 [ 8, 12, "oneword", 0, 7,
michael@0 181 [ [ 8, "ml_divbr1", kTodo, kOk, kTodo ],
michael@0 182 [ 8, "ml_edivbr1", kTodo, kOk, kTodo ],
michael@0 183 [ 9, "ml_divbr1", kTodo, kOk, kTodo ],
michael@0 184 [ 9, "ml_edivbr1", kTodo, kOk, kTodo ] ] ],
michael@0 185 [ 13, 18, "\n\ntwo", 7, 12 ],
michael@0 186 [ 19, 19, " words", 12, 18,
michael@0 187 [ [ 19, "ml_divbr1", kTodo, kTodo, kTodo, ],
michael@0 188 [ 19, "ml_edivbr1", kTodo, kTodo, kTodo, ] ] ]
michael@0 189 ] );
michael@0 190
michael@0 191 testTextAtOffset(ids, BOUNDARY_WORD_START,
michael@0 192 [ [ 0, 8, "oneword\n\n", 0, 9,
michael@0 193 [ [ 7, "ml_divbr1", kTodo, kTodo, kTodo ],
michael@0 194 [ 7, "ml_edivbr1", kTodo, kTodo, kTodo ],
michael@0 195 [ 8, "ml_divbr1", kTodo, kTodo, kTodo ],
michael@0 196 [ 8, "ml_edivbr1", kTodo, kTodo, kTodo ] ] ],
michael@0 197 [ 9, 12, "two ", 9, 13 ],
michael@0 198 [ 13, 19, "words\n", 13, 19 ] ]);
michael@0 199 testTextAtOffset(ids, BOUNDARY_WORD_END,
michael@0 200 [ [ 0, 6, "oneword", 0, 7 ],
michael@0 201 [ 7, 11, "\n\ntwo", 7, 12 ],
michael@0 202 [ 12, 17, " words", 12, 18 ],
michael@0 203 [ 18, 19, "\n", 18, 19,
michael@0 204 [ [ 18, "ml_divbr1", kTodo, kTodo, kOk ],
michael@0 205 [ 18, "ml_edivbr1", kTodo, kTodo, kOk ],
michael@0 206 [ 19, "ml_divbr1", kTodo, kTodo, kOk ],
michael@0 207 [ 19, "ml_edivbr1", kTodo, kTodo, kOk ] ] ] ]);
michael@0 208
michael@0 209 testTextAfterOffset(ids, BOUNDARY_WORD_START,
michael@0 210 [ [ 0, 8, "two ", 9, 13,
michael@0 211 [ [ 7, "ml_divbr1", kTodo, kTodo, kTodo ],
michael@0 212 [ 7, "ml_edivbr1", kTodo, kTodo, kTodo ],
michael@0 213 [ 8, "ml_divbr1", kTodo, kTodo, kTodo ],
michael@0 214 [ 8, "ml_edivbr1", kTodo, kTodo, kTodo ] ] ],
michael@0 215 [ 9, 12, "words\n", 13, 19 ],
michael@0 216 [ 13, 19, "", 19, 19 ] ]);
michael@0 217 testTextAfterOffset(ids, BOUNDARY_WORD_END,
michael@0 218 [ [ 0, 7, "\n\ntwo", 7, 12 ],
michael@0 219 [ 8, 12, " words", 12, 18 ],
michael@0 220 [ 13, 18, "\n", 18, 19,
michael@0 221 [ [ 18, "ml_divbr1", kTodo, kTodo, kOk ],
michael@0 222 [ 18, "ml_edivbr1", kTodo, kTodo, kOk ] ] ],
michael@0 223 [ 19, 19, "", 19, 19 ] ]);
michael@0 224
michael@0 225 // a <a href="#">b</a>
michael@0 226 // a *
michael@0 227 testTextBeforeOffset("cntr_1", BOUNDARY_WORD_START,
michael@0 228 [ [ 0, 1, "", 0, 0 ],
michael@0 229 [ 2, 3, "a ", 0, 2 ] ]);
michael@0 230
michael@0 231 testTextAtOffset("cntr_1", BOUNDARY_WORD_START,
michael@0 232 [ [ 0, 1, "a ", 0, 2 ],
michael@0 233 [ 2, 3, kEmbedChar, 2, 3 ] ]);
michael@0 234 testTextAfterOffset("cntr_1", BOUNDARY_WORD_START,
michael@0 235 [ [ 0, 1, kEmbedChar, 2, 3 ],
michael@0 236 [ 2, 3, "", 3, 3 ] ]);
michael@0 237
michael@0 238 SimpleTest.finish();
michael@0 239 }
michael@0 240
michael@0 241 SimpleTest.waitForExplicitFinish();
michael@0 242 addA11yLoadEvent(doTest);
michael@0 243 </script>
michael@0 244 </head>
michael@0 245 <body>
michael@0 246
michael@0 247 <p id="display"></p>
michael@0 248 <div id="content" style="display: none"></div>
michael@0 249 <pre id="test">
michael@0 250 </pre>
michael@0 251
michael@0 252 <input id="i1" value="hello"/>
michael@0 253 <div id="d1">hello</div>
michael@0 254 <div id="e1" contenteditable="true">hello</div>
michael@0 255 <textarea id="t1">hello</textarea>
michael@0 256
michael@0 257 <input id="i2" value="hello "/>
michael@0 258 <pre><div id="d2">hello </div></pre>
michael@0 259 <div id="e2" contenteditable="true">hello </div>
michael@0 260 <textarea id="t2">hello </textarea>
michael@0 261
michael@0 262 <input id="i6" value="hello all"/>
michael@0 263 <div id="d6">hello all</div>
michael@0 264 <div id="e6" contenteditable="true">hello all</div>
michael@0 265 <textarea id="t6">hello all</textarea>
michael@0 266
michael@0 267 <input id="i7" value="hello my friend"/>
michael@0 268 <div id="d7">hello my friend</div>
michael@0 269 <div id="e7" contenteditable="true">hello my friend</div>
michael@0 270 <textarea id="t7">hello my friend</textarea>
michael@0 271
michael@0 272 <input id="i8" value="Brave Sir Robin ran"/>
michael@0 273 <pre>
michael@0 274 <div id="d8">Brave Sir Robin ran</div>
michael@0 275 <div id="e8" contenteditable="true">Brave Sir Robin ran</div>
michael@0 276 </pre>
michael@0 277 <textarea id="t8" cols="300">Brave Sir Robin ran</textarea>
michael@0 278
michael@0 279 <pre>
michael@0 280 <div id="ml_div1">oneword
michael@0 281
michael@0 282 two words
michael@0 283 </div>
michael@0 284 <div id="ml_divbr1">oneword<br/><br/>two words<br/><br/></div>
michael@0 285 <div id="ml_ediv1" contenteditable="true">oneword
michael@0 286
michael@0 287 two words
michael@0 288 </div>
michael@0 289 <div id="ml_edivbr1" contenteditable="true">oneword<br/><br/>two words<br/><br/></div>
michael@0 290 <textarea id="ml_t1" cols="300">oneword
michael@0 291
michael@0 292 two words
michael@0 293 </textarea>
michael@0 294 </pre>
michael@0 295
michael@0 296 <div id="cntr_1">a <a href="#">b</a></div>
michael@0 297 </body>
michael@0 298 </html>

mercurial