Pop-up dictionary browser extension for language learning. Successor to Yomichan. (PERSONAL FORK)
at lambda-fork/main 395 lines 12 kB view raw
1<!DOCTYPE html> 2<html> 3<head> 4 <meta charset="UTF-8"> 5 <meta name="viewport" content="width=device-width,initial-scale=1"> 6 <title>DOMTextScanner Tests</title> 7 <link rel="icon" type="image/gif" href="data:image/gif;base64,R0lGODdhAQABAIABAAAAAP///ywAAAAAAQABAAACAkQBADs="> 8 <link rel="stylesheet" href="test-stylesheet.css"> 9</head> 10<body> 11 12 <h1>DOMTextScanner Tests</h1> 13 14 <test-description>Automated test cases for DOMTextScanner.</test-description> 15 16 <test-case 17 data-test-data='{ 18 "node": "div:nth-of-type(1)", 19 "offset": 0, 20 "length": 16, 21 "expected": { 22 "node": "div:nth-of-type(2)>div::text", 23 "offset": 3, 24 "content": "\n小ぢん\nまり1\n小ぢん\nまり2" 25 } 26 }' 27 > 28 <test-description>Layout newlines expected due to entering and exiting display:block nodes.</test-description> 29<div><div>小ぢん</div>まり1</div> 30<div>小ぢん<div>まり2</div></div> 31 </test-case> 32 33 <test-case 34 data-test-data='{ 35 "node": "div:nth-of-type(1)::text", 36 "offset": 0, 37 "length": 13, 38 "expected": { 39 "node": "div:nth-of-type(2)::text", 40 "offset": 6, 41 "content": "小ぢんまり1\n小ぢんまり2" 42 } 43 }' 44 > 45 <test-description>Layout newline expected due to sequential display:block elements.</test-description> 46<div>小ぢんまり1</div><div>小ぢんまり2</div> 47 </test-case> 48 49 <test-case 50 data-test-data='{ 51 "node": "div:nth-of-type(1)::text", 52 "offset": 0, 53 "length": 13, 54 "expected": { 55 "node": "div:nth-of-type(2)::text", 56 "offset": 6, 57 "content": "小ぢんまり1\n小ぢんまり2" 58 } 59 }' 60 > 61 <test-description>Layout newline expected due to sequential display:block elements separated by a newline.</test-description> 62<div>小ぢんまり1</div> 63<div>小ぢんまり2</div> 64 </test-case> 65 66 <test-case 67 data-test-data='{ 68 "node": "span:nth-of-type(1)::text", 69 "offset": 0, 70 "length": 12, 71 "expected": { 72 "node": "span:nth-of-type(2)::text", 73 "offset": 6, 74 "content": "小ぢんまり1小ぢんまり2" 75 } 76 }' 77 > 78 <test-description>No newlines expected due to display:inline.</test-description> 79<span>小ぢんまり1</span><span>小ぢんまり2</span> 80 </test-case> 81 82 <test-case 83 data-test-data='{ 84 "node": "span:nth-of-type(1)::text", 85 "offset": 0, 86 "length": 13, 87 "expected": { 88 "node": "span:nth-of-type(2)::text", 89 "offset": 6, 90 "content": "小ぢんまり1 小ぢんまり2" 91 } 92 }' 93 > 94 <test-description>No newlines expected due to white-space:normal.</test-description> 95<span>小ぢんまり1</span> 96<span>小ぢんまり2</span> 97 </test-case> 98 99 <test-case 100 data-test-data='{ 101 "node": "span:nth-of-type(1)::text", 102 "offset": 0, 103 "length": 13, 104 "expected": { 105 "node": "span:nth-of-type(2)::text", 106 "offset": 6, 107 "content": "小ぢんまり1\n小ぢんまり2" 108 } 109 }' 110 > 111 <test-description>Newline expected due to white-space:pre.</test-description> 112<pre> 113<span>小ぢんまり1</span> 114<span>小ぢんまり2</span> 115</pre> 116 </test-case> 117 118 <test-case 119 data-test-data='{ 120 "node": "span:nth-of-type(1)::text", 121 "offset": 0, 122 "length": 12, 123 "expected": { 124 "node": "span:nth-of-type(2)::text", 125 "offset": 6, 126 "content": "小ぢんまり1小ぢんまり2" 127 } 128 }' 129 > 130 <test-description>No newlines expected due to display:inline-block. Actual layout flow cannot be determined by DOM/CSS alone.</test-description> 131<span style="display: inline-block;">小ぢんまり1</span><span style="display: inline-block;">小ぢんまり2</span> 132 </test-case> 133 134 <test-case 135 style="position: relative;" 136 data-test-data='{ 137 "node": "div:nth-of-type(1)::text", 138 "offset": 0, 139 "length": 13, 140 "expected": { 141 "node": "div:nth-of-type(2)::text", 142 "offset": 6, 143 "content": "小ぢんまり1\n小ぢんまり2" 144 } 145 }' 146 > 147 <test-description>Single newline expected due to display:block layout.</test-description> 148<div>小ぢんまり1</div><div style="position: relative;">小ぢんまり2</div> 149 </test-case> 150 151 <test-case 152 style="position: relative; overflow: hidden;" 153 data-test-data='{ 154 "node": "div:nth-of-type(1)::text", 155 "offset": 0, 156 "length": 14, 157 "expected": { 158 "node": "div:nth-of-type(2)::text", 159 "offset": 6, 160 "content": "小ぢんまり1\n\n小ぢんまり2" 161 } 162 }' 163 > 164 <test-description>Two newlines expected due to position:absolute causing a significant layout change.</test-description> 165<div>小ぢんまり1</div><div style="position: absolute;">小ぢんまり2</div> 166 </test-case> 167 168 <test-case 169 style="position: relative; overflow: hidden;" 170 data-test-data='{ 171 "node": "div:nth-of-type(1)::text", 172 "offset": 0, 173 "length": 14, 174 "expected": { 175 "node": "div:nth-of-type(2)::text", 176 "offset": 6, 177 "content": "小ぢんまり1\n\n小ぢんまり2" 178 } 179 }' 180 > 181 <test-description>Two newlines expected due to position:fixed causing a significant layout change.</test-description> 182<div>小ぢんまり1</div><div style="position: fixed;">小ぢんまり2</div> 183 </test-case> 184 185 <test-case 186 style="position: relative;" 187 data-test-data='{ 188 "node": "div:nth-of-type(1)::text", 189 "offset": 0, 190 "length": 14, 191 "expected": { 192 "node": "div:nth-of-type(2)::text", 193 "offset": 6, 194 "content": "小ぢんまり1\n\n小ぢんまり2" 195 } 196 }' 197 > 198 <test-description>Two newlines expected due to position:sticky being able to cause a significant layout change.</test-description> 199<div>小ぢんまり1</div><div style="position: sticky;">小ぢんまり2</div> 200 </test-case> 201 202 <test-case 203 data-test-data='{ 204 "node": "rt", 205 "offset": 0, 206 "length": 6, 207 "expected": { 208 "node": "div::text", 209 "offset": 5, 210 "content": "小ぢんまり1" 211 } 212 }' 213 > 214 <test-description>Scanning text starting in an &lt;rt&gt; element. Should start scanning at the start of the &lt;ruby&gt; tag instead.</test-description> 215<div><ruby><rp>(</rp><rt></rt><rp>)</rp></ruby>ぢんまり1</div> 216 </test-case> 217 218 <test-case 219 data-test-data='{ 220 "node": "div", 221 "offset": 0, 222 "length": 6, 223 "expected": { 224 "node": "div::nth-text(2)", 225 "offset": 3, 226 "content": "小ぢんまり1" 227 } 228 }' 229 > 230 <test-description>Skip &lt;script&gt; content.</test-description> 231<div>小ぢん<script>/*comment*/</script>まり1</div> 232 </test-case> 233 234 <test-case 235 data-test-data='{ 236 "node": "div", 237 "offset": 0, 238 "length": 6, 239 "expected": { 240 "node": "div::nth-text(2)", 241 "offset": 3, 242 "content": "小ぢんまり1" 243 } 244 }' 245 > 246 <test-description>Skip &lt;style&gt; content.</test-description> 247<div>小ぢん<style>/*comment*/</style>まり1</div> 248 </test-case> 249 250 <test-case 251 data-test-data='{ 252 "node": "div", 253 "offset": 0, 254 "length": 6, 255 "expected": { 256 "node": "div::nth-text(2)", 257 "offset": 3, 258 "content": "小ぢんまり1" 259 } 260 }' 261 > 262 <test-description>Skip &lt;textarea&gt; content.</test-description> 263<div>小ぢん<textarea>textarea content</textarea>まり1</div> 264 </test-case> 265 266 <test-case 267 data-test-data='{ 268 "node": "div", 269 "offset": 0, 270 "length": 6, 271 "expected": { 272 "node": "div::nth-text(2)", 273 "offset": 3, 274 "content": "小ぢんまり1" 275 } 276 }' 277 > 278 <test-description>Skip &lt;input&gt; content.</test-description> 279<div>小ぢん<input type="text" value="content">まり1</div> 280 </test-case> 281 282 <test-case 283 data-test-data='{ 284 "node": "div", 285 "offset": 0, 286 "length": 6, 287 "expected": { 288 "node": "div::nth-text(2)", 289 "offset": 3, 290 "content": "小ぢんまり1" 291 } 292 }' 293 > 294 <test-description>Skip &lt;button&gt; content.</test-description> 295<div>小ぢん<button type="button">content</button>まり1</div> 296 </test-case> 297 298 <test-case 299 data-test-data='{ 300 "node": "div", 301 "offset": 0, 302 "length": 6, 303 "expected": { 304 "node": "div::nth-text(2)", 305 "offset": 3, 306 "content": "小ぢんまり1" 307 } 308 }' 309 > 310 <test-description>Skip content with font-size:0.</test-description> 311<div>小ぢん<span style="font-size: 0;">content</span>まり1</div> 312 </test-case> 313 314 <test-case 315 data-test-data='{ 316 "node": "div", 317 "offset": 0, 318 "length": 6, 319 "expected": { 320 "node": "div::nth-text(2)", 321 "offset": 3, 322 "content": "小ぢんまり1" 323 } 324 }' 325 > 326 <test-description>Skip content with opacity:0.</test-description> 327<div>小ぢん<span style="opacity: 0;">content</span>まり1</div> 328 </test-case> 329 330 <test-case 331 data-test-data='{ 332 "node": "div", 333 "offset": 0, 334 "length": 6, 335 "expected": { 336 "node": "div::nth-text(2)", 337 "offset": 3, 338 "content": "小ぢんまり1" 339 } 340 }' 341 > 342 <test-description>Skip content with visibility:hidden.</test-description> 343<div>小ぢん<span style="visibility: hidden;">content</span>まり1</div> 344 </test-case> 345 346 <test-case 347 data-test-data='{ 348 "node": "div", 349 "offset": 0, 350 "length": 6, 351 "expected": { 352 "node": "div::nth-text(2)", 353 "offset": 3, 354 "content": "小ぢんまり1" 355 } 356 }' 357 > 358 <test-description>Skip content with display:none.</test-description> 359<div>小ぢん<span style="display: none;">content</span>まり1</div> 360 </test-case> 361 362 <test-case 363 data-test-data='{ 364 "node": "div", 365 "offset": 0, 366 "length": 6, 367 "expected": { 368 "node": "div::nth-text(2)", 369 "offset": 3, 370 "content": "小ぢんまり1" 371 } 372 }' 373 > 374 <test-description>Don't skip content with user-select:none.</test-description> 375<div>小ぢ<span style="user-select: none;"></span>まり1</div> 376 </test-case> 377 378 <test-case 379 data-test-data='{ 380 "node": "div", 381 "offset": 0, 382 "length": 6, 383 "expected": { 384 "node": "div::nth-text(2)", 385 "offset": 3, 386 "content": "小ぢんまり1" 387 } 388 }' 389 > 390 <test-description>Skip content with user-select:none <em>and</em> a transparent color.</test-description> 391<div>小ぢん<span style="user-select: none; color: rgba(0, 0, 0, 0);">content</span>まり1</div> 392 </test-case> 393 394</body> 395</html>