Bug 1146199 - Return empty string from FontFace.family if the FontFace was constructed with an invalid family name. r=jdaggett

This commit is contained in:
Cameron McCormack 2015-03-24 19:34:32 +11:00
parent 1b8d1d5203
commit 05cbf53328
2 changed files with 7 additions and 1 deletions

View File

@ -401,6 +401,11 @@ FontFace::GetFamily(nsString& aResult)
GetDesc(eCSSFontDesc_Family, value);
aResult.Truncate();
if (value.GetUnit() == eCSSUnit_Null) {
return;
}
nsDependentString family(value.GetStringBufferValue());
if (!family.IsEmpty()) {
// The string length can be zero when the author passed an invalid

View File

@ -53,7 +53,7 @@ var invalidValues = {
// Invalid font family names.
var invalidFontFamilyNames = [
"", "\"\"", "sans-serif", "A, B", "inherit"
"", "\"\"", "sans-serif", "A, B", "inherit", "a 1"
];
// Will hold an ArrayBuffer containing a valid font.
@ -293,6 +293,7 @@ function runTest() {
familyTests = familyTests.then(function() {
var face = new FontFace(aFamilyName, fontData);
is(face.status, "error", "FontFace should be error immediately after construction with invalid family name " + aFamilyName + " (TEST 17)");
is(face.family, "", "FontFace.family should be the empty string after construction with invalid family name " + aFamilyName + " (TEST 17)");
return face.loaded.then(function() {
ok(false, "FontFace should not load after invalid family name " + aFamilyName + " specified (TEST 17)");
}, function(aError) {