blob: e345701d41c0de620d3506cf75e9bbf91ad0bab6 [file] [log] [blame]
<!DOCTYPE html>
<html>
<head>
<script src="../../resources/js-test-pre.js"></script>
</head>
<body>
<script>
function setFontFaceWeight(fontFace, weight) {
fontFace.weight = weight;
return fontFace.weight;
}
function setFontFaceStretch(fontFace, stretch) {
fontFace.stretch = stretch;
return fontFace.stretch;
}
function setFontFaceStyle(fontFace, style) {
fontFace.style = style;
return fontFace.style;
}
var fontFace = new FontFace("asdf", "url('notreal')");
shouldBeEqualToString("setFontFaceWeight(fontFace, '1')", "1");
shouldBeEqualToString("setFontFaceWeight(fontFace, '100')", "100");
shouldBeEqualToString("setFontFaceWeight(fontFace, '200')", "200");
shouldBeEqualToString("setFontFaceWeight(fontFace, '300')", "300");
shouldBeEqualToString("setFontFaceWeight(fontFace, '400')", "normal");
shouldBeEqualToString("setFontFaceWeight(fontFace, 'normal')", "normal");
shouldBeEqualToString("setFontFaceWeight(fontFace, '500')", "500");
shouldBeEqualToString("setFontFaceWeight(fontFace, '600')", "600");
shouldBeEqualToString("setFontFaceWeight(fontFace, '700')", "bold");
shouldBeEqualToString("setFontFaceWeight(fontFace, 'bold')", "bold");
shouldBeEqualToString("setFontFaceWeight(fontFace, '800')", "800");
shouldBeEqualToString("setFontFaceWeight(fontFace, '900')", "900");
shouldThrow("setFontFaceWeight(fontFace, 'garbage')");
shouldThrow("setFontFaceWeight(fontFace, 'initial')");
shouldBeEqualToString("setFontFaceWeight(fontFace, 'calc(3 + 4)')", "7");
shouldBeEqualToString("setFontFaceWeight(fontFace, 'calc(100 + 200)')", "300");
shouldBeEqualToString("setFontFaceWeight(fontFace, 'calc(150 + 50)')", "200");
shouldBeEqualToString("setFontFaceStretch(fontFace, '1%')", "1%");
shouldThrow("setFontFaceStretch(fontFace, '2')");
shouldBeEqualToString("setFontFaceStretch(fontFace, 'ultra-condensed')", "ultra-condensed");
shouldBeEqualToString("setFontFaceStretch(fontFace, 'extra-condensed')", "extra-condensed");
shouldBeEqualToString("setFontFaceStretch(fontFace, 'condensed')", "condensed");
shouldBeEqualToString("setFontFaceStretch(fontFace, 'semi-condensed')", "semi-condensed");
shouldBeEqualToString("setFontFaceStretch(fontFace, 'normal')", "normal");
shouldBeEqualToString("setFontFaceStretch(fontFace, 'semi-expanded')", "semi-expanded");
shouldBeEqualToString("setFontFaceStretch(fontFace, 'expanded')", "expanded");
shouldBeEqualToString("setFontFaceStretch(fontFace, 'extra-expanded')", "extra-expanded");
shouldBeEqualToString("setFontFaceStretch(fontFace, 'ultra-expanded')", "ultra-expanded");
shouldThrow("setFontFaceStretch(fontFace, 'garbage')");
shouldThrow("setFontFaceStretch(fontFace, 'initial')");
shouldThrow("setFontFaceStretch(fontFace, 'calc(3 + 4)')");
shouldBeEqualToString("setFontFaceStretch(fontFace, 'calc(3% + 4%)')", "7%");
shouldBeEqualToString("setFontFaceStyle(fontFace, 'oblique 1deg')", "oblique 1deg");
shouldBeEqualToString("setFontFaceStyle(fontFace, 'oblique 20grad')", "oblique 18deg");
shouldBeEqualToString("setFontFaceStyle(fontFace, 'oblique 0.28318rad')", "oblique 16deg");
shouldBeEqualToString("setFontFaceStyle(fontFace, 'oblique 0.04turn')", "oblique 14.25deg");
shouldThrow("setFontFaceStyle(fontFace, 'oblique 5')");
shouldThrow("setFontFaceStyle(fontFace, 'oblique 20')");
shouldBeEqualToString("setFontFaceStyle(fontFace, 'italic')", "italic");
shouldBeEqualToString("setFontFaceStyle(fontFace, 'oblique')", "italic");
shouldBeEqualToString("setFontFaceStyle(fontFace, 'normal')", "normal");
shouldThrow("setFontFaceStyle(fontFace, 'garbage')");
shouldThrow("setFontFaceStyle(fontFace, 'initial')");
shouldThrow("setFontFaceStyle(fontFace, 'oblique calc(3 + 4)')");
shouldBeEqualToString("setFontFaceStyle(fontFace, 'oblique calc(0.04turn + 1deg)')", "oblique 15.25deg");
</script>
<script src="../../resources/js-test-post.js"></script>
</body>
</html>