diff --git a/layout/style/FontFace.cpp b/layout/style/FontFace.cpp index 4b84e559c8a..6454c96ed2a 100644 --- a/layout/style/FontFace.cpp +++ b/layout/style/FontFace.cpp @@ -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 diff --git a/layout/style/test/test_font_loading_api.html b/layout/style/test/test_font_loading_api.html index 7b1e44eb521..db32127c909 100644 --- a/layout/style/test/test_font_loading_api.html +++ b/layout/style/test/test_font_loading_api.html @@ -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) {