OLD | NEW |
1 <html> | 1 <html> |
2 <head> | 2 <head> |
3 <script src="../../resources/js-test.js"></script> | 3 <script src="../../resources/js-test.js"></script> |
4 <script> | 4 <script> |
5 description('Tests that unicode-range descriptor is used to selectively download
fonts that are used in document.'); | 5 description('Tests that unicode-range descriptor is used to selectively download
fonts that are used in document.'); |
6 | 6 |
7 window.jsTestIsAsync = true; | 7 window.jsTestIsAsync = true; |
8 | 8 |
9 var latin1Loaded = false; | 9 var latin1Loaded = false; |
10 var cyrillicLoaded = false; | 10 var cyrillicLoaded = false; |
11 var arabicLoaded = false; | 11 var arabicLoaded = false; |
| 12 var iconLoaded = false; |
12 | 13 |
13 function runTests() { | 14 function runTests() { |
14 document.fonts.addEventListener('loadingdone', onloadingdone); | 15 document.fonts.addEventListener('loadingdone', onloadingdone); |
15 } | 16 } |
16 | 17 |
17 function onloadingdone(e) { | 18 function onloadingdone(e) { |
18 for (var i = 0; i < e.fontfaces.length; i++) { | 19 for (var i = 0; i < e.fontfaces.length; i++) { |
19 var range = e.fontfaces[i].unicodeRange; | 20 var range = e.fontfaces[i].unicodeRange; |
20 if (range == 'U+0-FF') | 21 if (range == 'U+0-FF') |
21 latin1Loaded = true; | 22 latin1Loaded = true; |
22 if (range == 'U+400-4FF') | 23 if (range == 'U+400-4FF') |
23 cyrillicLoaded = true; | 24 cyrillicLoaded = true; |
24 if (range == 'U+600-6FF') | 25 if (range == 'U+600-6FF') |
25 arabicLoaded = true; | 26 arabicLoaded = true; |
| 27 if (range == 'U+E000') |
| 28 iconLoaded = true; |
26 } | 29 } |
27 | 30 |
28 shouldBeTrue('latin1Loaded'); // Latin-1 font is loaded for basic font metri
cs. | 31 shouldBeTrue('latin1Loaded'); // Latin-1 font is loaded for basic font metri
cs. |
29 shouldBeTrue('cyrillicLoaded'); | 32 shouldBeTrue('cyrillicLoaded'); |
30 shouldBeFalse('arabicLoaded'); | 33 shouldBeFalse('arabicLoaded'); |
| 34 shouldBeFalse('iconLoaded'); |
31 finishJSTest(); | 35 finishJSTest(); |
32 } | 36 } |
33 | 37 |
34 if (document.fonts) | 38 if (document.fonts) |
35 runTests(); | 39 runTests(); |
36 else { | 40 else { |
37 testFailed('document.fonts does not exist'); | 41 testFailed('document.fonts does not exist'); |
38 finishJSTest(); | 42 finishJSTest(); |
39 } | 43 } |
40 </script> | 44 </script> |
41 <style> | 45 <style> |
42 @font-face { | 46 @font-face { |
43 font-family: TestFont; | 47 font-family: TestFont; |
44 src: url('../../resources/Ahem.ttf'); | 48 src: url('../../resources/Ahem.ttf'); |
45 unicode-range: U+00-0FF; /* Latin-1 */ | 49 unicode-range: U+00-0FF; /* Latin-1 */ |
46 } | 50 } |
47 @font-face { | 51 @font-face { |
48 font-family: TestFont; | 52 font-family: TestFont; |
49 src: url('../../resources/Ahem.otf'); | 53 src: url('../../resources/Ahem.otf'); |
50 unicode-range: U+0400-04FF; /* Cyrillic */ | 54 unicode-range: U+0400-04FF; /* Cyrillic */ |
51 } | 55 } |
52 @font-face { | 56 @font-face { |
53 font-family: TestFont; | 57 font-family: TestFont; |
54 src: url('../../resources/Ahem.woff'); | 58 src: url('../../resources/Ahem.woff'); |
55 unicode-range: U+0600-06FF; /* Arabic */ | 59 unicode-range: U+0600-06FF; /* Arabic */ |
56 } | 60 } |
57 #test { | 61 #test { |
58 font-family: TestFont; | 62 font-family: TestFont; |
59 } | 63 } |
| 64 |
| 65 @font-face { |
| 66 font-family: SingleCharacterOverride; |
| 67 src: url('../../resources/Ahem.woff'); |
| 68 unicode-range: U+E000; |
| 69 } |
| 70 #test2 { |
| 71 font-family: SingleCharacterOverride; |
| 72 } |
60 </style> | 73 </style> |
61 </head> | 74 </head> |
62 <body> | 75 <body> |
63 <p id="test">Проверка</p> | 76 <p id="test">Проверка</p> |
| 77 <p id="test2">hello</p> |
64 </body> | 78 </body> |
65 </html> | 79 </html> |
OLD | NEW |