Make style system mochitests handle cases where initial font family is sans-serif. (Bug 617372) a2.0=tests
authorL. David Baron <dbaron@dbaron.org>
Thu, 09 Dec 2010 20:38:53 -0800
changeset 59063 9103bd2267e78d3ea1b3524417f1c199c45f86dc
parent 59062 e71b310f048498af352c9b22e18e9624288257ac
child 59064 6986bf97d8b4e1762160c05d0be96b74a24a79a2
push id1
push usershaver@mozilla.com
push dateTue, 04 Jan 2011 17:58:04 +0000
bugs617372
milestone2.0b8pre
Make style system mochitests handle cases where initial font family is sans-serif. (Bug 617372) a2.0=tests
layout/style/test/property_database.js
--- a/layout/style/test/property_database.js
+++ b/layout/style/test/property_database.js
@@ -57,16 +57,28 @@ const CSS_TYPE_SHORTHAND_AND_LONGHAND = 
 //	   computed value for the property's initial value.
 //	 other_values: Values whose computed value should be different from the
 //	   computed value for the property's initial value.
 //	 XXX Should have a third field for values whose computed value may or
 //	   may not be the same as for the property's initial value.
 //	 invalid_values: Things that are not values for the property and
 //	   should be rejected.
 
+// Helper functions used to construct gCSSProperties.
+
+function initial_font_family_is_sans_serif()
+{
+	// The initial value of 'font-family' might be 'serif' or
+	// 'sans-serif'.
+	var div = document.createElement("div");
+	div.setAttribute("style", "font: -moz-initial");
+	return getComputedStyle(div, "").fontFamily == "sans-serif";
+}
+var gInitialFontFamilyIsSansSerif = initial_font_family_is_sans_serif();
+
 var gCSSProperties = {
 	"-moz-appearance": {
 		domProp: "MozAppearance",
 		inherited: false,
 		type: CSS_TYPE_LONGHAND,
 		initial_values: [ "none" ],
 		other_values: [ "radio", "menulist" ],
 		invalid_values: []
@@ -1708,26 +1720,26 @@ var gCSSProperties = {
 		invalid_values: []
 	},
 	"font": {
 		domProp: "font",
 		inherited: true,
 		type: CSS_TYPE_TRUE_SHORTHAND,
 		subproperties: [ "font-style", "font-variant", "font-weight", "font-size", "line-height", "font-family", "font-stretch", "font-size-adjust", "-moz-font-feature-settings", "-moz-font-language-override" ],
 		/* XXX could be sans-serif */
-		initial_values: [ "medium serif" ],
+		initial_values: [ (gInitialFontFamilyIsSansSerif ? "medium sans-serif" : "medium serif") ],
 		other_values: [ "large serif", "9px fantasy", "bold italic small-caps 24px/1.4 Times New Roman, serif", "caption", "icon", "menu", "message-box", "small-caption", "status-bar" ],
 		invalid_values: []
 	},
 	"font-family": {
 		domProp: "fontFamily",
 		inherited: true,
 		type: CSS_TYPE_LONGHAND,
-		initial_values: [ "serif" ],
-		other_values: [ "sans-serif", "Times New Roman, serif", "'Times New Roman', serif", "cursive", "fantasy", "\"Times New Roman", "Times, \"Times New Roman" ],
+		initial_values: [ (gInitialFontFamilyIsSansSerif ? "sans-serif" : "serif") ],
+		other_values: [ (gInitialFontFamilyIsSansSerif ? "serif" : "sans-serif"), "Times New Roman, serif", "'Times New Roman', serif", "cursive", "fantasy", "\"Times New Roman", "Times, \"Times New Roman" ],
 		invalid_values: [ "\"Times New\" Roman" ]
 	},
 	"-moz-font-feature-settings": {
 		domProp: "MozFontFeatureSettings",
 		inherited: true,
 		type: CSS_TYPE_LONGHAND,
 		initial_values: [ "normal" ],
 		other_values: [ "'liga=1'", "\"liga=1\"", "'foo,bar=\"hello\"'" ],