Wed, 31 Dec 2014 06:09:35 +0100
Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.
michael@0 | 1 | <html> |
michael@0 | 2 | |
michael@0 | 3 | <head> |
michael@0 | 4 | <title>Text attributes tests</title> |
michael@0 | 5 | <meta charset="utf-8" /> |
michael@0 | 6 | <link rel="stylesheet" type="text/css" href="chrome://mochikit/content/tests/SimpleTest/test.css" /> |
michael@0 | 7 | |
michael@0 | 8 | <style type="text/css"> |
michael@0 | 9 | .gencontent:before { content: "*"; } |
michael@0 | 10 | .gencontent:after { content: "*"; } |
michael@0 | 11 | </style> |
michael@0 | 12 | |
michael@0 | 13 | <script type="application/javascript" |
michael@0 | 14 | src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script> |
michael@0 | 15 | |
michael@0 | 16 | <script type="application/javascript" |
michael@0 | 17 | src="../common.js"></script> |
michael@0 | 18 | <script type="application/javascript" |
michael@0 | 19 | src="../attributes.js"></script> |
michael@0 | 20 | <script type="application/javascript" |
michael@0 | 21 | src="../events.js"></script> |
michael@0 | 22 | |
michael@0 | 23 | <script type="application/javascript"> |
michael@0 | 24 | var gComputedStyle = null; |
michael@0 | 25 | |
michael@0 | 26 | function doTest() |
michael@0 | 27 | { |
michael@0 | 28 | ////////////////////////////////////////////////////////////////////////// |
michael@0 | 29 | // area1 |
michael@0 | 30 | var ID = "area1"; |
michael@0 | 31 | var defAttrs = buildDefaultTextAttrs(ID, "10pt"); |
michael@0 | 32 | testDefaultTextAttrs(ID, defAttrs); |
michael@0 | 33 | |
michael@0 | 34 | var attrs = {}; |
michael@0 | 35 | testTextAttrs(ID, 0, attrs, defAttrs, 0, 7); |
michael@0 | 36 | |
michael@0 | 37 | attrs = { "font-weight": kBoldFontWeight }; |
michael@0 | 38 | testTextAttrs(ID, 7, attrs, defAttrs, 7, 11); |
michael@0 | 39 | |
michael@0 | 40 | attrs = {}; |
michael@0 | 41 | testTextAttrs(ID, 12, attrs, defAttrs, 11, 18); |
michael@0 | 42 | |
michael@0 | 43 | ////////////////////////////////////////////////////////////////////////// |
michael@0 | 44 | // area2 |
michael@0 | 45 | ID = "area2"; |
michael@0 | 46 | defAttrs = buildDefaultTextAttrs(ID, "14pt"); |
michael@0 | 47 | testDefaultTextAttrs(ID, defAttrs); |
michael@0 | 48 | |
michael@0 | 49 | attrs = {}; |
michael@0 | 50 | testTextAttrs(ID, 0, attrs, defAttrs, 0, 7); |
michael@0 | 51 | |
michael@0 | 52 | attrs = { "font-weight": kBoldFontWeight }; |
michael@0 | 53 | testTextAttrs(ID, 7, attrs, defAttrs, 7, 12); |
michael@0 | 54 | |
michael@0 | 55 | var tempElem = getNode(ID).firstChild.nextSibling.firstChild.nextSibling; |
michael@0 | 56 | gComputedStyle = document.defaultView.getComputedStyle(tempElem, ""); |
michael@0 | 57 | attrs = {"font-style": gComputedStyle.fontStyle, |
michael@0 | 58 | "font-weight": kBoldFontWeight }; |
michael@0 | 59 | testTextAttrs(ID, 13, attrs, defAttrs, 12, 19); |
michael@0 | 60 | |
michael@0 | 61 | attrs = { "font-weight": kBoldFontWeight }; |
michael@0 | 62 | testTextAttrs(ID, 20, attrs, defAttrs, 19, 23); |
michael@0 | 63 | |
michael@0 | 64 | attrs = {}; |
michael@0 | 65 | testTextAttrs(ID, 24, attrs, defAttrs, 23, 30); |
michael@0 | 66 | |
michael@0 | 67 | ////////////////////////////////////////////////////////////////////////// |
michael@0 | 68 | // area3 |
michael@0 | 69 | ID = "area3"; |
michael@0 | 70 | defAttrs = buildDefaultTextAttrs(ID, "12pt"); |
michael@0 | 71 | testDefaultTextAttrs(ID, defAttrs); |
michael@0 | 72 | |
michael@0 | 73 | tempElem = getNode(ID).firstChild.nextSibling; |
michael@0 | 74 | gComputedStyle = document.defaultView.getComputedStyle(tempElem, ""); |
michael@0 | 75 | attrs = {"color": gComputedStyle.color}; |
michael@0 | 76 | testTextAttrs(ID, 0, attrs, defAttrs, 0, 6); |
michael@0 | 77 | |
michael@0 | 78 | tempElem = tempElem.firstChild.nextSibling; |
michael@0 | 79 | gComputedStyle = document.defaultView.getComputedStyle(tempElem, ""); |
michael@0 | 80 | attrs = {"color": gComputedStyle.color}; |
michael@0 | 81 | testTextAttrs(ID, 6, attrs, defAttrs, 6, 26); |
michael@0 | 82 | |
michael@0 | 83 | tempElem = tempElem.parentNode; |
michael@0 | 84 | gComputedStyle = document.defaultView.getComputedStyle(tempElem, ""); |
michael@0 | 85 | attrs = {"color": gComputedStyle.color}; |
michael@0 | 86 | testTextAttrs(ID, 26, attrs, defAttrs, 26, 27); |
michael@0 | 87 | |
michael@0 | 88 | tempElem = tempElem.nextSibling; |
michael@0 | 89 | gComputedStyle = document.defaultView.getComputedStyle(tempElem, ""); |
michael@0 | 90 | attrs = {"color": gComputedStyle.color, |
michael@0 | 91 | "background-color": gComputedStyle.backgroundColor}; |
michael@0 | 92 | testTextAttrs(ID, 27, attrs, defAttrs, 27, 50); |
michael@0 | 93 | |
michael@0 | 94 | ////////////////////////////////////////////////////////////////////////// |
michael@0 | 95 | // area4 |
michael@0 | 96 | ID = "area4"; |
michael@0 | 97 | defAttrs = buildDefaultTextAttrs(ID, "12pt"); |
michael@0 | 98 | testDefaultTextAttrs(ID, defAttrs); |
michael@0 | 99 | |
michael@0 | 100 | tempElem = getNode(ID).firstChild.nextSibling; |
michael@0 | 101 | gComputedStyle = document.defaultView.getComputedStyle(tempElem, ""); |
michael@0 | 102 | attrs = {"color": gComputedStyle.color}; |
michael@0 | 103 | testTextAttrs(ID, 0, attrs, defAttrs, 0, 16); |
michael@0 | 104 | |
michael@0 | 105 | tempElem = tempElem.nextSibling.firstChild.nextSibling; |
michael@0 | 106 | gComputedStyle = document.defaultView.getComputedStyle(tempElem, ""); |
michael@0 | 107 | attrs = {"color": gComputedStyle.color}; |
michael@0 | 108 | testTextAttrs(ID, 16, attrs, defAttrs, 16, 33); |
michael@0 | 109 | |
michael@0 | 110 | tempElem = tempElem.parentNode; |
michael@0 | 111 | gComputedStyle = document.defaultView.getComputedStyle(tempElem, ""); |
michael@0 | 112 | attrs = {"color": gComputedStyle.color}; |
michael@0 | 113 | testTextAttrs(ID, 34, attrs, defAttrs, 33, 46); |
michael@0 | 114 | |
michael@0 | 115 | ////////////////////////////////////////////////////////////////////////// |
michael@0 | 116 | // area5: "Green!*!RedNormal" |
michael@0 | 117 | ID = "area5"; |
michael@0 | 118 | defAttrs = buildDefaultTextAttrs(ID, "12pt"); |
michael@0 | 119 | testDefaultTextAttrs(ID, defAttrs); |
michael@0 | 120 | |
michael@0 | 121 | // Green |
michael@0 | 122 | tempElem = getNode(ID).firstChild.nextSibling; |
michael@0 | 123 | gComputedStyle = document.defaultView.getComputedStyle(tempElem, ""); |
michael@0 | 124 | attrs = {"color": gComputedStyle.color}; |
michael@0 | 125 | testTextAttrs(ID, 0, attrs, defAttrs, 0, 5); |
michael@0 | 126 | |
michael@0 | 127 | // br |
michael@0 | 128 | attrs = {}; |
michael@0 | 129 | testTextAttrs(ID, 5, attrs, defAttrs, 5, 6); |
michael@0 | 130 | |
michael@0 | 131 | // img, embedded accessible, no attributes |
michael@0 | 132 | attrs = {}; |
michael@0 | 133 | testTextAttrs(ID, 6, attrs, {}, 6, 7); |
michael@0 | 134 | |
michael@0 | 135 | // br |
michael@0 | 136 | attrs = {}; |
michael@0 | 137 | testTextAttrs(ID, 7, attrs, defAttrs, 7, 8); |
michael@0 | 138 | |
michael@0 | 139 | // Red |
michael@0 | 140 | tempElem = tempElem.nextSibling.nextSibling.nextSibling.nextSibling; |
michael@0 | 141 | gComputedStyle = document.defaultView.getComputedStyle(tempElem, ""); |
michael@0 | 142 | attrs = {"color": gComputedStyle.color}; |
michael@0 | 143 | testTextAttrs(ID, 9, attrs, defAttrs, 8, 11); |
michael@0 | 144 | |
michael@0 | 145 | // Normal |
michael@0 | 146 | attrs = {}; |
michael@0 | 147 | testTextAttrs(ID, 11, attrs, defAttrs, 11, 18); |
michael@0 | 148 | |
michael@0 | 149 | ////////////////////////////////////////////////////////////////////////// |
michael@0 | 150 | // area6 (CSS vertical-align property, refer to bug 445938 for details |
michael@0 | 151 | // and sup and sub elements, refer to bug 735645 for details) |
michael@0 | 152 | ID = "area6"; |
michael@0 | 153 | defAttrs = buildDefaultTextAttrs(ID, "12pt"); |
michael@0 | 154 | testDefaultTextAttrs(ID, defAttrs); |
michael@0 | 155 | |
michael@0 | 156 | attrs = {}; |
michael@0 | 157 | testTextAttrs(ID, 0, attrs, defAttrs, 0, 5); |
michael@0 | 158 | |
michael@0 | 159 | attrs = { "text-position": "super", "font-size": "10pt" }; |
michael@0 | 160 | testTextAttrs(ID, 5, attrs, defAttrs, 5, 13); |
michael@0 | 161 | |
michael@0 | 162 | attrs = {}; |
michael@0 | 163 | testTextAttrs(ID, 13, attrs, defAttrs, 13, 27); |
michael@0 | 164 | |
michael@0 | 165 | attrs = { "text-position": "super" }; |
michael@0 | 166 | testTextAttrs(ID, 27, attrs, defAttrs, 27, 35); |
michael@0 | 167 | |
michael@0 | 168 | attrs = {}; |
michael@0 | 169 | testTextAttrs(ID, 35, attrs, defAttrs, 35, 39); |
michael@0 | 170 | |
michael@0 | 171 | attrs = { "text-position": "sub", "font-size": "10pt" }; |
michael@0 | 172 | testTextAttrs(ID, 39, attrs, defAttrs, 39, 50); |
michael@0 | 173 | |
michael@0 | 174 | attrs = {}; |
michael@0 | 175 | testTextAttrs(ID, 50, attrs, defAttrs, 50, 55); |
michael@0 | 176 | |
michael@0 | 177 | attrs = { "text-position": "sub" }; |
michael@0 | 178 | testTextAttrs(ID, 55, attrs, defAttrs, 55, 64); |
michael@0 | 179 | |
michael@0 | 180 | attrs = {}; |
michael@0 | 181 | testTextAttrs(ID, 64, attrs, defAttrs, 64, 69); |
michael@0 | 182 | |
michael@0 | 183 | attrs = { "text-position": "super" }; |
michael@0 | 184 | testTextAttrs(ID, 69, attrs, defAttrs, 69, 84); |
michael@0 | 185 | |
michael@0 | 186 | attrs = {}; |
michael@0 | 187 | testTextAttrs(ID, 84, attrs, defAttrs, 84, 89); |
michael@0 | 188 | |
michael@0 | 189 | attrs = { "text-position": "sub" }; |
michael@0 | 190 | testTextAttrs(ID, 89, attrs, defAttrs, 89, 102); |
michael@0 | 191 | |
michael@0 | 192 | attrs = {}; |
michael@0 | 193 | testTextAttrs(ID, 102, attrs, defAttrs, 102, 107); |
michael@0 | 194 | |
michael@0 | 195 | attrs = { "text-position": "super" }; |
michael@0 | 196 | testTextAttrs(ID, 107, attrs, defAttrs, 107, 123); |
michael@0 | 197 | |
michael@0 | 198 | attrs = {}; |
michael@0 | 199 | testTextAttrs(ID, 123, attrs, defAttrs, 123, 128); |
michael@0 | 200 | |
michael@0 | 201 | attrs = { "text-position": "sub" }; |
michael@0 | 202 | testTextAttrs(ID, 128, attrs, defAttrs, 128, 142); |
michael@0 | 203 | |
michael@0 | 204 | ////////////////////////////////////////////////////////////////////////// |
michael@0 | 205 | // area7 |
michael@0 | 206 | ID = "area7"; |
michael@0 | 207 | defAttrs = buildDefaultTextAttrs(ID, "12pt"); |
michael@0 | 208 | defAttrs["language"] = "en"; |
michael@0 | 209 | testDefaultTextAttrs(ID, defAttrs); |
michael@0 | 210 | |
michael@0 | 211 | attrs = {"language": "ru"}; |
michael@0 | 212 | testTextAttrs(ID, 0, attrs, defAttrs, 0, 6); |
michael@0 | 213 | |
michael@0 | 214 | attrs = {}; |
michael@0 | 215 | testTextAttrs(ID, 6, attrs, defAttrs, 6, 7); |
michael@0 | 216 | |
michael@0 | 217 | tempElem = getNode(ID).firstChild.nextSibling.nextSibling.nextSibling; |
michael@0 | 218 | gComputedStyle = document.defaultView.getComputedStyle(tempElem, ""); |
michael@0 | 219 | attrs = { "background-color": gComputedStyle.backgroundColor}; |
michael@0 | 220 | testTextAttrs(ID, 13, attrs, defAttrs, 7, 20); |
michael@0 | 221 | |
michael@0 | 222 | attrs = {}; |
michael@0 | 223 | testTextAttrs(ID, 20, attrs, defAttrs, 20, 21); |
michael@0 | 224 | |
michael@0 | 225 | attrs = {"language": "de"}; |
michael@0 | 226 | testTextAttrs(ID, 21, attrs, defAttrs, 21, 36); |
michael@0 | 227 | |
michael@0 | 228 | attrs = {}; |
michael@0 | 229 | testTextAttrs(ID, 36, attrs, defAttrs, 36, 44); |
michael@0 | 230 | |
michael@0 | 231 | attrs = {}; |
michael@0 | 232 | testTextAttrs(ID, 37, attrs, defAttrs, 36, 44); |
michael@0 | 233 | |
michael@0 | 234 | tempElem = tempElem.nextSibling.nextSibling.nextSibling.nextSibling.firstChild.nextSibling; |
michael@0 | 235 | gComputedStyle = document.defaultView.getComputedStyle(tempElem, ""); |
michael@0 | 236 | attrs = {"color": gComputedStyle.color}; |
michael@0 | 237 | testTextAttrs(ID, 44, attrs, defAttrs, 44, 51); |
michael@0 | 238 | |
michael@0 | 239 | tempElem = tempElem.firstChild.nextSibling; |
michael@0 | 240 | gComputedStyle = document.defaultView.getComputedStyle(tempElem, ""); |
michael@0 | 241 | attrs = {"font-weight": kBoldFontWeight, |
michael@0 | 242 | "color": gComputedStyle.color}; |
michael@0 | 243 | testTextAttrs(ID, 51, attrs, defAttrs, 51, 55); |
michael@0 | 244 | |
michael@0 | 245 | tempElem = tempElem.parentNode; |
michael@0 | 246 | gComputedStyle = document.defaultView.getComputedStyle(tempElem, ""); |
michael@0 | 247 | attrs = {"color": gComputedStyle.color}; |
michael@0 | 248 | testTextAttrs(ID, 55, attrs, defAttrs, 55, 62); |
michael@0 | 249 | |
michael@0 | 250 | ////////////////////////////////////////////////////////////////////////// |
michael@0 | 251 | // area9, different single style spans in styled paragraph |
michael@0 | 252 | ID = "area9"; |
michael@0 | 253 | defAttrs = buildDefaultTextAttrs(ID, "10pt"); |
michael@0 | 254 | testDefaultTextAttrs(ID, defAttrs); |
michael@0 | 255 | |
michael@0 | 256 | attrs = {}; |
michael@0 | 257 | testTextAttrs(ID, 0, attrs, defAttrs, 0, 6); |
michael@0 | 258 | |
michael@0 | 259 | attrs = { "font-size": "12pt" }; |
michael@0 | 260 | testTextAttrs(ID, 7, attrs, defAttrs, 6, 12); |
michael@0 | 261 | |
michael@0 | 262 | attrs = {}; |
michael@0 | 263 | testTextAttrs(ID, 13, attrs, defAttrs, 12, 21); |
michael@0 | 264 | |
michael@0 | 265 | // Walk to the span with the different background color |
michael@0 | 266 | tempElem = getNode(ID).firstChild.nextSibling.nextSibling.nextSibling; |
michael@0 | 267 | gComputedStyle = document.defaultView.getComputedStyle(tempElem, ""); |
michael@0 | 268 | attrs = { "background-color": gComputedStyle.backgroundColor }; |
michael@0 | 269 | testTextAttrs(ID, 22, attrs, defAttrs, 21, 36); |
michael@0 | 270 | |
michael@0 | 271 | attrs = {}; |
michael@0 | 272 | testTextAttrs(ID, 37, attrs, defAttrs, 36, 44); |
michael@0 | 273 | |
michael@0 | 274 | // Walk from the background color span to the one with font-style |
michael@0 | 275 | tempElem = tempElem.nextSibling.nextSibling; |
michael@0 | 276 | gComputedStyle = document.defaultView.getComputedStyle(tempElem, ""); |
michael@0 | 277 | attrs = { "font-style": gComputedStyle.fontStyle }; |
michael@0 | 278 | testTextAttrs(ID, 45, attrs, defAttrs, 44, 61); |
michael@0 | 279 | |
michael@0 | 280 | attrs = {}; |
michael@0 | 281 | testTextAttrs(ID, 62, attrs, defAttrs, 61, 69); |
michael@0 | 282 | |
michael@0 | 283 | // Walk from span with font-style to the one with font-family. |
michael@0 | 284 | tempElem = tempElem.nextSibling.nextSibling; |
michael@0 | 285 | gComputedStyle = document.defaultView.getComputedStyle(tempElem, ""); |
michael@0 | 286 | attrs = { "font-family": kMonospaceFontFamily }; |
michael@0 | 287 | testTextAttrs(ID, 70, attrs, defAttrs, 69, 83); |
michael@0 | 288 | |
michael@0 | 289 | attrs = {}; |
michael@0 | 290 | testTextAttrs(ID, 84, attrs, defAttrs, 83, 91); |
michael@0 | 291 | |
michael@0 | 292 | attrs = { |
michael@0 | 293 | "text-underline-style": "solid", |
michael@0 | 294 | "text-underline-color": gComputedStyle.color |
michael@0 | 295 | }; |
michael@0 | 296 | testTextAttrs(ID, 92, attrs, defAttrs, 91, 101); |
michael@0 | 297 | |
michael@0 | 298 | attrs = {}; |
michael@0 | 299 | testTextAttrs(ID, 102, attrs, defAttrs, 101, 109); |
michael@0 | 300 | |
michael@0 | 301 | attrs = { |
michael@0 | 302 | "text-line-through-style": "solid", |
michael@0 | 303 | "text-line-through-color": gComputedStyle.color |
michael@0 | 304 | }; |
michael@0 | 305 | testTextAttrs(ID, 110, attrs, defAttrs, 109, 122); |
michael@0 | 306 | |
michael@0 | 307 | attrs = {}; |
michael@0 | 308 | testTextAttrs(ID, 123, attrs, defAttrs, 122, 130); |
michael@0 | 309 | |
michael@0 | 310 | attrs = { |
michael@0 | 311 | "text-line-through-style": "solid", |
michael@0 | 312 | "text-line-through-color": gComputedStyle.color |
michael@0 | 313 | }; |
michael@0 | 314 | testTextAttrs(ID, 131, attrs, defAttrs, 130, 143); |
michael@0 | 315 | |
michael@0 | 316 | attrs = {}; |
michael@0 | 317 | testTextAttrs(ID, 144, attrs, defAttrs, 143, 151); |
michael@0 | 318 | |
michael@0 | 319 | attrs = { |
michael@0 | 320 | "text-line-through-style": "solid", |
michael@0 | 321 | "text-line-through-color": gComputedStyle.color |
michael@0 | 322 | }; |
michael@0 | 323 | testTextAttrs(ID, 152, attrs, defAttrs, 151, 164); |
michael@0 | 324 | |
michael@0 | 325 | attrs = {}; |
michael@0 | 326 | testTextAttrs(ID, 165, attrs, defAttrs, 164, 172); |
michael@0 | 327 | |
michael@0 | 328 | ////////////////////////////////////////////////////////////////////////// |
michael@0 | 329 | // area10, different single style spans in non-styled paragraph |
michael@0 | 330 | ID = "area10"; |
michael@0 | 331 | defAttrs = buildDefaultTextAttrs(ID, "12pt"); |
michael@0 | 332 | testDefaultTextAttrs(ID, defAttrs); |
michael@0 | 333 | |
michael@0 | 334 | attrs = {}; |
michael@0 | 335 | testTextAttrs(ID, 0, attrs, defAttrs, 0, 7); |
michael@0 | 336 | |
michael@0 | 337 | attrs = { "font-size": "14pt" }; |
michael@0 | 338 | testTextAttrs(ID, 7, attrs, defAttrs, 7, 13); |
michael@0 | 339 | |
michael@0 | 340 | attrs = {}; |
michael@0 | 341 | testTextAttrs(ID, 13, attrs, defAttrs, 13, 22); |
michael@0 | 342 | |
michael@0 | 343 | // Walk to the span with the different background color |
michael@0 | 344 | tempElem = getNode(ID).firstChild.nextSibling.nextSibling.nextSibling; |
michael@0 | 345 | gComputedStyle = document.defaultView.getComputedStyle(tempElem, ""); |
michael@0 | 346 | attrs = { "background-color": gComputedStyle.backgroundColor }; |
michael@0 | 347 | testTextAttrs(ID, 23, attrs, defAttrs, 22, 37); |
michael@0 | 348 | |
michael@0 | 349 | attrs = {}; |
michael@0 | 350 | testTextAttrs(ID, 38, attrs, defAttrs, 37, 45); |
michael@0 | 351 | |
michael@0 | 352 | // Walk from the background color span to the one with font-style |
michael@0 | 353 | tempElem = tempElem.nextSibling.nextSibling; |
michael@0 | 354 | gComputedStyle = document.defaultView.getComputedStyle(tempElem, ""); |
michael@0 | 355 | attrs = {"font-style": gComputedStyle.fontStyle}; |
michael@0 | 356 | testTextAttrs(ID, 46, attrs, defAttrs, 45, 62); |
michael@0 | 357 | |
michael@0 | 358 | attrs = {}; |
michael@0 | 359 | testTextAttrs(ID, 63, attrs, defAttrs, 62, 70); |
michael@0 | 360 | |
michael@0 | 361 | // Walk from span with font-style to the one with font-family. |
michael@0 | 362 | tempElem = tempElem.nextSibling.nextSibling; |
michael@0 | 363 | gComputedStyle = document.defaultView.getComputedStyle(tempElem, ""); |
michael@0 | 364 | attrs = { "font-family": kMonospaceFontFamily }; |
michael@0 | 365 | testTextAttrs(ID, 71, attrs, defAttrs, 70, 84); |
michael@0 | 366 | |
michael@0 | 367 | attrs = {}; |
michael@0 | 368 | testTextAttrs(ID, 85, attrs, defAttrs, 84, 92); |
michael@0 | 369 | |
michael@0 | 370 | attrs = { |
michael@0 | 371 | "text-underline-style": "solid", |
michael@0 | 372 | "text-underline-color": gComputedStyle.color |
michael@0 | 373 | }; |
michael@0 | 374 | testTextAttrs(ID, 93, attrs, defAttrs, 92, 102); |
michael@0 | 375 | |
michael@0 | 376 | attrs = {}; |
michael@0 | 377 | testTextAttrs(ID, 103, attrs, defAttrs, 102, 110); |
michael@0 | 378 | |
michael@0 | 379 | attrs = { |
michael@0 | 380 | "text-line-through-style": "solid", |
michael@0 | 381 | "text-line-through-color": gComputedStyle.color |
michael@0 | 382 | }; |
michael@0 | 383 | testTextAttrs(ID, 111, attrs, defAttrs, 110, 123); |
michael@0 | 384 | |
michael@0 | 385 | attrs = {}; |
michael@0 | 386 | testTextAttrs(ID, 124, attrs, defAttrs, 123, 131); |
michael@0 | 387 | |
michael@0 | 388 | ////////////////////////////////////////////////////////////////////////// |
michael@0 | 389 | // area11, "font-weight" tests |
michael@0 | 390 | ID = "area11"; |
michael@0 | 391 | defAttrs = buildDefaultTextAttrs(ID, "12pt", kBoldFontWeight); |
michael@0 | 392 | testDefaultTextAttrs(ID, defAttrs); |
michael@0 | 393 | |
michael@0 | 394 | attrs = { }; |
michael@0 | 395 | testTextAttrs(ID, 0, attrs, defAttrs, 0, 13); |
michael@0 | 396 | |
michael@0 | 397 | attrs = { "font-weight": kNormalFontWeight }; |
michael@0 | 398 | testTextAttrs(ID, 13, attrs, defAttrs, 13, 20); |
michael@0 | 399 | |
michael@0 | 400 | attrs = { }; |
michael@0 | 401 | testTextAttrs(ID, 20, attrs, defAttrs, 20, 27); |
michael@0 | 402 | |
michael@0 | 403 | attrs = { "font-weight": kNormalFontWeight }; |
michael@0 | 404 | testTextAttrs(ID, 27, attrs, defAttrs, 27, 33); |
michael@0 | 405 | |
michael@0 | 406 | attrs = { }; |
michael@0 | 407 | testTextAttrs(ID, 33, attrs, defAttrs, 33, 51); |
michael@0 | 408 | |
michael@0 | 409 | attrs = { "font-weight": kNormalFontWeight }; |
michael@0 | 410 | testTextAttrs(ID, 51, attrs, defAttrs, 51, 57); |
michael@0 | 411 | |
michael@0 | 412 | attrs = { }; |
michael@0 | 413 | testTextAttrs(ID, 57, attrs, defAttrs, 57, 97); |
michael@0 | 414 | |
michael@0 | 415 | ////////////////////////////////////////////////////////////////////////// |
michael@0 | 416 | // test out of range offset |
michael@0 | 417 | testTextAttrsWrongOffset("area12", -1); |
michael@0 | 418 | testTextAttrsWrongOffset("area12", 500); |
michael@0 | 419 | |
michael@0 | 420 | ////////////////////////////////////////////////////////////////////////// |
michael@0 | 421 | // test zero offset on empty hypertext accessibles |
michael@0 | 422 | ID = "area13"; |
michael@0 | 423 | defAttrs = buildDefaultTextAttrs(ID, "12pt"); |
michael@0 | 424 | attrs = { }; |
michael@0 | 425 | testTextAttrs(ID, 0, attrs, defAttrs, 0, 0); |
michael@0 | 426 | |
michael@0 | 427 | ID = "area14"; |
michael@0 | 428 | defAttrs = buildDefaultTextAttrs(ID, kInputFontSize, |
michael@0 | 429 | kNormalFontWeight, kInputFontFamily); |
michael@0 | 430 | |
michael@0 | 431 | attrs = { }; |
michael@0 | 432 | testTextAttrs(ID, 0, attrs, defAttrs, 0, 0); |
michael@0 | 433 | |
michael@0 | 434 | ////////////////////////////////////////////////////////////////////////// |
michael@0 | 435 | // area15, embed char tests, "*plain*plain**bold*bold*" |
michael@0 | 436 | ID = "area15"; |
michael@0 | 437 | defAttrs = buildDefaultTextAttrs(ID, "12pt"); |
michael@0 | 438 | |
michael@0 | 439 | // p |
michael@0 | 440 | testTextAttrs(ID, 0, { }, { }, 0, 1); |
michael@0 | 441 | // plain |
michael@0 | 442 | testTextAttrs(ID, 1, { }, defAttrs, 1, 6); |
michael@0 | 443 | // p |
michael@0 | 444 | testTextAttrs(ID, 6, { }, { }, 6, 7); |
michael@0 | 445 | // plain |
michael@0 | 446 | testTextAttrs(ID, 7, { }, defAttrs, 7, 12); |
michael@0 | 447 | // p and img |
michael@0 | 448 | testTextAttrs(ID, 12, { }, { }, 12, 14); |
michael@0 | 449 | // bold |
michael@0 | 450 | attrs = { "font-weight": kBoldFontWeight }; |
michael@0 | 451 | testTextAttrs(ID, 14, attrs, defAttrs, 14, 18); |
michael@0 | 452 | // p |
michael@0 | 453 | testTextAttrs(ID, 18, { }, { }, 18, 19); |
michael@0 | 454 | // bold |
michael@0 | 455 | attrs = { "font-weight": kBoldFontWeight }; |
michael@0 | 456 | testTextAttrs(ID, 19, attrs, defAttrs, 19, 23); |
michael@0 | 457 | // p |
michael@0 | 458 | testTextAttrs(ID, 23, { }, { }, 23, 24); |
michael@0 | 459 | |
michael@0 | 460 | ////////////////////////////////////////////////////////////////////////// |
michael@0 | 461 | // area16, "font-family" tests |
michael@0 | 462 | ID = "area16"; |
michael@0 | 463 | defAttrs = buildDefaultTextAttrs(ID, "12pt"); |
michael@0 | 464 | testDefaultTextAttrs(ID, defAttrs); |
michael@0 | 465 | |
michael@0 | 466 | attrs = { "font-family": kMonospaceFontFamily }; |
michael@0 | 467 | testTextAttrs(ID, 0, attrs, defAttrs, 0, 4); |
michael@0 | 468 | |
michael@0 | 469 | attrs = { }; |
michael@0 | 470 | testTextAttrs(ID, 4, attrs, defAttrs, 4, 9); |
michael@0 | 471 | |
michael@0 | 472 | attrs = { "font-family": kSerifFontFamily }; |
michael@0 | 473 | testTextAttrs(ID, 9, attrs, defAttrs, 9, 13); |
michael@0 | 474 | |
michael@0 | 475 | attrs = { }; |
michael@0 | 476 | testTextAttrs(ID, 13, attrs, defAttrs, 13, 18); |
michael@0 | 477 | |
michael@0 | 478 | attrs = { "font-family": kAbsentFontFamily }; |
michael@0 | 479 | testTextAttrs(ID, 18, attrs, defAttrs, 18, 22); |
michael@0 | 480 | |
michael@0 | 481 | attrs = { }; |
michael@0 | 482 | testTextAttrs(ID, 22, attrs, defAttrs, 22, 27); |
michael@0 | 483 | |
michael@0 | 484 | attrs = { "font-family": kCursiveFontFamily }; |
michael@0 | 485 | testTextAttrs(ID, 27, attrs, defAttrs, 27, 31); |
michael@0 | 486 | |
michael@0 | 487 | attrs = { }; |
michael@0 | 488 | testTextAttrs(ID, 31, attrs, defAttrs, 31, 45); |
michael@0 | 489 | |
michael@0 | 490 | ////////////////////////////////////////////////////////////////////////// |
michael@0 | 491 | // area17, "text-decoration" tests |
michael@0 | 492 | ID = "area17"; |
michael@0 | 493 | defAttrs = buildDefaultTextAttrs(ID, "12pt"); |
michael@0 | 494 | testDefaultTextAttrs(ID, defAttrs); |
michael@0 | 495 | |
michael@0 | 496 | attrs = { |
michael@0 | 497 | "text-underline-style": "solid", |
michael@0 | 498 | "text-underline-color": "rgb(0, 0, 0)", |
michael@0 | 499 | }; |
michael@0 | 500 | testTextAttrs(ID, 0, attrs, defAttrs, 0, 10); |
michael@0 | 501 | |
michael@0 | 502 | attrs = { |
michael@0 | 503 | "text-underline-style": "solid", |
michael@0 | 504 | "text-underline-color": "rgb(0, 0, 255)", |
michael@0 | 505 | }; |
michael@0 | 506 | testTextAttrs(ID, 10, attrs, defAttrs, 10, 15); |
michael@0 | 507 | |
michael@0 | 508 | attrs = { |
michael@0 | 509 | "text-underline-style": "dotted", |
michael@0 | 510 | "text-underline-color": "rgb(0, 0, 0)", |
michael@0 | 511 | }; |
michael@0 | 512 | testTextAttrs(ID, 15, attrs, defAttrs, 15, 22); |
michael@0 | 513 | |
michael@0 | 514 | attrs = { |
michael@0 | 515 | "text-line-through-style": "solid", |
michael@0 | 516 | "text-line-through-color": "rgb(0, 0, 0)", |
michael@0 | 517 | }; |
michael@0 | 518 | testTextAttrs(ID, 22, attrs, defAttrs, 22, 34); |
michael@0 | 519 | |
michael@0 | 520 | attrs = { |
michael@0 | 521 | "text-line-through-style": "solid", |
michael@0 | 522 | "text-line-through-color": "rgb(0, 0, 255)", |
michael@0 | 523 | }; |
michael@0 | 524 | testTextAttrs(ID, 34, attrs, defAttrs, 34, 39); |
michael@0 | 525 | |
michael@0 | 526 | attrs = { |
michael@0 | 527 | "text-line-through-style": "wavy", |
michael@0 | 528 | "text-line-through-color": "rgb(0, 0, 0)", |
michael@0 | 529 | }; |
michael@0 | 530 | testTextAttrs(ID, 39, attrs, defAttrs, 39, 44); |
michael@0 | 531 | |
michael@0 | 532 | ////////////////////////////////////////////////////////////////////////// |
michael@0 | 533 | // area18, "auto-generation text" tests |
michael@0 | 534 | ID = "area18"; |
michael@0 | 535 | defAttrs = buildDefaultTextAttrs(ID, "12pt"); |
michael@0 | 536 | testDefaultTextAttrs(ID, defAttrs); |
michael@0 | 537 | |
michael@0 | 538 | var attrs = { |
michael@0 | 539 | "auto-generated": "true" |
michael@0 | 540 | }; |
michael@0 | 541 | testTextAttrs(ID, 0, attrs, defAttrs, 0, 2); |
michael@0 | 542 | testTextAttrs(ID, 2, { }, defAttrs, 2, 6); |
michael@0 | 543 | testTextAttrs(ID, 6, attrs, defAttrs, 6, 7); |
michael@0 | 544 | |
michael@0 | 545 | ////////////////////////////////////////////////////////////////////////// |
michael@0 | 546 | // area19, "HTML5 mark tag" test |
michael@0 | 547 | // text enclosed in mark tag will have a different background color |
michael@0 | 548 | ID = "area19"; |
michael@0 | 549 | defAttrs = buildDefaultTextAttrs(ID, "12pt"); |
michael@0 | 550 | |
michael@0 | 551 | attrs = {}; |
michael@0 | 552 | testTextAttrs(ID, 0, attrs, defAttrs, 0, 10); |
michael@0 | 553 | |
michael@0 | 554 | tempElem = getNode(ID).firstChild.nextSibling; |
michael@0 | 555 | gComputedStyle = document.defaultView.getComputedStyle(tempElem, ""); |
michael@0 | 556 | attrs = { "background-color": gComputedStyle.backgroundColor }; |
michael@0 | 557 | testTextAttrs(ID, 11, attrs, defAttrs, 10, 17); |
michael@0 | 558 | |
michael@0 | 559 | attrs = {}; |
michael@0 | 560 | testTextAttrs(ID, 18, attrs, defAttrs, 17, 28); |
michael@0 | 561 | |
michael@0 | 562 | ////////////////////////////////////////////////////////////////////////// |
michael@0 | 563 | // area20, "aOffset as -1 (Mozilla Bug 789621)" test |
michael@0 | 564 | |
michael@0 | 565 | ID = "area20"; |
michael@0 | 566 | defAttrs = buildDefaultTextAttrs(ID, "15pt"); |
michael@0 | 567 | testDefaultTextAttrs(ID, defAttrs); |
michael@0 | 568 | |
michael@0 | 569 | testTextAttrs(ID, -1, {}, defAttrs, 0, 11); |
michael@0 | 570 | SimpleTest.finish(); |
michael@0 | 571 | } |
michael@0 | 572 | |
michael@0 | 573 | SimpleTest.waitForExplicitFinish(); |
michael@0 | 574 | addA11yLoadEvent(doTest); |
michael@0 | 575 | </script> |
michael@0 | 576 | </head> |
michael@0 | 577 | <body style="font-size: 12pt"> |
michael@0 | 578 | |
michael@0 | 579 | <a target="_blank" |
michael@0 | 580 | href="https://bugzilla.mozilla.org/show_bug.cgi?id=345759" |
michael@0 | 581 | title="Implement text attributes"> |
michael@0 | 582 | Mozilla Bug 345759 |
michael@0 | 583 | </a> |
michael@0 | 584 | <a target="_blank" |
michael@0 | 585 | href="https://bugzilla.mozilla.org/show_bug.cgi?id=473569" |
michael@0 | 586 | title="Restrict text-position to allowed values"> |
michael@0 | 587 | Mozilla Bug 473569 |
michael@0 | 588 | </a> |
michael@0 | 589 | <a target="_blank" |
michael@0 | 590 | href="https://bugzilla.mozilla.org/show_bug.cgi?id=473576" |
michael@0 | 591 | title="font-family text attribute should expose actual font used"> |
michael@0 | 592 | Mozilla Bug 473576 |
michael@0 | 593 | </a> |
michael@0 | 594 | <a target="_blank" |
michael@0 | 595 | href="https://bugzilla.mozilla.org/show_bug.cgi?id=523304" |
michael@0 | 596 | title="expose text-underline-color and text-line-through-color text attributes"> |
michael@0 | 597 | Mozilla Bug 523304 |
michael@0 | 598 | </a> |
michael@0 | 599 | <a target="_blank" |
michael@0 | 600 | href="https://bugzilla.mozilla.org/show_bug.cgi?id=735645" |
michael@0 | 601 | title="expose sub and sup elements in text attributes"> |
michael@0 | 602 | Mozilla Bug 735645 |
michael@0 | 603 | </a> |
michael@0 | 604 | <a target="_blank" |
michael@0 | 605 | href="https://bugzilla.mozilla.org/show_bug.cgi?id=445516" |
michael@0 | 606 | title="Support auto-generated text attribute on bullet lists"> |
michael@0 | 607 | Mozilla Bug 445516 |
michael@0 | 608 | </a> |
michael@0 | 609 | <a target="_blank" |
michael@0 | 610 | href="https://bugzilla.mozilla.org/show_bug.cgi?id=789621" |
michael@0 | 611 | title="getTextAttributes doesn't work with magic offsets"> |
michael@0 | 612 | Mozilla Bug 789621 |
michael@0 | 613 | </a> |
michael@0 | 614 | <p id="display"></p> |
michael@0 | 615 | <div id="content" style="display: none"></div> |
michael@0 | 616 | <pre id="test"> |
michael@0 | 617 | </pre> |
michael@0 | 618 | |
michael@0 | 619 | <p id="area1" style="font-size: smaller">Normal <b>Bold</b> Normal</p> |
michael@0 | 620 | <p id="area2" style="font-size: 120%">Normal <b>Bold <i>Italic </i>Bold</b> Normal</p> |
michael@0 | 621 | <p id="area3" style="background-color: blue;"> |
michael@0 | 622 | <span style="color: green; background-color: rgb(0, 0, 255)"> |
michael@0 | 623 | Green |
michael@0 | 624 | <span style="color: red">but children are red</span> |
michael@0 | 625 | </span><span style="color: green; background-color: rgb(255, 255, 0);"> |
michael@0 | 626 | Another green section. |
michael@0 | 627 | </span> |
michael@0 | 628 | </p> |
michael@0 | 629 | <p id="area4"> |
michael@0 | 630 | <span style="color: green"> |
michael@0 | 631 | Green |
michael@0 | 632 | </span><span style="color: green"> |
michael@0 | 633 | Green too |
michael@0 | 634 | <span style="color: red">with red children</span> |
michael@0 | 635 | Green again |
michael@0 | 636 | </span> |
michael@0 | 637 | </p> |
michael@0 | 638 | <!-- Green!*!RedNormal--> |
michael@0 | 639 | <p id="area5"> |
michael@0 | 640 | <span style="color: green">Green</span> |
michael@0 | 641 | <img src="../moz.png" alt="image"/> |
michael@0 | 642 | <span style="color: red">Red</span>Normal |
michael@0 | 643 | </p> |
michael@0 | 644 | <p id="area6"> |
michael@0 | 645 | This <sup>sentence</sup> has the word |
michael@0 | 646 | <span style="vertical-align:super;">sentence</span> in |
michael@0 | 647 | <sub>superscript</sub> and |
michael@0 | 648 | <span style="vertical-align:sub;">subscript</span> and |
michael@0 | 649 | <span style="vertical-align:20%;">superscript 20%</span> and |
michael@0 | 650 | <span style="vertical-align:-20%;">subscript 20%</span> and |
michael@0 | 651 | <span style="vertical-align:20px;">superscript 20px</span> and |
michael@0 | 652 | <span style="vertical-align:-20px;">subscript 20px</span> |
michael@0 | 653 | </p> |
michael@0 | 654 | |
michael@0 | 655 | <p lang="en" id="area7"> |
michael@0 | 656 | <span lang="ru">Привет</span> |
michael@0 | 657 | <span style="background-color: blue">Blue BG color</span> |
michael@0 | 658 | <span lang="de">Ich bin/Du bist</span> |
michael@0 | 659 | <span lang="en"> |
michael@0 | 660 | Normal |
michael@0 | 661 | <span style="color: magenta">Magenta<b>Bold</b>Magenta</span> |
michael@0 | 662 | </span> |
michael@0 | 663 | </p> |
michael@0 | 664 | |
michael@0 | 665 | <p id="area9" style="font-size: smaller">Small |
michael@0 | 666 | <span style="font-size: 120%">bigger</span> smaller |
michael@0 | 667 | <span style="background-color: blue;">background blue</span> normal |
michael@0 | 668 | <span style="font-style: italic;">Different styling</span> normal |
michael@0 | 669 | <span style="font-family: monospace;">Different font</span> normal |
michael@0 | 670 | <span style="text-decoration: underline;">underlined</span> normal |
michael@0 | 671 | <span style="text-decoration: line-through;">strikethrough</span> normal |
michael@0 | 672 | <s>strikethrough</s> normal |
michael@0 | 673 | <strike>strikethrough</strike> normal |
michael@0 | 674 | </p> |
michael@0 | 675 | |
michael@0 | 676 | <p id="area10">Normal |
michael@0 | 677 | <span style="font-size: 120%">bigger</span> smaller |
michael@0 | 678 | <span style="background-color: blue;">background blue</span> normal |
michael@0 | 679 | <span style="font-style: italic;">Different styling</span> normal |
michael@0 | 680 | <span style="font-family: monospace;">Different font</span> normal |
michael@0 | 681 | <span style="text-decoration: underline;">underlined</span> normal |
michael@0 | 682 | <span style="text-decoration: line-through;">strikethrough</span> normal |
michael@0 | 683 | </p> |
michael@0 | 684 | |
michael@0 | 685 | <p id="area11" style="font-weight: bolder;"> |
michael@0 | 686 | <span style="font-weight: bolder;">bolder</span>bolder |
michael@0 | 687 | <span style="font-weight: lighter;">lighter</span>bolder |
michael@0 | 688 | <span style="font-weight: normal;">normal</span>bolder |
michael@0 | 689 | <b>bold</b>bolder |
michael@0 | 690 | <span style="font-weight: 400;">normal</span>bolder |
michael@0 | 691 | <span style="font-weight: 700;">bold</span>bolder |
michael@0 | 692 | <span style="font-weight: bold;">bold</span>bolder |
michael@0 | 693 | <span style="font-weight: 900;">bold</span>bolder |
michael@0 | 694 | </p> |
michael@0 | 695 | |
michael@0 | 696 | <p id="area12">hello</p> |
michael@0 | 697 | <p id="area13"></p> |
michael@0 | 698 | <input id="area14"> |
michael@0 | 699 | |
michael@0 | 700 | <!-- *plain*plain**bold*bold*--> |
michael@0 | 701 | <div id="area15"><p>embed</p>plain<p>embed</p>plain<p>embed</p><img src="../moz.png" alt="image"/><b>bold</b><p>embed</p><b>bold</b><p>embed</p></div> |
michael@0 | 702 | |
michael@0 | 703 | <p id="area16" style="font-family: sans-serif;"> |
michael@0 | 704 | <span style="font-family: monospace;">text</span>text |
michael@0 | 705 | <span style="font-family: serif;">text</span>text |
michael@0 | 706 | <span style="font-family: BodoniThatDoesntExist;">text</span>text |
michael@0 | 707 | <span style="font-family: Comic Sans MS, cursive;">text</span>text |
michael@0 | 708 | <span style="font-family: sans-serif, fantasy;">text</span>text |
michael@0 | 709 | </p> |
michael@0 | 710 | |
michael@0 | 711 | <p id="area17"> |
michael@0 | 712 | <span style="-moz-text-decoration-line: underline;">underline |
michael@0 | 713 | </span><span style="text-decoration: underline; -moz-text-decoration-color: blue;">blue |
michael@0 | 714 | </span><span style="text-decoration: underline; -moz-text-decoration-style: dotted;">dotted |
michael@0 | 715 | </span><span style="-moz-text-decoration-line: line-through;">linethrough |
michael@0 | 716 | </span><span style="text-decoration: line-through; -moz-text-decoration-color: blue;">blue |
michael@0 | 717 | </span><span style="text-decoration: line-through; -moz-text-decoration-style: wavy;">wavy |
michael@0 | 718 | </span> |
michael@0 | 719 | </p> |
michael@0 | 720 | |
michael@0 | 721 | <ul> |
michael@0 | 722 | <li id="area18" class="gencontent">item</li> |
michael@0 | 723 | </ul> |
michael@0 | 724 | |
michael@0 | 725 | <p id="area19">uncolored |
michael@0 | 726 | <mark>colored</mark> uncolored |
michael@0 | 727 | </p> |
michael@0 | 728 | |
michael@0 | 729 | <p id="area20" style="font-size: 15pt;">offset test</p> |
michael@0 | 730 | |
michael@0 | 731 | </body> |
michael@0 | 732 | </html> |