Limit the hashless color quirk to the properties where it's needed, per http://simon.html5.org/specs/quirks-mode#the-hashless-hex-color-quirk . (Bug 774122, patch 1) r=bzbarsky

This changes test_property_syntax_errors.html in the following ways:
 (1) removes the "known failures" handling, since there aren't any
 (2) changes it to test syntax errors in both quirks mode and standards
     mode, instead of only in standards mode
 (3) uses a (new) quirks_values mechanism to property_database.js to
     test cases that should be invalid in standards mode but accepted in
     quirks mode
This commit is contained in:
L. David Baron 2012-07-16 09:11:33 -04:00
Родитель d1bb327966
Коммит a9208a1f33
5 изменённых файлов: 153 добавлений и 71 удалений

Просмотреть файл

@ -653,6 +653,9 @@ protected:
// True if we are in quirks mode; false in standards or almost standards mode // True if we are in quirks mode; false in standards or almost standards mode
bool mNavQuirkMode : 1; bool mNavQuirkMode : 1;
// True when the hashless color quirk applies.
bool mHashlessColorQuirk : 1;
// True if unsafe rules should be allowed // True if unsafe rules should be allowed
bool mUnsafeRulesEnabled : 1; bool mUnsafeRulesEnabled : 1;
@ -746,6 +749,7 @@ CSSParserImpl::CSSParserImpl()
mNameSpaceMap(nsnull), mNameSpaceMap(nsnull),
mHavePushBack(false), mHavePushBack(false),
mNavQuirkMode(false), mNavQuirkMode(false),
mHashlessColorQuirk(false),
mUnsafeRulesEnabled(false), mUnsafeRulesEnabled(false),
mHTMLMediaMode(false), mHTMLMediaMode(false),
mParsingCompoundProperty(false) mParsingCompoundProperty(false)
@ -3752,7 +3756,7 @@ CSSParserImpl::ParseColor(nsCSSValue& aValue)
} }
// try 'xxyyzz' without '#' prefix for compatibility with IE and Nav4x (bug 23236 and 45804) // try 'xxyyzz' without '#' prefix for compatibility with IE and Nav4x (bug 23236 and 45804)
if (mNavQuirkMode && !IsParsingCompoundProperty()) { if (mHashlessColorQuirk) {
// - If the string starts with 'a-f', the nsCSSScanner builds the // - If the string starts with 'a-f', the nsCSSScanner builds the
// token as a eCSSToken_Ident and we can parse the string as a // token as a eCSSToken_Ident and we can parse the string as a
// 'xxyyzz' RGB color. // 'xxyyzz' RGB color.
@ -4553,7 +4557,7 @@ CSSParserImpl::ParseVariant(nsCSSValue& aValue,
return ParseElement(aValue); return ParseElement(aValue);
} }
if ((aVariantMask & VARIANT_COLOR) != 0) { if ((aVariantMask & VARIANT_COLOR) != 0) {
if ((mNavQuirkMode && !IsParsingCompoundProperty()) || // NONSTANDARD: Nav interprets 'xxyyzz' values even without '#' prefix if (mHashlessColorQuirk || // NONSTANDARD: Nav interprets 'xxyyzz' values even without '#' prefix
(eCSSToken_ID == tk->mType) || (eCSSToken_ID == tk->mType) ||
(eCSSToken_Ref == tk->mType) || (eCSSToken_Ref == tk->mType) ||
(eCSSToken_Ident == tk->mType) || (eCSSToken_Ident == tk->mType) ||
@ -5614,36 +5618,58 @@ static const nsCSSProperty kOutlineRadiusIDs[] = {
bool bool
CSSParserImpl::ParseProperty(nsCSSProperty aPropID) CSSParserImpl::ParseProperty(nsCSSProperty aPropID)
{ {
// Can't use AutoRestore<bool> because it's a bitfield.
NS_ABORT_IF_FALSE(!mHashlessColorQuirk,
"hashless color quirk should not be set");
if (mNavQuirkMode) {
mHashlessColorQuirk =
nsCSSProps::PropHasFlags(aPropID, CSS_PROPERTY_HASHLESS_COLOR_QUIRK);
}
NS_ASSERTION(aPropID < eCSSProperty_COUNT, "index out of range"); NS_ASSERTION(aPropID < eCSSProperty_COUNT, "index out of range");
bool result;
switch (nsCSSProps::PropertyParseType(aPropID)) { switch (nsCSSProps::PropertyParseType(aPropID)) {
case CSS_PROPERTY_PARSE_INACCESSIBLE: { case CSS_PROPERTY_PARSE_INACCESSIBLE: {
// The user can't use these // The user can't use these
REPORT_UNEXPECTED(PEInaccessibleProperty2); REPORT_UNEXPECTED(PEInaccessibleProperty2);
return false; result = false;
break;
} }
case CSS_PROPERTY_PARSE_FUNCTION: { case CSS_PROPERTY_PARSE_FUNCTION: {
return ParsePropertyByFunction(aPropID); result = ParsePropertyByFunction(aPropID);
break;
} }
case CSS_PROPERTY_PARSE_VALUE: { case CSS_PROPERTY_PARSE_VALUE: {
result = false;
nsCSSValue value; nsCSSValue value;
if (ParseSingleValueProperty(value, aPropID)) { if (ParseSingleValueProperty(value, aPropID)) {
if (ExpectEndProperty()) { if (ExpectEndProperty()) {
AppendValue(aPropID, value); AppendValue(aPropID, value);
return true; result = true;
} }
// XXX Report errors? // XXX Report errors?
} }
// XXX Report errors? // XXX Report errors?
return false; break;
} }
case CSS_PROPERTY_PARSE_VALUE_LIST: { case CSS_PROPERTY_PARSE_VALUE_LIST: {
return ParseValueList(aPropID); result = ParseValueList(aPropID);
break;
}
default: {
result = false;
NS_ABORT_IF_FALSE(false,
"Property's flags field in nsCSSPropList.h is missing "
"one of the CSS_PROPERTY_PARSE_* constants");
break;
} }
} }
NS_ABORT_IF_FALSE(false,
"Property's flags field in nsCSSPropList.h is missing " if (mNavQuirkMode) {
"one of the CSS_PROPERTY_PARSE_* constants"); mHashlessColorQuirk = false;
return false; }
return result;
} }
bool bool

Просмотреть файл

@ -482,7 +482,8 @@ CSS_PROP_BACKGROUND(
BackgroundColor, BackgroundColor,
CSS_PROPERTY_PARSE_VALUE | CSS_PROPERTY_PARSE_VALUE |
CSS_PROPERTY_APPLIES_TO_FIRST_LETTER_AND_FIRST_LINE | CSS_PROPERTY_APPLIES_TO_FIRST_LETTER_AND_FIRST_LINE |
CSS_PROPERTY_IGNORED_WHEN_COLORS_DISABLED, CSS_PROPERTY_IGNORED_WHEN_COLORS_DISABLED |
CSS_PROPERTY_HASHLESS_COLOR_QUIRK,
"", "",
VARIANT_HC, VARIANT_HC,
nsnull, nsnull,
@ -592,7 +593,8 @@ CSS_PROP_BORDER(
BorderBottomColor, BorderBottomColor,
CSS_PROPERTY_PARSE_VALUE | CSS_PROPERTY_PARSE_VALUE |
CSS_PROPERTY_APPLIES_TO_FIRST_LETTER | CSS_PROPERTY_APPLIES_TO_FIRST_LETTER |
CSS_PROPERTY_IGNORED_WHEN_COLORS_DISABLED, CSS_PROPERTY_IGNORED_WHEN_COLORS_DISABLED |
CSS_PROPERTY_HASHLESS_COLOR_QUIRK,
"", "",
VARIANT_HCK, VARIANT_HCK,
kBorderColorKTable, kBorderColorKTable,
@ -647,7 +649,8 @@ CSS_PROP_SHORTHAND(
border-color, border-color,
border_color, border_color,
BorderColor, BorderColor,
CSS_PROPERTY_PARSE_FUNCTION, CSS_PROPERTY_PARSE_FUNCTION |
CSS_PROPERTY_HASHLESS_COLOR_QUIRK,
"") "")
CSS_PROP_SHORTHAND( CSS_PROP_SHORTHAND(
-moz-border-end, -moz-border-end,
@ -785,7 +788,8 @@ CSS_PROP_SHORTHAND(
border-left-color, border-left-color,
border_left_color, border_left_color,
BorderLeftColor, BorderLeftColor,
CSS_PROPERTY_PARSE_FUNCTION, CSS_PROPERTY_PARSE_FUNCTION |
CSS_PROPERTY_HASHLESS_COLOR_QUIRK,
"") "")
#ifndef CSS_PROP_LIST_EXCLUDE_INTERNAL #ifndef CSS_PROP_LIST_EXCLUDE_INTERNAL
CSS_PROP_BORDER( CSS_PROP_BORDER(
@ -939,7 +943,8 @@ CSS_PROP_SHORTHAND(
border-right-color, border-right-color,
border_right_color, border_right_color,
BorderRightColor, BorderRightColor,
CSS_PROPERTY_PARSE_FUNCTION, CSS_PROPERTY_PARSE_FUNCTION |
CSS_PROPERTY_HASHLESS_COLOR_QUIRK,
"") "")
#ifndef CSS_PROP_LIST_EXCLUDE_INTERNAL #ifndef CSS_PROP_LIST_EXCLUDE_INTERNAL
CSS_PROP_BORDER( CSS_PROP_BORDER(
@ -1176,7 +1181,8 @@ CSS_PROP_BORDER(
BorderTopColor, BorderTopColor,
CSS_PROPERTY_PARSE_VALUE | CSS_PROPERTY_PARSE_VALUE |
CSS_PROPERTY_APPLIES_TO_FIRST_LETTER | CSS_PROPERTY_APPLIES_TO_FIRST_LETTER |
CSS_PROPERTY_IGNORED_WHEN_COLORS_DISABLED, CSS_PROPERTY_IGNORED_WHEN_COLORS_DISABLED |
CSS_PROPERTY_HASHLESS_COLOR_QUIRK,
"", "",
VARIANT_HCK, VARIANT_HCK,
kBorderColorKTable, kBorderColorKTable,
@ -1352,7 +1358,8 @@ CSS_PROP_COLOR(
Color, Color,
CSS_PROPERTY_PARSE_VALUE | CSS_PROPERTY_PARSE_VALUE |
CSS_PROPERTY_APPLIES_TO_FIRST_LETTER_AND_FIRST_LINE | CSS_PROPERTY_APPLIES_TO_FIRST_LETTER_AND_FIRST_LINE |
CSS_PROPERTY_IGNORED_WHEN_COLORS_DISABLED, CSS_PROPERTY_IGNORED_WHEN_COLORS_DISABLED |
CSS_PROPERTY_HASHLESS_COLOR_QUIRK,
"", "",
VARIANT_HC, VARIANT_HC,
nsnull, nsnull,

Просмотреть файл

@ -92,7 +92,8 @@ MOZ_STATIC_ASSERT((CSS_PROPERTY_PARSE_PROPERTY_MASK &
// should enforce that the value of this property must be 1 or larger. // should enforce that the value of this property must be 1 or larger.
#define CSS_PROPERTY_VALUE_AT_LEAST_ONE (2<<13) #define CSS_PROPERTY_VALUE_AT_LEAST_ONE (2<<13)
// NOTE: next free bit is (1<<15) // Does this property suppor the hashless hex color quirk in quirks mode?
#define CSS_PROPERTY_HASHLESS_COLOR_QUIRK (1<<15)
/** /**
* Types of animatable values. * Types of animatable values.

Просмотреть файл

@ -29,6 +29,8 @@ const CSS_TYPE_SHORTHAND_AND_LONGHAND = 2;
// may not be the same as for the property's initial value. // may not be the same as for the property's initial value.
// invalid_values: Things that are not values for the property and // invalid_values: Things that are not values for the property and
// should be rejected. // should be rejected.
// quirks_values: Values that should be accepted in quirks mode only,
// mapped to the values they are equivalent to.
// Helper functions used to construct gCSSProperties. // Helper functions used to construct gCSSProperties.
@ -148,7 +150,7 @@ var gCSSProperties = {
type: CSS_TYPE_LONGHAND, type: CSS_TYPE_LONGHAND,
initial_values: [ "none" ], initial_values: [ "none" ],
other_values: [ "red green", "red #fc3", "#ff00cc", "currentColor", "blue currentColor orange currentColor" ], other_values: [ "red green", "red #fc3", "#ff00cc", "currentColor", "blue currentColor orange currentColor" ],
invalid_values: [ "red none", "red inherit", "red, green", "none red", "inherit red" ] invalid_values: [ "red none", "red inherit", "red, green", "none red", "inherit red", "ff00cc" ]
}, },
"-moz-border-end": { "-moz-border-end": {
domProp: "MozBorderEnd", domProp: "MozBorderEnd",
@ -166,7 +168,7 @@ var gCSSProperties = {
get_computed: logical_box_prop_get_computed, get_computed: logical_box_prop_get_computed,
initial_values: [ "currentColor" ], initial_values: [ "currentColor" ],
other_values: [ "green", "rgba(255,128,0,0.5)", "transparent" ], other_values: [ "green", "rgba(255,128,0,0.5)", "transparent" ],
invalid_values: [ "#0", "#00", "#0000", "#00000", "#0000000", "#00000000", "#000000000" ] invalid_values: [ "#0", "#00", "#0000", "#00000", "#0000000", "#00000000", "#000000000", "000000" ]
}, },
"-moz-border-end-style": { "-moz-border-end-style": {
domProp: "MozBorderEndStyle", domProp: "MozBorderEndStyle",
@ -279,7 +281,7 @@ var gCSSProperties = {
type: CSS_TYPE_LONGHAND, type: CSS_TYPE_LONGHAND,
initial_values: [ "none" ], initial_values: [ "none" ],
other_values: [ "red green", "red #fc3", "#ff00cc", "currentColor", "blue currentColor orange currentColor" ], other_values: [ "red green", "red #fc3", "#ff00cc", "currentColor", "blue currentColor orange currentColor" ],
invalid_values: [ "red none", "red inherit", "red, green", "none red", "inherit red" ] invalid_values: [ "red none", "red inherit", "red, green", "none red", "inherit red", "ff00cc" ]
}, },
"border-radius": { "border-radius": {
domProp: "borderRadius", domProp: "borderRadius",
@ -385,7 +387,7 @@ var gCSSProperties = {
type: CSS_TYPE_LONGHAND, type: CSS_TYPE_LONGHAND,
initial_values: [ "none" ], initial_values: [ "none" ],
other_values: [ "red green", "red #fc3", "#ff00cc", "currentColor", "blue currentColor orange currentColor" ], other_values: [ "red green", "red #fc3", "#ff00cc", "currentColor", "blue currentColor orange currentColor" ],
invalid_values: [ "red none", "red inherit", "red, green", "none red", "inherit red" ] invalid_values: [ "red none", "red inherit", "red, green", "none red", "inherit red", "ff00cc" ]
}, },
"-moz-border-start": { "-moz-border-start": {
domProp: "MozBorderStart", domProp: "MozBorderStart",
@ -403,7 +405,7 @@ var gCSSProperties = {
get_computed: logical_box_prop_get_computed, get_computed: logical_box_prop_get_computed,
initial_values: [ "currentColor" ], initial_values: [ "currentColor" ],
other_values: [ "green", "rgba(255,128,0,0.5)", "transparent" ], other_values: [ "green", "rgba(255,128,0,0.5)", "transparent" ],
invalid_values: [ "#0", "#00", "#0000", "#00000", "#0000000", "#00000000", "#000000000" ] invalid_values: [ "#0", "#00", "#0000", "#00000", "#0000000", "#00000000", "#000000000", "000000" ]
}, },
"-moz-border-start-style": { "-moz-border-start-style": {
domProp: "MozBorderStartStyle", domProp: "MozBorderStartStyle",
@ -440,7 +442,7 @@ var gCSSProperties = {
type: CSS_TYPE_LONGHAND, type: CSS_TYPE_LONGHAND,
initial_values: [ "none" ], initial_values: [ "none" ],
other_values: [ "red green", "red #fc3", "#ff00cc", "currentColor", "blue currentColor orange currentColor" ], other_values: [ "red green", "red #fc3", "#ff00cc", "currentColor", "blue currentColor orange currentColor" ],
invalid_values: [ "red none", "red inherit", "red, green", "none red", "inherit red" ] invalid_values: [ "red none", "red inherit", "red, green", "none red", "inherit red", "ff00cc" ]
}, },
"-moz-box-align": { "-moz-box-align": {
domProp: "MozBoxAlign", domProp: "MozBoxAlign",
@ -829,7 +831,7 @@ var gCSSProperties = {
prerequisites: { "color": "green" }, prerequisites: { "color": "green" },
initial_values: [ "currentColor", "-moz-use-text-color" ], initial_values: [ "currentColor", "-moz-use-text-color" ],
other_values: [ "red", "blue", "#ffff00" ], other_values: [ "red", "blue", "#ffff00" ],
invalid_values: [ ] invalid_values: [ "ffff00" ]
}, },
"-moz-column-width": { "-moz-column-width": {
domProp: "MozColumnWidth", domProp: "MozColumnWidth",
@ -1468,6 +1470,8 @@ var gCSSProperties = {
invalid_values: [ invalid_values: [
/* mixes with keywords have to be in correct order */ /* mixes with keywords have to be in correct order */
"50% left", "top 50%", "50% left", "top 50%",
/* no quirks mode colors */
"-moz-radial-gradient(10% bottom, ffffff, black) scroll no-repeat",
/* bug 258080: don't accept background-position separated */ /* bug 258080: don't accept background-position separated */
"left url(404.png) top", "top url(404.png) left", "left url(404.png) top", "top url(404.png) left",
/* not allowed to have color in non-bottom layer */ /* not allowed to have color in non-bottom layer */
@ -1512,7 +1516,8 @@ var gCSSProperties = {
type: CSS_TYPE_LONGHAND, type: CSS_TYPE_LONGHAND,
initial_values: [ "transparent", "rgba(255, 127, 15, 0)", "hsla(240, 97%, 50%, 0.0)", "rgba(0, 0, 0, 0)", "rgba(255,255,255,-3.7)" ], initial_values: [ "transparent", "rgba(255, 127, 15, 0)", "hsla(240, 97%, 50%, 0.0)", "rgba(0, 0, 0, 0)", "rgba(255,255,255,-3.7)" ],
other_values: [ "green", "rgb(255, 0, 128)", "#fc2", "#96ed2a", "black", "rgba(255,255,0,3)" ], other_values: [ "green", "rgb(255, 0, 128)", "#fc2", "#96ed2a", "black", "rgba(255,255,0,3)" ],
invalid_values: [ "#0", "#00", "#0000", "#00000", "#0000000", "#00000000", "#000000000", "rgb(255.0,0.387,3489)" ] invalid_values: [ "#0", "#00", "#0000", "#00000", "#0000000", "#00000000", "#000000000", "rgb(255.0,0.387,3489)" ],
quirks_values: { "000000": "#000000", "96ed2a": "#96ed2a" },
}, },
"background-image": { "background-image": {
domProp: "backgroundImage", domProp: "backgroundImage",
@ -1793,6 +1798,8 @@ var gCSSProperties = {
"-moz-element(#a a)", "-moz-element(#a a)",
"-moz-element(#a+a)", "-moz-element(#a+a)",
"-moz-element(#a()", "-moz-element(#a()",
/* no quirks mode colors */
"linear-gradient(red, ff00ff)",
/* Old syntax */ /* Old syntax */
"-moz-linear-gradient(10px 10px, 20px, 30px 30px, 40px, from(blue), to(red))", "-moz-linear-gradient(10px 10px, 20px, 30px 30px, 40px, from(blue), to(red))",
"-moz-radial-gradient(20px 20px, 10px 10px, from(green), to(#ff00ff))", "-moz-radial-gradient(20px 20px, 10px 10px, from(green), to(#ff00ff))",
@ -2105,7 +2112,7 @@ var gCSSProperties = {
subproperties: [ "border-bottom-color", "border-bottom-style", "border-bottom-width", "border-left-color", "border-left-style", "border-left-width", "border-right-color", "border-right-style", "border-right-width", "border-top-color", "border-top-style", "border-top-width", "-moz-border-top-colors", "-moz-border-right-colors", "-moz-border-bottom-colors", "-moz-border-left-colors", "border-image-source", "border-image-slice", "border-image-width", "border-image-outset", "border-image-repeat" ], subproperties: [ "border-bottom-color", "border-bottom-style", "border-bottom-width", "border-left-color", "border-left-style", "border-left-width", "border-right-color", "border-right-style", "border-right-width", "border-top-color", "border-top-style", "border-top-width", "-moz-border-top-colors", "-moz-border-right-colors", "-moz-border-bottom-colors", "-moz-border-left-colors", "border-image-source", "border-image-slice", "border-image-width", "border-image-outset", "border-image-repeat" ],
initial_values: [ "none", "medium", "currentColor", "thin", "none medium currentcolor", "calc(4px - 1px) none" ], initial_values: [ "none", "medium", "currentColor", "thin", "none medium currentcolor", "calc(4px - 1px) none" ],
other_values: [ "solid", "medium solid", "green solid", "10px solid", "thick solid", "calc(2px) solid blue" ], other_values: [ "solid", "medium solid", "green solid", "10px solid", "thick solid", "calc(2px) solid blue" ],
invalid_values: [ "5%" ] invalid_values: [ "5%", "medium solid ff00ff" ]
}, },
"border-bottom": { "border-bottom": {
domProp: "borderBottom", domProp: "borderBottom",
@ -2123,7 +2130,8 @@ var gCSSProperties = {
prerequisites: { "color": "black" }, prerequisites: { "color": "black" },
initial_values: [ "currentColor", "-moz-use-text-color" ], initial_values: [ "currentColor", "-moz-use-text-color" ],
other_values: [ "green", "rgba(255,128,0,0.5)", "transparent" ], other_values: [ "green", "rgba(255,128,0,0.5)", "transparent" ],
invalid_values: [ "#0", "#00", "#0000", "#00000", "#0000000", "#00000000", "#000000000" ] invalid_values: [ "#0", "#00", "#0000", "#00000", "#0000000", "#00000000", "#000000000" ],
quirks_values: { "000000": "#000000", "96ed2a": "#96ed2a" },
}, },
"border-bottom-style": { "border-bottom-style": {
domProp: "borderBottomStyle", domProp: "borderBottomStyle",
@ -2167,7 +2175,8 @@ var gCSSProperties = {
subproperties: [ "border-top-color", "border-right-color", "border-bottom-color", "border-left-color" ], subproperties: [ "border-top-color", "border-right-color", "border-bottom-color", "border-left-color" ],
initial_values: [ "currentColor", "currentColor currentColor", "currentColor currentColor currentColor", "currentColor currentColor currentcolor CURRENTcolor" ], initial_values: [ "currentColor", "currentColor currentColor", "currentColor currentColor currentColor", "currentColor currentColor currentcolor CURRENTcolor" ],
other_values: [ "green", "currentColor green", "currentColor currentColor green", "currentColor currentColor currentColor green", "rgba(255,128,0,0.5)", "transparent" ], other_values: [ "green", "currentColor green", "currentColor currentColor green", "currentColor currentColor currentColor green", "rgba(255,128,0,0.5)", "transparent" ],
invalid_values: [ "#0", "#00", "#0000", "#00000", "#0000000", "#00000000", "#000000000" ] invalid_values: [ "#0", "#00", "#0000", "#00000", "#0000000", "#00000000", "#000000000" ],
quirks_values: { "000000": "#000000", "96ed2a": "#96ed2a" },
}, },
"border-left": { "border-left": {
domProp: "borderLeft", domProp: "borderLeft",
@ -2185,7 +2194,8 @@ var gCSSProperties = {
prerequisites: { "color": "black" }, prerequisites: { "color": "black" },
initial_values: [ "currentColor", "-moz-use-text-color" ], initial_values: [ "currentColor", "-moz-use-text-color" ],
other_values: [ "green", "rgba(255,128,0,0.5)", "transparent" ], other_values: [ "green", "rgba(255,128,0,0.5)", "transparent" ],
invalid_values: [ "#0", "#00", "#0000", "#00000", "#0000000", "#00000000", "#000000000" ] invalid_values: [ "#0", "#00", "#0000", "#00000", "#0000000", "#00000000", "#000000000" ],
quirks_values: { "000000": "#000000", "96ed2a": "#96ed2a" },
}, },
"border-left-style": { "border-left-style": {
domProp: "borderLeftStyle", domProp: "borderLeftStyle",
@ -2230,7 +2240,8 @@ var gCSSProperties = {
prerequisites: { "color": "black" }, prerequisites: { "color": "black" },
initial_values: [ "currentColor", "-moz-use-text-color" ], initial_values: [ "currentColor", "-moz-use-text-color" ],
other_values: [ "green", "rgba(255,128,0,0.5)", "transparent" ], other_values: [ "green", "rgba(255,128,0,0.5)", "transparent" ],
invalid_values: [ "#0", "#00", "#0000", "#00000", "#0000000", "#00000000", "#000000000" ] invalid_values: [ "#0", "#00", "#0000", "#00000", "#0000000", "#00000000", "#000000000" ],
quirks_values: { "000000": "#000000", "96ed2a": "#96ed2a" },
}, },
"border-right-style": { "border-right-style": {
domProp: "borderRightStyle", domProp: "borderRightStyle",
@ -2293,7 +2304,8 @@ var gCSSProperties = {
prerequisites: { "color": "black" }, prerequisites: { "color": "black" },
initial_values: [ "currentColor", "-moz-use-text-color" ], initial_values: [ "currentColor", "-moz-use-text-color" ],
other_values: [ "green", "rgba(255,128,0,0.5)", "transparent" ], other_values: [ "green", "rgba(255,128,0,0.5)", "transparent" ],
invalid_values: [ "#0", "#00", "#0000", "#00000", "#0000000", "#00000000", "#000000000" ] invalid_values: [ "#0", "#00", "#0000", "#00000", "#0000000", "#00000000", "#000000000" ],
quirks_values: { "000000": "#000000", "96ed2a": "#96ed2a" },
}, },
"border-top-style": { "border-top-style": {
domProp: "borderTopStyle", domProp: "borderTopStyle",
@ -2403,7 +2415,8 @@ var gCSSProperties = {
/* XXX should test currentColor, but may or may not be initial */ /* XXX should test currentColor, but may or may not be initial */
initial_values: [ "black", "#000" ], initial_values: [ "black", "#000" ],
other_values: [ "green", "#f3c", "#fed292", "rgba(45,300,12,2)", "transparent", "-moz-nativehyperlinktext", "rgba(255,128,0,0.5)" ], other_values: [ "green", "#f3c", "#fed292", "rgba(45,300,12,2)", "transparent", "-moz-nativehyperlinktext", "rgba(255,128,0,0.5)" ],
invalid_values: [ "fff", "ffffff", "#f", "#ff", "#ffff", "#fffff", "#fffffff", "#ffffffff", "#fffffffff" ] invalid_values: [ "#f", "#ff", "#ffff", "#fffff", "#fffffff", "#ffffffff", "#fffffffff" ],
quirks_values: { "000000": "#000000", "96ed2a": "#96ed2a", "fff": "#ffffff", "ffffff": "#ffffff", },
}, },
"content": { "content": {
domProp: "content", domProp: "content",
@ -2925,7 +2938,7 @@ var gCSSProperties = {
prerequisites: { "color": "black" }, prerequisites: { "color": "black" },
initial_values: [ "currentColor", "-moz-use-text-color" ], // XXX should be invert initial_values: [ "currentColor", "-moz-use-text-color" ], // XXX should be invert
other_values: [ "green", "rgba(255,128,0,0.5)", "transparent" ], other_values: [ "green", "rgba(255,128,0,0.5)", "transparent" ],
invalid_values: [ "#0", "#00", "#0000", "#00000", "#0000000", "#00000000", "#000000000" ] invalid_values: [ "#0", "#00", "#0000", "#00000", "#0000000", "#00000000", "#000000000", "000000", "cc00ff" ]
}, },
"outline-offset": { "outline-offset": {
domProp: "outlineOffset", domProp: "outlineOffset",
@ -3198,7 +3211,7 @@ var gCSSProperties = {
prerequisites: { "color": "black" }, prerequisites: { "color": "black" },
initial_values: [ "currentColor", "-moz-use-text-color" ], initial_values: [ "currentColor", "-moz-use-text-color" ],
other_values: [ "green", "rgba(255,128,0,0.5)", "transparent" ], other_values: [ "green", "rgba(255,128,0,0.5)", "transparent" ],
invalid_values: [ "#0", "#00", "#0000", "#00000", "#0000000", "#00000000", "#000000000" ] invalid_values: [ "#0", "#00", "#0000", "#00000", "#0000000", "#00000000", "#000000000", "000000", "ff00ff" ]
}, },
"-moz-text-decoration-line": { "-moz-text-decoration-line": {
domProp: "MozTextDecorationLine", domProp: "MozTextDecorationLine",
@ -3569,7 +3582,7 @@ var gCSSProperties = {
prerequisites: { "color": "blue" }, prerequisites: { "color": "blue" },
initial_values: [ "black", "#000", "#000000", "rgb(0,0,0)", "rgba(0,0,0,1)" ], initial_values: [ "black", "#000", "#000000", "rgb(0,0,0)", "rgba(0,0,0,1)" ],
other_values: [ "green", "#fc3", "url('#myserver')", "url(foo.svg#myserver)", 'url("#myserver") green', "none", "currentColor" ], other_values: [ "green", "#fc3", "url('#myserver')", "url(foo.svg#myserver)", 'url("#myserver") green', "none", "currentColor" ],
invalid_values: [] invalid_values: [ "000000", "ff00ff" ]
}, },
"fill-opacity": { "fill-opacity": {
domProp: "fillOpacity", domProp: "fillOpacity",
@ -3602,7 +3615,7 @@ var gCSSProperties = {
prerequisites: { "color": "blue" }, prerequisites: { "color": "blue" },
initial_values: [ "black", "#000", "#000000", "rgb(0,0,0)", "rgba(0,0,0,1)" ], initial_values: [ "black", "#000", "#000000", "rgb(0,0,0)", "rgba(0,0,0,1)" ],
other_values: [ "green", "#fc3", "currentColor" ], other_values: [ "green", "#fc3", "currentColor" ],
invalid_values: [ "url('#myserver')", "url(foo.svg#myserver)", 'url("#myserver") green' ] invalid_values: [ "url('#myserver')", "url(foo.svg#myserver)", 'url("#myserver") green', "000000", "ff00ff" ]
}, },
"flood-opacity": { "flood-opacity": {
domProp: "floodOpacity", domProp: "floodOpacity",
@ -3627,7 +3640,7 @@ var gCSSProperties = {
prerequisites: { "color": "blue" }, prerequisites: { "color": "blue" },
initial_values: [ "white", "#fff", "#ffffff", "rgb(255,255,255)", "rgba(255,255,255,1.0)", "rgba(255,255,255,42.0)" ], initial_values: [ "white", "#fff", "#ffffff", "rgb(255,255,255)", "rgba(255,255,255,1.0)", "rgba(255,255,255,42.0)" ],
other_values: [ "green", "#fc3", "currentColor" ], other_values: [ "green", "#fc3", "currentColor" ],
invalid_values: [ "url('#myserver')", "url(foo.svg#myserver)", 'url("#myserver") green' ] invalid_values: [ "url('#myserver')", "url(foo.svg#myserver)", 'url("#myserver") green', "000000", "ff00ff" ]
}, },
"marker": { "marker": {
domProp: "marker", domProp: "marker",
@ -3685,7 +3698,7 @@ var gCSSProperties = {
prerequisites: { "color": "blue" }, prerequisites: { "color": "blue" },
initial_values: [ "black", "#000", "#000000", "rgb(0,0,0)", "rgba(0,0,0,1)" ], initial_values: [ "black", "#000", "#000000", "rgb(0,0,0)", "rgba(0,0,0,1)" ],
other_values: [ "green", "#fc3", "currentColor" ], other_values: [ "green", "#fc3", "currentColor" ],
invalid_values: [ "url('#myserver')", "url(foo.svg#myserver)", 'url("#myserver") green' ] invalid_values: [ "url('#myserver')", "url(foo.svg#myserver)", 'url("#myserver") green', "000000", "ff00ff" ]
}, },
"stop-opacity": { "stop-opacity": {
domProp: "stopOpacity", domProp: "stopOpacity",
@ -3701,7 +3714,7 @@ var gCSSProperties = {
type: CSS_TYPE_LONGHAND, type: CSS_TYPE_LONGHAND,
initial_values: [ "none" ], initial_values: [ "none" ],
other_values: [ "black", "#000", "#000000", "rgb(0,0,0)", "rgba(0,0,0,1)", "green", "#fc3", "url('#myserver')", "url(foo.svg#myserver)", 'url("#myserver") green', "currentColor" ], other_values: [ "black", "#000", "#000000", "rgb(0,0,0)", "rgba(0,0,0,1)", "green", "#fc3", "url('#myserver')", "url(foo.svg#myserver)", 'url("#myserver") green', "currentColor" ],
invalid_values: [] invalid_values: [ "000000", "ff00ff" ]
}, },
"stroke-dasharray": { "stroke-dasharray": {
domProp: "strokeDasharray", domProp: "strokeDasharray",

Просмотреть файл

@ -8,8 +8,9 @@
<script type="text/javascript" src="property_database.js"></script> <script type="text/javascript" src="property_database.js"></script>
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" /> <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
</head> </head>
<body> <body onload="run()">
<p id="display"></p> <p id="display"></p>
<iframe id="quirks" src="data:text/html,<div id='testnode'></div>"></iframe>
<div id="content" style="display: none"> <div id="content" style="display: none">
<div id="testnode"></div> <div id="testnode"></div>
@ -18,42 +19,76 @@
<pre id="test"> <pre id="test">
<script class="testbody" type="text/javascript"> <script class="testbody" type="text/javascript">
var gDeclaration = document.getElementById("testnode").style; SimpleTest.waitForExplicitFinish();
var gKnownFails = { function check_not_accepted(decl, property, info, badval)
"pitch-range": [ " -0.01", "100.2", "108", "-3" ], {
"richness": [ " -0.01", "100.2", "108", "-3" ], decl.setProperty(property, badval, "");
"stress": [ " -0.01", "100.2", "108", "-3" ],
"volume": [ " -0.01", "100.2", "108", "-3" ] is(decl.getPropertyValue(property), "",
"invalid value '" + badval + "' not accepted for '" + property +
"' property");
if ("subproperties" in info) {
for (var sidx in info.subproperties) {
var subprop = info.subproperties[sidx];
is(decl.getPropertyValue(subprop), "",
"invalid value '" + badval + "' not accepted for '" + property +
"' property when testing subproperty '" + subprop + "'");
}
}
decl.removeProperty(property);
} }
for (var property in gCSSProperties) { function run()
var info = gCSSProperties[property]; {
for (var idx in info.invalid_values) { var gDeclaration = document.getElementById("testnode").style;
var badval = info.invalid_values[idx]; var gQuirksDeclaration = document.getElementById("quirks").contentDocument
.getElementById("testnode").style;
gDeclaration.setProperty(property, badval, ""); for (var property in gCSSProperties) {
var info = gCSSProperties[property];
var func = is; for (var idx in info.invalid_values) {
if (property in gKnownFails && check_not_accepted(gDeclaration, property, info,
gKnownFails[property].indexOf(badval) != -1) info.invalid_values[idx]);
func = todo_is; check_not_accepted(gQuirksDeclaration, property, info,
info.invalid_values[idx]);
func(gDeclaration.getPropertyValue(property), "",
"invalid value '" + badval + "' not accepted for '" + property +
"' property");
if ("subproperties" in info) {
for (var sidx in info.subproperties) {
var subprop = info.subproperties[sidx];
func(gDeclaration.getPropertyValue(subprop), "",
"invalid value '" + badval + "' not accepted for '" + property +
"' property when testing subproperty '" + subprop + "'");
}
} }
gDeclaration.removeProperty(property); if ("quirks_values" in info) {
for (var quirkval in info.quirks_values) {
var standardval = info.quirks_values[quirkval];
check_not_accepted(gDeclaration, property, info, quirkval);
gQuirksDeclaration.setProperty(property, quirkval, "");
gDeclaration.setProperty(property, standardval, "");
var quirkret = gQuirksDeclaration.getPropertyValue(property);
var standardret = gDeclaration.getPropertyValue(property);
isnot(quirkret, "", property + ": " + quirkval +
" should be accepted in quirks mode");
is(quirkret, standardret, property + ": " + quirkval + " result");
if ("subproperties" in info) {
for (var sidx in info.subproperties) {
var subprop = info.subproperties[sidx];
var quirksub = gQuirksDeclaration.getPropertyValue(subprop);
var standardsub = gDeclaration.getPropertyValue(subprop);
isnot(quirksub, "", property + ": " + quirkval +
" should be accepted in quirks mode" +
" when testing subproperty " + subprop);
is(quirksub, standardsub, property + ": " + quirkval + " result" +
" when testing subproperty " + subprop);
}
}
gQuirksDeclaration.removeProperty(property);
gDeclaration.removeProperty(property);
}
}
} }
SimpleTest.finish();
} }
</script> </script>