Commit 7a18f0ba authored by Dominik Röttsches's avatar Dominik Röttsches Committed by Commit Bot

Avoid looking up empty font name in FontFaceCache

When document.fonts.load() is called with font specification such as
'1px ""' (containing two quotes) as the argument, CSS font property
parsing parses this successfully as the empty string. FontFaceCache
was not prepared to handle that correctly.

Fix FontFaceCache to guard against that. Add test to actually
ensure that this font specification's load promise resolves
successfully.

In parallel, raised
https://github.com/w3c/csswg-drafts/issues/4510
in CSS WG to discuss whether it would make sense to reject such
a font specification at the parsing stage already.

Bug: 1023206
Change-Id: If46aef0c7fcd2e06bc657480b9189857438d8cc1
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1914392Reviewed-by: default avatarRune Lillesveen <futhark@chromium.org>
Reviewed-by: default avatarKoji Ishii <kojii@chromium.org>
Commit-Queue: Dominik Röttsches <drott@chromium.org>
Cr-Commit-Position: refs/heads/master@{#715261}
parent 19d13b49
...@@ -148,6 +148,9 @@ void FontFaceCache::IncrementVersion() { ...@@ -148,6 +148,9 @@ void FontFaceCache::IncrementVersion() {
CSSSegmentedFontFace* FontFaceCache::Get( CSSSegmentedFontFace* FontFaceCache::Get(
const FontDescription& font_description, const FontDescription& font_description,
const AtomicString& family) { const AtomicString& family) {
if (family.IsEmpty())
return nullptr;
SegmentedFacesByFamily::iterator segmented_faces_for_family = SegmentedFacesByFamily::iterator segmented_faces_for_family =
segmented_faces_.find(family); segmented_faces_.find(family);
if (segmented_faces_for_family == segmented_faces_.end() || if (segmented_faces_for_family == segmented_faces_.end() ||
......
<!DOCTYPE html>
<meta charset="utf-8">
<link rel="author" title="Dominik Röttsches" href="drott@chromium.org">
<link rel="help" href="https://drafts.csswg.org/css-font-loading/#font-face-load">
<link rel="help" href="https://github.com/w3c/csswg-drafts/issues/4510">
<meta name="assert" content="Ensure that an empty font family name loads and resolves to array." />
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script>
promise_test(function(t) {
var testFontFace = new FontFace('a', 'url(a)');
document.fonts.add(testFontFace);
return document.fonts.load("1px \"\"").then(function(result) {
assert_true(Array.isArray(result),
"Resolved promise's value must be an array.") });
})
</script>
</html>
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment