haikuwebkit/LayoutTests/fast/text/font-loading-global-keyword...

49 lines
3.4 KiB
HTML
Raw Permalink Normal View History

<!DOCTYPE HTML>
<html>
<head>
<script src="../../resources/js-test-pre.js"></script>
</head>
<body>
<script>
description("This test ensure that global CSS keywords generate expected syntax errors.");
shouldThrowErrorName("document.fonts.check('initial', 'A')", "SyntaxError");
shouldThrowErrorName("document.fonts.check('inherited', 'A')", "SyntaxError");
shouldThrowErrorName("document.fonts.check('unset', 'A')", "SyntaxError");
shouldThrowErrorName("document.fonts.check('revert', 'A')", "SyntaxError");
shouldReject("document.fonts.load('initial', 'A')");
shouldReject("document.fonts.load('inherited', 'A')");
shouldReject("document.fonts.load('unset', 'A')");
shouldReject("document.fonts.load('revert', 'A')");
new FontFace() should not throw when failing to parse arguments https://bugs.webkit.org/show_bug.cgi?id=205770 Patch by Nikos Mouchtaris <nmouchtaris@apple.com> on 2020-02-14 Reviewed by Myles Maxfield. Source/WebCore: Change FontFace constructor to conform to API specification: https://drafts.csswg.org/css-font-loading/#dom-fontface-fontface. No longer throws. For parsing failure, now rejects promise, sets status to error, and sets FontFace members to default string. Test: http/tests/css/font-face-constructor.html * css/CSSFontFace.cpp: (WebCore::CSSFontFace::setErrorState): * css/CSSFontFace.h: * css/CSSFontFaceSet.cpp: (WebCore::CSSFontFaceSet::addToFacesLookupTable): (WebCore::CSSFontFaceSet::remove): (WebCore::CSSFontFaceSet::fontFace): * css/CSSSegmentedFontFace.cpp: (WebCore::CSSSegmentedFontFace::fontRanges): * css/FontFace.cpp: (WebCore::FontFace::setErrorState): (WebCore::FontFace::create): (WebCore::FontFace::family const): (WebCore::FontFace::style const): (WebCore::FontFace::weight const): (WebCore::FontFace::stretch const): (WebCore::FontFace::unicodeRange const): (WebCore::FontFace::featureSettings const): (WebCore::FontFace::display const): (WebCore::FontFace::fontStateChanged): * css/FontFace.h: * css/FontFace.idl: LayoutTests: Tests that constructor doesn't throw, sets members to corresponding default strings. * http/tests/css/font-face-constructor-expected.txt: Added. * http/tests/css/font-face-constructor.html: Added. Canonical link: https://commits.webkit.org/220759@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@256659 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2020-02-15 01:18:49 +00:00
shouldBeEqualToString("new FontFace('abc', 'url(asdf)', {'style': 'initial'}).status","error");
shouldBeEqualToString("new FontFace('abc', 'url(asdf)', {'style': 'inherited'}).status","error");
shouldBeEqualToString("new FontFace('abc', 'url(asdf)', {'style': 'unset'}).status","error");
shouldBeEqualToString("new FontFace('abc', 'url(asdf)', {'style': 'revert'}).status","error");
shouldBeEqualToString("new FontFace('abc', 'url(asdf)', {'weight': 'initial'}).status","error");
shouldBeEqualToString("new FontFace('abc', 'url(asdf)', {'weight': 'inherited'}).status","error");
shouldBeEqualToString("new FontFace('abc', 'url(asdf)', {'weight': 'unset'}).status","error");
shouldBeEqualToString("new FontFace('abc', 'url(asdf)', {'weight': 'revert'}).status","error");
shouldBeEqualToString("new FontFace('abc', 'url(asdf)', {'stretch': 'initial'}).status","error");
shouldBeEqualToString("new FontFace('abc', 'url(asdf)', {'stretch': 'inherited'}).status","error");
shouldBeEqualToString("new FontFace('abc', 'url(asdf)', {'stretch': 'unset'}).status","error");
shouldBeEqualToString("new FontFace('abc', 'url(asdf)', {'stretch': 'revert'}).status","error");
shouldBeEqualToString("new FontFace('abc', 'url(asdf)', {'unicodeRange': 'initial'}).status","error");
shouldBeEqualToString("new FontFace('abc', 'url(asdf)', {'unicodeRange': 'inherited'}).status","error");
shouldBeEqualToString("new FontFace('abc', 'url(asdf)', {'unicodeRange': 'unset'}).status","error");
shouldBeEqualToString("new FontFace('abc', 'url(asdf)', {'unicodeRange': 'revert'}).status","error");
shouldBeEqualToString("new FontFace('abc', 'url(asdf)', {'featureSettings': 'initial'}).status","error");
shouldBeEqualToString("new FontFace('abc', 'url(asdf)', {'featureSettings': 'inherited'}).status","error");
shouldBeEqualToString("new FontFace('abc', 'url(asdf)', {'featureSettings': 'unset'}).status","error");
shouldBeEqualToString("new FontFace('abc', 'url(asdf)', {'featureSettings': 'revert'}).status","error");
shouldBeEqualToString("new FontFace('abc', 'url(asdf)', {'display': 'initial'}).status","error");
shouldBeEqualToString("new FontFace('abc', 'url(asdf)', {'display': 'inherited'}).status","error");
shouldBeEqualToString("new FontFace('abc', 'url(asdf)', {'display': 'unset'}).status","error");
shouldBeEqualToString("new FontFace('abc', 'url(asdf)', {'display': 'initial'}).status","error");
shouldBeEqualToString("new FontFace('abc', 'inherited').status","error");
shouldBeEqualToString("new FontFace('abc', 'unset').status","error");
shouldBeEqualToString("new FontFace('abc', 'revert').status","error");
shouldBeEqualToString("new FontFace('abc', 'revert').status","error");
</script>
<script src="../../resources/js-test-post.js"></script>
</body>
</html>