Move parseFontFaceDescriptor to CSSPropertyParser.cpp
[chromium-blink-merge.git] / third_party / WebKit / LayoutTests / fast / css / fontface-properties.html
blob4b1437d9d0cc2a3d929c52bfefe2d1e248a8e29d
1 <html>
2 <head>
3 <script src="../../resources/js-test.js"></script>
4 <style>
5 @font-face {
6 font-family: 'Ahem';
7 src: url(../../resources/Ahem.ttf);
8 font-style: italic;
9 font-weight: 300;
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 */
15 </style>
16 <script>
17 description('Test getting/setting FontFace properties.');
19 function getDocumentFontFaces() {
20 var faces = [];
21 document.fonts.forEach(function(face) { faces.push(face); });
22 return faces;
25 function runTests() {
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");
34 debug('');
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');
44 debug('');
45 constructedFace = new FontFace('constructedFace', 'local(bar)', {
46 'style': 'oblique',
47 'weight': 'bold',
48 'unicodeRange': 'U+100-1FF, U+ABCD',
49 'variant': 'small-caps',
50 'featureSettings': "'liga' 0"
51 });
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");
59 debug('');
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");
74 debug('');
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');
87 promise1.then(
88 function() {
89 debug('FAIL: Expected NetworkError');
90 }).catch(function(err) {
91 shouldBeEqualToString('"' + err.message + '"' , 'A network error occurred.');
92 });
95 if (document.fonts)
96 runTests();
97 else {
98 testFailed('document.fonts does not exist');
100 </script>
101 </head>
102 <body>
103 </body>
104 </html>