| 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 <style> | 4 <style> |
| 5 @font-face { | 5 @font-face { |
| 6 font-family: 'Ahem'; | 6 font-family: 'Ahem'; |
| 7 src: url(../../resources/Ahem.ttf); | 7 src: url(../../resources/Ahem.ttf); |
| 8 font-style: italic; | 8 font-style: italic; |
| 9 font-weight: 300; | 9 font-weight: 300; |
| 10 unicode-range: U+0-3FF; | 10 unicode-range: U+0-3FF; |
| 11 font-variant: small-caps; | 11 font-variant: small-caps; |
| 12 -webkit-font-feature-settings: "dlig" 1; | 12 -webkit-font-feature-settings: "dlig" 1; |
| 13 font-display: block; |
| 13 /* font-stretch property is not supported */ | 14 /* font-stretch property is not supported */ |
| 14 } | 15 } |
| 15 </style> | 16 </style> |
| 16 <script> | 17 <script> |
| 17 description('Test getting/setting FontFace properties.'); | 18 description('Test getting/setting FontFace properties.'); |
| 18 | 19 |
| 19 function getDocumentFontFaces() { | 20 function getDocumentFontFaces() { |
| 20 var faces = []; | 21 var faces = []; |
| 21 document.fonts.forEach(function(face) { faces.push(face); }); | 22 document.fonts.forEach(function(face) { faces.push(face); }); |
| 22 return faces; | 23 return faces; |
| 23 } | 24 } |
| 24 | 25 |
| 25 function runTests() { | 26 function runTests() { |
| 26 window.jsTestIsAsync = true; | 27 window.jsTestIsAsync = true; |
| 27 ahemFace = getDocumentFontFaces()[0]; | 28 ahemFace = getDocumentFontFaces()[0]; |
| 28 shouldBeEqualToString('ahemFace.family', 'Ahem'); | 29 shouldBeEqualToString('ahemFace.family', 'Ahem'); |
| 29 shouldBeEqualToString('ahemFace.style', 'italic'); | 30 shouldBeEqualToString('ahemFace.style', 'italic'); |
| 30 shouldBeEqualToString('ahemFace.weight', '300'); | 31 shouldBeEqualToString('ahemFace.weight', '300'); |
| 31 shouldBeEqualToString('ahemFace.unicodeRange', 'U+0-3FF'); | 32 shouldBeEqualToString('ahemFace.unicodeRange', 'U+0-3FF'); |
| 32 shouldBeEqualToString('ahemFace.variant', 'small-caps'); | 33 shouldBeEqualToString('ahemFace.variant', 'small-caps'); |
| 33 shouldBeEqualToString('ahemFace.featureSettings', "'dlig' 1"); | 34 shouldBeEqualToString('ahemFace.featureSettings', "'dlig' 1"); |
| 35 shouldBeEqualToString('ahemFace.display', 'block'); |
| 34 | 36 |
| 35 debug(''); | 37 debug(''); |
| 36 defaultFace = new FontFace('defaultFace', 'local(foo)'); | 38 defaultFace = new FontFace('defaultFace', 'local(foo)'); |
| 37 shouldBeEqualToString('defaultFace.family', 'defaultFace'); | 39 shouldBeEqualToString('defaultFace.family', 'defaultFace'); |
| 38 shouldBeEqualToString('defaultFace.style', 'normal'); | 40 shouldBeEqualToString('defaultFace.style', 'normal'); |
| 39 shouldBeEqualToString('defaultFace.weight', 'normal'); | 41 shouldBeEqualToString('defaultFace.weight', 'normal'); |
| 40 shouldBeEqualToString('defaultFace.stretch', 'normal'); | 42 shouldBeEqualToString('defaultFace.stretch', 'normal'); |
| 41 shouldBeEqualToString('defaultFace.unicodeRange', 'U+0-10FFFF'); | 43 shouldBeEqualToString('defaultFace.unicodeRange', 'U+0-10FFFF'); |
| 42 shouldBeEqualToString('defaultFace.variant', 'normal'); | 44 shouldBeEqualToString('defaultFace.variant', 'normal'); |
| 43 shouldBeEqualToString('defaultFace.featureSettings', 'normal'); | 45 shouldBeEqualToString('defaultFace.featureSettings', 'normal'); |
| 46 shouldBeEqualToString('defaultFace.display', 'auto'); |
| 44 | 47 |
| 45 debug(''); | 48 debug(''); |
| 46 constructedFace = new FontFace('constructedFace', 'local(bar)', { | 49 constructedFace = new FontFace('constructedFace', 'local(bar)', { |
| 47 'style': 'oblique', | 50 'style': 'oblique', |
| 48 'weight': 'bold', | 51 'weight': 'bold', |
| 49 'unicodeRange': 'U+100-1FF, U+ABCD', | 52 'unicodeRange': 'U+100-1FF, U+ABCD', |
| 50 'variant': 'small-caps', | 53 'variant': 'small-caps', |
| 51 'featureSettings': "'liga' 0" | 54 'featureSettings': "'liga' 0", |
| 55 'display': 'optional' |
| 52 }); | 56 }); |
| 53 shouldBeEqualToString('constructedFace.family', 'constructedFace'); | 57 shouldBeEqualToString('constructedFace.family', 'constructedFace'); |
| 54 shouldBeEqualToString('constructedFace.style', 'oblique'); | 58 shouldBeEqualToString('constructedFace.style', 'oblique'); |
| 55 shouldBeEqualToString('constructedFace.weight', 'bold'); | 59 shouldBeEqualToString('constructedFace.weight', 'bold'); |
| 56 shouldBeEqualToString('constructedFace.unicodeRange', 'U+100-1FF, U+ABCD'); | 60 shouldBeEqualToString('constructedFace.unicodeRange', 'U+100-1FF, U+ABCD'); |
| 57 shouldBeEqualToString('constructedFace.variant', 'small-caps'); | 61 shouldBeEqualToString('constructedFace.variant', 'small-caps'); |
| 58 shouldBeEqualToString('constructedFace.featureSettings', "'liga' 0"); | 62 shouldBeEqualToString('constructedFace.featureSettings', "'liga' 0"); |
| 63 shouldBeEqualToString('constructedFace.display', 'optional'); |
| 59 | 64 |
| 60 debug(''); | 65 debug(''); |
| 61 modifiedFace = new FontFace('unmodified', 'local(baz)'); | 66 modifiedFace = new FontFace('unmodified', 'local(baz)'); |
| 62 modifiedFace.family = 'modified'; | 67 modifiedFace.family = 'modified'; |
| 63 modifiedFace.style = 'italic'; | 68 modifiedFace.style = 'italic'; |
| 64 modifiedFace.weight = 900; | 69 modifiedFace.weight = 900; |
| 65 modifiedFace.unicodeRange = 'U+0-3FF'; | 70 modifiedFace.unicodeRange = 'U+0-3FF'; |
| 66 modifiedFace.variant = 'small-caps'; | 71 modifiedFace.variant = 'small-caps'; |
| 67 modifiedFace.featureSettings = "'dlig' 1, 'liga' 0"; | 72 modifiedFace.featureSettings = "'dlig' 1, 'liga' 0"; |
| 73 modifiedFace.display = 'fallback'; |
| 68 shouldBeEqualToString('modifiedFace.family', 'modified'); | 74 shouldBeEqualToString('modifiedFace.family', 'modified'); |
| 69 shouldBeEqualToString('modifiedFace.style', 'italic'); | 75 shouldBeEqualToString('modifiedFace.style', 'italic'); |
| 70 shouldBeEqualToString('modifiedFace.weight', '900'); | 76 shouldBeEqualToString('modifiedFace.weight', '900'); |
| 71 shouldBeEqualToString('modifiedFace.unicodeRange', 'U+0-3FF'); | 77 shouldBeEqualToString('modifiedFace.unicodeRange', 'U+0-3FF'); |
| 72 shouldBeEqualToString('modifiedFace.variant', 'small-caps'); | 78 shouldBeEqualToString('modifiedFace.variant', 'small-caps'); |
| 73 shouldBeEqualToString('modifiedFace.featureSettings', "'dlig' 1, 'liga' 0"); | 79 shouldBeEqualToString('modifiedFace.featureSettings', "'dlig' 1, 'liga' 0"); |
| 80 shouldBeEqualToString('modifiedFace.display', 'fallback'); |
| 74 | 81 |
| 75 debug(''); | 82 debug(''); |
| 76 face = new FontFace('test', 'local(foo)'); | 83 face = new FontFace('test', 'local(foo)'); |
| 77 shouldThrow("face.style = ''"); | 84 shouldThrow("face.style = ''"); |
| 78 shouldThrow("face.weight = 'a'"); | 85 shouldThrow("face.weight = 'a'"); |
| 79 shouldThrow("face.unicodeRange = 'U+'"); | 86 shouldThrow("face.unicodeRange = 'U+'"); |
| 80 shouldThrow("face.variant = '???'"); | 87 shouldThrow("face.variant = '???'"); |
| 81 shouldThrow("face.featureSettings = null"); | 88 shouldThrow("face.featureSettings = null"); |
| 89 shouldThrow("face.display = 123"); |
| 82 promise1 = face.loaded; | 90 promise1 = face.loaded; |
| 83 promise2 = face.load(); | 91 promise2 = face.load(); |
| 84 promise3 = face.loaded; | 92 promise3 = face.loaded; |
| 85 shouldBeTrue('promise1 === promise2'); | 93 shouldBeTrue('promise1 === promise2'); |
| 86 shouldBeTrue('promise1 === promise3'); | 94 shouldBeTrue('promise1 === promise3'); |
| 87 | 95 |
| 88 promise1.then( | 96 promise1.then( |
| 89 function() { | 97 function() { |
| 90 debug('FAIL: Expected NetworkError'); | 98 debug('FAIL: Expected NetworkError'); |
| 91 }).catch(function(err) { | 99 }).catch(function(err) { |
| 92 shouldBeEqualToString('"' + err.message + '"' , 'A network error oc
curred.'); | 100 shouldBeEqualToString('"' + err.message + '"' , 'A network error oc
curred.'); |
| 93 }).then(finishJSTest); | 101 }).then(finishJSTest); |
| 94 } | 102 } |
| 95 | 103 |
| 96 if (document.fonts) | 104 if (document.fonts) |
| 97 runTests(); | 105 runTests(); |
| 98 else { | 106 else { |
| 99 testFailed('document.fonts does not exist'); | 107 testFailed('document.fonts does not exist'); |
| 100 } | 108 } |
| 101 </script> | 109 </script> |
| 102 </head> | 110 </head> |
| 103 <body> | 111 <body> |
| 104 </body> | 112 </body> |
| 105 </html> | 113 </html> |
| OLD | NEW |