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