Diff
Modified: branches/safari-608.5.7.3-branch/LayoutTests/ChangeLog (254283 => 254284)
--- branches/safari-608.5.7.3-branch/LayoutTests/ChangeLog 2020-01-09 19:40:57 UTC (rev 254283)
+++ branches/safari-608.5.7.3-branch/LayoutTests/ChangeLog 2020-01-09 19:49:19 UTC (rev 254284)
@@ -1,3 +1,49 @@
+2020-01-09 Kocsen Chung <kocsen_ch...@apple.com>
+
+ Cherry-pick r254220. rdar://problem/58450166
+
+ Fix specification violation in Font Loading API
+ https://bugs.webkit.org/show_bug.cgi?id=205901
+ <rdar://problem/58083743>
+
+ Reviewed by Brent Fulgham.
+
+ Source/WebCore:
+
+ Our Font Loading API does not comply with the spec:
+
+ > If the parsed value is a CSS-wide keyword, return a syntax error.
+
+ Rather than crashing, we should return a syntax error.
+
+ Test: fast/text/font-loading-global-keyword.html
+
+ * css/CSSFontFaceSet.cpp:
+ (WebCore::computeFontSelectionRequest):
+ (WebCore::CSSFontFaceSet::matchingFacesExcludingPreinstalledFonts):
+
+ LayoutTests:
+
+ Test all the entry points to the CSS Font Loading API that accept CSS keywords.
+
+ * fast/text/font-loading-global-keyword-expected.txt: Added.
+ * fast/text/font-loading-global-keyword.html: Added.
+
+ git-svn-id: https://svn.webkit.org/repository/webkit/trunk@254220 268f45cc-cd09-0410-ab3c-d52691b4dbfc
+
+ 2020-01-08 Myles C. Maxfield <mmaxfi...@apple.com>
+
+ Fix specification violation in Font Loading API
+ https://bugs.webkit.org/show_bug.cgi?id=205901
+ <rdar://problem/58083743>
+
+ Reviewed by Brent Fulgham.
+
+ Test all the entry points to the CSS Font Loading API that accept CSS keywords.
+
+ * fast/text/font-loading-global-keyword-expected.txt: Added.
+ * fast/text/font-loading-global-keyword.html: Added.
+
2019-12-18 Dan Robson <dan_rob...@apple.com>
Cherry-pick r253563. rdar://problem/58049160
Added: branches/safari-608.5.7.3-branch/LayoutTests/fast/text/font-loading-global-keyword-expected.txt (0 => 254284)
--- branches/safari-608.5.7.3-branch/LayoutTests/fast/text/font-loading-global-keyword-expected.txt (rev 0)
+++ branches/safari-608.5.7.3-branch/LayoutTests/fast/text/font-loading-global-keyword-expected.txt 2020-01-09 19:49:19 UTC (rev 254284)
@@ -0,0 +1,45 @@
+This test ensure that global CSS keywords generate expected syntax errors.
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+PASS document.fonts.check('initial', 'A') threw exception SyntaxError: The string did not match the expected pattern..
+PASS document.fonts.check('inherited', 'A') threw exception SyntaxError: The string did not match the expected pattern..
+PASS document.fonts.check('unset', 'A') threw exception SyntaxError: The string did not match the expected pattern..
+PASS document.fonts.check('revert', 'A') threw exception SyntaxError: The string did not match the expected pattern..
+PASS new FontFace('abc', 'url(asdf)', {'style': 'initial'}) threw exception SyntaxError: The string did not match the expected pattern..
+PASS new FontFace('abc', 'url(asdf)', {'style': 'inherited'}) threw exception SyntaxError: The string did not match the expected pattern..
+PASS new FontFace('abc', 'url(asdf)', {'style': 'unset'}) threw exception SyntaxError: The string did not match the expected pattern..
+PASS new FontFace('abc', 'url(asdf)', {'style': 'revert'}) threw exception SyntaxError: The string did not match the expected pattern..
+PASS new FontFace('abc', 'url(asdf)', {'weight': 'initial'}) threw exception SyntaxError: The string did not match the expected pattern..
+PASS new FontFace('abc', 'url(asdf)', {'weight': 'inherited'}) threw exception SyntaxError: The string did not match the expected pattern..
+PASS new FontFace('abc', 'url(asdf)', {'weight': 'unset'}) threw exception SyntaxError: The string did not match the expected pattern..
+PASS new FontFace('abc', 'url(asdf)', {'weight': 'revert'}) threw exception SyntaxError: The string did not match the expected pattern..
+PASS new FontFace('abc', 'url(asdf)', {'stretch': 'initial'}) threw exception SyntaxError: The string did not match the expected pattern..
+PASS new FontFace('abc', 'url(asdf)', {'stretch': 'inherited'}) threw exception SyntaxError: The string did not match the expected pattern..
+PASS new FontFace('abc', 'url(asdf)', {'stretch': 'unset'}) threw exception SyntaxError: The string did not match the expected pattern..
+PASS new FontFace('abc', 'url(asdf)', {'stretch': 'revert'}) threw exception SyntaxError: The string did not match the expected pattern..
+PASS new FontFace('abc', 'url(asdf)', {'unicodeRange': 'initial'}) threw exception SyntaxError: The string did not match the expected pattern..
+PASS new FontFace('abc', 'url(asdf)', {'unicodeRange': 'inherited'}) threw exception SyntaxError: The string did not match the expected pattern..
+PASS new FontFace('abc', 'url(asdf)', {'unicodeRange': 'unset'}) threw exception SyntaxError: The string did not match the expected pattern..
+PASS new FontFace('abc', 'url(asdf)', {'unicodeRange': 'revert'}) threw exception SyntaxError: The string did not match the expected pattern..
+PASS new FontFace('abc', 'url(asdf)', {'featureSettings': 'initial'}) threw exception SyntaxError: The string did not match the expected pattern..
+PASS new FontFace('abc', 'url(asdf)', {'featureSettings': 'inherited'}) threw exception SyntaxError: The string did not match the expected pattern..
+PASS new FontFace('abc', 'url(asdf)', {'featureSettings': 'unset'}) threw exception SyntaxError: The string did not match the expected pattern..
+PASS new FontFace('abc', 'url(asdf)', {'featureSettings': 'revert'}) threw exception SyntaxError: The string did not match the expected pattern..
+PASS new FontFace('abc', 'url(asdf)', {'display': 'initial'}) threw exception SyntaxError: The string did not match the expected pattern..
+PASS new FontFace('abc', 'url(asdf)', {'display': 'inherited'}) threw exception SyntaxError: The string did not match the expected pattern..
+PASS new FontFace('abc', 'url(asdf)', {'display': 'unset'}) threw exception SyntaxError: The string did not match the expected pattern..
+PASS new FontFace('abc', 'url(asdf)', {'display': 'initial'}) threw exception SyntaxError: The string did not match the expected pattern..
+PASS new FontFace('abc', 'inherited') threw exception SyntaxError: The string did not match the expected pattern..
+PASS new FontFace('abc', 'unset') threw exception SyntaxError: The string did not match the expected pattern..
+PASS new FontFace('abc', 'revert') threw exception SyntaxError: The string did not match the expected pattern..
+PASS new FontFace('abc', 'revert') threw exception SyntaxError: The string did not match the expected pattern..
+PASS document.fonts.load('initial', 'A') rejected promise with SyntaxError: The string did not match the expected pattern..
+PASS document.fonts.load('inherited', 'A') rejected promise with SyntaxError: The string did not match the expected pattern..
+PASS document.fonts.load('unset', 'A') rejected promise with SyntaxError: The string did not match the expected pattern..
+PASS document.fonts.load('revert', 'A') rejected promise with SyntaxError: The string did not match the expected pattern..
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
Added: branches/safari-608.5.7.3-branch/LayoutTests/fast/text/font-loading-global-keyword.html (0 => 254284)
--- branches/safari-608.5.7.3-branch/LayoutTests/fast/text/font-loading-global-keyword.html (rev 0)
+++ branches/safari-608.5.7.3-branch/LayoutTests/fast/text/font-loading-global-keyword.html 2020-01-09 19:49:19 UTC (rev 254284)
@@ -0,0 +1,48 @@
+<!DOCTYPE HTML>
+<html>
+<head>
+<script src=""
+</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')");
+shouldThrowErrorName("new FontFace('abc', 'url(asdf)', {'style': 'initial'})", "SyntaxError");
+shouldThrowErrorName("new FontFace('abc', 'url(asdf)', {'style': 'inherited'})", "SyntaxError");
+shouldThrowErrorName("new FontFace('abc', 'url(asdf)', {'style': 'unset'})", "SyntaxError");
+shouldThrowErrorName("new FontFace('abc', 'url(asdf)', {'style': 'revert'})", "SyntaxError");
+shouldThrowErrorName("new FontFace('abc', 'url(asdf)', {'weight': 'initial'})", "SyntaxError");
+shouldThrowErrorName("new FontFace('abc', 'url(asdf)', {'weight': 'inherited'})", "SyntaxError");
+shouldThrowErrorName("new FontFace('abc', 'url(asdf)', {'weight': 'unset'})", "SyntaxError");
+shouldThrowErrorName("new FontFace('abc', 'url(asdf)', {'weight': 'revert'})", "SyntaxError");
+shouldThrowErrorName("new FontFace('abc', 'url(asdf)', {'stretch': 'initial'})", "SyntaxError");
+shouldThrowErrorName("new FontFace('abc', 'url(asdf)', {'stretch': 'inherited'})", "SyntaxError");
+shouldThrowErrorName("new FontFace('abc', 'url(asdf)', {'stretch': 'unset'})", "SyntaxError");
+shouldThrowErrorName("new FontFace('abc', 'url(asdf)', {'stretch': 'revert'})", "SyntaxError");
+shouldThrowErrorName("new FontFace('abc', 'url(asdf)', {'unicodeRange': 'initial'})", "SyntaxError");
+shouldThrowErrorName("new FontFace('abc', 'url(asdf)', {'unicodeRange': 'inherited'})", "SyntaxError");
+shouldThrowErrorName("new FontFace('abc', 'url(asdf)', {'unicodeRange': 'unset'})", "SyntaxError");
+shouldThrowErrorName("new FontFace('abc', 'url(asdf)', {'unicodeRange': 'revert'})", "SyntaxError");
+shouldThrowErrorName("new FontFace('abc', 'url(asdf)', {'featureSettings': 'initial'})", "SyntaxError");
+shouldThrowErrorName("new FontFace('abc', 'url(asdf)', {'featureSettings': 'inherited'})", "SyntaxError");
+shouldThrowErrorName("new FontFace('abc', 'url(asdf)', {'featureSettings': 'unset'})", "SyntaxError");
+shouldThrowErrorName("new FontFace('abc', 'url(asdf)', {'featureSettings': 'revert'})", "SyntaxError");
+shouldThrowErrorName("new FontFace('abc', 'url(asdf)', {'display': 'initial'})", "SyntaxError");
+shouldThrowErrorName("new FontFace('abc', 'url(asdf)', {'display': 'inherited'})", "SyntaxError");
+shouldThrowErrorName("new FontFace('abc', 'url(asdf)', {'display': 'unset'})", "SyntaxError");
+shouldThrowErrorName("new FontFace('abc', 'url(asdf)', {'display': 'initial'})", "SyntaxError");
+shouldThrowErrorName("new FontFace('abc', 'inherited')", "SyntaxError");
+shouldThrowErrorName("new FontFace('abc', 'unset')", "SyntaxError");
+shouldThrowErrorName("new FontFace('abc', 'revert')", "SyntaxError");
+shouldThrowErrorName("new FontFace('abc', 'revert')", "SyntaxError");
+</script>
+<script src=""
+</body>
+</html>
Modified: branches/safari-608.5.7.3-branch/Source/WebCore/ChangeLog (254283 => 254284)
--- branches/safari-608.5.7.3-branch/Source/WebCore/ChangeLog 2020-01-09 19:40:57 UTC (rev 254283)
+++ branches/safari-608.5.7.3-branch/Source/WebCore/ChangeLog 2020-01-09 19:49:19 UTC (rev 254284)
@@ -1,3 +1,56 @@
+2020-01-09 Kocsen Chung <kocsen_ch...@apple.com>
+
+ Cherry-pick r254220. rdar://problem/58450166
+
+ Fix specification violation in Font Loading API
+ https://bugs.webkit.org/show_bug.cgi?id=205901
+ <rdar://problem/58083743>
+
+ Reviewed by Brent Fulgham.
+
+ Source/WebCore:
+
+ Our Font Loading API does not comply with the spec:
+
+ > If the parsed value is a CSS-wide keyword, return a syntax error.
+
+ Rather than crashing, we should return a syntax error.
+
+ Test: fast/text/font-loading-global-keyword.html
+
+ * css/CSSFontFaceSet.cpp:
+ (WebCore::computeFontSelectionRequest):
+ (WebCore::CSSFontFaceSet::matchingFacesExcludingPreinstalledFonts):
+
+ LayoutTests:
+
+ Test all the entry points to the CSS Font Loading API that accept CSS keywords.
+
+ * fast/text/font-loading-global-keyword-expected.txt: Added.
+ * fast/text/font-loading-global-keyword.html: Added.
+
+ git-svn-id: https://svn.webkit.org/repository/webkit/trunk@254220 268f45cc-cd09-0410-ab3c-d52691b4dbfc
+
+ 2020-01-08 Myles C. Maxfield <mmaxfi...@apple.com>
+
+ Fix specification violation in Font Loading API
+ https://bugs.webkit.org/show_bug.cgi?id=205901
+ <rdar://problem/58083743>
+
+ Reviewed by Brent Fulgham.
+
+ Our Font Loading API does not comply with the spec:
+
+ > If the parsed value is a CSS-wide keyword, return a syntax error.
+
+ Rather than crashing, we should return a syntax error.
+
+ Test: fast/text/font-loading-global-keyword.html
+
+ * css/CSSFontFaceSet.cpp:
+ (WebCore::computeFontSelectionRequest):
+ (WebCore::CSSFontFaceSet::matchingFacesExcludingPreinstalledFonts):
+
2019-12-18 youenn fablet <you...@apple.com>
Protect ServiceWorker::postMessage from a null execState
Modified: branches/safari-608.5.7.3-branch/Source/WebCore/css/CSSFontFaceSet.cpp (254283 => 254284)
--- branches/safari-608.5.7.3-branch/Source/WebCore/css/CSSFontFaceSet.cpp 2020-01-09 19:40:57 UTC (rev 254283)
+++ branches/safari-608.5.7.3-branch/Source/WebCore/css/CSSFontFaceSet.cpp 2020-01-09 19:49:19 UTC (rev 254284)
@@ -300,7 +300,7 @@
return m_faces[i];
}
-static FontSelectionRequest computeFontSelectionRequest(MutableStyleProperties& style)
+static ExceptionOr<FontSelectionRequest> computeFontSelectionRequest(MutableStyleProperties& style)
{
RefPtr<CSSValue> weightValue = style.getPropertyCSSValue(CSSPropertyFontWeight).get();
if (!weightValue)
@@ -314,11 +314,14 @@
if (!styleValue)
styleValue = CSSFontStyleValue::create(CSSValuePool::singleton().createIdentifierValue(CSSValueNormal));
+ if (weightValue->isGlobalKeyword() || stretchValue->isGlobalKeyword() || styleValue->isGlobalKeyword())
+ return Exception { SyntaxError };
+
auto weightSelectionValue = StyleBuilderConverter::convertFontWeightFromValue(*weightValue);
auto stretchSelectionValue = StyleBuilderConverter::convertFontStretchFromValue(*stretchValue);
auto styleSelectionValue = StyleBuilderConverter::convertFontStyleFromValue(*styleValue);
- return { weightSelectionValue, stretchSelectionValue, styleSelectionValue };
+ return {{ weightSelectionValue, stretchSelectionValue, styleSelectionValue }};
}
static HashSet<UChar32> codePointsFromString(StringView stringView)
@@ -344,7 +347,10 @@
if (parseResult == CSSParser::ParseResult::Error)
return Exception { SyntaxError };
- FontSelectionRequest request = computeFontSelectionRequest(style.get());
+ auto requestOrException = computeFontSelectionRequest(style.get());
+ if (requestOrException.hasException())
+ return requestOrException.releaseException();
+ auto request = requestOrException.releaseReturnValue();
auto family = style->getPropertyCSSValue(CSSPropertyFontFamily);
if (!is<CSSValueList>(family))