3 <script src=
"../../resources/js-test.js"></script>
7 src: url(../../resources/Ahem.ttf);
10 unicode-range: U+
0-
3FF;
11 font-variant: small-caps;
12 -webkit-font-feature-settings:
"dlig" 1;
13 /* font-stretch property is not supported */
17 description('Test getting/setting FontFace properties.');
19 function getDocumentFontFaces() {
21 document
.fonts
.forEach(function(face
) { faces
.push(face
); });
26 ahemFace
= getDocumentFontFaces()[0];
27 shouldBeEqualToString('ahemFace.family', 'Ahem');
28 shouldBeEqualToString('ahemFace.style', 'italic');
29 shouldBeEqualToString('ahemFace.weight', '300');
30 shouldBeEqualToString('ahemFace.unicodeRange', 'U+0-3FF');
31 shouldBeEqualToString('ahemFace.variant', 'small-caps');
32 shouldBeEqualToString('ahemFace.featureSettings', "'dlig' 1");
35 defaultFace
= new FontFace('defaultFace', 'local(foo)');
36 shouldBeEqualToString('defaultFace.family', 'defaultFace');
37 shouldBeEqualToString('defaultFace.style', 'normal');
38 shouldBeEqualToString('defaultFace.weight', 'normal');
39 shouldBeEqualToString('defaultFace.stretch', 'normal');
40 shouldBeEqualToString('defaultFace.unicodeRange', 'U+0-10FFFF');
41 shouldBeEqualToString('defaultFace.variant', 'normal');
42 shouldBeEqualToString('defaultFace.featureSettings', 'normal');
45 constructedFace
= new FontFace('constructedFace', 'local(bar)', {
48 'unicodeRange': 'U+100-1FF, U+ABCD',
49 'variant': 'small-caps',
50 'featureSettings': "'liga' 0"
52 shouldBeEqualToString('constructedFace.family', 'constructedFace');
53 shouldBeEqualToString('constructedFace.style', 'oblique');
54 shouldBeEqualToString('constructedFace.weight', 'bold');
55 shouldBeEqualToString('constructedFace.unicodeRange', 'U+100-1FF, U+ABCD');
56 shouldBeEqualToString('constructedFace.variant', 'small-caps');
57 shouldBeEqualToString('constructedFace.featureSettings', "'liga' 0");
60 modifiedFace
= new FontFace('unmodified', 'local(baz)');
61 modifiedFace
.family
= 'modified';
62 modifiedFace
.style
= 'italic';
63 modifiedFace
.weight
= 900;
64 modifiedFace
.unicodeRange
= 'U+0-3FF';
65 modifiedFace
.variant
= 'small-caps';
66 modifiedFace
.featureSettings
= "'dlig' 1, 'liga' 0";
67 shouldBeEqualToString('modifiedFace.family', 'modified');
68 shouldBeEqualToString('modifiedFace.style', 'italic');
69 shouldBeEqualToString('modifiedFace.weight', '900');
70 shouldBeEqualToString('modifiedFace.unicodeRange', 'U+0-3FF');
71 shouldBeEqualToString('modifiedFace.variant', 'small-caps');
72 shouldBeEqualToString('modifiedFace.featureSettings', "'dlig' 1, 'liga' 0");
75 face
= new FontFace('test', 'local(foo)');
76 shouldThrow("face.style = ''");
77 shouldThrow("face.weight = 'a'");
78 shouldThrow("face.unicodeRange = 'U+'");
79 shouldThrow("face.variant = '???'");
80 shouldThrow("face.featureSettings = null");
81 promise1
= face
.loaded
;
82 promise2
= face
.load();
83 promise3
= face
.loaded
;
84 shouldBeTrue('promise1 === promise2');
85 shouldBeTrue('promise1 === promise3');
89 debug('FAIL: Expected NetworkError');
90 }).catch(function(err
) {
91 shouldBeEqualToString('"' + err
.message
+ '"' , 'A network error occurred.');
98 testFailed('document.fonts does not exist');